:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242e;
  --line: #2b313c;
  --text: #e7eaf0;
  --muted: #9aa4b2;
  --accent: #4c8dff;
  --accent-2: #2f6fe0;
  --good: #35c07a;
  --good-dim: #1f6e48;
  --warn: #f0a83a;
  --bad: #ff6b6b;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }
b { color: #fff; }
.muted { color: var(--muted); font-weight: 400; }

/* buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #262c37; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-2); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-pick { width: 100%; margin-top: 10px; font-weight: 600; }

/* ============ gate ============ */
.gate { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.gate-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 560px; width: 100%; padding: 32px;
}
.gate-card h1 { margin: 0 0 12px; font-size: 22px; }
.lede { color: var(--muted); }
.gate-points { color: var(--muted); font-size: 14px; padding-left: 18px; }
.gate-points li { margin: 4px 0; }
.gate-label { display: block; margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.gate-input {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 15px; margin-bottom: 14px;
}
.gate-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.gate-err { color: var(--bad); min-height: 18px; font-size: 13px; }

/* ============ topbar ============ */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.brand { font-weight: 700; }
.whoami { color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sync-status { font-size: 12px; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--line); }
.sync-status.ok { color: var(--good); border-color: var(--good-dim); }
.sync-status.pending { color: #101317; background: var(--warn); border-color: var(--warn); font-weight: 600; }
.overall { display: flex; align-items: center; gap: 8px; }
.overall-bar { width: 180px; height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.overall-fill { height: 100%; width: 0; background: var(--good); transition: width .2s; }
.overall-text { font-size: 13px; color: var(--muted); min-width: 74px; text-align: right; }

/* ============ layout ============ */
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 260px; flex-shrink: 0; border-right: 1px solid var(--line);
  background: var(--panel); overflow-y: auto; max-height: calc(100vh - 53px); position: sticky; top: 53px;
}
.sidebar-head { padding: 12px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.group-list { list-style: none; margin: 0; padding: 0; }
.group-item {
  padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.group-item:hover { background: var(--panel-2); }
.group-item.active { background: #223049; border-left: 3px solid var(--accent); padding-left: 11px; }
.gi-check { width: 16px; text-align: center; color: var(--good); }
.gi-body { flex: 1; min-width: 0; }
.gi-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gi-genre { color: var(--muted); font-size: 11px; }
.gi-count { font-size: 11px; color: var(--muted); }
.gi-count.done { color: var(--good); }

.main { flex: 1; min-width: 0; padding: 18px 22px; overflow-y: auto; max-height: calc(100vh - 53px); }

/* ============ meta card ============ */
.meta-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.meta-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 14px 18px; }
.meta-title { margin: 6px 0 0; font-size: 23px; }
.chip { display: inline-block; background: #223049; color: #cfe0ff; font-size: 12px; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.meta-body { padding: 0 18px 18px; }
.synopsis { color: #c4ccd8; font-size: 16.5px; line-height: 1.65; margin: 2px 0 16px; }
.meta-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.meta-col h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.chars { display: flex; flex-wrap: wrap; gap: 14px; }
.char { width: 86px; text-align: center; }
.char img { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); }
.char .noimg { width: 72px; height: 72px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 24px; }
.char-name { font-size: 13.5px; margin-top: 5px; }
.char-actor { font-size: 12px; color: var(--muted); }
.events { margin: 0; padding-left: 20px; color: #c4ccd8; font-size: 15px; line-height: 1.55; }
.events li { margin-bottom: 8px; }

/* ============ mode row ============ */
.mode-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mode-tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; }
.tab { border: none; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--accent-2); color: #fff; font-weight: 600; }
.group-progress { display: flex; align-items: center; gap: 10px; }
.gp-bar { width: 160px; height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.gp-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ============ judge ============ */
.judge-q { font-size: 16px; margin-bottom: 14px; }
.pair-label { display: inline-block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; margin-right: 8px; font-size: 13px; color: var(--muted); }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; }
.cand { margin: 0; }
.cand-imgwrap { position: relative; background: #000; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.cand-img { display: block; width: 100%; height: 46vh; object-fit: contain; background: #000; cursor: pointer; }
.cand.chosen .cand-imgwrap { border-color: var(--good); box-shadow: 0 0 0 3px rgba(53,192,122,.25); }
.cand.chosen .btn-pick { background: var(--good-dim); border-color: var(--good); color: #fff; }
.zoom-btn { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.55); color: #fff; font-size: 18px; cursor: pointer; }
.zoom-btn:hover { background: rgba(0,0,0,.8); }
.vs { color: var(--muted); font-weight: 700; }
.judge-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.pair-state { font-size: 13px; color: var(--muted); min-width: 160px; text-align: center; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ============ review ============ */
.review-hint { color: var(--muted); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.rev-cell { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; }
.rev-cell:hover { border-color: var(--accent); }
.rev-cell.undone { border-color: var(--warn); }
.rev-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rev-thumb { position: relative; }
.rev-thumb img { width: 100%; height: 92px; object-fit: contain; background: #000; border: 2px solid transparent; border-radius: 6px; }
.rev-thumb.win img { border-color: var(--good); }
.rev-thumb.win::after { content: "✓"; position: absolute; top: 4px; left: 6px; color: var(--good); font-weight: 700; text-shadow: 0 1px 3px #000; }
.rev-caption { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; justify-content: space-between; }
.review-foot { margin-top: 18px; text-align: right; }

/* ============ lightbox ============ */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; z-index: 100; }
.lightbox-img { max-width: 94vw; max-height: 92vh; object-fit: contain; }
.lightbox-close { position: absolute; top: 18px; right: 24px; font-size: 36px; line-height: 1; background: none; border: none; color: #fff; cursor: pointer; }

/* ============ language selector ============ */
.lang-row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-bottom: 6px; }
.lang-label { font-size: 12px; color: var(--muted); }
.lang-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; font-size: 13px; cursor: pointer;
}

/* ============ collaborative topbar bits ============ */
.mode-row { padding: 10px 18px 0; }
.prog-chip { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; }
.prog-chip b { color: var(--text); }
.main { padding: 0 22px 22px; max-height: none; }

/* now-judging banner */
.now-judging { font-size: 14px; color: var(--muted); margin: 12px 0 10px; }
.now-judging b { color: var(--text); }

/* done box */
.done-box { text-align: center; padding: 60px 20px; }
.done-box h2 { font-size: 24px; margin-bottom: 10px; }
.done-box p { color: var(--muted); max-width: 520px; margin: 0 auto; }

/* my-work: per-movie sections */
.mine-section { margin-bottom: 22px; }
.mine-head { display: flex; align-items: center; gap: 10px; padding: 8px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.mine-title { font-size: 16px; font-weight: 600; }
.mine-count { margin-left: auto; font-size: 12px; color: var(--muted); }
[dir="rtl"] .mine-count { margin-left: 0; margin-right: auto; }

/* ============ RTL: keep the L/R image row physically stable so ← / → stay correct ============ */
.pair { direction: ltr; }
[dir="rtl"] .topbar-left, [dir="rtl"] .topbar-right { flex-direction: row-reverse; }
[dir="rtl"] .now-judging, [dir="rtl"] .judge-q, [dir="rtl"] .synopsis, [dir="rtl"] .events { text-align: right; }

@media (max-width: 900px) {
  .meta-cols { grid-template-columns: 1fr; }
  .cand-img { height: 38vh; }
}
