:root {
  --bg: #0b1220;
  --bg-soft: #131c2e;
  --card: #17233a;
  --line: #24314d;
  --text: #e8eefc;
  --muted: #8fa0bf;
  --brand: #4f8dfd;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 类选择器里的 display 会覆盖 [hidden] 的默认 display:none，这里强制生效 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 780px;
  margin: 0 auto;
}

.app-header h1 { font-size: 20px; margin: 6px 0 2px; letter-spacing: .5px; }
.app-header .sub { margin: 0; color: var(--muted); font-size: 12.5px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
}
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 15px; padding: 10px 0; border-radius: 999px; font-family: inherit;
  transition: background .18s, color .18s;
}
.tab.active { background: var(--brand); color: #fff; font-weight: 600; }

main { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.panel { display: none; flex-direction: column; gap: 12px; }
.panel.active { display: flex; }

.tip {
  margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px;
}
.tip b { color: var(--text); }
.tip a { color: var(--brand); }
.tip.warn { border-color: #6b4b12; background: #2a1f0b; color: #f3d9a4; }
.tip.warn a { color: #ffd479; }

.slots { display: flex; flex-direction: column; gap: 12px; }

.slot {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.slot-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.badge {
  width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.slot-state { margin-left: auto; color: var(--muted); font-size: 12px; }
.slot-state.ready { color: var(--ok); }

.preview {
  position: relative; border-radius: 12px; overflow: hidden; background: #0d1626;
  min-height: 132px; display: grid; place-items: center;
}
.preview video { width: 100%; max-height: 260px; display: block; background: #000; }
.preview .placeholder { color: #48607f; font-size: 13px; padding: 36px 10px; text-align: center; }
.preview audio { width: 100%; padding: 14px 8px; }
.preview canvas.wave { width: 100%; height: 92px; display: block; }

.slot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text); font-family: inherit; font-size: 14.5px; padding: 11px 14px;
  border-radius: 11px; cursor: pointer; transition: transform .06s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #2a0b0b; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.actions { display: flex; gap: 10px; }

.result {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.result .verdict-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.verdict { font-size: 30px; font-weight: 800; letter-spacing: 1px; }
.verdict.same { color: var(--ok); }
.verdict.diff { color: var(--bad); }
.verdict.unsure { color: var(--warn); }
.score { color: var(--muted); font-size: 13.5px; }
.score b { color: var(--text); font-size: 15px; }

.media-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.media-cell {
  background: #0d1626; border-radius: 12px; padding: 8px; font-size: 12px;
  color: var(--muted); display: flex; flex-direction: column; gap: 6px;
}
.media-cell img { width: 100%; border-radius: 8px; display: block; }
.media-cell canvas { width: 100%; height: 62px; display: block; }
.media-cell .caption { text-align: center; }

.detail-list { margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.warn-list { margin: 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }
.error-box { color: var(--bad); font-size: 13px; line-height: 1.6; }

.app-footer { color: #5b6f8f; font-size: 11.5px; text-align: center; padding-top: 4px; }

.modal {
  position: fixed; inset: 0; background: rgba(3, 8, 18, .84); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 18px; z-index: 50;
}
.modal-card {
  width: 100%; max-width: 520px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.rec-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.rec-head #rec-timer { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-stage {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  min-height: 180px; display: grid; place-items: center;
}
.rec-stage video { width: 100%; max-height: 320px; display: block; }
.rec-hint { position: absolute; color: #cfe0ff; font-size: 13px; padding: 44px 12px; text-align: center; }
.meter {
  position: absolute; left: 12px; right: 12px; bottom: 12px; height: 6px;
  background: rgba(255,255,255,.16); border-radius: 99px; overflow: hidden;
}
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.rec-actions { display: flex; gap: 10px; }
.rec-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: #22304a; border: 1px solid var(--line);
  color: var(--text); font-size: 13px; padding: 10px 16px; border-radius: 999px;
  z-index: 60; max-width: 86vw; text-align: center;
}

.token-input {
  width: 100%; padding: 13px 14px; border-radius: 11px; font-size: 16px;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  font-family: inherit;
}
.token-input:focus { outline: none; border-color: var(--brand); }
