/* Layout: sticky search bar; filter toolbar; result rows (cover + sources) beside a "đang chờ tiếng Việt" board. Title pages reuse the same header, rows and panels. */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --ink: #171a33;
  --muted: #5c6180;
  --faint: #8a8fab;
  --line: #e1e3ee;
  --accent: #3b3fd1;
  --accent-soft: #ecedfd;
  --hl: #ffd23f;
  --hl-ink: #171a33;
  --ok: #12784c;
  --ok-bg: #e3f4eb;
  --vi: #0f6b8f;
  --vi-bg: #e2f1f7;
  --warn: #8a5a08;
  --warn-bg: #fbf0d8;
  --cover-bg: #dfe1ee;
  --display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101226; --surface: #181b33; --ink: #eceeff; --muted: #a7abcb; --faint: #7d82a3; --line: #2a2e4f;
    --accent: #9a9dff; --accent-soft: #252966; --ok: #5fd39d; --ok-bg: #163327; --vi: #6cc7ea; --vi-bg: #132f3d;
    --warn: #efc063; --warn-bg: #362a12; --cover-bg: #23264a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101226; --surface: #181b33; --ink: #eceeff; --muted: #a7abcb; --faint: #7d82a3; --line: #2a2e4f;
  --accent: #9a9dff; --accent-soft: #252966; --ok: #5fd39d; --ok-bg: #163327; --vi: #6cc7ea; --vi-bg: #132f3d;
  --warn: #efc063; --warn-bg: #362a12; --cover-bg: #23264a; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; }
img { max-width: 100%; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top .wrap { display: flex; align-items: center; gap: 20px; padding-block: 12px; }
.logo { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.02em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.logo mark { background: var(--hl); color: var(--hl-ink); padding: 0 .14em; border-radius: 3px; }
.search { position: relative; flex: 1; min-width: 0; max-width: 620px; margin: 0; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; font: 500 16px/1.2 var(--body); color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 40px 12px 42px; outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.clear:hover { background: var(--line); }
.top-link { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.top-link:hover { color: var(--ink); }
@media (max-width: 640px) {
  .top .wrap { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
}

/* intro */
.intro .wrap { padding-block: 28px 8px; display: grid; gap: 10px; }
.intro h1 { font-family: var(--display); font-weight: 800; font-size: clamp(26px, 4.4vw, 38px); line-height: 1.1; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
.intro p { margin: 0; color: var(--muted); max-width: 64ch; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); font-weight: 700; }

/* toolbar */
.toolbar .wrap { padding-block: 16px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: 600 13px/1 var(--body); color: var(--muted); background: transparent; border: 0; border-radius: 7px; padding: 9px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:not([aria-pressed="true"]):hover { color: var(--ink); background: var(--bg); }
.sort-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-left: auto; }
@media (max-width: 640px) { .sort-label { margin-left: 0; } }
.select { font: 600 13px/1 var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }

/* layout */
.main .wrap { padding-block: 18px 48px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .main .wrap { grid-template-columns: minmax(0, 1fr); } }
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.list-head h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0; }
.list-head span { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.list { display: grid; gap: 10px; }
.group + .group { margin-top: 28px; }

/* covers */
.cover { display: block; background: var(--cover-bg); border-radius: 8px; overflow: hidden; aspect-ratio: 7 / 10; object-fit: cover; width: 100%; height: auto; }
.cover-fallback { display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--muted); font-size: 18px; text-transform: uppercase; }

/* shelf of featured covers */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 16px 14px; }
.shelf a { text-decoration: none; color: var(--ink); display: grid; gap: 6px; min-width: 0; }
.shelf a:hover .cover { box-shadow: 0 0 0 2px var(--accent); }
.shelf .t { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf .pill { justify-self: start; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

/* MyAnimeList score */
.score { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.score .star { color: #e0a100; }
.score.big { font-size: 20px; }
.score-line { margin: 10px 0 0; font-size: 14px; color: var(--muted); display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.score-line a { color: var(--muted); }

/* row */
.row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; min-width: 0; }
.row > .cover-link { align-self: start; text-decoration: none; }
.row-body { display: grid; gap: 10px; min-width: 0; }
.row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px 12px; flex-wrap: wrap; }
.row h3 { font-size: 17px; font-weight: 700; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.row h3 a { color: var(--ink); text-decoration: none; }
.row h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sub { font-size: 13px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.badges { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; }
.pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.pill.online { color: var(--ok); background: var(--ok-bg); }
.pill.print { color: var(--vi); background: var(--vi-bg); }
.pill.en { color: var(--warn); background: var(--warn-bg); }
@media (max-width: 480px) { .row { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; } }

.srcs { display: grid; gap: 6px; }
.src { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; background: var(--bg); }
.lang { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-align: center; border-radius: 5px; padding: 3px 0; }
.lang.VI { background: var(--vi-bg); color: var(--vi); }
.lang.EN { background: var(--line); color: var(--muted); }
.src-main { min-width: 0; font-size: 14px; }
.src-main strong { font-weight: 600; }
.src-main .meta { display: block; font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.src-main .meta a { color: inherit; }
.go { font: 600 13px/1 var(--body); color: var(--accent); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; text-decoration: none; white-space: nowrap; }
.go:hover { border-color: var(--accent); }
@media (max-width: 560px) {
  .src { grid-template-columns: 30px minmax(0, 1fr); }
  .go { grid-column: 2; justify-self: start; }
}

.row-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding-top: 2px; }
.row-foot .hint { font-size: 12px; color: var(--muted); }
.vote {
  display: inline-flex; align-items: center; gap: 8px; font: 700 13px/1 var(--body); cursor: pointer;
  color: var(--hl-ink); background: var(--hl); border: 0; border-radius: 9px; padding: 9px 12px; font-variant-numeric: tabular-nums;
}
.vote .n { background: rgba(23, 26, 51, .12); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.vote[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.vote[aria-pressed="true"] .n { background: var(--bg); }
.vote[disabled] { opacity: .55; cursor: not-allowed; }

.more { margin-top: 14px; width: 100%; font: 600 14px/1 var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 13px; cursor: pointer; }
.more:hover { border-color: var(--faint); }

.empty { background: var(--surface); border: 1.5px dashed var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 10px; justify-items: start; }
.empty h3 { margin: 0; font-size: 18px; }
.empty p { margin: 0; color: var(--muted); }

/* aside */
aside { position: sticky; top: 84px; display: grid; gap: 14px; }
@media (max-width: 900px) { aside { position: static; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel h2 { font-family: var(--display); font-weight: 800; font-size: 18px; margin: 0 0 2px; }
.panel > p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: r; }
.rank li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 14px; counter-increment: r; }
.rank li::before { content: counter(r); font-weight: 700; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.rank .nm { font-weight: 600; overflow-wrap: anywhere; }
.rank .nm a { color: var(--ink); text-decoration: none; }
.rank .nm small { display: block; font-weight: 400; color: var(--faint); font-size: 12px; }
.rank .c { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; background: var(--hl); color: var(--hl-ink); border-radius: 6px; padding: 2px 8px; }
.rank-empty { font-size: 13px; color: var(--muted); margin: 0; }
.legend { display: grid; gap: 10px; font-size: 13px; color: var(--muted); }
.legend div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }
.dot.ok { background: var(--ok); }
.dot.cm { background: var(--warn); }
.note { font-size: 12px; color: var(--faint); margin: 0; padding: 0 4px; }

/* title page */
.crumbs { font-size: 13px; color: var(--muted); padding-block: 20px 0; }
.crumbs a { color: var(--muted); }
.title-hero { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start; padding-block: 16px 8px; }
.title-hero h1 { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 4.6vw, 42px); line-height: 1.08; margin: 0 0 6px; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: anywhere; }
.title-hero .sub { font-size: 15px; }
.title-hero .summary { margin: 14px 0 0; font-size: 16px; max-width: 60ch; }
.title-hero .badges { margin-top: 12px; }
@media (max-width: 560px) { .title-hero { grid-template-columns: 110px minmax(0, 1fr); gap: 16px; } }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }
.title-main { display: grid; gap: 26px; min-width: 0; }

footer { border-top: 1px solid var(--line); }
footer .wrap { padding-block: 24px 36px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
footer p { margin: 0; max-width: 80ch; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20; }
