/* bance-rsi-eval — palette follows the published atmosphere report. Light only:
   a fixed light-neutral surround keeps colour judgements comparable. */
:root {
  --bg: #FDFDFB; --surface: #EDF4F4; --blue: #B4D8DD; --coral: #EF9DA6; --acc: #486B70;
  --rose: #FBEFEF; --text: #3B4142; --muted: #6B7476; --line: #DFE7E7; --ink: #191919;
  --canvas: #F0F0ED; --warn: #A9493A; --radius: 14px; --gutter: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
body.modal-open { overflow: hidden; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.boot { padding: 40vh var(--gutter) 0; text-align: center; color: var(--muted); }
.center { text-align: center; padding-top: 16vh; }
.center h1 { color: var(--ink); font-size: 24px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 16px; min-height: 46px; font-weight: 600; cursor: pointer; line-height: 1.3;
}
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.light { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; min-height: 44px; }

/* Welcome */
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--acc); margin: 28px 0 0; font-weight: 600; }
.welcome h1 { font-size: 25px; line-height: 1.3; margin: 6px 0 10px; color: var(--ink); font-weight: 650; }
.hello { font-weight: 600; color: var(--ink); }
.facts { display: flex; gap: 8px; flex-wrap: wrap; padding: 0; margin: 14px 0; list-style: none; }
.facts li { background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.notice { font-size: 13px; color: var(--muted); background: var(--rose); border-radius: 10px; padding: 10px 12px; }
.welcome { padding-bottom: 40px; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 8px var(--gutter); padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(253,253,251,.95); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-back { border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 8px 6px 0; cursor: pointer; color: var(--ink); }
.bar-mid { flex: 1; min-width: 0; }
.bar-title { font-size: 14px; font-weight: 600; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.bar-title .kind { font-size: 12px; font-weight: 500; color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress .fill { display: block; height: 100%; background: var(--acc); transition: width .3s; }
.save { font-size: 12px; color: var(--muted); white-space: nowrap; border: 0; background: none; padding: 4px 0; }
.save.error { color: var(--warn); text-decoration: underline; cursor: pointer; }

/* Brief */
.brief { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0 6px; }
.brief .kicker { font-size: 12px; color: var(--acc); font-weight: 600; line-height: 1.4; }
.brief h2 { font-size: 17px; line-height: 1.35; margin: 3px 0 6px; color: var(--ink); }
.brief dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; line-height: 1.5; }
.brief dt { color: var(--muted); white-space: nowrap; }
.brief dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.question { font-weight: 650; color: var(--ink); margin: 14px 0 10px; font-size: 17px; line-height: 1.45; }

/* Images */
.shot {
  display: block; width: 100%; padding: 0; border: 0; background: var(--canvas); border-radius: 12px;
  overflow: hidden; cursor: zoom-in;
}
.shot img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Portrait pairs sit side by side even on phones so A and B can be compared at a
   glance; landscape pairs stack on phones. On wide screens each image is capped
   at 66vh tall (width follows its ratio) so the answer stays close. */
.pair { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.pair.portrait { grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 760px) {
  .pair, .pair.portrait { grid-template-columns: 1fr 1fr; gap: 16px; }
  .pair .shot { width: min(100%, calc(66vh * var(--r, 0.667))); margin: 0 auto; }
}
.cand { margin: 0; position: relative; }
.tag {
  position: absolute; top: 10px; left: 10px; z-index: 2; background: rgba(25,25,25,.84); color: #fff;
  border-radius: 8px; padding: 1px 11px; font-size: 16px; pointer-events: none;
}
.note-btn {
  margin-top: 2px; background: none; border: 0; color: var(--acc); font-size: 14px; padding: 8px 2px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-align: left; min-height: 40px;
}
@media (min-width: 760px) { .pair .note-btn { display: block; margin: 2px auto 0; } }
.note-btn.has { color: var(--warn); }
.sets { display: grid; gap: 20px; }
@media (min-width: 900px) { .sets { grid-template-columns: 1fr 1fr; } }
.set-title { margin: 0 0 8px; font-size: 15px; color: var(--ink); }
.set-title b { background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 9px; margin-right: 4px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cell { margin: 0; min-width: 0; }
.cell .shot { aspect-ratio: 3 / 4; border-radius: 8px; }
.cell figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.3; }

/* Answer */
.answer { margin-top: 18px; padding-bottom: 6px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 62px;
  padding: 8px 2px; border: 1px solid var(--line); background: #fff; border-radius: 12px; cursor: pointer; min-width: 0;
}
.scale-btn b { font-size: 18px; color: var(--ink); line-height: 1.2; }
.scale-btn span { font-size: 12px; color: var(--muted); line-height: 1.25; text-align: center; }
.scale-btn.on { background: var(--ink); border-color: var(--ink); }
.scale-btn.on b, .scale-btn.on span { color: #fff; }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px;
  cursor: pointer; min-height: 36px; line-height: 1.35;
}
.chip.on { background: var(--surface); border-color: var(--acc); color: var(--ink); font-weight: 600; }
textarea {
  display: block; width: 100%; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: #fff; resize: vertical; min-height: 64px; font-size: 16px; line-height: 1.5;
}
textarea:focus { outline: none; border-color: var(--acc); }

/* Pager sits after the answer (not sticky), so it never covers the images. */
.pager {
  margin-top: 18px; border-top: 1px solid var(--line);
  padding: 12px var(--gutter); padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.pager-inner { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* Bottom sheet */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(25,25,25,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 16px var(--gutter); padding-bottom: max(16px, env(safe-area-inset-bottom));
}
@media (min-width: 760px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; } }
.sheet-head { display: flex; gap: 12px; align-items: center; }
.sheet-head h3 { margin: 0; font-size: 17px; color: var(--ink); }
.sheet-head p { margin: 2px 0 0; font-size: 13px; line-height: 1.45; }
.note-thumb { width: 56px; height: 74px; object-fit: contain; background: var(--canvas); border-radius: 8px; flex: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; min-height: 42px; padding: 6px; cursor: pointer; font-size: 14px; }
.seg-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 60; background: #121212; color: #fff; display: flex; flex-direction: column; }
.lb-top, .lb-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; }
.lb-top { padding-top: max(8px, env(safe-area-inset-top)); font-size: 14px; }
.lb-bottom { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.lb-caption { font-size: 13px; color: rgba(255,255,255,.75); }
.lb-close { background: none; border: 0; color: #fff; font-size: 30px; line-height: 1; padding: 2px 8px; cursor: pointer; }
.lb-nav { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; min-width: 52px; min-height: 44px; font-size: 20px; cursor: pointer; }
.lb-nav:disabled { opacity: .25; cursor: default; }

/* Final + reveal */
.final, .done { padding-bottom: 48px; }
.final h2, .done h1 { color: var(--ink); margin: 22px 0 4px; }
.q { display: block; margin-top: 18px; }
.q > span { font-weight: 600; color: var(--ink); line-height: 1.5; }
.missing { background: var(--rose); border-radius: 12px; padding: 10px 12px; margin-top: 18px; }
.missing p { margin: 0 0 8px; }
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.fine { font-size: 13px; color: var(--muted); text-align: center; margin: 8px 0 0; }
.groups { display: grid; gap: 10px; margin: 16px 0; }
.group { background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.group h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink); }
.group p { margin: 2px 0; font-size: 14px; line-height: 1.5; }
.reveal-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.rv { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fff; }
.rv-head { margin: 0 0 8px; font-size: 14px; color: var(--muted); line-height: 1.4; }
.rv-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rv-side { border-radius: 10px; padding: 6px; border: 2px solid transparent; min-width: 0; }
.rv-side.picked { border-color: var(--acc); background: var(--surface); }
.rv-thumbs { display: grid; grid-template-columns: 1fr; gap: 4px; }
.rv-thumbs.many { grid-template-columns: repeat(3, 1fr); }
.rv-thumbs img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: var(--canvas); border-radius: 6px; display: block; }
.rv-side p { font-size: 13px; margin: 6px 0 0; line-height: 1.45; overflow-wrap: anywhere; }
.badge { display: inline-block; margin-left: 6px; background: var(--acc); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 6px; vertical-align: 1px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 70;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
