:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --line: #e2e7ee;
  --line-2: #d3dae4;
  --text: #121826;
  --muted: #667085;
  --accent: #2f6fed;
  --accent-2: #2359c7;
  --accent-soft: #e8f0fe;
  --good: #16a35c;
  --good-soft: #e6f6ed;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --bad: #d92d20;
  --bad-soft: #fdecea;
  --stage: #e6eaf0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- PC layout ---------- */
.app { display: grid; grid-template-rows: 56px minmax(0, 1fr); height: 100%; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.1px; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa4b2; flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px rgba(22, 163, 92, 0.16); }
.dot.warn { background: #e0a030; }
.dot.bad { background: var(--bad); }
.spacer { flex: 1; }
.ghost {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 7px 12px; font-size: 13px; color: var(--text); text-decoration: none; white-space: nowrap;
}
.ghost:hover { background: var(--panel-2); }

.main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 40vw); min-height: 0; }
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 46vh minmax(0, 1fr); }
}

/* stage */
.stage {
  position: relative; overflow: hidden; background: var(--stage); min-height: 0;
  cursor: grab; touch-action: none; user-select: none;
}
.stage.dragging { cursor: grabbing; }
.wrap { position: absolute; transform-origin: 50% 50%; will-change: transform; box-shadow: 0 2px 18px rgba(16, 24, 40, 0.12); }
.wrap video, .wrap img { display: block; width: 100%; height: 100%; pointer-events: none; background: #000; }
.empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--muted); padding: 24px;
}
.empty b { color: var(--text); display: block; font-size: 18px; margin-bottom: 6px; }
.zoombar {
  position: absolute; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px;
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); border-radius: 11px; padding: 3px;
  box-shadow: var(--shadow);
}
.zoombar button { background: transparent; border: 0; width: 34px; height: 30px; border-radius: 8px; font-size: 18px; }
.zoombar button:hover { background: var(--panel-2); }
.zoombar .pct { min-width: 52px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.zoombar .reset { width: auto; padding: 0 10px; font-size: 12px; color: var(--muted); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.35s; }
.flash.on { opacity: 0.7; transition: none; }
.hint {
  position: absolute; right: 14px; bottom: 14px; font-size: 12px; color: var(--muted);
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; pointer-events: none;
}
@media (max-width: 900px) { .hint { display: none; } }

/* answer panel */
.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
@media (max-width: 900px) { .panel { border-left: 0; border-top: 1px solid var(--line); } }
.shoot {
  margin: 14px 14px 0; height: 64px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 19px; font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(47, 111, 237, 0.28);
  transition: transform 0.06s, background 0.15s;
}
.shoot:hover { background: var(--accent-2); }
.shoot:active { transform: scale(0.985); }
.shoot kbd { font: 12px var(--mono); background: rgba(255, 255, 255, 0.22); border-radius: 6px; padding: 2px 7px; font-weight: 500; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; padding: 14px; }
.banner {
  margin: 12px 14px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: var(--warn-soft); border: 1px solid #f1d39c; color: #8a5a10;
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.card-head img { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--stage); cursor: zoom-in; border: 1px solid var(--line); }
.status { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.status.err { color: var(--bad); }
.spin {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.card-body { padding: 16px; min-height: 90px; }
.placeholder { color: var(--muted); }

/* answer formats */
.choice { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 12px; }
.choice:last-child { margin-bottom: 0; }
.choice .letter {
  flex: none; min-width: 52px; height: 52px; padding: 0 10px; border-radius: 12px; background: var(--good); color: #fff;
  display: grid; place-items: center; font-size: 28px; font-weight: 800;
}
.choice .qn { flex: none; font-size: 13px; color: var(--muted); padding-top: 16px; min-width: 22px; }
.choice .opt { font-size: 21px; line-height: 1.35; padding-top: 10px; font-weight: 600; word-break: break-word; }
.ans { font-size: 24px; font-weight: 650; line-height: 1.35; margin: 0 0 12px; word-break: break-word; }
.ans .qn { font-size: 13px; color: var(--muted); font-weight: 500; margin-right: 8px; }
.warnline { font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; margin: 0 0 12px; }
.para { margin: 0 0 10px; font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.para code, .ans code, .opt code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.code { position: relative; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafbfc; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--panel-2); }
.copy { background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px; padding: 3px 10px; font-size: 12px; }
.copy:hover { background: var(--accent-soft); }
.code pre { margin: 0; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font: 13.5px/1.55 var(--mono); tab-size: 4; color: #1f2328; }
.code pre code.hljs { background: transparent; padding: 0; }
.errbox { color: var(--bad); font-size: 15px; }

.hist-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 2px 8px; display: flex; justify-content: space-between; }
.hist-title button { background: none; border: 0; color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; }
.hist-title button:hover { color: var(--text); }
.hist { display: flex; flex-direction: column; gap: 6px; }
.hrow {
  display: flex; gap: 10px; align-items: center; padding: 7px; border-radius: 10px; border: 1px solid transparent; background: transparent; text-align: left; width: 100%;
}
.hrow:hover { background: var(--panel); border-color: var(--line); }
.hrow img, .hrow .noimg { width: 52px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--stage); flex: none; border: 1px solid var(--line); }
.hrow .t { flex: 1; min-width: 0; }
.hrow .l1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.hrow .l2 { font-size: 12px; color: var(--muted); }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(18, 24, 38, 0.38); display: grid; place-items: center; z-index: 20; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(420px, 100%); text-align: center; box-shadow: 0 20px 50px rgba(16, 24, 40, 0.18); }
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: inline-block; }
.qr img, .qr canvas { display: block; width: 240px; height: 240px; image-rendering: pixelated; }
.link { font: 12px var(--mono); color: var(--muted); word-break: break-all; margin: 12px 0 16px; user-select: all; }
.row { display: flex; gap: 8px; justify-content: center; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-size: 16px; margin-bottom: 12px; text-align: center; letter-spacing: 0.08em;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.primary { background: var(--accent); border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; color: #fff; }
.primary:hover { background: var(--accent-2); }
.errtext { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }
.bigimg { max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25); background: #fff; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.25);
}

/* ---------- Screenshots page ---------- */
.shots-page { min-height: 100%; }
.shots-page .top { position: sticky; top: 0; z-index: 5; height: 56px; }
.shots { max-width: 1280px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); align-items: start; }
.shot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.shot > img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: var(--stage); cursor: zoom-in; border-bottom: 1px solid var(--line); }
.shot .meta { font-size: 12px; color: var(--muted); padding: 10px 14px 0; display: flex; justify-content: space-between; gap: 8px; }
.shot .meta a { color: var(--muted); }
.shot .body { padding: 10px 14px 14px; }
.shot .choice .letter { min-width: 40px; height: 40px; font-size: 21px; border-radius: 10px; }
.shot .choice .opt { font-size: 16px; padding-top: 8px; }
.shot .ans { font-size: 18px; }
.shot .code pre { max-height: 360px; overflow-y: auto; }
.more { display: block; margin: 0 auto 40px; }
.center-note { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Phone ---------- */
.cam { position: fixed; inset: 0; background: #000; overflow: hidden; }
.cam video#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.keepawake { position: fixed; width: 1px; height: 1px; opacity: 0.01; left: 0; top: 0; pointer-events: none; }
.cam-top {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.92);
  color: var(--text); font-size: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.pill.small { font-size: 12px; padding: 5px 11px; }
.cam-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 20px max(22px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.cam-side { display: flex; gap: 10px; }
.cam-side.right { justify-content: flex-end; }
.round {
  width: 50px; height: 50px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.92); color: var(--text);
  display: grid; place-items: center; font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.round.on { background: #ffd166; color: #3d2a00; }
.snapbtn {
  width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: var(--accent); padding: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.snapbtn:active { background: var(--accent-2); transform: scale(0.96); }
.zoomrow {
  position: absolute; left: 24px; right: 24px; bottom: calc(130px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; font-size: 13px;
  background: rgba(255, 255, 255, 0.92); color: var(--text); padding: 8px 14px; border-radius: 999px;
}
.zoomrow input { flex: 1; accent-color: var(--accent); }
.start { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--bg); color: var(--text); }
.start h1 { font-size: 24px; margin: 0 0 8px; }
.start p { color: var(--muted); margin: 0 0 22px; }
.start .primary { font-size: 18px; padding: 16px 28px; border-radius: 14px; }
.start .tip { font-size: 13px; margin-top: 18px; color: var(--muted); max-width: 320px; }
