:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --text: #1b1b1a;
  --text-2: #52514e;
  --muted: #7c7b76;
  --border: #e0dfda;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefb;
  --good: #1d7f45;
  --good-soft: #e1f3e8;
  --bad: #c8403a;
  --bad-soft: #fbe6e4;
  --focus: #2a78d6;
  /* PotatoVN window background (Windows 11 light Mica) that the faded header image sits on */
  --mica: #f3f3f3;
  --mica-text: #1b1b1b;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 5%);
  --radius: 12px;
  --series-1: #2a78d6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131312;
    --surface: #1c1c1b;
    --surface-2: #262624;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #94938c;
    --border: #33332f;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: #1d3150;
    --good: #4cc27c;
    --good-soft: #17331f;
    --bad: #ef6b63;
    --bad-soft: #3d1c1a;
    --focus: #6aa8f0;
    --mica: #202020;
    --mica-text: #ffffff;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --series-1: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312;
  --surface: #1c1c1b;
  --surface-2: #262624;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #94938c;
  --border: #33332f;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --accent-soft: #1d3150;
  --good: #4cc27c;
  --good-soft: #17331f;
  --bad: #ef6b63;
  --bad-soft: #3d1c1a;
  --focus: #6aa8f0;
  --mica: #202020;
  --mica-text: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --series-1: #3987e5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 16px 24px 32px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.brand b { font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14em; }
.user-id { font-size: 12px; color: var(--muted); white-space: nowrap; }
.user-id b { font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.btn.large { min-height: 46px; padding: 10px 22px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.link { background: none; border: 0; padding: 4px 2px; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.del { color: var(--muted); }

/* ---------- landing ---------- */
.landing { display: grid; place-items: center; padding: 6vh 0; }
.landing-card {
  max-width: 560px; padding: 32px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.landing-card h1 { margin: 0 0 12px; font-size: 24px; }
.landing-card p { color: var(--text-2); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.notice.error { background: var(--bad-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }

/* ---------- summary tiles ---------- */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 4px 0 16px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.tile-label { font-size: 13px; color: var(--text-2); }
.tile-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-sub { font-size: 12px; color: var(--muted); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto;
}
.seg button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 14px;
  padding: 5px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; min-height: 30px;
}
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.seg .n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; margin-left: 2px; }
.status-line { min-height: 1.4em; margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
.status-line.error { color: var(--bad); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; align-items: start; }
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card[data-verdict="good"] { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.card[data-verdict="bad"] { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }

/* The banner box keeps the 2048x768 (8:3) ratio, like PotatoVN's Stretch="Uniform" header. */
.banner {
  position: relative; display: block; width: 100%; aspect-ratio: 8 / 3; padding: 0; margin: 0;
  border: 0; cursor: zoom-in; overflow: hidden; background: var(--surface-2);
}
.banner-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.banner-img.broken { visibility: hidden; }
.banner-title { display: none; }

/* PotatoVN rendering: the image's alpha follows DownloadHelper.CalcAlpha (left/right/bottom fade,
   global 0.35 cap) and sits on the window background, with the game title over the left side. */
.fx .banner, .viewer-frame.fx { background: var(--mica); }
.fx .banner-img, .viewer-frame.fx img {
  -webkit-mask-image: var(--fade-mask); mask-image: var(--fade-mask);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.fx .banner-title {
  display: flex; flex-direction: column; position: absolute; left: 4%; top: 13%; max-width: 46%;
  color: var(--mica-text); text-align: left; pointer-events: none;
}
.fx .banner-title b { font-size: clamp(15px, 2.3vw, 24px); font-weight: 650; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fx .banner-title small { font-size: clamp(11px, 1.2vw, 13px); opacity: .7; margin-top: 2px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (min-width: 1100px) {
  .fx .banner-title b { font-size: 20px; }
}

.card-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.titles { min-width: 0; }
.title { margin: 0; font-size: 16px; font-weight: 620; overflow-wrap: anywhere; }
.alt { margin: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid {
  flex: none; font-size: 12px; color: var(--muted); text-decoration: none; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; font-variant-numeric: tabular-nums;
}
.vid:hover { color: var(--accent); border-color: var(--accent); }

.verdict-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vbtn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer;
}
.vbtn:hover { background: var(--surface-2); }
.vbtn.good[aria-pressed="true"] { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.vbtn.bad[aria-pressed="true"] { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.vbtn:disabled { opacity: .6; cursor: progress; }
.state { font-size: 13px; color: var(--muted); }

.summary-line { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--bad-soft); color: var(--text); }
.comment-text { margin: 0; font-size: 14px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.summary-actions { display: flex; gap: 10px; }

.detail { display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.reasons { border: 0; padding: 0; margin: 0; }
.reasons legend { font-size: 13px; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.reason-list { display: flex; flex-wrap: wrap; gap: 6px; }
.reason {
  position: relative; display: inline-flex; align-items: center; min-height: 34px; padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 14px;
  cursor: pointer; user-select: none;
}
.reason input { position: absolute; opacity: 0; pointer-events: none; }
.reason:has(input:checked) { background: var(--bad-soft); border-color: var(--bad); color: var(--text); font-weight: 600; }
.reason:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.comment { display: flex; flex-direction: column; gap: 4px; position: relative; }
.comment-label { font-size: 13px; color: var(--text-2); }
.comment textarea {
  width: 100%; resize: vertical; min-height: 60px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.counter { align-self: flex-end; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-error { margin: 0; min-height: 0; color: var(--bad); font-size: 13px; }
.form-error:empty { display: none; }
.form-actions { display: flex; gap: 8px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.nobanner { margin-top: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; }
.nobanner summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.nobanner ul { list-style: none; padding: 0; margin: 0 0 12px; columns: 2 280px; column-gap: 24px; }
.nobanner li { padding: 4px 0; break-inside: avoid; font-size: 14px; border-bottom: 1px dashed var(--border); overflow-wrap: anywhere; }
.nobanner li .muted { font-size: 12px; margin-left: 6px; }

/* ---------- skeleton ---------- */
.skeleton .banner { background: linear-gradient(90deg, var(--surface-2), var(--bg), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton .banner { animation: none; } }

/* ---------- viewer ---------- */
.viewer {
  width: min(96vw, 1600px); max-width: none; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); overflow: hidden;
}
.viewer::backdrop { background: rgb(0 0 0 / 72%); }
.viewer-frame { position: relative; aspect-ratio: 8 / 3; background: var(--surface-2); }
.viewer-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-size: 14px; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.viewer-title { font-weight: 600; overflow-wrap: anywhere; }
.viewer-actions { display: flex; gap: 8px; }

/* ---------- footer ---------- */
.footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px;
  padding: 18px 16px 26px; font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border);
}

/* ---------- admin ---------- */
.admin h1 { font-size: 22px; margin: 6px 0 14px; }
.admin h2 { font-size: 17px; margin: 0 0 10px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:hover td { background: var(--surface-2); }
.bar-cell { min-width: 120px; width: 40%; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 10px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); }
.bar-label { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-item { display: grid; grid-template-columns: 128px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-item img { width: 128px; aspect-ratio: 8 / 3; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.comment-meta { font-size: 12px; color: var(--muted); }
.verdict-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 0 8px; border-radius: 999px; margin-right: 6px; }
.verdict-tag.good { background: var(--good-soft); color: var(--good); }
.verdict-tag.bad { background: var(--bad-soft); color: var(--bad); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  main { padding: 12px 16px 24px; }
  .topbar { padding: 8px 16px; }
  .brand span { display: none; }
  .user-name { max-width: 7em; }
  .summary { gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-value { font-size: 21px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 5px 6px; }
  #viewSeg { width: auto; flex: 1; }
  .card-body { padding: 10px 12px 12px; }
  .landing-card { padding: 22px 18px; }
  .comment-item { grid-template-columns: 96px 1fr; }
  .comment-item img { width: 96px; }
}
