/* =========================================================================
   알러젠 탐험 퀘스트 — 디자인 시스템
   크림 종이 + 숲 녹색 + 호박색. 도장(stamp)·도감(dex)·트레일(trail)·스테이지(stage) 컴포넌트.
   일러스트(web/art.js)는 .art .k-* 토큰 클래스로 칠하고 .an-* 로 움직인다.
   토큰 기반, 라이트/다크, prefers-reduced-motion 대응.
   ========================================================================= */

:root {
  --bg: #fbf7ee;
  --bg-elev: #fffdf8;
  --bg-subtle: #f3ecdc;
  --surface-2: #f7f1e3;
  --border: #e6dcc6;
  --border-strong: #d2c4a6;
  --text: #1f2a24;
  --text-2: #4d5a52;
  --text-3: #5f6d63;
  --ink: #1f2a24;

  --brand: #2f8f5b;
  --brand-strong: #24734a;    /* 채움 컨트롤(버튼·선택 칩) — 흰 글자 5.8:1 */
  --brand-soft: #e3f2e9;
  --brand-contrast: #ffffff;
  --accent: #f2a33a;
  --accent-soft: #fdeed6;
  --accent-ink: #8a5a12;
  --ink-on-accent: #2b1d05;   /* 호박 채움 위 글자 7.9:1 */

  --relevant: #e4572e;        /* 채움·테두리용 */
  --relevant-ink: #a83616;    /* 텍스트용(AA) */
  --relevant-soft: #fde9e2;
  --relevant-border: #f6c3b3;
  --sensitized: #6b7a8f;
  --sensitized-ink: #4a5768;
  --sensitized-soft: #eef1f5;
  --sensitized-border: #d5dce6;
  --indet: #d9860a;
  --indet-ink: #8a5405;
  --indet-soft: #fdf3e3;
  --indet-border: #f3dcae;
  --ok: #2f8f5b;
  --ok-soft: #e3f2e9;

  --shadow-sm: 0 1px 2px rgba(60,48,20,.06), 0 1px 3px rgba(60,48,20,.05);
  --shadow-md: 0 6px 16px rgba(60,48,20,.10), 0 2px 6px rgba(60,48,20,.05);
  --shadow-lg: 0 18px 44px rgba(60,48,20,.16);
  --shadow-brand: 0 8px 24px rgba(47,143,91,.28);

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;

  --font: 'Pretendard', 'Pretendard Variable', -apple-system, BlinkMacSystemFont,
          'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --font-display: 'Do Hyeon', 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;

  --maxw: 980px;
  --dur: .32s;
  --ease: cubic-bezier(.2,.8,.2,1);
  --grid-dot: rgba(47,143,91,.06);

  /* 일러스트 팔레트 */
  --art-ink: #24342b; --art-line: #b9ad90; --art-cream: #fff4dc; --art-leaf-d: #24734a;
  --art-sky: #7fb7d6; --art-blush: #f4a58a; --art-glass: rgba(150,205,225,.42);
  /* 도감 카드의 종류(카테고리) 색 — 판정색(주홍·슬레이트·호박)과 겹치지 않게 고른 자연색 */
  --type-mite: #7d6bb0; --type-animal: #a8713f; --type-pollen_tree: #2f8f5b; --type-pollen_grass: #6f9427;
  --type-pollen_weed: #988a1f; --type-mold: #2f8894; --type-insect: #8a5a6a; --type-venom: #3f5fae; --type-food: #b5588f; --type-other: #6f7a72;
  /* 라텍스·약물·검사 대조 — 판정색(주황빨강·회청·호박)과 겹치지 않는 보라·하늘·회갈 */
  --type-latex: #9a53b8; --type-drug: #1f8fc4; --type-control: #7a6c5d;
  color-scheme: light;
}

/* 다크 토큰 — 수동 토글(data-theme="dark")과 OS 선호 양쪽. 수동 토글이 항상 이긴다. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1a16; --bg-elev: #16231e; --bg-subtle: #1c2b25; --surface-2: #1a2822;
  --border: #27392f; --border-strong: #35493e;
  --text: #ecf1ea; --text-2: #b6c3b8; --text-3: #7f8e83; --ink: #ecf1ea;
  --brand: #4fb87f; --brand-strong: #4fb87f; --brand-soft: #173124; --brand-contrast: #08150f;
  --accent: #f5b25a; --accent-soft: #3a2a12; --accent-ink: #f5d39a;
  --relevant: #ff7a54; --relevant-ink: #ff7a54; --relevant-soft: #3a1f16; --relevant-border: #5a2e21;
  --sensitized: #9aa9bd; --sensitized-ink: #9aa9bd; --sensitized-soft: #1f2732; --sensitized-border: #33404f;
  --indet: #f0a33a; --indet-ink: #f0a33a; --indet-soft: #3a2a12; --indet-border: #5a4320;
  --ok: #4fb87f; --ok-soft: #173124;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 16px rgba(0,0,0,.45); --shadow-lg: 0 18px 44px rgba(0,0,0,.6);
  --shadow-brand: 0 8px 24px rgba(79,184,127,.3);
  --grid-dot: rgba(79,184,127,.08);
  --art-ink: #dfe8e1; --art-line: #4a5f53; --art-cream: #2b3d33; --art-leaf-d: #2f8f5b;
  --art-sky: #6aa3c4; --art-blush: #e08a6e; --art-glass: rgba(150,205,225,.22);
  --type-mite: #a898dc; --type-animal: #d19a64; --type-pollen_tree: #4fb87f; --type-pollen_grass: #9cc24a;
  --type-pollen_weed: #c9b942; --type-mold: #55b6c2; --type-insect: #c48a9c; --type-venom: #8aa5ea; --type-food: #e083b8; --type-other: #9aa69d;
  --type-latex: #c690e2; --type-drug: #5cbcf0; --type-control: #b9ab9a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1a16; --bg-elev: #16231e; --bg-subtle: #1c2b25; --surface-2: #1a2822;
    --border: #27392f; --border-strong: #35493e;
    --text: #ecf1ea; --text-2: #b6c3b8; --text-3: #7f8e83; --ink: #ecf1ea;
    --brand: #4fb87f; --brand-strong: #4fb87f; --brand-soft: #173124; --brand-contrast: #08150f;
    --accent: #f5b25a; --accent-soft: #3a2a12; --accent-ink: #f5d39a;
    --relevant: #ff7a54; --relevant-ink: #ff7a54; --relevant-soft: #3a1f16; --relevant-border: #5a2e21;
    --sensitized: #9aa9bd; --sensitized-ink: #9aa9bd; --sensitized-soft: #1f2732; --sensitized-border: #33404f;
    --indet: #f0a33a; --indet-ink: #f0a33a; --indet-soft: #3a2a12; --indet-border: #5a4320;
    --ok: #4fb87f; --ok-soft: #173124;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 16px rgba(0,0,0,.45); --shadow-lg: 0 18px 44px rgba(0,0,0,.6);
    --shadow-brand: 0 8px 24px rgba(79,184,127,.3);
    --grid-dot: rgba(79,184,127,.08);
    --art-ink: #dfe8e1; --art-line: #4a5f53; --art-cream: #2b3d33; --art-leaf-d: #2f8f5b;
    --art-sky: #6aa3c4; --art-blush: #e08a6e; --art-glass: rgba(150,205,225,.22);
    --type-mite: #a898dc; --type-animal: #d19a64; --type-pollen_tree: #4fb87f; --type-pollen_grass: #9cc24a;
    --type-pollen_weed: #c9b942; --type-mold: #55b6c2; --type-insect: #c48a9c; --type-venom: #8aa5ea; --type-food: #e083b8; --type-other: #9aa69d;
  --type-latex: #c690e2; --type-drug: #5cbcf0; --type-control: #b9ab9a;
  }
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--text); background-color: var(--bg);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  line-height: 1.55; -webkit-font-smoothing: antialiased; font-size: 16px;
}
button { font-family: inherit; cursor: pointer; }
:where(button, [role="button"], [tabindex], .dropzone, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: .2px; margin: 0; text-wrap: balance; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
main { max-width: var(--maxw); margin: 0 auto; padding: 18px 20px 40px; }
body[data-appstep="3"] main { padding-bottom: 96px; }  /* 문진 단계에만 하단 퀘스트바 여백 */

/* ---------- header + HUD ---------- */
.app-header { position: sticky; top: 0; z-index: 30; backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent); border-bottom: 1px solid var(--border); }
.app-header .bar { max-width: var(--maxw); margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 20px; color: var(--text); line-height: 1.1; }
.logo .mark { font-size: 22px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand-soft); border: 1.5px dashed var(--brand); flex: none; }
.logo small { display: block; font-family: var(--font); font-size: 11.5px; color: var(--text-3); font-weight: 500; margin-top: 2px; }
.hud { margin-left: auto; width: 240px; min-width: 150px; }
.hud-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--text-2); }
.hud-title { color: var(--brand-strong); }
.hud-xp small { color: var(--text-3); font-weight: 600; }
.hud-bar { height: 8px; border-radius: var(--r-pill); background: var(--bg-subtle); border: 1px solid var(--border); overflow: hidden; margin-top: 4px; }
.hud-fill { height: 100%; width: 100%; border-radius: inherit; transform-origin: left center; transform: scaleX(var(--p, 0)); transition: transform .6s var(--ease);
  background: linear-gradient(90deg, var(--brand), var(--accent)); }
.lang-sel { font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-pill); padding: 6px 28px 6px 10px; font-family: inherit; min-height: 34px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
/* 쓸 수 없는 AI 엔진 — 고를 수 없고, 흐리게·점선으로 구분한다 */
.lang-sel.unavail { color: var(--text-3); border-style: dashed; opacity: 1; }
.lang-sel:disabled { cursor: not-allowed; }
.ui-switch { font-size: 12px; font-weight: 800; color: var(--text-2); border: 1px solid var(--border-strong); border-radius: var(--r-pill); padding: 6px 10px; text-decoration: none; white-space: nowrap; }
.ui-switch:hover { background: var(--bg-subtle); color: var(--text); }
.theme-toggle { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2); font-size: 16px; flex: none; }
.theme-toggle:hover { background: var(--bg-subtle); }
a.admin-link { display: grid; place-items: center; text-decoration: none; }
a.admin-link svg { display: block; }

/* ---------- 퀘스트 트레일 ---------- */
.trail { position: relative; margin: 8px 0 22px; padding: 6px 0 0; }
.tpath { position: absolute; left: 0; right: 0; top: 6px; width: 100%; height: 48px; overflow: visible; pointer-events: none; }
.tpath path { fill: none; stroke-width: 4; stroke-linecap: round; }
.tpath-bg { stroke: var(--border-strong); stroke-dasharray: 8 10; }
.tpath-fg { stroke: var(--brand); stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--prog, 0)); transition: stroke-dashoffset .6s var(--ease); }
.tnodes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.tnode { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--text-3); position: relative; }
.tnum { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: 18px;
  background: var(--bg-elev); border: 2px solid var(--border-strong); color: var(--text-3); transition: transform var(--dur) var(--ease), background var(--dur), border-color var(--dur); }
.tlabel { font-size: 13px; font-weight: 800; color: var(--text-2); line-height: 1.25; }
.tlabel small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); margin-top: 2px; }
.tnode.done .tnum { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-contrast); }
.tnode.active .tnum { background: var(--accent); border-color: var(--accent); color: var(--ink-on-accent); transform: scale(1.12); position: relative; }
.tnode.active .tnum::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--accent); animation: ring 1.8s ease-out infinite; }
.tnode.active .tlabel { color: var(--text); }
.tnode.locked { opacity: .55; }
.tnode[role="button"] { cursor: pointer; }
.tnode[role="button"]:hover .tnum { transform: translateY(-2px); border-color: var(--brand); }
.tnode[role="button"]:focus-visible { outline: none; }
.tnode[role="button"]:focus-visible .tnum { outline: 3px solid var(--accent); outline-offset: 2px; }
.dropzone:focus-within { border-color: var(--brand); }

/* ---------- 패널 ---------- */
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 28px; box-shadow: var(--shadow-md); position: relative; animation: rise var(--dur) var(--ease) both; }
.panel::before { content: ''; position: absolute; inset: 8px; border: 1.5px dashed var(--border); border-radius: calc(var(--r-xl) - 6px); pointer-events: none; }
.panel-head { margin-bottom: 20px; }
.eyebrow { display: inline-block; font-size: 11.5px; letter-spacing: 2px; font-weight: 800; color: var(--accent-ink); background: var(--accent-soft); padding: 4px 10px; border-radius: var(--r-pill); margin-bottom: 10px; }
.panel-head h1 { font-size: 30px; line-height: 1.2; color: var(--text); }
.panel-head p { margin: 10px 0 0; color: var(--text-2); font-size: 15.5px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; }
.card.soft { background: var(--surface-2); }

/* ---------- 버튼 ---------- */
.btn { border: 1.5px solid transparent; border-radius: var(--r-pill); padding: 12px 20px; font-weight: 800; font-size: 14.5px;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .12s var(--ease), box-shadow .2s, background .2s; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand-strong); color: var(--brand-contrast); box-shadow: var(--shadow-brand); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn.secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--bg-subtle); }
.btn.subtle { background: var(--bg-subtle); color: var(--text-2); }
.btn.sm { padding: 8px 14px; font-size: 13px; }
.btn.danger-ghost { background: transparent; color: var(--relevant); padding: 6px; border-radius: 8px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 24px; }
.spacer { flex: 1; }
.spinner { width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; }
.btn.secondary .spinner, .notice .spinner { border-color: var(--border-strong); border-top-color: var(--brand); }

/* ---------- 업로드 ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 42px 20px; text-align: center; background: var(--surface-2); transition: border-color .2s, background-color .2s; cursor: pointer; position: relative; overflow: hidden; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { font-size: 40px; display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--border); margin-bottom: 8px; animation: bob 3s ease-in-out infinite; }
.dropzone h2 { font-size: 20px; color: var(--text); }
.dropzone p { margin: 6px 0 0; color: var(--text-3); font-size: 13px; }
.preview-img { display: block; max-width: 100%; max-height: 320px; margin: 16px auto 0; border-radius: var(--r-md); border: 1px solid var(--border); }
.upload-alt { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.notice { border-radius: var(--r-md); padding: 12px 14px; font-size: 13.5px; border: 1px solid var(--border); background: var(--bg-subtle); display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }
.notice.warn, .notice.flag { background: var(--indet-soft); border-color: var(--indet-border); color: var(--text); }

/* ---------- 폼 ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 800; font-size: 13.5px; margin-bottom: 8px; color: var(--text); }
.field .hint, .hint { color: var(--text-3); font-weight: 500; font-size: 12px; }
.field-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input { width: 100%; padding: 11px 13px; border-radius: var(--r-md); border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font-size: 14.5px; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text-2); border-radius: var(--r-pill); padding: 8px 14px; font-size: 13.5px; font-weight: 700; transition: border-color .15s, background-color .15s, color .15s; }
.chip-opt:hover { border-color: var(--brand); color: var(--text); }
.chip-opt.sel { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-contrast); }

/* ---------- OCR 검토 표 ---------- */
.rv-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.rv-tab { border: 1.5px solid var(--border); background: var(--bg-elev); color: var(--text-2); border-radius: var(--r-pill); padding: 7px 12px; font-size: 13px; font-weight: 800; }
.rv-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.rv-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: var(--r-pill); background: var(--bg-subtle); font-size: 11px; text-align: center; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.grid th { text-align: left; font-size: 11.5px; letter-spacing: .5px; color: var(--text-3); padding: 10px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
table.grid td { padding: 6px 6px; border-bottom: 1px solid var(--border); }
table.grid tr:last-child td { border-bottom: none; }
table.grid input { width: 100%; border: 1px solid transparent; background: transparent; color: var(--text); padding: 7px 8px; border-radius: var(--r-sm); font-size: 14px; font-family: inherit; }
table.grid input:hover { background: var(--bg-subtle); }
table.grid input:focus { background: var(--bg-elev); border-color: var(--brand); outline: none; }
.pos-toggle { border: 1.5px solid var(--border-strong); border-radius: var(--r-pill); padding: 5px 10px; font-size: 12px; font-weight: 800; background: var(--bg-elev); color: var(--text-3); }
.pos-toggle.on { background: var(--relevant-soft); border-color: var(--relevant-border); color: var(--relevant-ink); }
.tbl-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.badge-count { display: inline-block; min-width: 22px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--relevant-ink); color: #fff; font-weight: 800; font-size: 12px; text-align: center; }
.pos-summary { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px dashed var(--accent); color: var(--text); font-size: 13.5px; font-weight: 700; }

/* ---------- 문진(퀘스트 챕터) ---------- */
.chapter { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; background: var(--bg-elev); position: relative; overflow: hidden; }
.ch-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.ring { --p: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: var(--text-2); flex: none;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--bg-subtle) 0); }
.ring::before { content: attr(data-label); width: 30px; height: 30px; border-radius: 50%; background: var(--bg-elev); display: grid; place-items: center; }
.ch-title { font-family: var(--font-display); font-size: 20px; color: var(--text); }
.q-sub { color: var(--text-2); font-size: 13.5px; margin: 0 0 10px 52px; }
.q-block { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); margin-top: 10px; transition: border-color .2s, box-shadow .2s; position: relative; }
.q-block.answered { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.q-block.clue-new { animation: clue-in .5s var(--ease) both; border-color: var(--accent); }
.clue-tag { position: absolute; top: -10px; right: 12px; font-size: 11px; font-weight: 800; background: var(--accent); color: var(--ink-on-accent); padding: 2px 10px; border-radius: var(--r-pill); animation: pop .4s var(--ease) both; }
.q-title { font-family: var(--font); font-weight: 800; font-size: 15px; color: var(--text); text-wrap: pretty; }
.q-help { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.55; }
.q-applies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q-applies .tag { font-size: 11px; font-weight: 700; background: var(--bg-elev); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px 9px; }
.choice-row, .choice-list { display: flex; gap: 8px; margin-top: 10px; }
.choice-row { flex-wrap: wrap; }
.choice-list { flex-direction: column; }
.choice { display: flex; align-items: flex-start; gap: 10px; text-align: left; border: 1.5px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-elev); padding: 10px 12px; color: var(--text); transition: border-color .15s, background-color .15s; }
.choice-row .choice { flex: 1 1 140px; }
.choice:hover { border-color: var(--brand); }
.choice .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; margin-top: 2px; display: grid; place-items: center; }
.choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.choice.sel .radio { border-color: var(--brand-strong); background: var(--brand-strong); }
.choice.sel .radio::after { content: '✓'; color: var(--brand-contrast); font-size: 11px; font-weight: 900; animation: pop .25s var(--ease); }
.choice .t { display: block; font-weight: 700; font-size: 14px; }
.choice .h { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.quest-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 10px 20px 14px; background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.qb-text { max-width: var(--maxw); margin: 0 auto 6px; font-size: 12.5px; color: var(--text-2); }
.qb-track { max-width: var(--maxw); margin: 0 auto; height: 8px; border-radius: var(--r-pill); background: var(--bg-subtle); overflow: hidden; }
.qb-fill { height: 100%; width: 100%; transform-origin: left center; transform: scaleX(var(--p, 0)); background: linear-gradient(90deg, var(--brand), var(--accent)); transition: transform .5s var(--ease); }

/* ---------- 결과: 스코어보드·배지·도감 ---------- */
.scoreboard { border-radius: var(--r-xl); padding: 26px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1f5f3f 0%, #2f8f5b 60%, #3f9a68 100%); box-shadow: var(--shadow-lg); animation: rise var(--dur) var(--ease) both; }
.scoreboard.calm { background: linear-gradient(135deg, #2b3a44 0%, #3f5563 100%); }
.scoreboard::after { content: ''; position: absolute; inset: 10px; border: 1.5px dashed rgba(255,255,255,.35); border-radius: calc(var(--r-xl) - 8px); pointer-events: none; }
.scoreboard .sb-eyebrow { font-size: 11.5px; letter-spacing: 2px; font-weight: 800; opacity: .85; }
.scoreboard h1 { font-size: 32px; margin-top: 6px; }
.scoreboard p { margin: 6px 0 0; opacity: .92; font-size: 14px; }
.trophies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.trophy { background: rgba(10,25,18,.32); border-radius: var(--r-lg); padding: 12px; text-align: center; border: 1px solid rgba(255,255,255,.28); }
.trophy .n { font-family: var(--font-display); font-size: 34px; line-height: 1; }
.trophy .l { font-size: 12px; margin-top: 4px; opacity: .95; font-weight: 700; }
.trophy.relevant .n { color: #ffd6c8; } .trophy.sensitized .n { color: #e6ecf5; } .trophy.indet .n { color: #ffe1a8; }
.alert-severe { margin-top: 14px; border-radius: var(--r-md); padding: 12px 14px; background: rgba(255,255,255,.92); border: 1.5px solid var(--relevant); color: #1f2a24; font-size: 13.5px; font-weight: 700; position: relative; z-index: 1; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.badge-item { display: flex; gap: 10px; align-items: center; border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: 10px 12px; background: var(--bg-elev); opacity: .55; filter: grayscale(1); }
.badge-item.earned { opacity: 1; filter: none; border-style: solid; border-color: var(--accent); background: var(--accent-soft); animation: pop .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }
.b-icon { font-size: 24px; }
.b-name { font-weight: 800; font-size: 13px; color: var(--text); }
.b-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }
.result-tabs { display: flex; gap: 6px; margin: 18px 0 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.result-tabs button { border: none; background: transparent; color: var(--text-2); font-weight: 800; padding: 8px 14px; border-radius: var(--r-pill); font-size: 14px; }
.result-tabs button.active { background: var(--brand-strong); color: var(--brand-contrast); }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
/* ----- 알러젠 도감: 수집형 카드 -----
   판정은 테두리 모양(실선/이중선/점선) + 색 + 도장 문구로 겹쳐 표시한다(색만으로 구분하지 않는다).
   광택(.foil)은 data-grade(기록 등급)만 따른다 — 양성·수치·중증과 무관. */
:root { --tc: var(--type-other); }
[data-cat="mite"] { --tc: var(--type-mite); } [data-cat="animal"] { --tc: var(--type-animal); }
[data-cat="pollen_tree"] { --tc: var(--type-pollen_tree); } [data-cat="pollen_grass"] { --tc: var(--type-pollen_grass); }
[data-cat="pollen_weed"] { --tc: var(--type-pollen_weed); } [data-cat="mold"] { --tc: var(--type-mold); }
[data-cat="insect"] { --tc: var(--type-insect); } [data-cat="venom"] { --tc: var(--type-venom); } [data-cat="food"] { --tc: var(--type-food); } [data-cat="other"] { --tc: var(--type-other); }
[data-cat="latex"] { --tc: var(--type-latex); } [data-cat="drug"] { --tc: var(--type-drug); } [data-cat="control"] { --tc: var(--type-control); }
.v-relevant { --frame: var(--relevant); } .v-sensitized { --frame: var(--sensitized); }
.v-indet { --frame: var(--indet); } .v-na { --frame: var(--border-strong); }

.dex-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.dex-progress { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: var(--text); margin-right: auto; }
.dex-progress .aicon { width: 30px; height: 30px; flex: none; }
.seg { display: inline-flex; border: 1.5px solid var(--border-strong); border-radius: var(--r-pill); overflow: hidden; background: var(--bg-elev); }
.seg button { border: 0; background: transparent; color: var(--text-2); font-weight: 800; font-size: 13px; padding: 8px 16px; min-height: 38px; }
.seg button.on { background: var(--brand-strong); color: var(--brand-contrast); }
.dex-tools { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.dex-tools .cat-chips { flex: 1 1 300px; margin-bottom: 8px; }
.type-chip { display: inline-flex; align-items: center; gap: 6px; }
.type-chip svg { width: 18px; height: 18px; color: var(--tc); flex: none; }
.type-chip.sel svg { color: currentColor; }
.sort-sel { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; color: var(--text-2); margin-left: auto; margin-bottom: 8px; }
.sort-sel .input { width: auto; padding: 8px 12px; font-size: 13.5px; border-radius: var(--r-pill); }
.dex-legend { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-md); padding: 9px 12px; margin: 4px 0 16px; line-height: 1.55; }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.dex-card { --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 30%; position: relative; perspective: 1100px; cursor: pointer; aspect-ratio: 5 / 8; min-height: 404px; max-width: 340px; width: 100%; justify-self: center;
  touch-action: pan-y; -webkit-tap-highlight-color: transparent; animation: card-deal .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.dex-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 20px; }
.dex-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .6s var(--ease); transform: rotateX(var(--rx)) rotateY(var(--ry)); }
.dex-card.flip .dex-inner { transform: rotateX(var(--rx)) rotateY(calc(180deg + var(--ry))); }
.dex-card.tilting .dex-inner { transition: transform .09s linear; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; border: 3px solid var(--frame, var(--border-strong));
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 11%, var(--bg-elev)) 0%, var(--bg-elev) 48%); padding: 11px 12px 9px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md); overflow: hidden; transition: visibility 0s linear .28s, box-shadow .25s; }
.dex-card:hover .face, .dex-card.tilting .face { box-shadow: var(--shadow-lg); }
.v-sensitized .face { border-style: double; border-width: 6px; padding: 8px 9px 6px; }
.v-indet .face, .v-na .face { border-style: dashed; }
.face.back { transform: rotateY(180deg); visibility: hidden; font-size: 13px; background: var(--bg-elev); }
.dex-card.flip .face.back { visibility: visible; }
.dex-card.flip .face.front { visibility: hidden; }

.dc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.type-badge { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: 11.5px; font-weight: 800; padding: 2px 9px 2px 3px; border-radius: var(--r-pill);
  color: color-mix(in srgb, var(--tc) 62%, var(--text)); background: color-mix(in srgb, var(--tc) 15%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--tc) 45%, var(--border)); }
.type-badge svg { width: 20px; height: 20px; padding: 2px; border-radius: 50%; background: var(--tc); color: #fff; flex: none; }
.type-badge > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge.sm { font-size: 10.5px; }
.dc-no { font-size: 11px; font-weight: 800; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: .5px; flex: none; }
.dc-art { position: relative; flex: 1 1 0; min-height: 92px; border-radius: 64px 64px 12px 12px; overflow: hidden; border: 1.5px solid color-mix(in srgb, var(--tc) 50%, var(--border)); }
.dc-art .art { position: absolute; inset: 0; width: 100%; height: 100%; }
.v-sensitized .dc-art .art, .mini-card.v-sensitized .mc-art .art { filter: saturate(.5); }
.v-sensitized .dc-art::after, .mini-card.v-sensitized .mc-art::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--sensitized) 26%, transparent) 7px 8.5px); }
.dex-name { font-family: var(--font-display); font-size: 20px; color: var(--text); line-height: 1.18; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dex-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.dex-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.dc-stats { margin: 7px 0 0; display: grid; gap: 3px; border-top: 1px dashed var(--border-strong); padding-top: 7px; }
.stat { display: grid; grid-template-columns: 6.4em minmax(0, 1fr); align-items: center; gap: 6px; font-size: 12px; min-height: 19px; }
.stat dt { color: var(--text-3); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat dd { margin: 0; color: var(--text); display: flex; align-items: center; gap: 6px; min-width: 0; }
.stat .clamp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dim { color: var(--text-3); }
.pips { display: inline-flex; gap: 2px; flex: none; }
.pips i { width: 9px; height: 10px; border-radius: 2.5px; border: 1.5px solid color-mix(in srgb, var(--tc) 70%, var(--text-3)); background: transparent; }
.pips i.on { background: var(--tc); border-color: var(--tc); }
.dc-verdict { margin-top: 8px; padding: 7px 10px 8px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg-subtle); display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.dc-verdict.tone-relevant { background: var(--relevant-soft); border-color: var(--relevant-border); }
.dc-verdict.tone-sensitized { background: var(--sensitized-soft); border-color: var(--sensitized-border); }
.dc-verdict.tone-indet { background: var(--indet-soft); border-color: var(--indet-border); border-style: dashed; }
.dc-verdict.tone-na { border-style: dashed; }
.verdict-stamp { align-self: flex-start; font-family: var(--font-display); font-size: 16px; padding: 3px 11px; border: 2.5px solid currentColor; border-radius: 8px; transform: rotate(-3deg); letter-spacing: 1px;
  animation: stamp .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + .35s); background: color-mix(in srgb, var(--bg-elev) 55%, transparent); }
.tone-relevant { color: var(--relevant-ink); } .tone-sensitized { color: var(--sensitized-ink); } .tone-indet { color: var(--indet-ink); } .tone-na { color: var(--text-3); }
.dex-note { font-size: 11.5px; color: var(--text-2); line-height: 1.35; }
.dc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.grade { font-weight: 700; white-space: nowrap; }
.gems { color: var(--accent-ink); letter-spacing: 1px; }
.dex-flip-hint { font-size: 11px; color: var(--text-3); font-weight: 700; white-space: nowrap; }
.foil { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s; mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255,255,255,.75), transparent 44%); }
.dex-card:hover .foil, .dex-card.tilting .foil { opacity: .55; }
.dex-card[data-grade="1"] .foil { opacity: .3;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255,255,255,.8), transparent 46%), linear-gradient(118deg, transparent 30%, rgba(255,255,255,.5) 48%, transparent 62%); }
.dex-card[data-grade="2"] .foil { opacity: .5; mix-blend-mode: hard-light; background-size: 100% 100%, 240% 240%; background-position: 0 0, var(--mx) var(--my);
  background-image: radial-gradient(circle at var(--mx) var(--my), rgba(255,255,255,.5), transparent 42%),
    linear-gradient(118deg, transparent 18%, rgba(120,226,190,.34) 32%, rgba(255,226,140,.36) 46%, rgba(160,196,255,.34) 60%, rgba(244,170,214,.3) 72%, transparent 86%); }
.dex-card[data-grade="1"]:hover .foil, .dex-card[data-grade="1"].tilting .foil { opacity: .7; }
.dex-card[data-grade="2"]:hover .foil, .dex-card[data-grade="2"].tilting .foil { opacity: .85; }
.dex-card[data-grade="2"]:not(.tilting):not(:hover) .foil { animation: foil-idle 7s ease-in-out infinite alternate; }
.dex-card.flip .foil { opacity: 0 !important; }
.back-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px dashed var(--border-strong); margin-bottom: 8px; }
.back-head b { font-family: var(--font-display); font-weight: 400; font-size: 16px; color: var(--text); margin-right: auto; }
.back-body { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-right: 2px; }
.face.back .dex-flip-hint { align-self: flex-end; margin-top: 6px; }
.face.back .k { font-size: 11px; font-weight: 800; color: var(--accent-ink); }
.face.back .rationale { font-weight: 700; color: var(--text); margin: 2px 0 10px; line-height: 1.5; }
.kb-item.guide { background: var(--brand-soft); border-radius: 10px; padding: 8px 10px; }
.kb-item.guide .k { color: var(--brand-strong); }

/* 작은 카드(등록 연출·바인더) */
.mini-card { display: flex; flex-direction: column; gap: 4px; align-items: stretch; text-align: left; width: 100%; padding: 6px 6px 8px; border-radius: 12px;
  border: 2px solid var(--frame, var(--border-strong)); background: var(--bg-elev); color: var(--text); font: inherit; position: relative; }
.mini-card.v-sensitized { border-style: double; border-width: 5px; padding: 3px 3px 5px; }
.mini-card.v-indet, .mini-card.v-na { border-style: dashed; }
button.mini-card { cursor: pointer; transition: transform .16s var(--ease), box-shadow .2s; animation: card-deal .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
button.mini-card:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-md); }
.mc-art { position: relative; display: block; aspect-ratio: 200 / 130; border-radius: 8px; overflow: hidden; background: color-mix(in srgb, var(--tc) 14%, var(--bg-elev)); }
.mc-art .art { position: absolute; inset: 0; }
.mc-name { font-weight: 800; font-size: 12.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.mc-status { font-size: 11px; font-weight: 800; }
.binder-sec { border: 1.5px dashed color-mix(in srgb, var(--tc) 45%, var(--border)); border-radius: var(--r-lg); padding: 12px; margin-bottom: 14px; background: color-mix(in srgb, var(--tc) 5%, var(--bg-elev)); }
.binder-h { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; font-family: var(--font); }
.binder-n { font-size: 12px; font-weight: 800; color: var(--text-3); }
.binder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }

/* 도감 모달 */
.dex-modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 780px;
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; overflow: hidden; animation: rise .3s var(--ease) both; }
.dm-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dm-head h2 { font-size: 22px; color: var(--text); }
.dm-sub { font-size: 12.5px; color: var(--text-3); font-weight: 700; margin-right: auto; }
.dm-body { padding: 14px 18px 18px; overflow: auto; overscroll-behavior: contain; }
.dm-body > .hint { margin: 0 0 10px; }
.inspect { display: grid; grid-template-columns: 44px minmax(0, 330px) 44px; gap: 10px; align-items: center; justify-content: center; }
.inspect-card .dex-card { max-width: none; }
.inspect-nav { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font-size: 22px; line-height: 1; }
.inspect-nav:hover:not(:disabled) { background: var(--bg-subtle); }
.inspect-nav:disabled { opacity: .35; cursor: default; }
.inspect-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.kb-grid { display: grid; gap: 8px; }
.kb-item .k { font-size: 11px; font-weight: 800; color: var(--accent-ink); }
.kb-item .v { color: var(--text-2); margin: 2px 0 0; }
.kb-item ul { color: var(--text-2); margin: 2px 0 0; padding-left: 16px; }
.src-tag { color: var(--text-3); font-weight: 500; }
.rel-badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: var(--r-pill); border: 1px solid; }
.rel-badge.clinically_relevant { background: var(--relevant-soft); color: var(--relevant-ink); border-color: var(--relevant-border); }
.rel-badge.sensitized_only { background: var(--sensitized-soft); color: var(--sensitized-ink); border-color: var(--sensitized-border); }
.rel-badge.indeterminate { background: var(--indet-soft); color: var(--indet-ink); border-color: var(--indet-border); }
.rel-badge.not_assessed { background: var(--bg-subtle); color: var(--text-3); border-color: var(--border); }
.report-frame, .cardnews-frame { width: 100%; border: 1px solid var(--border); border-radius: var(--r-lg); background: #fff; }
.report-frame { height: 760px; } .cardnews-frame { height: 660px; background: var(--bg-subtle); }
.download-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.report-render { line-height: 1.7; font-size: 14.5px; }
.report-render h1 { font-size: 22px; margin: 4px 0 14px; }
.report-render h2 { font-size: 18px; margin: 24px 0 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.report-render table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px; }
.report-render th, .report-render td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }

/* ---------- 발견 오버레이 ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(20,30,24,.62); backdrop-filter: blur(6px); animation: fade .25s both; }
.discover { background: var(--bg-elev); border-radius: var(--r-xl); padding: 28px; max-width: 760px; width: 100%; text-align: center; border: 1px solid var(--border); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.d-eyebrow { display: inline-block; font-family: var(--font-display); font-size: 22px; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 14px; border-radius: var(--r-pill); animation: pop .5s var(--ease) both; }
.discover h2 { font-size: 26px; margin-top: 10px; color: var(--text); }
.discover p { color: var(--text-2); font-size: 14px; margin: 6px 0 16px; }
.discover-deck { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 20px; max-height: 50vh; overflow: auto; padding: 6px 4px; }
.dcard { width: 124px; perspective: 800px; animation: card-deal .45s var(--ease) both; animation-delay: calc(var(--i) * 90ms); }
.dc-in { position: relative; transform-style: preserve-3d; animation: dc-flip .7s var(--ease) both; animation-delay: calc(var(--i) * 150ms + .55s); }
.dc-front { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.dc-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; transform: rotateY(180deg); border-radius: 12px; display: grid; place-items: center;
  color: rgba(255,255,255,.9); border: 2px solid var(--art-leaf-d);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 6px, transparent 6px 12px), linear-gradient(150deg, #1f5f3f, #2f8f5b); }
.dc-back .emblem { width: 46px; height: 46px; }
.dcard.more { display: grid; place-items: center; min-height: 150px; border-radius: 12px; border: 2px dashed var(--border-strong); font-family: var(--font-display); font-size: 20px; color: var(--text-2); }

/* ---------- 연출 요소 ---------- */
.xp-float { position: fixed; z-index: 60; transform: translate(-50%, 0); pointer-events: none; font-weight: 900; font-size: 14px; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid var(--accent); padding: 2px 10px; border-radius: var(--r-pill); animation: float-up .7s var(--ease) both; }
.sparkle { position: absolute; bottom: 30%; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); pointer-events: none; animation: sparkle .9s var(--ease) both; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 600; z-index: 70; transition: opacity .25s, transform .25s; pointer-events: none; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.disclaimer { color: var(--text-3); font-size: 12px; text-align: center; margin-top: 26px; line-height: 1.6; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes stamp { 0% { transform: rotate(-4deg) scale(1.6); opacity: 0; } 60% { transform: rotate(-4deg) scale(.96); opacity: 1; } 100% { transform: rotate(-4deg) scale(1); } }
@keyframes flip-in { 0% { transform: rotateY(90deg) translateY(10px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes clue-in { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -36px); } }
@keyframes sparkle { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }
@keyframes ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .dex-card.flip .dex-inner { transform: rotateY(180deg); }
}

/* ---------- 모바일 ---------- */
@media (max-width: 720px) {
  main { padding: 12px 14px 40px; }
  body[data-appstep="2"] main, body[data-appstep="3"] main { padding-bottom: 120px; }
  .logo small, .tlabel small { display: none; }
  .logo { font-size: 17px; }
  .hud { width: 120px; min-width: 100px; }
  .lang-sel { padding: 6px 22px 6px 6px; font-size: 11.5px; }
  .ui-switch { display: none; }
  .hud-top { font-size: 11px; }
  .panel { padding: 18px; }
  .panel-head h1 { font-size: 24px; }
  .grid-3 { grid-template-columns: 1fr; }
  .tlabel { font-size: 11px; }
  .tnum { width: 34px; height: 34px; font-size: 15px; }
  .tpath { top: 4px; height: 40px; }
  .trophies { gap: 6px; } .trophy .n { font-size: 26px; }
  .choice-row { flex-direction: column; } .choice-row .choice { flex: 1 1 auto; }
  .choice { padding: 14px; min-height: 52px; align-items: center; }
  .choice .radio { width: 22px; height: 22px; }
  .input, .choice .t, .chip-opt { font-size: 16px; }
  .chip-opt, .rv-tab, .result-tabs button, .btn.sm, .pos-toggle { min-height: 44px; }
  .btn.danger-ghost, .theme-toggle { min-width: 44px; min-height: 44px; }
  table.grid input { min-height: 44px; }
  .discover { padding: 20px 16px; }
  .discover h2 { font-size: 22px; }
  .dcard { width: 104px; }
  .report-frame { height: 68vh; } .cardnews-frame { height: min(78vh, 680px); }

  /* 스크리닝(2)·문진(3): 하단 고정 내비 + 문진 진행바는 그 위에 */
  /* fixed 내비의 containing block 이 패널이 되지 않도록(패널 진입 애니메이션이 transform 을 남김) 애니메이션 해제 */
  body[data-appstep="2"] .panel, body[data-appstep="3"] .panel { padding-bottom: 92px; animation: none; }
  body[data-appstep="2"] .actions, body[data-appstep="3"] .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0;
    padding: 11px 16px calc(11px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-elev); border-top: 1px solid var(--border);
    box-shadow: 0 -6px 22px rgba(0,0,0,.10); gap: 10px; align-items: stretch;
  }
  body[data-appstep="2"] .actions .btn.primary, body[data-appstep="3"] .actions .btn.primary { flex: 1 1 auto; min-height: 52px; font-size: 15.5px; }
  body[data-appstep="2"] .actions .btn.secondary, body[data-appstep="3"] .actions .btn.secondary { min-height: 52px; flex: 0 0 auto; }
  body[data-appstep="2"] .actions .spacer, body[data-appstep="3"] .actions .spacer { display: none; }
  body[data-appstep="3"] .quest-bar { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); padding: 8px 16px 8px; }
}

/* ---------- 결과 상담 챗봇 ---------- */
.chat-panel { display: flex; flex-direction: column; gap: 10px; }
.chat-sugg-t { font-size: 12px; font-weight: 800; color: var(--text-3); margin-bottom: 6px; }
.chat-log { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); }
.chat-log:empty { display: none; }
.chat-msg { display: flex; flex-direction: column; gap: 3px; max-width: 88%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-who { font-size: 11px; font-weight: 800; color: var(--text-3); }
.chat-bubble { font-size: 14px; line-height: 1.65; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.chat-msg.user .chat-bubble { background: var(--brand-soft); border-color: var(--brand); }
.chat-input { display: flex; gap: 8px; }
.chat-input .input { flex: 1; }
.chat-foot { display: flex; align-items: center; gap: 10px; justify-content: space-between;
  font-size: 11.5px; color: var(--text-3); }
@media (max-width: 720px) { .chat-msg { max-width: 96%; } .chat-log { max-height: 52vh; } }

/* 챗봇 답변에 쓰인 일반지식 출처 — 기본은 접어두고, 펼치면 주제·항목·원문 링크를 보여준다 */
.kb-src { margin-top: 6px; font-size: 11.5px; color: var(--text-2); }
.kb-src summary { cursor: pointer; opacity: .8; }
.kb-src summary:hover { opacity: 1; }
.kb-src .src-item { margin: 6px 0 0 2px; line-height: 1.5; }
.kb-src .src-item a { color: var(--brand); text-decoration: underline; }
.kb-src .src-note { margin-top: 6px; opacity: .75; font-style: italic; }
.kb-src .src-list { margin: 4px 0 0; padding-left: 16px; }
.kb-src .src-list li { margin: 4px 0; }
.kb-src .src-pred { font-weight: 700; opacity: .85; }
.kb-src .src-quote { margin: 2px 0 0; padding-left: 8px; border-left: 2px solid var(--line, #d8d8d8); opacity: .85; }
.kb-src .src-ids { font-size: 10.5px; opacity: .6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.kb-src .src-map { font-size: 10.5px; opacity: .7; }

/* OCR 확인 화면 — 검증 규칙이 표시한 행 */
tr.row-flag td { background: rgba(255, 176, 32, .13); }
tr.row-flag td:first-child { box-shadow: inset 3px 0 0 #e8a33d; }
.rv-gate { display: block; }
.rv-gate b { font-weight: 800; }

/* =========================================================================
   일러스트 (web/art.js) — 토큰으로 칠하고 .an-* 로만 움직인다
   ========================================================================= */
.art { display: block; width: 100%; height: 100%; overflow: visible; }
.art .ol { stroke: var(--art-ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.art .ol.thin { stroke-width: 1.3; }
.art .ln { fill: none; stroke: var(--art-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.art .ln.thin { stroke-width: 1.7; } .art .ln.thick { stroke-width: 3.2; }
.art .ln.soft { stroke: var(--art-line); } .art .ln.dash { stroke: var(--art-line); stroke-dasharray: 4 6; } .art .ln.dotted { stroke-dasharray: 1 5; }
.art .ln.leaf { stroke: var(--brand); } .art .ln.amberln { stroke: var(--accent); } .art .ln.red { stroke: var(--relevant); } .art .ln.sky { stroke: var(--art-sky); }
.art .ln.onfill { stroke: rgba(255,255,255,.78); } .art .ln.glint { stroke: #fff; opacity: .85; stroke-width: 1.8; } .art .ln.tln { stroke: var(--tc); }
.art .k-wash { fill: var(--brand-soft); } .art .k-wash2 { fill: var(--accent-soft); } .art .k-paper { fill: var(--bg-elev); } .art .k-body { fill: var(--art-cream); }
.art .k-leaf { fill: var(--brand); } .art .k-leaf-d { fill: var(--art-leaf-d); } .art .k-amber { fill: var(--accent); } .art .k-red { fill: var(--relevant); }
.art .k-slate { fill: var(--sensitized); } .art .k-sky { fill: var(--art-sky); } .art .k-ink { fill: var(--art-ink); } .art .k-blush { fill: var(--art-blush); opacity: .75; }
.art .k-shadow { fill: rgba(0,0,0,.13); } .art .k-glass { fill: var(--art-glass); } .art .k-scan { fill: var(--accent); opacity: .45; } .art .k-ping { fill: var(--relevant); opacity: .28; }
.art .k-txt { fill: var(--art-ink); font-family: var(--font-display); font-size: 22px; } .art .k-txt.big { font-size: 30px; } .art .k-fillcur { fill: currentColor; }
.art .t-fill { fill: var(--tc); } .art .t-mid { fill: color-mix(in srgb, var(--tc) 36%, var(--bg-elev)); } .art .t-soft { fill: color-mix(in srgb, var(--tc) 15%, var(--bg-elev)); }
.art.emblem .ln { stroke: currentColor; } .art.emblem .ln.soft { opacity: .5; }
.art [class*="an-"] { transform-box: fill-box; transform-origin: center; animation-delay: var(--d, 0s); }
.art .an-bob { animation: a-bob 3.2s ease-in-out infinite; animation-delay: var(--d, 0s); }
.art .an-leaf { transform-origin: 50% 100%; animation: a-sway 3.2s ease-in-out infinite; }
.art .an-blink { animation: a-blink 4.2s ease-in-out infinite; }
.art .an-drift { animation: a-drift 3.4s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
.art .an-step { animation: a-pop .5s var(--ease) both; animation-delay: var(--d, 0s); }
.art .an-rise { animation: a-rise .6s var(--ease) both; animation-delay: var(--d, 0s); }
.art .an-pop { animation: a-pop .5s var(--ease) both; animation-delay: var(--d, 0s); }
.art .an-peek { animation: a-peek 2.6s ease-in-out infinite alternate; }
.art .an-sweep { animation: a-sweep 3.4s ease-in-out infinite alternate; }
.art .an-scan { animation: a-scan 1.7s ease-in-out infinite alternate; }
.art .an-drop { animation: a-drop 2.8s var(--ease) infinite; }
.art .an-float { animation: a-bob 3.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.art .an-tick, .art .an-draw, .art .an-beat { stroke-dasharray: 1; stroke-dashoffset: 0; }
.art .an-tick { animation: a-draw .45s var(--ease) both; animation-delay: var(--d, 0s); }
.art .an-draw { animation: a-draw 1.3s var(--ease) both; animation-delay: .5s; }
.art .an-beat { animation: a-draw 2.6s linear infinite; }
.art .an-write { animation: a-write 1.3s ease-in-out infinite alternate; }
.art .an-pin { transform-origin: 50% 100%; animation: a-pin .7s var(--ease) both, a-bob 3s ease-in-out .7s infinite; }
.art .an-spin { animation: a-spin 7s linear infinite; }
.art .an-spin.slow { animation-duration: 56s; }
.art .an-wobble { animation: a-wobble 3.6s ease-in-out infinite alternate; }
.art .an-puff { animation: a-puff 2.2s ease-in-out infinite; }
.art .an-ping { animation: a-ping 2.2s ease-out infinite; animation-delay: var(--d, 0s); }
.art .an-tail { transform-origin: 100% 100%; animation: a-sway 1.6s ease-in-out infinite; }
.art .an-tail.r { transform-origin: 0% 100%; }
.art .an-blinkbox { animation: a-fade 1.8s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
.art .an-sway { transform-origin: 50% 100%; animation: a-sway 4.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
.art .an-stamp { animation: a-stamp 1.9s var(--ease) infinite; }
.art .an-stampmark { animation: a-stampmark 1.9s linear infinite; }
.art .an-pulse { animation: a-pulse 3.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
.art .an-scuttle { animation: a-scuttle 2.8s ease-in-out infinite; }
.art .an-feel { transform-origin: 50% 100%; animation: a-sway 1.4s ease-in-out infinite; }
@keyframes a-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3.5px); } }
@keyframes a-sway { 0%,100% { transform: rotate(-3.5deg); } 50% { transform: rotate(3.5deg); } }
@keyframes a-blink { 0%,44%,50%,100% { transform: scaleY(1); } 47% { transform: scaleY(.1); } }
@keyframes a-drift { from { transform: translate(0,0); opacity: .45; } to { transform: translate(7px,-9px); opacity: 1; } }
@keyframes a-pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes a-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes a-peek { from { transform: translate(-3px, 1px); } to { transform: translate(9px, -3px); } }
@keyframes a-sweep { from { transform: translate(-46px, 12px); } to { transform: translate(8px, -8px); } }
@keyframes a-scan { from { transform: translateY(0); } to { transform: translateY(82px); } }
@keyframes a-drop { 0% { transform: translateY(-16px); opacity: 0; } 22% { opacity: 1; } 55%,100% { transform: translateY(6px); opacity: 1; } }
@keyframes a-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes a-write { from { transform: translate(0,0) rotate(0); } to { transform: translate(7px,5px) rotate(-5deg); } }
@keyframes a-pin { 0% { transform: translateY(-22px); opacity: 0; } 60% { transform: translateY(2px); opacity: 1; } 100% { transform: none; } }
@keyframes a-spin { to { transform: rotate(360deg); } }
@keyframes a-wobble { from { transform: rotate(-14deg); } to { transform: rotate(12deg); } }
@keyframes a-puff { 0% { transform: translateX(-4px); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateX(6px); opacity: 0; } }
@keyframes a-ping { 0% { transform: scale(.4); opacity: .55; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes a-fade { from { opacity: .35; } to { opacity: 1; } }
@keyframes a-stamp { 0%,100% { transform: translateY(-14px); } 38%,58% { transform: translateY(4px); } }
@keyframes a-stampmark { 0%,36% { opacity: 0; } 46%,88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes a-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes a-scuttle { 0%,100% { transform: translate(0,0) rotate(0); } 30% { transform: translate(3px,-2px) rotate(2deg); } 65% { transform: translate(-3px,1px) rotate(-2deg); } }

/* =========================================================================
   스테이지 — 퀘스트 안의 작은 단계 (레일·장면·전환)
   ========================================================================= */
.stage-panel { animation: none; padding-top: 20px; }
.stage-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; min-height: 38px; position: relative; z-index: 1; }
.stage-rail { flex: 1 1 auto; min-width: 0; }
.srail { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 0; }
.sdot { display: flex; align-items: center; }
.sdot + .sdot::before { content: ''; width: 14px; height: 2px; background: var(--border-strong); border-radius: 2px; margin: 0 3px; }
.sdot.done + .sdot::before { background: var(--brand); }
.sdot button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 3px; border-radius: var(--r-pill); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 800; cursor: pointer; }
.sdot button[aria-disabled="true"] { cursor: default; }
.sd-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none;
  background: var(--bg-elev); border: 2px solid var(--border-strong); color: var(--text-3); transition: transform .2s var(--ease), background-color .2s, border-color .2s; }
.sdot.done .sd-mark { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-contrast); animation: pop .4s var(--ease) both; }
.sdot.cur button { background: var(--accent-soft); padding: 3px 12px 3px 3px; color: var(--accent-ink); }
.sdot.cur .sd-mark { background: var(--accent); border-color: var(--accent); color: var(--ink-on-accent); }
.sdot:not(.cur) .sd-label, .sdot:not(.cur) .sd-meta { display: none; }
.sd-label { max-width: 15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-meta { font-size: 11px; font-weight: 700; opacity: .8; font-variant-numeric: tabular-nums; }
.sdot button:not([aria-disabled="true"]):hover .sd-mark { transform: translateY(-2px); border-color: var(--brand); }
.dex-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text); border-radius: var(--r-pill);
  padding: 3px 13px 3px 4px; font-size: 12.5px; font-weight: 800; min-height: 36px; transition: transform .15s var(--ease), border-color .15s; }
.dex-chip:hover { border-color: var(--brand); transform: translateY(-1px); }
.dex-chip .aicon { width: 28px; height: 28px; }

.stage[data-dir="fwd"] { animation: stage-fwd .44s var(--ease) both; }
.stage[data-dir="back"] { animation: stage-back .44s var(--ease) both; }
.stage[data-dir="fwd"] .scene-box, .stage[data-dir="back"] .scene-box { animation: scene-in .6s var(--ease) both; }
.stage-top { display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 20px; }
.scene-box { aspect-ratio: 320 / 150; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); padding: 6px 8px 2px; overflow: hidden; }
.stage-top .panel-head { margin: 0; }
.stage-top .panel-head h1 { font-size: 27px; }
.stage-top .panel-head h1:focus, .q-title:focus { outline: none; }
.stage-top .panel-head p { font-size: 14.5px; }
.stage-hint { margin: 0 0 10px; }
.chips.big { gap: 10px; }
.chips.big .chip-opt { padding: 11px 18px; font-size: 15px; min-height: 46px; }
.trace-banner { margin-bottom: 16px; border-left: 4px solid var(--brand); }
@keyframes stage-fwd { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes stage-back { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }
@keyframes scene-in { from { transform: scale(.93); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes card-deal { from { opacity: 0; transform: translateY(18px) rotate(-3deg) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes dc-flip { from { transform: rotateY(180deg); } to { transform: rotateY(0); } }
@keyframes foil-idle { from { background-position: 0 0, 10% 20%; } to { background-position: 0 0, 90% 80%; } }

/* Q1 브리핑 */
.beats { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.beat { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); animation: rise .45s var(--ease) both; animation-delay: calc(var(--i) * 110ms + .15s); position: relative; }
.beat-ic { width: 46px; height: 46px; flex: none; }
.beat-t { font-family: var(--font-display); font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.beat-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--ink-on-accent); display: inline-grid; place-items: center; font-family: var(--font); font-size: 12px; font-weight: 800; flex: none; }
.beat p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); line-height: 1.55; }
.loot { border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: 14px 16px; }
.loot-t { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--accent-ink); }
.loot-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; gap: 10px 22px; flex-wrap: wrap; }
.loot-list li { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px; color: var(--text); }
.loot-list .aicon { width: 34px; height: 34px; }
.loot .hint { margin: 10px 0 0; line-height: 1.55; }
.dropzone { padding: 34px 20px; }
.dropzone h2 { font-family: var(--font); font-weight: 800; font-size: 17px; }

/* Q4 진범 감별: 한 번에 한 단서 */
.stage-panel .chapter { border: 0; padding: 0; margin: 0; background: transparent; overflow: visible; }
.clue-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.clue-count { font-weight: 800; font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.clue-dots { display: flex; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.clue-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--bg-subtle); border: 1.5px solid var(--border-strong); }
.clue-dots i.on { background: var(--brand); border-color: var(--brand); }
.clue-dots i.cur { box-shadow: 0 0 0 3px var(--accent); }
.stage-panel .q-block { padding: 20px; border-radius: var(--r-lg); margin-top: 0; }
.q-block[data-dir="fwd"] { animation: stage-fwd .36s var(--ease) both; }
.q-block[data-dir="back"] { animation: stage-back .36s var(--ease) both; }
.stage-panel .q-title { font-size: 18px; line-height: 1.45; margin: 0; }
.stage-panel .q-help { font-size: 13.5px; }
.stage-panel .choice-row, .stage-panel .choice-list, .stage-panel .q-block .chips { margin-top: 14px; }
.stage-panel .choice { padding: 13px 14px; }
.clue-tip { margin: 10px 2px 0; }
.clue-note { min-height: 0; }
.clue-note .clue-tag { position: static; display: inline-block; margin-top: 10px; font-size: 12.5px; padding: 5px 12px; }
.btn.primary.ready { animation: ready-pulse 1.1s var(--ease) 1; }
@keyframes ready-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent, var(--shadow-brand); } }
.sum-ch { margin-bottom: 18px !important; }
.sum-ch .ch-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sum-count { font-family: var(--font); font-size: 12px; font-weight: 700; color: var(--text-3); }
.sum-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sum-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; font: inherit; color: var(--text);
  padding: 11px 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--brand); transition: border-color .15s, background-color .15s; }
.sum-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.sum-item.un { box-shadow: inset 3px 0 0 var(--indet); border-style: dashed; }
.sum-q { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.sum-a { font-size: 14px; font-weight: 800; }
.sum-item.un .sum-a { color: var(--indet-ink); }
.sum-edit { font-size: 12px; font-weight: 800; color: var(--brand-strong); }

/* Q5 결과 */
.scoreboard[data-dir="back"], .scoreboard[data-dir="none"] { animation: none; }
.sb-top { display: flex; align-items: center; gap: 18px; position: relative; z-index: 1; }
.sb-text { flex: 1 1 auto; min-width: 0; }
.sb-scene { width: 210px; flex: none; aspect-ratio: 320 / 150; }
.sb-scene .art .k-wash2 { fill: rgba(255,255,255,.14); }
.sb-scene .art .ln.soft { stroke: rgba(0,0,0,.2); }
.trophies { position: relative; z-index: 1; }
.loot-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.loot-row .loot-t { margin-right: 4px; }
.loot-btn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text); border-radius: var(--r-pill);
  padding: 4px 16px 4px 5px; font-weight: 800; font-size: 13.5px; min-height: 44px; transition: transform .15s var(--ease), border-color .15s, background-color .15s; }
.loot-btn .aicon { width: 34px; height: 34px; }
.loot-btn:hover { transform: translateY(-2px); border-color: var(--brand); }
.loot-btn.on { border-color: var(--brand-strong); background: var(--brand-soft); }
.overlay { overflow: auto; }

@media (max-width: 720px) {
  .stage-panel { padding-top: 14px; }
  .stage-top { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .scene-box { width: min(100%, 300px); margin: 0 auto; }
  .stage-top .panel-head h1 { font-size: 22px; }
  .beats { grid-template-columns: 1fr; gap: 8px; }
  .beat { padding: 12px; }
  .sdot + .sdot::before { width: 8px; margin: 0 1px; }
  .sd-label { max-width: 8.5em; }
  .dex-chip span { font-size: 12px; }
  .stage-panel .q-block { padding: 16px 14px; }
  .sum-item { grid-template-columns: 1fr auto; }
  .sum-q { grid-column: 1 / -1; }
  .sb-scene { display: none; }
  .loot-btn { flex: 1 1 auto; justify-content: flex-start; }
  .dex-grid { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
  .seg button, .sort-sel .input { min-height: 44px; }
  .sort-sel { margin-left: 0; }
  .binder-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .inspect { grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 4px; }
  .inspect-nav { width: 36px; height: 44px; border-radius: 12px; }
  .inspect-foot { position: sticky; bottom: -18px; background: var(--bg-elev); padding: 10px 0; margin-top: 8px; }
  .dm-head h2 { font-size: 19px; }
  .overlay { padding: 12px; }
  /* 흔적 수집(0)·증거 확인(1) 은 하단 고정 내비가 없다 */
  body[data-appstep="2"] .stage-panel, body[data-appstep="3"] .stage-panel { padding-bottom: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  .dex-card .dex-inner { transform: none; }
  .dex-card.flip .dex-inner { transform: rotateY(180deg); }
  .foil { background-position: 0 0, 50% 50% !important; }
}

/* 좁은 화면의 헤더: 언어·AI 엔진 선택이 늘어나 한 줄에 다 들어가지 않는다 — HUD 를 둘째 줄로 내린다 */
@media (max-width: 720px) {
  .app-header .bar { flex-wrap: wrap; gap: 8px; padding: 8px 14px; }
  .logo { flex: 1 1 auto; min-width: 0; }
  .logo > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logo .mark { width: 34px; height: 34px; font-size: 18px; }
  .hud { order: 9; flex: 1 1 60%; width: auto; min-width: 0; margin: 0; }
  .theme-toggle { order: 10; min-height: 40px; height: 40px; }
  a.admin-link { order: 11; }
  #engineSel { max-width: 104px; text-overflow: ellipsis; }
  #engineSel.unavail { max-width: 172px; }   /* '사용 불가' 표시가 잘리지 않게 */
}

/* ---------- 알러젠 자동완성(표 입력 칸의 제안 목록) ----------
   body 에 붙는 position:fixed 목록 — 가로 스크롤되는 .tbl-wrap 에 잘리지 않는다. 위치·너비는 app.js(acPlace)가 정한다. */
.ac-list { position: fixed; z-index: 45; margin: 0; padding: 4px; list-style: none; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-elev); border: 1.5px solid var(--brand); border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.ac-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.ac-list li:hover { background: var(--bg-subtle); }
.ac-list li[aria-selected="true"] { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-strong); }
.ac-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; color: var(--text); }
.ac-main span { color: var(--text-2); font-size: 13.5px; }
.ac-sub { font-size: 12px; color: var(--text-3); }
.ac-hint { margin: 8px 0 0; }

/* ---------- 결과 이메일 받기 ---------- */
.mail-panel { margin-top: 18px; }
.mail-panel h2 { font-size: 17px; margin: 0 0 4px; }
.mail-panel .q-help { margin-bottom: 12px; }
.mail-kinds { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mail-kinds legend, .mail-label { display: block; padding: 0; font-weight: 800; font-size: 13.5px; margin-bottom: 8px; color: var(--text); }
.mail-kind { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  border-radius: var(--r-pill); padding: 8px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.mail-kind:has(input:checked) { border-color: var(--brand-strong); background: var(--brand-soft); }
.mail-kind:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.mail-kind input { width: 18px; height: 18px; accent-color: var(--brand-strong); }
.mail-row { display: flex; gap: 8px; align-items: stretch; }
.mail-row .input { flex: 1 1 auto; min-width: 0; }
.mail-row .input[aria-invalid="true"] { border-color: var(--relevant-ink); }
.mail-row .btn { flex: none; white-space: nowrap; justify-content: center; }
#mailMsg .notice { margin-top: 12px; }
#pdfMsg .notice { margin-top: 10px; }
.mail-files { margin-top: 4px; font-size: 12.5px; overflow-wrap: anywhere; }
.mail-files ul { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 6px; }
.mail-files code { display: inline-block; max-width: 100%; margin: 2px 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; }
.mail-panel > .hint { margin: 12px 0 0; }
@media (max-width: 720px) {
  .ac-list li { padding: 11px 10px; }
  .ac-main { font-size: 15px; }
  .mail-kind { min-height: 44px; }
  .mail-row { flex-direction: column; }
  .mail-row .btn { min-height: 48px; }
}

/* 결과 화면 — 화면 언어의 결과를 준비하는 중/준비하지 못함 안내 */
#langSync:empty { display: none; }
.lang-sync { margin: 0 0 14px; align-items: center; }
.lang-sync .spinner { flex: none; }
.lang-sync .btn { margin-left: auto; flex: none; }

/* 검토 표의 검사 대조 행 안내 · 화면 언어로 오지 않은 상담 답변 표시 */
.ctl-note { font-size: 11.5px; color: var(--text-2); margin-top: 3px; }
.unk-note { font-size: 11.5px; color: var(--text-2); margin-top: 3px; }   /* 등록 목록에 없는 알러젠 이름 — 막지 않는 안내 */
.chat-tr { font-size: 11.5px; color: var(--indet-ink); margin-top: 2px; }
