:root {
  --bar: 64px; --stim-bg: #ffffff;
  --ink: #1d1d1b; --muted: #6a6862; --line: #d9d6ce; --paper: #f4f2ed; --card: #ffffff;
  --accent: #1f5f8b; --accent-ink: #ffffff; --good: #1d6b46; --bad: #a8321f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink);
  font: 17px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }

#app { position: fixed; inset: 0; z-index: 1; overflow: auto; padding: 5vh 20px 8vh; display: flex; justify-content: center; align-items: flex-start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 30px 34px; width: 100%; max-width: 800px; }
.card h1 { font-size: 22px; margin: 0; font-weight: 650; }
.card h2 { font-size: 21px; margin: 0 0 12px; font-weight: 650; text-wrap: balance; }
.card h3 { font-size: 15px; margin: 26px 0 10px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
.pre { white-space: pre-line; margin: 0 0 8px; }
.lead { font-size: 18px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0; }
.err { color: var(--bad); font-size: 15px; margin: 8px 0; white-space: pre-line; }
.good { color: var(--good); font-size: 15px; margin: 4px 0; }
.small { font-size: 12.5px; }
pre.small { background: var(--paper); padding: 10px; border-radius: 6px; overflow: auto; max-height: 180px; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.center-msg { align-self: center; margin: auto; font-size: 20px; color: var(--muted); text-align: center; }

.btn {
  font: inherit; font-weight: 600; padding: 10px 22px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: #b9b5aa; }
.btn:focus-visible, .pt:focus-visible, .opt:focus-visible { outline: 3px solid #9cc3de; outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #194f75; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: 14px; }
.btn.danger { color: var(--bad); }

/* setup */
.setup .head { display: flex; align-items: baseline; gap: 12px; }
.setup .ver { color: var(--muted); font-size: 14px; flex: 1; font-variant-numeric: tabular-nums; }
.opt-row { display: flex; align-items: center; gap: 14px; margin: 8px 0; flex-wrap: wrap; }
.opt-row .hint { flex: 1; min-width: 220px; }
.summary { margin-top: 12px; padding: 12px 16px; background: var(--paper); border-radius: 8px; font-size: 15px; }
.summary p { margin: 2px 0; }
.grid { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; align-items: start; font-size: 15px; }
.grid > label { padding-top: 8px; color: var(--muted); }
.grid input[type=number], .grid select, .grid textarea, .stored textarea { width: 100%; max-width: 320px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.grid textarea, .stored textarea { max-width: none; resize: vertical; }
label.inline { margin-right: 18px; }
label.check { display: block; margin: 12px 0 0; font-size: 15px; }
.ask { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; }
.ask .btn { margin-right: 8px; }
.stored { margin-top: 18px; font-size: 14px; }
.stored summary { cursor: pointer; color: var(--muted); }
.stored ul { padding-left: 18px; }
.foot { margin-top: 22px; }

/* questionnaires */
.survey .cue { display: inline-block; font-weight: 650; font-size: 19px; padding: 6px 14px; background: var(--paper); border-radius: 6px; margin-bottom: 14px; }
.item { padding: 18px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.stem { margin: 0 0 12px; font-weight: 550; }
.scale { display: grid; grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr); gap: 12px; align-items: center; }
.scale .end { font-size: 14px; color: var(--muted); text-align: right; line-height: 1.3; }
.scale .end.right { text-align: left; }
.pts { display: flex; gap: 8px; }
.pt { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid #bdb9ae; background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums; }
.pt:hover { border-color: var(--accent); }
.pt.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: var(--ink); cursor: pointer; }
.opt:hover { border-color: #b9b5aa; }
.opt i { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #a9a59a; }
.opt.on { border-color: var(--accent); background: #eef5fa; }
.opt.on i { border: 5px solid var(--accent); }
.conf-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.conf-row .end { font-size: 14px; color: var(--muted); }
.conf input[type=range] { width: 100%; height: 36px; accent-color: var(--accent); }
.conf input[type=range].untouched { accent-color: #b5b1a6; opacity: .6; }
.conf-num { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.conf-num input { width: 110px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.conf-num output { font-weight: 650; font-size: 20px; font-variant-numeric: tabular-nums; }
.survey textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.survey input.num { width: 140px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }

/* stimulus */
#stage { position: fixed; left: 0; top: 0; right: 0; bottom: var(--bar); z-index: 10; background: var(--stim-bg); overflow: hidden; }
#stage img, #stage video { position: absolute; display: block; max-width: none; -webkit-user-drag: none; pointer-events: none; }
#nextbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar); z-index: 11; background: var(--stim-bg); border-top: 1px solid rgba(0,0,0,.08); display: flex; align-items: center; justify-content: flex-end; padding: 0 28px; }

/* calibration */
#calib { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; cursor: default; }
.calib-card { max-width: 560px; }
.calib-card.wide { max-width: 760px; }
.target { position: absolute; width: 0; height: 0; }
.target::before { content: ""; position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; background: #222; animation: shrink var(--dur, 1700ms) ease-out forwards; }
.target i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
@keyframes shrink { from { transform: scale(1); } to { transform: scale(.36); } }
@media (prefers-reduced-motion: reduce) { .target::before { animation: none; transform: scale(.5); } }
.cc-grid { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; margin-top: 14px; }
.cam-preview { width: 400px; max-width: 100%; height: auto; border-radius: 8px; background: #222; }
.checks { list-style: none; padding: 0; margin: 0; font-size: 16px; }
.checks li { margin: 8px 0; color: var(--muted); }
.checks li.ok { color: var(--good); }
.checks li.bad b { color: var(--bad); }
@media (max-width: 700px) { .cc-grid { grid-template-columns: 1fr; } .scale { grid-template-columns: 1fr; } .scale .end, .scale .end.right { text-align: center; } .pt { width: 38px; height: 38px; } .pts { gap: 5px; justify-content: center; } .grid { grid-template-columns: 1fr; } .card { padding: 22px 18px; } }

/* overlays */
#gazeDot { position: fixed; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; z-index: 55; background: rgba(214, 40, 40, .55); border: 2px solid #fff; pointer-events: none; will-change: transform; }
#pause { position: fixed; inset: 0; z-index: 60; background: #3d3c39; display: flex; align-items: center; justify-content: center; padding: 20px; }
#panel { position: fixed; top: 12px; right: 12px; z-index: 80; width: 320px; background: #fffef9; border: 1px solid #b9b5aa; border-radius: 8px; padding: 12px 14px; font-size: 13.5px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#panel h4 { margin: 0 0 6px; font-size: 14px; }
#panel .stat { margin: 0 0 8px; font: 13px/1.5 ui-monospace, "SF Mono", Consolas, monospace; white-space: pre-wrap; }
#panel textarea { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13.5px; resize: vertical; }
.pn-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
#cam { position: fixed; left: 0; bottom: 0; width: 2px; height: 2px; opacity: .01; pointer-events: none; z-index: 0; }

/* researcher menu on the setup screen */
.topnav { display: flex; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #fff; position: fixed; top: 0; left: 0; right: 0; z-index: 5; }
.topnav[hidden] { display: none; }
.topnav a { padding: 6px 14px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600; }
.topnav a.on { background: var(--paper); color: var(--ink); }
.topnav a:hover { color: var(--ink); }
body.with-nav #app { top: 50px; }
