/* urtube v1: system fonts only (no external font requests); light/dark follows the OS. */
:root {
  color-scheme: light dark;
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1f1d1a;
  --muted: #6a645b;
  --line: #e5dfd4;
  --chip: #f0ebe2;
  --accent: #9a3412;
  --accent-ink: #ffffff;
  --focus: #2563eb;
  --cover-l: 86%;
  --cover-ink: 20%;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", Roboto, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1c1b18;
    --ink: #ebe6de;
    --muted: #a29b90;
    --line: #2f2c27;
    --chip: #262420;
    --accent: #f29e7d;
    --accent-ink: #1b0e08;
    --focus: #8ab4ff;
    --cover-l: 24%;
    --cover-ink: 88%;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--sans); }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; padding: 6px 12px; background: var(--surface); }

/* header */
.top { border-bottom: 1px solid var(--line); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { font: 700 1.35rem/1 var(--serif); letter-spacing: 0.02em; text-decoration: none; }
.bar form { flex: 1 1 260px; }
.bar input {
  width: 100%;
  padding: 8px 14px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.bar nav { display: flex; gap: 16px; font-size: 15px; }
.bar nav a { color: var(--muted); text-decoration: none; }
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--ink); }
/* Phone: brand and search share the first row; the nav gets its own row and scrolls sideways
   inside itself if it ever runs out of room, so the page never scrolls horizontally. */
@media (max-width: 600px) {
  .bar form { flex: 1 1 0; min-width: 0; }
  .bar nav { order: 3; flex-basis: 100%; gap: 18px; overflow-x: auto; white-space: nowrap; padding-bottom: 2px; }
}

/* page */
main { display: block; min-height: 60vh; padding-top: 24px; padding-bottom: 48px; }
main:focus { outline: none; }
h1, h2 { font-family: var(--serif); line-height: 1.3; }
h1 { font-size: 1.9rem; margin: 8px 0; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h2 a { text-decoration: none; }
h2 a::after { content: " →"; color: var(--muted); font-family: var(--sans); }
.lede { max-width: 40em; margin: 0 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.block { margin-top: 36px; }
.status { padding: 24px 0; color: var(--muted); }

/* cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 24px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.card { display: block; text-decoration: none; }
.card > span { display: block; }
.thumb, .cover { aspect-ratio: 16 / 9; margin-bottom: 10px; overflow: hidden; border-radius: var(--r); }
.thumb { background: var(--chip); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover {
  --hue: 30;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  color: hsl(var(--hue) 35% var(--cover-ink));
  background: hsl(var(--hue) 32% var(--cover-l));
  border: 1px solid hsl(var(--hue) 25% calc(var(--cover-l) - 8%));
}
.cover-t {
  display: -webkit-box;
  overflow: hidden;
  font: 600 1.15rem/1.3 var(--serif);
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.cover-a { font-size: 0.85rem; opacity: 0.85; }
.cover.big { max-width: 360px; }
.cover.big .cover-t { font-size: 1.5rem; }
.kind { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; color: var(--accent); }
.card-t { margin-top: 2px; font-weight: 600; line-height: 1.4; }
.card:hover .card-t { text-decoration: underline; }
.card-zh { font-size: 0.95rem; }
.card-by, .card-note, .card-origin { font-size: 0.875rem; color: var(--muted); }
.card-origin { font-size: 0.8rem; }
.card-note { margin-top: 4px; }
.more { margin: 16px 0 0; }

/* plain lists: title + tags + link */
.rows { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row-main { display: flex; flex: 1 1 360px; flex-direction: column; min-width: 0; }
.row-t { font-weight: 600; line-height: 1.4; text-decoration: none; overflow-wrap: anywhere; }
.row-t:hover { text-decoration: underline; }
.row-zh { font-size: 0.95rem; }
.row-meta, .row-tags, .origin { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.row-tags { font-size: 0.8rem; }
.origin { display: block; font-size: 0.8rem; }
.row-go { flex: 0 0 auto; font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.row-go a { color: var(--accent); text-decoration: none; }
.row-go a:hover { text-decoration: underline; }

/* filters */
.tabs { display: flex; gap: 6px; margin: 0 0 16px; }
.tabs a {
  padding: 4px 12px;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tabs a[aria-current="page"] { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.chips a { display: inline-block; padding: 3px 12px; font-size: 0.9rem; text-decoration: none; background: var(--chip); border-radius: 999px; }
/* tags (sub-topics) are outlined so they read differently from subject categories */
.chips a.tag { background: transparent; border: 1px solid var(--line); }
.chips a.tag::before { content: "#"; color: var(--muted); margin-right: 1px; }
.chips.topics { margin: 4px 0 8px; }
.row-tags a { color: var(--muted); }

/* detail */
.detail { max-width: 860px; }
.head { margin-top: 20px; }
.zh { margin: 0; font: 1.15rem/1.4 var(--serif); }
.byline { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
}
.btn.ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.btn[aria-pressed="true"]::before { content: "✓"; }
.summary { max-width: 40em; font-size: 1.05rem; }
.why { max-width: 40em; }
.rights { margin-top: 28px; padding-top: 12px; font-size: 0.9rem; color: var(--muted); border-top: 1px solid var(--line); }
.rights p { margin: 4px 0 0; }

/* YouTube Required Minimum Functionality: viewport at least 200x200 px, nothing drawn over
   the player, no clipping of the player (so no border-radius or overflow tricks on it). */
.player { position: relative; width: 100%; min-width: 200px; min-height: 200px; aspect-ratio: 16 / 9; background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.poster { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; cursor: pointer; background: #000; border: 0; }
.poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 50%;
}
.play::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 28px;
  border-style: solid;
  border-width: 14px 0 14px 22px;
  border-color: transparent transparent transparent #fff;
}
.poster:hover .play, .poster:focus-visible .play { background: var(--accent); }
.notice { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }

/* static pages */
.prose { max-width: 720px; }
.prose h2 { margin-top: 32px; }
.prose li { margin: 4px 0; }

/* footer */
.foot { padding: 20px 0 32px; font-size: 0.875rem; color: var(--muted); border-top: 1px solid var(--line); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; }
