/* 색은 전부 여기 토큰으로만 둔다. 라이트 값을 맨 :root 에 두고,
   OS 다크 설정과 사용자 토글(html[data-theme]) 두 경우에 다시 덮어쓴다.
   :not([data-theme="light"]) 덕분에 "밝게" 로 고정하면 OS 가 다크여도 밝게 남는다.

   --viz-1..4 는 점수 밴드(<70 / 70 / 80 / 90+)용 단일 색상 순서 램프다.
   dataviz 검증기(ordinal)로 두 모드 모두 통과시킨 값이니 눈대중으로 고치지 말 것. */
:root {
  color-scheme: light;
  --bg: #f3f6f9;
  --panel: #ffffff;
  --inset: #edf2f7;
  --border: #d9e2ea;
  --text: #14212e;
  --muted: #5a6b7b;
  --accent: #1b63a5;
  --accent-hover: #14507f;
  --on-accent: #ffffff;

  --code-bg: #0f1c29;
  --code-fg: #e6edf3;
  --warn-bg: #fff6e5;
  --warn-border: #f1d9a6;
  --warn-text: #7a5200;
  --ok: #1c7c5a;
  --danger-border: #efc9c6;
  --danger-text: #b3382f;
  --backdrop: rgba(15, 28, 41, 0.5);

  --viz-1: #74a7d6;
  --viz-2: #3f80be;
  --viz-3: #1d5c9a;
  --viz-4: #0e3f6e;

  /* 점수 등급(우수·양호·보통·미흡) 색. 점수 칩에만 쓴다 — 크기 비교 그래프는 위 --viz 램프를 쓴다. */
  --grade-4: #1f8a4c;
  --grade-3: #5c9a2e;
  --grade-2: #c28a00;
  --grade-1: #c2453a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1722;
    --panel: #16212d;
    --inset: #1c2937;
    --border: #2a3a4b;
    --text: #e5edf5;
    --muted: #93a5b7;
    --accent: #5aa7e8;
    --accent-hover: #7dbcf2;
    --on-accent: #0b1722;

    --code-bg: #0a121b;
    --code-fg: #e5edf5;
    --warn-bg: #2b2412;
    --warn-border: #4d4020;
    --warn-text: #e6c36f;
    --ok: #55c29a;
    --danger-border: #5a3430;
    --danger-text: #f0a19a;
    --backdrop: rgba(0, 0, 0, 0.65);

    --viz-1: #2f6498;
    --viz-2: #4688c6;
    --viz-3: #72a9dc;
    --viz-4: #b0d0ee;

    --grade-4: #4cc27f;
    --grade-3: #9acb5c;
    --grade-2: #e6b440;
    --grade-1: #ec7a6f;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1722;
  --panel: #16212d;
  --inset: #1c2937;
  --border: #2a3a4b;
  --text: #e5edf5;
  --muted: #93a5b7;
  --accent: #5aa7e8;
  --accent-hover: #7dbcf2;
  --on-accent: #0b1722;

  --code-bg: #0a121b;
  --code-fg: #e5edf5;
  --warn-bg: #2b2412;
  --warn-border: #4d4020;
  --warn-text: #e6c36f;
  --ok: #55c29a;
  --danger-border: #5a3430;
  --danger-text: #f0a19a;
  --backdrop: rgba(0, 0, 0, 0.65);

  --viz-1: #2f6498;
  --viz-2: #4688c6;
  --viz-3: #72a9dc;
  --viz-4: #b0d0ee;

  --grade-4: #4cc27f;
  --grade-3: #9acb5c;
  --grade-2: #e6b440;
  --grade-1: #ec7a6f;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.version-badge {
  font-size: 0.72rem;
  color: var(--muted);
}

.topbar nav { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.topbar nav a { color: var(--accent); text-decoration: none; }
.who { color: var(--muted); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-card {
  max-width: 360px;
  margin: 40px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px 28px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  background: var(--inset);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
}
.tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

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

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }

input, textarea, select {
  background: var(--panel);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
}
textarea { resize: vertical; }

.err { color: var(--danger-text); font-size: 0.85rem; min-height: 1.1em; margin: 0; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
/* 링크를 버튼 모양으로 쓸 때. a 는 기본이 inline 이라 위아래 여백이 안 먹는다. */
a.btn { display: inline-block; text-decoration: none; }

/* 설명서 내려받기 줄 — 버튼과 설명이 한 줄, 좁은 화면에서는 접힌다. */
.doc-dl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.doc-dl .hint { margin: 0; }

/* 설정 화면의 다른 탭 바로가기 버튼 줄 */
.settings-links { display: flex; gap: 10px; flex-wrap: wrap; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 4px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 14px; }

.row { display: flex; gap: 12px; }
.row label { flex: 1; }

.panel-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.avg { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.empty { color: var(--muted); font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.note { max-width: 220px; white-space: pre-wrap; color: var(--muted); }

/* ---------- 대시보드 하위 탭 ---------- */
.subnav { display: flex; gap: 6px; }
.subtab {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--muted);
}
.subtab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

#viewRecords, #viewAnalysis, #viewPair, #viewSettings, #analysisBody {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- 동의 ---------- */
.consent {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--muted);
}
.consent-title { margin: 0 0 6px; font-weight: 600; color: var(--text); }
.consent ul { margin: 0 0 10px; padding-left: 18px; line-height: 1.55; }

.check {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
  cursor: pointer;
}
.check input { width: auto; margin-top: 2px; flex-shrink: 0; }
/* 설정 목록의 켜짐/꺼짐 — 좁은 칸에서 글자가 한 자씩 세로로 꺾이지 않게 */
.sl-toggle { white-space: nowrap; flex-shrink: 0; align-items: center; }
.check.big { font-size: 0.95rem; margin-bottom: 10px; }

/* ---------- 연결 안내 ---------- */
.steps { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 1.7; }
.steps > li { margin-bottom: 16px; }
.steps > li:last-child { margin-bottom: 0; }

.code, code {
  font-family: ui-monospace, Consolas, "D2Coding", monospace;
  font-size: 0.82rem;
}
code { background: var(--inset); padding: 1px 5px; border-radius: 4px; }
pre.code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 9px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}

.pair-box { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; align-items: flex-start; }
.token {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.7rem;
  word-break: break-all;
  background: var(--inset);
  color: var(--muted);
}
.pair-actions { display: flex; align-items: center; gap: 10px; }
.copied { font-size: 0.8rem; color: var(--accent); }

.warn {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 9px 12px;
  margin: 8px 0 0;
}
.ok { font-size: 0.85rem; color: var(--ok); margin: 0; }

.toast-ok {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: 8px;
  padding: 9px 12px;
  margin: 0 0 12px;
}

.panel.danger { border-color: var(--danger-border); }
.panel.danger h2 { color: var(--danger-text); }

/* ---------- 기록 표 ---------- */
.table-wrap { overflow-x: auto; }
td.score { font-weight: 700; }
.pill {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--inset);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--muted);
  vertical-align: middle;
}

/* ---------- 상세 모달 ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  width: min(720px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 0.98rem; min-width: 0; overflow-wrap: anywhere; }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
/* 창 안 스크롤이 끝에 닿으면 남은 스크롤이 뒤 페이지로 넘어가 바깥이 오르락내리락했다 —
   창이 열려 있는 동안 뒤 페이지를 잠그고, 배경을 문질러도 넘어가지 않게 한다. */
.backdrop { overscroll-behavior: contain; }
html:has(.backdrop:not(.hidden)), body:has(.backdrop:not(.hidden)) { overflow: hidden; }

.detail-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.dtab {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--inset);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--muted);
}
.dtab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.detail-pane {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.7;
}

/* 채점 결과 탭 — 마크다운 렌더링 (문진 전사 탭은 그대로 pre 평문) */
.detail-pane.md { white-space: normal; }
.md > *:first-child { margin-top: 0; }
.md h2 { margin: 18px 0 8px; font-size: 0.95rem; }
.md h3 { margin: 16px 0 8px; font-size: 0.9rem; }
.md h4 { margin: 14px 0 6px; font-size: 0.85rem; color: var(--muted); }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 20px; }
.md li { margin: 5px 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md code {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.85em;
}
/* 표가 넓으면 모달 전체가 아니라 표 안에서만 가로 스크롤되게 한다. */
.md .table-scroll { overflow-x: auto; margin: 8px 0 14px; }
.md table { min-width: 360px; }
.md th, .md td { font-size: 0.82rem; padding: 6px 8px; }
/* 휴대폰에서는 채점표(항목·평가·점수·근거)가 360px 에 맞춰 근거 칸 오른쪽이 잘려 보였다 — 화면 폭에 맞추고 칸 여백을 줄인다. */
@media (max-width: 480px) {
  .md table { min-width: 0; width: 100%; }
  .md th, .md td { padding: 6px 5px; }
}

/* 넓은 표는 패널 밖으로 넘치지 않고 표 안에서 가로 스크롤한다. */
.table-scroll { overflow-x: auto; }
.status-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
}
.status-pill.on { color: var(--ok); border-color: var(--ok); }
.status-pill.wait { color: var(--accent); border-color: var(--accent); }

/* ---------- 테마 토글 ---------- */
.topbar nav { margin-left: auto; }
.theme-toggle {
  margin-left: 12px;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { color: var(--text); }

/* ---------- 검색 · 필터 · 정렬 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.filters input, .filters select {
  font-size: 0.82rem;
  padding: 6px 9px;
  color: var(--text);
}
.flt-search { flex: 1 1 160px; min-width: 130px; }
.filters select { flex: 0 0 auto; }
.filters .btn { align-self: center; }


.muted { color: var(--muted); }

/* ---------- 영역별 성취율 ---------- */
.sbars { display: flex; flex-direction: column; gap: 4px; }
.sbar {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 0.83rem;
}
.sbar-label { display: flex; align-items: center; gap: 5px; }
.sbar .tag {
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.66rem;
}
.sbar-track {
  height: 14px;
  border-radius: 4px;
  background: var(--inset);
  border: 1px solid var(--border);
  overflow: hidden;
}
/* 막대는 0 에 붙어 있으니 왼쪽 모서리는 각지게, 값 쪽 끝만 둥글게. */
.sbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.sbar-fill.b1 { background: var(--viz-1); }
.sbar-fill.b2 { background: var(--viz-2); }
.sbar-fill.b3 { background: var(--viz-3); }
.sbar-fill.b4 { background: var(--viz-4); }
.sbar-val { font-variant-numeric: tabular-nums; font-size: 0.8rem; white-space: nowrap; }
.sbar-pct { margin-left: 7px; color: var(--muted); }


.warn-inline { color: var(--warn-text); margin-top: 12px; margin-bottom: 0; }


td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 4px; }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; }
  .topbar nav { gap: 8px; font-size: 0.82rem; }
  .who { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .container { padding: 16px 12px 48px; gap: 14px; }
  .panel { padding: 14px 14px; }

  /* 하위 탭은 줄바꿈 대신 가로로 밀어서 본다. */
  .subnav { overflow-x: auto; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subtab { flex: 0 0 auto; white-space: nowrap; }

  .panel-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .row { flex-direction: column; }
  .flt-search { flex-basis: 100%; }
  .filters select { flex: 1 1 auto; }

  /* 기록 표는 8칸을 가로로 밀기보다 한 건씩 카드로 접는다. */
  #recordTable, #recordTable tbody, #recordTable tr, #recordTable td { display: block; width: 100%; }
  #recordTable thead { display: none; }
  #recordTable tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 11px;
    margin-bottom: 10px;
  }
  #recordTable td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 3px 0;
  }
  #recordTable td:empty { display: none; }
  #recordTable td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 600;
  }
  #recordTable td.note { max-width: none; text-align: right; }
  #recordTable td.actions {
    justify-content: flex-end;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }

  /* 카드를 낮게: 주제·총점이 제목줄, 날짜는 그 아래, 병력·진찰·PPI 는 한 줄 3칸. */
  #recordTable tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 8px;
    align-items: center;
  }
  #recordTable td:nth-child(2) { grid-column: 1 / 3; grid-row: 1; font-weight: 700; justify-content: flex-start; }
  #recordTable td:nth-child(3) { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  #recordTable td:nth-child(1) { grid-column: 1 / 4; grid-row: 2; justify-content: flex-start; color: var(--muted); font-size: 0.8rem; }
  #recordTable td:nth-child(n + 4):nth-child(-n + 6) {
    grid-row: 3;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-top: 6px;
    padding: 6px 0;
    background: var(--inset);
    border-radius: 8px;
  }
  #recordTable td:nth-child(n + 4):nth-child(-n + 6)::before { font-size: 0.72rem; font-weight: 500; }
  #recordTable td:nth-child(-n + 3)::before { display: none; }
  #recordTable td.note { grid-column: 1 / 4; justify-content: flex-start; text-align: left; padding-top: 8px; font-size: 0.85rem; line-height: 1.5; word-break: keep-all; }
  #recordTable td.note::before { display: none; }
  #recordTable td.actions { grid-column: 1 / 4; }

  .sbar { grid-template-columns: 78px 1fr auto; gap: 8px; font-size: 0.8rem; }

  .modal { max-height: 92vh; }
  .backdrop { padding: 10px; }
}

/* ---------- 케이스별 점수 ---------- */
.case-sort { font-size: 0.78rem; padding: 4px 8px; }

#caseTable { font-size: 0.82rem; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
#caseTable td { vertical-align: middle; }

.case-row { cursor: pointer; }
.case-row:hover td, .case-row:focus-visible td { background: var(--inset); }
.case-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.case-name { display: flex; align-items: center; gap: 6px; word-break: keep-all; }
.caret { color: var(--muted); font-size: 0.7rem; width: 0.8em; flex: 0 0 auto; }

/* 평균 칸은 숫자가 값을 말하고, 아래 막대는 훑어보기용이다. */
#caseTable td.mean { min-width: 66px; }
.cell-val { display: block; }
.cell-meter {
  display: block;
  height: 3px;
  margin-top: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.cell-meter > span { display: block; height: 100%; border-radius: 2px; }
.cell-meter.b1 > span { background: var(--viz-1); }
.cell-meter.b2 > span { background: var(--viz-2); }
.cell-meter.b3 > span { background: var(--viz-3); }
.cell-meter.b4 > span { background: var(--viz-4); }

.case-detail > td { padding: 0 8px 10px; border-bottom: 1px solid var(--border); }
.attempts {
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  counter-reset: att;
  background: var(--inset);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.attempts li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.78rem;
}
.attempts li::before {
  counter-increment: att;
  content: counter(att) "회";
  flex: 0 0 auto;
  min-width: 2.4em;
  color: var(--muted);
  font-size: 0.72rem;
}
.att-date { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.att-total { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.att-sect { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  /* 8칸을 가로로 밀지 않게 영역별 평균은 접는다 — 펼친 회차 목록에 그대로 있다. */
  #caseTable .sect { display: none; }
  #caseTable { font-size: 0.78rem; }
  #caseTable th, #caseTable td { padding: 6px 5px; }
  .attempts li { flex-wrap: wrap; gap: 4px 8px; }
  .att-sect { flex-basis: 100%; }
}


/* 영역 점수가 남는 자리를 먹어 뒤따르는 버튼들을 오른쪽으로 민다.
   버튼마다 margin-left:auto 를 주면 버튼끼리 서로 밀어내므로 그렇게 하지 않는다. */
.att-sect { flex: 1; }
.attempts li .btn { flex: 0 0 auto; }
.att-none { flex: 0 0 auto; color: var(--muted); font-size: 0.72rem; }

/* 안 해본 케이스 — 펼칠 것이 없으니 클릭 대상이 아니고, 배경으로 물러나 있는다. */
.case-row.undone > td { color: var(--muted); }
.case-row.undone { cursor: default; }
.case-row.undone:hover > td { background: transparent; }
.tag-undone {
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.66rem;
  white-space: nowrap;
}

/* 케이스 표는 58줄까지 늘어난다. 표 안에 또 스크롤을 만들지 않고 페이지째 넘기되,
   머리글만 붙여두어 한참 내려가도 열 이름이 보이게 한다.
   그래서 이 표의 감싸개에는 .table-scroll(=스크롤 컨테이너)을 쓰지 않는다 — 쓰면 sticky 가 죽는다. */
#caseTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}


/* ---------- 케이스 펼침 안쪽 — 회차 / 자주 놓친 항목 ---------- */
.case-panes {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0 2px;
}
.case-pane {
  background: var(--inset);
  border-radius: 8px;
  padding: 9px 11px 10px;
}
.case-pane h4 {
  margin: 0 0 7px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}
/* 안쪽 패널이 제 배경을 갖게 됐으니 회차 목록은 배경을 벗는다. */
.case-pane .attempts { background: none; border-radius: 0; padding: 0; }

@media (max-width: 760px) {
  /* 좁으면 나란히 두지 않고 회차 아래로 내린다. */
  .case-panes { grid-template-columns: 1fr; }
}

/* 케이스 성적 추이 — 회차가 한 자릿수라 그래프 대신 회차별 막대로 낸다. */
.tr-delta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 9px;
  font-size: 0.78rem;
}
/* 오르내림을 색만으로 말하지 않는다 — 화살표 글리프가 같이 붙는다. */
.tr-delta.up .tr-arrow, .tr-delta.up .tr-amount { color: var(--ok); }
.tr-delta.down .tr-arrow, .tr-delta.down .tr-amount { color: var(--accent); }
.tr-delta.flat .tr-arrow, .tr-delta.flat .tr-amount { color: var(--muted); }
.tr-arrow { font-size: 0.7rem; }
.tr-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.tr-span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-once { margin: 0 0 9px; font-size: 0.78rem; color: var(--muted); }

.tr-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.tr-list li {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr) 2.2em 2.6em;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
}
.tr-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-track {
  height: 10px;
  border-radius: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}
/* 막대는 0 에 붙어 있으니 왼쪽 모서리는 각지게, 값 쪽 끝만 둥글게. */
.tr-fill { display: block; height: 100%; border-radius: 0 3px 3px 0; }
.tr-fill.b1 { background: var(--viz-1); }
.tr-fill.b2 { background: var(--viz-2); }
.tr-fill.b3 { background: var(--viz-3); }
.tr-fill.b4 { background: var(--viz-4); }
.tr-score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tr-date { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-foot { margin: 9px 0 0; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 기록 상세 — 내려받기 / 점수 요약 ---------- */
.modal-actions { display: flex; flex-wrap: wrap; gap: 5px; flex: 0 0 auto; }
.detail-meta {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- 인쇄 = PDF로 저장 ----------
   PDF 라이브러리를 싣는 대신 브라우저 인쇄로 넘긴다. 한글이 그대로 나오고
   글자가 선택·검색되는 PDF 가 만들어진다.
   .printing 은 인쇄 직전 app.js 가 <html> 에 붙였다가 끝나면 뗀다. */
@media print {
  @page { margin: 16mm 14mm; }

  /* 기록 상세만 남기고 화면의 나머지는 인쇄하지 않는다. */
  body > *:not(.backdrop) { display: none !important; }

  .backdrop {
    position: static;
    display: block;
    padding: 0;
    background: none;
  }
  .modal {
    width: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: none;
  }
  .modal-head { padding: 0 0 8px; border-bottom: 1px solid #999; }
  .modal-head h3 { font-size: 1.15rem; }
  .modal-actions { display: none; }
  .modal-body { padding: 12px 0 0; overflow: visible; }
  .detail-tabs { display: none; }

  /* 화면에서는 한 번에 한 탭이지만 인쇄물에는 둘 다 담는다.
     .hidden 의 display:none !important 를 이기려면 id+class 로 특이도를 올려야 한다. */
  .printing #paneEval.hidden,
  .printing #paneScript.hidden { display: block !important; }
  .printing #paneScript::before {
    content: "문진 전사";
    display: block;
    margin: 22px 0 8px;
    font-weight: 700;
    font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  }
  .printing #paneEval::before {
    content: "채점 결과";
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
  }

  /* 종이에서는 배경색을 빼고 검정 글씨로. */
  .detail-pane, .modal-head h3, .detail-meta { color: #000; }
  .detail-meta { border-bottom: 0; }
  .md code, .md table { background: none; }
  .md th, .md td { border-bottom: 1px solid #bbb; }

  /* 페이지가 넘어갈 때 항목이 반으로 잘리지 않게 한다.
     걸치는 항목은 쪼개지 말고 통째로 다음 장으로 밀라는 뜻이다.
     break-inside 를 못 읽는 뷰어를 위해 옛 이름도 함께 준다. */
  .md tr, .md li, .md p, .md h2, .md h3, .md h4, .md table {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* 제목만 페이지 맨 아래에 남고 내용이 다음 장으로 넘어가는 것도 막는다. */
  .md h2, .md h3, .md h4 {
    page-break-after: avoid;
    break-after: avoid;
  }
  /* 표는 여러 장에 걸쳐도 되지만, 걸치면 장마다 열 이름을 다시 낸다. */
  .md tbody { page-break-inside: auto; break-inside: auto; }
  .md thead { display: table-header-group; }
  /* 문단이 한두 줄만 떨어져 나가는 것도 막는다. */
  .md p, .md li, .detail-pane { orphans: 3; widows: 3; }
  /* 문진 전사는 새 장에서 시작한다 — 채점표 꼬리에 붙으면 읽기 나쁘다. */
  .printing #paneScript { page-break-before: always; break-before: page; }

  .md .table-scroll { overflow: visible; }
}

/* ---------- 오류 제보 ---------- */
#viewReport { display: flex; flex-direction: column; gap: 18px; }

.report-form { display: flex; flex-direction: column; gap: 8px; }
.report-form textarea { width: 100%; font-size: 0.9rem; line-height: 1.5; }
.report-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.report-foot .hint { margin: 0; font-variant-numeric: tabular-nums; }
.report-note { margin: 12px 0 0; }

.report-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rp {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--inset);
}
/* 처리된 제보는 물러나 있되 읽을 수는 있어야 한다. */
.rp.done { background: transparent; }
.rp.done .rp-text { color: var(--muted); }

.rp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.76rem;
}
.rp-who { font-weight: 600; }
.rp-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-head .status-pill { margin-left: auto; }

.rp-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.rp-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--muted);
}
.rp-page { flex: 0 0 auto; }
/* 브라우저 문자열은 길어서 펼쳐두면 제보가 안 보인다. 툴팁으로만 둔다. */
.rp-agent { flex: 0 0 auto; text-decoration: underline dotted; cursor: help; }
.rp-foot .btn { margin-left: auto; }
.rp-foot .btn + .btn { margin-left: 0; }

@media (max-width: 640px) {
  .report-foot { flex-direction: column; align-items: stretch; }
  .report-foot .btn { width: 100%; }
  .rp-foot .btn { margin-left: 0; }
}

/* ---------- 제보 이미지 첨부 ---------- */
.report-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* label 을 버튼처럼 쓴다 — 숨긴 file input 을 여는 용도다. */
.attach-btn { display: inline-block; cursor: pointer; }
.report-attach .hint { margin: 0; }

.attach-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}
.attach-preview img {
  width: 120px;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}
.attach-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 제보에 펼친 이미지 */
.rp-img-slot:empty { display: none; }
.rp-img {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 640px) {
  .attach-preview img { width: 84px; max-height: 84px; }
}

/* ---------- 이용 방법: 운영체제 전환 ---------- */
.seg {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 4px 12px;
  cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 해당 운영체제 것만 남긴다. 안 고른 쪽은 문서에서 지우지 않고 감추기만 한다. */
:root[data-os="mac"] .win-only,
:root[data-os="win"] .mac-only { display: none !important; }

/* ---------- 이용 방법: 접이식 ---------- */
.alt, .faq {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 8px;
}
.faq { border-top: 0; border-bottom: 1px solid var(--border); margin-top: 0; padding: 9px 0; }
.alt > summary, .faq > summary {
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--muted);
  list-style: none;
  display: flex;
  gap: 7px;
  align-items: baseline;
}
.faq > summary { color: var(--text); font-size: 0.9rem; }
.alt > summary::-webkit-details-marker,
.faq > summary::-webkit-details-marker { display: none; }
.alt > summary::before, .faq > summary::before {
  content: "+";
  flex: 0 0 auto;
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
}
.alt[open] > summary::before, .faq[open] > summary::before { content: "\2212"; }
.alt > summary:focus-visible, .faq > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
.faq-a { padding: 8px 0 2px 18px; font-size: 0.86rem; color: var(--muted); line-height: 1.6; }
.faq-a p { margin: 0; }
.faq-a p + p { margin-top: 7px; }
.alt .hint { margin: 6px 0 0; }

/* ---------- 모바일 조작성 ----------
   폭은 이미 안 넘쳤다. 문제는 손가락 크기다.
   .btn.small 29px, 세그먼트 25px, 체크박스 13px 로는 정확히 누르기 어렵다.
   화면이 좁을수록 오히려 대상을 키운다. */
@media (max-width: 640px) {
  .btn.small { padding: 9px 13px; font-size: 0.84rem; }

  /* 상단바는 .container 밖이라 따로 챙긴다. 테마 버튼과 로그아웃도 손가락 대상이다. */
  .theme-toggle { width: 38px; height: 38px; font-size: 1.05rem; }
  .brand { min-height: 44px; }
  #btnResetPw { padding: 12px 8px; }
  .topbar nav a { padding: 8px 2px; }
  .dtab { padding: 9px 14px; font-size: 0.86rem; }
  .seg-btn { padding: 9px 15px; font-size: 0.86rem; }
  .subtab { padding: 9px 13px; }

  /* iOS 는 글자가 16px 보다 작은 입력칸을 누르면 화면을 확대해버린다.
     확대되면 사용자가 손으로 되돌려야 하므로 입력 요소만 16px 로 올린다. */
  input, textarea, select,
  .filters input, .filters select, #caseSort, #caseScope, #reportFilter {
    font-size: 16px;
    padding: 9px 11px;
  }

  /* 체크박스는 기본 13px 라 빗나가기 쉽다. */
  .check input { width: 20px; height: 20px; margin-top: 1px; }
  .check.big { font-size: 1rem; }

  /* 접이식 제목은 글자만큼만 눌리면 좁다. 위아래로 여유를 준다. */
  .alt > summary, .faq > summary { padding: 9px 0; }

  /* .report-form textarea 와 .token 은 뒤에서 더 구체적인 선택자로 크기를 덮으므로
     여기서 다시 못박는다. 안 그러면 iOS 가 눌렀을 때 화면을 확대한다. */
  .report-form textarea, .token { font-size: 16px; }

  /* 10px 대 글자는 휴대폰에서 읽히지 않는다. */
  .pill { font-size: 0.74rem; }
  .sbar .tag, .tag-undone { font-size: 0.72rem; }
  .caret { font-size: 0.78rem; }
  .tr-arrow { font-size: 0.76rem; }
  .att-none, .rp-agent, .rp-page { font-size: 0.76rem; }

  /* 표 안 버튼이 커지면서 줄이 붙지 않게 한다. */
  .attempts li { gap: 6px 8px; }
  #recordTable td.actions { gap: 8px; }
}

/* ---------- 하위 탭이 더 있다는 표시 ----------
   375px 에서 7개 중 4개만 보이고 나머지는 오른쪽에 숨는다.
   표시가 없으면 설정·관리자 탭이 있는 줄도 모른다.
   오른쪽에 아직 남았을 때만 가장자리를 흐리게 해서 밀 수 있다는 걸 알린다. */
.subnav {
  -webkit-mask-image: none;
  mask-image: none;
}
.subnav.more-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

/* 아주 좁은 화면(320px 대)에서는 케이스 표 5열이 2px 정도 모자라 가로 스크롤이 생긴다.
   "최고" 를 접는다 — 펼치면 성적 추이에 최고점이 그대로 나오므로 잃는 정보가 없다.
   (앞선 규칙이 병력/진찰/PPI 를 이미 감췄으므로 여기서 4번째 칸이 "최고" 다.) */
/* ---------- 면담(Gemini) 채팅 ---------- */
.ivfield { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; max-width: 320px; }
.pair-box .ivfield { width: 100%; max-width: 420px; margin-bottom: 0; }
.ivfield select, .ivfield input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}

.iv-topicbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}
.iv-topicbar .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
  flex: none;
}
.iv-topicbar b { color: var(--text); font-weight: 600; }

.iv-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  scroll-behavior: smooth;
}

.iv-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: iv-in 0.18s ease-out;
}
@keyframes iv-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.iv-msg.iv-me { justify-content: flex-end; }
.iv-msg.iv-them { justify-content: flex-start; }
.iv-msg.iv-eval { justify-content: stretch; }

.iv-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border: 1px solid var(--border);
}

.iv-bubble {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 74%;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: keep-all; /* 한글을 글자 중간에서 끊지 않는다 */
  overflow-wrap: anywhere; /* 공백 없는 긴 문자열(주소 등)만 예외로 끊는다 */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
@media (max-width: 640px) {
  .iv-bubble { max-width: 84%; }
  .iv-quick .btn { padding: 10px 20px; min-height: 40px; }
}
.iv-me .iv-bubble {
  background: linear-gradient(165deg, var(--accent), var(--accent-hover));
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 35%, transparent);
}
.iv-them .iv-bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.iv-note {
  justify-content: center;
}
.iv-note .iv-bubble {
  max-width: 92%;
  word-break: keep-all;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.82rem;
  border-radius: 10px;
  box-shadow: none;
  text-align: center;
}

.iv-walkout .iv-bubble {
  background: var(--inset);
  border-color: var(--danger-border);
  color: var(--danger-text);
  font-weight: 600;
  padding: 12px 16px;
}
.iv-input input:disabled { cursor: not-allowed; opacity: 0.6; }
.iv-quick .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 채점 결과 — 말풍선이 아니라 카드로 낸다. 정보량이 많아서 폭을 다 쓴다. */
.iv-eval-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.iv-eval-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--on-accent);
}
.iv-eval-head .grade {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}
.iv-eval-head .score {
  font-size: 0.82rem;
  opacity: 0.92;
}
.iv-eval-fatal {
  margin: 10px 16px 0;
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  color: var(--danger-text);
  font-size: 0.88rem;
  line-height: 1.5;
}
.iv-eval-missed {
  margin: 8px 16px 0;
  padding: 8px 12px;
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.88rem;
  line-height: 1.5;
}
.iv-score { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 8px 0 12px; }
.iv-score td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.iv-score td:nth-child(2), .iv-score td:nth-child(3) { text-align: right; white-space: nowrap; }
.iv-score tr.sub td { font-weight: 600; color: var(--text); }
.iv-eval-topic {
  padding: 10px 16px 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.iv-eval-body {
  padding: 4px 16px 14px;
  font-size: 0.88rem;
}

/* 타이핑 표시 — 답이 오기 전까지 잠깐 나오는 점 세 개 */
.iv-typing .iv-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 16px;
}
.iv-typing .iv-bubble span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: iv-bounce 1.1s infinite ease-in-out;
}
.iv-typing .iv-bubble span:nth-child(2) { animation-delay: 0.15s; }
.iv-typing .iv-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes iv-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.iv-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.iv-quick .btn {
  border-radius: 999px;
  padding: 6px 14px;
}

.iv-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.iv-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.iv-input input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  padding: 8px 0;
  outline: none;
}
.iv-input .btn.primary {
  border-radius: 999px;
  padding: 8px 18px;
}
.iv-input .btn.primary:disabled { opacity: 0.6; }

@media (max-width: 340px) {
  #caseTable th:nth-child(4),
  #caseTable td:nth-child(4) { display: none; }
}

/* 관리자 계정 표 — 휴대폰에서는 작업 버튼(승인·삭제)이 화면 밖에 있어 매번 옆으로 밀어야 했다.
   가입일 열을 숨기고 이메일을 줄바꿈하며, 버튼은 세로로 쌓는다. */
@media (max-width: 640px) {
  #adminTable th:nth-child(3),
  #adminTable td:nth-child(3) { display: none; }
  #adminTable td:nth-child(2) { word-break: break-all; min-width: 90px; font-size: 0.82rem; }
  #adminTable td.actions { white-space: normal; }
  #adminTable td.actions .btn { display: block; width: 100%; }
  #adminTable td.actions .btn + .btn { margin: 4px 0 0; }
}

/* ======================================================================
   디자인 다듬기 (2026-10) — 차분한 임상 톤.
   색은 맨 위 토큰만 쓴다. 위 규칙은 건드리지 않고 여기서 덮어쓰므로, 되돌리려면 이 블록만 지우면 된다.
   ====================================================================== */
:root {
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 42, 67, 0.05), 0 4px 16px rgba(16, 42, 67, 0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 상단 바: 얇은 강조선과 로고 마크로 정돈된 느낌을 준다. */
.topbar {
  border-top: 3px solid var(--accent);
  box-shadow: 0 1px 0 var(--border);
  border-bottom: none;
}
.brand-group { align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.brand-mark { width: 24px; height: 24px; flex: none; color: var(--accent); }
.version-badge { padding: 1px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--inset); font-variant-numeric: tabular-nums; }

/* 폭: 표·분석은 넓게, 설정·제보·이용 방법 같은 읽는 화면은 좁게. */
@media (min-width: 900px) {
  /* 모든 탭이 같은 폭을 쓴다. 화면마다 패널 폭이 다르면 탭을 바꿀 때 한쪽으로 치우쳐 보인다. */
  .container { max-width: 920px; }
}

/* 패널 */
.panel { border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; }
.panel h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px; }
.hint { line-height: 1.55; }

/* 하위 탭: 알약 대신 밑줄. */
.subnav { gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.subtab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px 9px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.subtab:hover { color: var(--text); }
.subtab.active { background: transparent; color: var(--accent); border-bottom-color: var(--accent); }

/* 버튼·입력 */
.btn { border-radius: 8px; font-weight: 500; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { font-weight: 600; }
.btn.primary:hover:not(:disabled) { border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
input, textarea, select { border-radius: 8px; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* 표 */
table { font-variant-numeric: tabular-nums; }
th {
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: var(--inset);
  border-bottom: 1px solid var(--border);
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: 10px 10px; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
td.note { max-width: 380px; line-height: 1.5; }

/* 점수 칩: 점수대별로 한눈에 구분된다 (--viz 램프, 밝은색 = 낮음). */
.score-chip {
  display: inline-block;
  min-width: 2.4em;
  padding: 1px 8px;
  border-radius: 999px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--chip, var(--viz-1)) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip, var(--viz-1)) 55%, transparent);
}
/* 등급 색: 90+ 우수(초록) · 80 양호(연두) · 70 보통(노랑) · 그 아래 미흡(빨강) */
.score-chip.b1 { --chip: var(--grade-1); }
.score-chip.b2 { --chip: var(--grade-2); }
.score-chip.b3 { --chip: var(--grade-3); }
.score-chip.b4 { --chip: var(--grade-4); }

/* 퇴실·빈 면담(20점 미만) 기록은 흐리게 */

/* 총평은 한 줄로 자르고, 누르면 펼친다 */
.note-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  cursor: pointer;
}
.note-clamp.open { -webkit-line-clamp: unset; display: block; }

/* 삭제는 실수로 누르기 어렵게 작고 흐린 글자 버튼 */
.btn-del {
  margin-left: 8px;
  padding: 2px 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.btn-del:hover, .btn-del:focus-visible { color: var(--danger-text); }
/* 손가락으로 누르는 화면에서는 작은 글자 버튼도 누를 자리를 넉넉히 준다(겉모습은 그대로, 2026-11-30 점검: 19~22px 였다). */
@media (pointer: coarse) {
  .btn-del, .topbar nav .subtab.toplink { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-del { padding: 6px 10px; }
}

/* 영역별 성취율: 이름이 세로로 깨지지 않게 칸을 넓히고 줄바꿈을 막는다. */
.sbar { grid-template-columns: 132px 1fr auto; gap: 12px; }
.sbar-label { white-space: nowrap; }
.sbar-track { height: 12px; border-radius: 6px; }
.sbar-fill { border-radius: 0 6px 6px 0; }

/* 상태 알약 */
.status-pill { font-weight: 600; }

@media (max-width: 640px) {
  .panel { padding: 16px 16px; }
  .sbar { grid-template-columns: 104px 1fr auto; gap: 8px; }
  .subtab { padding: 10px 12px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ======================================================================
   면담 중에는 다른 탭 없이 화면 전체를 면담 창으로 쓴다.
   채팅 패널을 화면 전체를 덮는 고정 레이어로 띄운다. 다른 화면으로 이동하면 부모(#viewInterview)가
   숨겨지면서 레이어도 같이 사라지므로 뒤로가기로 갇히지 않는다. 출구는 "나가기" 버튼 하나다.
   ====================================================================== */
#ivChatPanel {
  position: fixed;
  inset: 0;
  z-index: 100;
  height: 100vh;
  height: 100dvh;
  max-width: none !important;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--bg);
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body:has(#ivChatPanel:not(.hidden)) { overflow: hidden; }
#ivChatPanel > * { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
#ivChatPanel .panel-header { margin-top: 0; margin-bottom: 0; flex: none; align-items: center; flex-direction: row; }
#ivChatPanel .iv-chat { flex: 1 1 auto; min-height: 0; max-height: none; margin-bottom: 0; background: var(--panel); }
#ivChatPanel .iv-quick, #ivChatPanel .iv-input { flex: none; }
#ivChatPanel .hint { flex: none; margin: 0; min-height: 1.2em; }
@media (max-width: 640px) {
  #ivChatPanel { padding: 10px 10px 12px; }
  #ivChatPanel .panel-header { flex-direction: row; }
}

/* 면담 채점 결과 창 — 면담 전체 화면 레이어(z-index 100)보다 위에 뜬다. */
#ivResultBackdrop { z-index: 200; }
.iv-result-modal { width: min(820px, 100%); max-height: 90vh; max-height: 90dvh; }
.iv-result-modal .modal-body { padding: 0; }
.iv-result-modal .iv-eval-card { border: none; border-radius: 0; box-shadow: none; }
.iv-head-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  #ivResultBackdrop { padding: 0; }
  .iv-result-modal { width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
}

/* 채점 결과 표 — 항목·평가·점수와 근거를 한 표에. 근거는 항목 이름 아래 작은 글씨. */
.iv-score { font-variant-numeric: tabular-nums; margin: 4px 0 6px; }
.iv-score td, .iv-score th { vertical-align: top; }
.iv-score td:nth-child(2) { text-align: center; width: 4.5em; white-space: nowrap; }
.iv-score td:nth-child(3) { text-align: right; width: 5.2em; white-space: nowrap; }
.iv-score td.mk { font-weight: 700; }
.iv-score td.mk-o { color: var(--ok); }
.iv-score td.mk-p { color: var(--warn-text); }
.iv-score td.mk-x { color: var(--danger-text); }
.iv-score td.mk-n { color: var(--muted); font-weight: 500; }
.iv-score tr.sec th {
  padding: 14px 6px 6px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  background: none;
}
.iv-score tr.item td { padding: 7px 6px; }
.iv-item-name { font-weight: 500; }
.iv-item-why { margin-top: 2px; font-size: 0.78rem; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.iv-score tr.sub td { background: var(--inset); font-weight: 700; }
.iv-score tr.sub td:first-child { border-radius: 6px 0 0 6px; }
.iv-score tr.sub td:last-child { border-radius: 0 6px 6px 0; }
.iv-eval-body h2, .iv-eval-body h3, .iv-eval-body h4 { font-size: 0.95rem; margin: 14px 0 6px; }

/* 짧은 화면(면담·설정)과 긴 화면(기록·분석)을 오갈 때 스크롤바 유무 때문에 콘텐츠가 좌우로 흔들리지 않게 자리를 항상 확보한다. */
html { scrollbar-gutter: stable; }

/* 키 설정 화면: 계정 저장 체크박스와 안내문 간격 */
#ivCloudBox { margin: 14px 0 6px; }
#ivCloudBox .hint { margin: 6px 0 0 26px; font-size: 0.8rem; }
#ivKeyPanel .pair-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* 케이스 표: td 에 display:flex 를 주면 표 셀이 아니게 되어 같은 행의 다른 칸과 높이가 따로 놀고 구분선이 어긋난다.
   표 셀을 그대로 두고 캐럿만 인라인으로 맞춘다. */
#caseTable td.case-name { display: table-cell; }
#caseTable .case-name .caret { display: inline-block; margin-right: 6px; vertical-align: middle; }

/* 면담 중·직후 오류 제보 창 — 면담 전체 화면(100)과 채점 결과 창(200)보다 위에 뜬다. */
#ivReportBackdrop { z-index: 300; }
.iv-report-modal { width: min(560px, 100%); }
.iv-report-modal textarea { width: 100%; }
.iv-report-modal .report-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
#ivReportDone { color: var(--ok); font-weight: 600; margin: 10px 0 0; }
@media (max-width: 640px) {
  #ivResultBackdrop .modal-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* 관리자 계정 표: 계정별 하루 면담 횟수 선택 */
.ai-limit { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; margin-left: 4px; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.ai-limit select { padding: 3px 6px; font-size: 0.78rem; }
@media (max-width: 640px) { #adminTable .ai-limit { display: flex; margin: 4px 0 0; } }

/* ---------- 불러오는 중 · 더 보기 · 표 머리의 만점 · 관리자 소제목 ---------- */
.boot-msg { color: var(--muted); text-align: center; margin: 48px 0; font-size: 0.9rem; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 4px; font-size: 0.85rem; }
.pager-size { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; color: var(--muted); white-space: nowrap; }
.pager-size select { width: auto; font-size: 0.85rem; padding: 4px 8px; }
.pager-nav { display: inline-flex; align-items: center; gap: 10px; }
.pager-info { color: var(--muted); font-variant-numeric: tabular-nums; }
.pager .btn:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 640px) { .pager { justify-content: center; } .pager-nav .btn { min-height: 36px; } }
.th-max { margin-left: 2px; font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.sub-h { margin: 14px 0 6px; font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.btn.danger-btn { color: var(--danger-text); border-color: var(--danger-border); }
.btn.danger-btn:hover { background: color-mix(in srgb, var(--danger-text) 10%, transparent); }

/* ---------- 공부 탭 ---------- */
#stBody h3 { margin: 20px 0 8px; }
.study-dx { margin: 0 0 6px 1.2em; padding: 0; }
.study-dx li { margin: 2px 0; }
.study-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  margin: 8px 0;
  padding: 0 14px;
}
.study-card > summary {
  cursor: pointer;
  padding: 12px 0;
  list-style-position: outside;
}
.study-card[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.study-card h4 { margin: 14px 0 6px; font-size: 0.92rem; color: var(--muted); }
.study-card ul { margin: 0 0 4px 1.2em; padding: 0; }
.study-card li { margin: 3px 0; }
.study-card .hint { margin: 4px 0 0; }
.study-card > :last-child { margin-bottom: 14px; }
/* 진찰 방법 카드 — 단계별 순서, 말할 문장, 놓치기 쉬운 것 */
.exam-card .ex-when { font-size: 0.82rem; color: var(--muted); margin-left: 6px; }
.exam-card .ex-step h5 { margin: 12px 0 4px; font-size: 0.88rem; color: var(--accent); }
.exam-card .ex-step ol { margin: 0 0 4px 1.3em; padding: 0; }
.exam-card .ex-step li { margin: 3px 0; line-height: 1.5; }
.exam-card .ex-say, .exam-card .ex-tips { margin: 10px 0 0; }
.exam-card .ex-say .tag, .exam-card .ex-tips .tag { display: inline-block; margin-bottom: 4px; }
.exam-card .ex-src { font-size: 0.78rem; }
.study-pos li::marker { content: "＋ "; color: var(--ok); }
.study-neg li::marker { content: "－ "; color: var(--muted); }
.study-flags .q { color: var(--muted); }
.study-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.study-dl dt { color: var(--muted); white-space: nowrap; }
.study-dl dd { margin: 0; }
.study-checklist { background: var(--inset); border-radius: 8px; padding: 4px 14px 10px; }
@media (max-width: 560px) {
  .study-dl { grid-template-columns: 1fr; gap: 0; }
  .study-dl dt { margin-top: 6px; }
}

/* 공부 탭 — 면담 가이드 */
.guide-summary { background: var(--inset); border-radius: 8px; padding: 10px 14px; }
.guide-summary p { margin: 4px 0; }
.guide-summary .tag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); margin-right: 4px; }
.guide-summary .tag-danger { border-color: var(--danger-border); color: var(--danger-text); }
.guide-strategy { margin-top: 8px !important; }
.guide-flow { list-style: none; margin: 0; padding: 0; }
.guide-step { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 10px 14px; margin: 8px 0; }
.guide-step-head { display: flex; align-items: center; gap: 8px; }
.guide-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 0.8rem; flex: none; }
.guide-ask { margin: 8px 0 2px; padding-left: 10px; border-left: 3px solid var(--accent); }
.guide-step .hint { margin: 6px 0 4px; }
.guide-sorts { list-style: none; margin: 4px 0 0; padding: 0; }
.guide-sorts li { display: grid; grid-template-columns: 1fr auto minmax(0, 1fr); gap: 8px; padding: 4px 0; border-top: 1px dashed var(--border); align-items: baseline; }
.guide-sorts .arrow { color: var(--muted); }
.guide-compare { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.guide-compare th, .guide-compare td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.guide-compare thead th { background: var(--inset); }
.guide-compare tbody th { white-space: normal; min-width: 9em; }
/* 휴대폰: 4~5칸 표가 375px 안에 눌려 "발병" 칸이 한 글자씩 세로로 쌓였다 — 진단별 카드로 접는다. */
@media (max-width: 640px) {
  .guide-compare thead { display: none; }
  .guide-compare, .guide-compare tbody, .guide-compare tr, .guide-compare th, .guide-compare td { display: block; width: auto; }
  .guide-compare tr { border: 1px solid var(--border); margin-bottom: 10px; }
  .guide-compare tbody th { background: var(--inset); border: 0; }
  .guide-compare td { border: 0; border-top: 1px solid var(--border); }
  .guide-compare td::before { content: attr(data-label); display: block; font-size: 0.76rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
  .guide-row { flex-direction: column; gap: 4px; }
}
.guide-row { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.guide-row > .tag { flex: 0 0 auto; margin-top: 2px; }
.guide-emergency { margin: 0; padding-left: 1.1em; }
.guide-emergency li { margin: 2px 0; }
.guide-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.guide-chip { border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 0.88rem; background: var(--inset); }
.guide-pitfalls li { margin: 4px 0; }
.study-rubric { margin-top: 18px; }
@media (max-width: 560px) {
  .guide-sorts li { grid-template-columns: 1fr; gap: 0; }
  .guide-sorts .arrow { display: none; }
  .guide-sorts b::before { content: "→ "; color: var(--muted); font-weight: normal; }
}

/* 면담 음성 */
.iv-mic { flex: none; min-width: 44px; padding-left: 10px; padding-right: 10px; }
.iv-mic.listening { border-color: var(--danger-text); color: var(--danger-text); animation: iv-mic-pulse 1.2s ease-in-out infinite; }
@keyframes iv-mic-pulse { 50% { box-shadow: 0 0 0 4px var(--danger-border); } }
@media (prefers-reduced-motion: reduce) { .iv-mic.listening { animation: none; } }
.iv-tts { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 0.85rem; color: var(--muted); cursor: pointer; }
#ivTtsWrap.iv-tts { flex-direction: row; } /* 일반 label 규칙(세로 쌓기)이 체크칸을 글자 위로 올리던 것 */
.iv-tts-note { flex-basis: 100%; text-align: right; font-size: 0.75rem; color: var(--muted); margin-top: -4px; }
.iv-tts-note .link-btn { background: none; border: 0; padding: 0; color: var(--accent, #2563eb); text-decoration: underline; cursor: pointer; font: inherit; }
/* 환자 답이 한 글자씩 나오는 동안 — 줄바꿈을 유지하고, 눌러서 바로 다 볼 수 있다 */
.iv-bubble.iv-said { white-space: pre-wrap; }
.iv-bubble.typing-out { cursor: pointer; }

/* 공부 탭 — 표 */
.study-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--panel); }
.study-table th, .study-table td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.study-table thead th { background: var(--inset); white-space: nowrap; }
.study-table .muted { color: var(--muted); }
/* 면담 흐름 */
.flow-table { min-width: 680px; table-layout: fixed; }
.flow-table col.c-step { width: 24%; }
.flow-table col.c-ask { width: 28%; }
.flow-table col.c-if { width: 28%; }
.flow-table col.c-dx { width: 20%; }
.flow-table th.flow-step { background: var(--inset); }
.flow-table .flow-step .guide-num { margin-right: 4px; }
.flow-why { font-weight: normal; color: var(--muted); font-size: 0.8rem; margin-top: 6px; line-height: 1.4; }
.flow-table td.flow-ask div { margin: 2px 0; padding-left: 8px; border-left: 3px solid var(--accent); }
.flow-table td.flow-dx { font-weight: 600; }
.flow-table tr.flow-first > * { border-top: 2px solid var(--border); }
/* 진단별 비교표 — 첫 열(항목 이름)을 고정해 옆으로 밀어도 무엇의 행인지 보이게 */
.matrix-table { min-width: calc(110px + var(--cols, 5) * 190px); }
.matrix-table th, .matrix-table td { min-width: 170px; }
.matrix-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--inset); min-width: 96px; width: 96px; white-space: nowrap; }
.matrix-table thead th:first-child { position: sticky; left: 0; z-index: 2; min-width: 96px; width: 96px; }
.matrix-table thead th { white-space: normal; }
@media (max-width: 560px) {
  .flow-table td.flow-dx { white-space: normal; }
  .matrix-table th, .matrix-table td { min-width: 150px; }
}
/* 사이트 공통 th 규칙(줄바꿈 금지·둥근 모서리·작은 글씨)이 공부 표의 왼쪽 칸에 걸리지 않게 */
.study-table tbody th { white-space: normal; overflow-wrap: anywhere; border-radius: 0; text-transform: none; letter-spacing: 0; font-size: 0.88rem; color: var(--text); }
.study-table thead th { border-radius: 0; }
.matrix-table tbody th { white-space: nowrap; }

/* 채점 결과 → 공부 탭 복습 링크 */
.iv-review {
  margin: 0 16px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}
.iv-review-head { font-weight: 700; margin-bottom: 4px; }
.iv-review .hint { margin: 0 0 6px; }
.iv-review ul { margin: 0 0 8px; padding-left: 0; list-style: none; }
.iv-review li { padding: 3px 0; }
.iv-review .mk { display: inline-block; min-width: 1.4em; font-weight: 700; text-align: center; }
.iv-review .mk-p { color: var(--warn-text); }
.iv-review .mk-x { color: var(--danger-text); }
.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.linklike:hover { color: var(--accent-hover); }
/* 복습 링크로 들어온 가이드 부분을 잠깐 표시 */
.st-flash { animation: st-flash 2s ease-out; border-radius: 4px; }
@keyframes st-flash {
  0%, 40% { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) { .st-flash { animation: none; } }

/* 면담 순서 (A→G 카테고리별 질문 목록) */
.script-cat { margin: 0 0 14px; }
.script-cat h4 { margin: 14px 0 4px; font-size: 0.98rem; display: flex; align-items: center; gap: 8px; }
.cat-letter {
  display: inline-grid; place-items: center;
  width: 1.6em; height: 1.6em; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.85rem; font-weight: 700;
}
.script-cat > .hint { margin: 0 0 6px; }
.script-qs { margin: 0; padding-left: 1.8em; }
.script-qs li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.script-qs li:last-child { border-bottom: 0; }
.script-q { font-weight: 600; }
.script-q + .script-q { margin-top: 2px; }
.one-by-one { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--panel); vertical-align: 1px; white-space: nowrap; }
.guide-callout { margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--accent, var(--border)); background: var(--panel); border-radius: 6px; font-size: 0.88rem; }
.script-hint { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.script-ext { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 0.8rem; }
.script-ext-label { color: var(--danger-text); font-weight: 700; margin-right: 2px; }
.script-ext .tag { display: inline-block; font-size: 0.76rem; padding: 0 7px; border-radius: 999px; border: 1px solid var(--danger-border); color: var(--danger-text); background: var(--panel); }

/* 가리기 모드 — 해설·배제 질환을 가리고 질문을 눌러 확인 */
.script-toggle { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 2px 0 8px; font-size: 0.88rem; font-weight: 600; color: var(--text); cursor: pointer; }
.script-toggle input { margin: 0; }
.script-toggle .hint { font-weight: 400; }
.script.hide-hints .script-hint,
.script.hide-hints .script-ext { display: none; }
.script.hide-hints .script-qs li.has-note { cursor: pointer; }
.script.hide-hints .script-qs li.has-note::after {
  content: "눌러서 확인"; display: block; margin-top: 2px; font-size: 0.75rem; color: var(--muted);
}
.script.hide-hints .script-qs li.revealed::after { content: none; }
.script.hide-hints .script-qs li.revealed .script-hint,
.script.hide-hints .script-qs li.revealed .script-ext { display: block; }
.script.hide-hints .script-qs li.revealed .script-ext { display: flex; }

/* ===== 공부 탭 첫 화면: 계통별 주제 카드 ===== */
.tg-progress { margin: 4px 0 18px; }
.tg-progress-text { font-size: 0.92rem; margin-bottom: 6px; }
.tg-bar { height: 8px; border-radius: 999px; background: var(--inset); overflow: hidden; }
.tg-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.tg-group h3 { font-size: 0.95rem; margin: 18px 0 8px; color: var(--muted); }
.tg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tg-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; font: inherit;
}
.tg-card:hover, .tg-card:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.tg-name { font-weight: 700; font-size: 0.95rem; word-break: keep-all; }
.tg-sub { font-size: 0.78rem; color: var(--muted); }
.tg-meta { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; margin-top: 2px; }
.tg-count { color: var(--muted); }
.tg-best { color: var(--muted); font-size: 0.78rem; margin-left: 6px; }
.st-title { margin: 12px 0 2px; }
.st-title-sub { margin: 0 0 10px; }
.tg-new { color: var(--accent); font-weight: 600; }
.tg-card.is-new { border-style: dashed; }
.st-back { margin-bottom: 12px; }

/* ===== 위쪽 오른편의 설정·관리자 (탭 전환 로직은 .subtab 그대로) ===== */
.topbar nav .subtab.toplink {
  padding: 2px 4px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  border-bottom: 2px solid transparent;
}
.topbar nav .subtab.toplink:hover { color: var(--accent-hover); }
.topbar nav .subtab.toplink.active { color: var(--text); border-bottom-color: var(--accent); background: none; }

/* ===== 기록 화면의 "목록 | 분석" 전환 ===== */
.rec-switch {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.rec-switch .seg-btn { padding: 6px 16px; font-size: 0.88rem; }

/* ===== 홈 ===== */
#viewHome { display: flex; flex-direction: column; gap: 18px; }
.home-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.home-hero h2 { margin: 0 0 12px; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-actions .btn.primary { font-size: 1rem; padding: 10px 18px; }
.home-status { margin: 10px 0 0; }
.btn-link {
  border: none; background: none; padding: 0; font: inherit; font-size: 0.85rem;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.btn-link:hover { color: var(--accent-hover); }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.home-card h3 { margin: 0 0 10px; font-size: 1rem; }
.home-card .panel-header h3 { margin: 0; }
.home-wide { grid-column: 1 / -1; }
.home-big { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; }
.home-of { font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.home-delta.up { color: var(--ok); }
.home-delta.down { color: var(--danger-text); }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 64px; margin-top: 8px; }
.spark-bar { flex: 1 1 0; min-width: 6px; border-radius: 3px 3px 0 0; background: var(--grade-1); }
.spark-bar.b2 { background: var(--grade-2); }
.spark-bar.b3 { background: var(--grade-3); }
.spark-bar.b4 { background: var(--grade-4); }
/* 막대 위 점수 — 휴대폰은 마우스를 올릴 수 없어 title 만으로는 점수가 안 보였다 */
.spark { margin-top: 22px; }
.spark-bar { position: relative; }
.spark-bar::after { content: attr(data-score); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .68rem; line-height: 1.6; color: var(--muted); }
.spark-legend { margin-top: 6px; font-size: .8rem; }
.spark-li { white-space: nowrap; } /* 색 칸과 글자가 줄바꿈으로 갈라지지 않게 */
.spark-key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 2px 0 6px; vertical-align: baseline; background: var(--grade-1); }
.spark-key.b2 { background: var(--grade-2); }
.spark-key.b3 { background: var(--grade-3); }
.spark-key.b4 { background: var(--grade-4); }
.home-help { margin-top: 10px; }
.home-mock-modes { margin: 10px 0 0; padding-left: 18px; }
.home-mock-modes li { margin: 2px 0; }
.home-todo { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.6; }
.home-recent { list-style: none; margin: 0; padding: 0; }
.home-recent li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.home-recent li:last-child { border-bottom: none; }
.home-when { color: var(--muted); font-size: 0.82rem; min-width: 110px; }
.home-topic { flex: 1 1 auto; font-weight: 600; }
@media (max-width: 640px) {
  .home-grid { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
}

/* ===== 면담 타이머 ===== */
.iv-timer {
  margin-left: auto; margin-right: 10px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.9rem;
  padding: 3px 10px; border-radius: 999px;
  background: var(--inset); color: var(--text);
}
.iv-timer.warn { background: color-mix(in srgb, var(--grade-2) 25%, transparent); }
.iv-timer.over { background: color-mix(in srgb, var(--grade-1) 25%, transparent); color: var(--danger-text); }

/* ===== 결과 창: 다음 행동 ===== */
.iv-next { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }

/* ---------- 공부: 바로가기 메뉴 ---------- */
.st-jump { position: sticky; top: 0; z-index: 6; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 8px -4px 4px; padding: 8px 4px; background: var(--panel); border-bottom: 1px solid var(--border); }
.st-jump::-webkit-scrollbar { display: none; }
.st-jump a { flex: 0 0 auto; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem;
  color: var(--text); text-decoration: none; background: var(--inset); white-space: nowrap; }
.st-jump a:hover { border-color: var(--accent); color: var(--accent); }
/* 위에 붙은 메뉴에 제목이 가리지 않게 */
#viewStudy h3[id], #st-rubric { scroll-margin-top: 56px; }

/* ---------- 공부: 진단별 단서 비교 (하나씩 / 전체) ---------- */
.mx-bar { display: flex; justify-content: flex-start; margin: 4px 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: transparent; padding: 5px 14px; font: inherit; font-size: 0.86rem; color: var(--muted); cursor: pointer; }
.mx[data-mode="one"] .seg-btn[data-mx-mode="one"], .mx[data-mode="all"] .seg-btn[data-mx-mode="all"] { background: var(--accent); color: #fff; }
.mx-dx { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mx-dx-btn { border: 1px solid var(--border); background: var(--inset); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--text); text-align: left; }
.mx-dx-btn.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.mx-one { display: none; margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mx-one.on { display: block; }
.mx-one dt { padding: 6px 10px 0; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.mx-one dd { margin: 0; padding: 2px 10px 8px; border-bottom: 1px solid var(--border); }
.mx-one dd:last-child { border-bottom: 0; }
.mx[data-mode="all"] .mx-dx, .mx[data-mode="all"] .mx-ones { display: none; }
.mx[data-mode="one"] .matrix-wrap { display: none; }

/* 채점 결과: 같은 주제 지난번과 비교 */
.iv-compare { margin: 8px 0 10px; padding: 8px 10px; border-radius: 8px; font-size: 0.88rem; line-height: 1.5; border: 1px solid var(--border); }
.iv-compare.up { border-left: 4px solid #2e9d5b; }
.iv-compare.down { border-left: 4px solid #c9483b; }

/* 관리자: 최근 24시간 시간대별 뉴런 막대 */
.uw { margin: 6px 0 12px; }
.uw-bars { display: flex; align-items: flex-end; gap: 2px; height: 70px; padding-bottom: 14px; position: relative; }
.uw-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.uw-bar i { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.uw-bar em { position: absolute; bottom: -14px; left: 0; font-size: 0.65rem; font-style: normal; color: var(--muted, #888); }

/* 모의고사 결과 요약 */
.iv-mock-summary { margin: 8px 0 10px; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; font-size: 0.9rem; line-height: 1.6; }
.iv-mock-summary ol { margin: 4px 0 4px 18px; padding: 0; }

/* 홈: 시험 대비 모의고사 칸 */
.home-mock { border-left: 4px solid var(--accent); }
.home-mock h3 { margin: 0 0 4px; }

/* 공부: 시험 대비 세트로 좁혀 보기 */
.st-setbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; }

/* 관리자: 켜기·끄기 토글 */
.switch-list li { padding: 0; }
.sw-row { display: flex; flex-direction: row; font-size: inherit; color: var(--text); align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 10px 0; cursor: pointer; }
.sw-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sw-ctl { display: flex; flex-direction: row-reverse; align-items: center; gap: 10px; flex-shrink: 0; }
.sw-state::after { content: "꺼짐"; display: inline-block; min-width: 2.4em; text-align: right; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.toggle:checked + .sw-state::after { content: "켜짐"; color: var(--accent); }
/* input 공통 스타일(테두리·여백·모서리, [data-skin] 포함)을 덮어야 해서 input.toggle 로 쓴다 */
input[type="checkbox"].toggle { appearance: none; -webkit-appearance: none; box-sizing: border-box; padding: 0; border: 0; flex-shrink: 0; width: 48px; height: 28px; margin: 0; border-radius: 999px; background: var(--toggle-off); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18); position: relative; cursor: pointer; transition: background-color 0.2s ease; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.06); transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.15); }
input[type="checkbox"].toggle:focus { border: 0; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18); }
input[type="checkbox"].toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(20px); }
.toggle:hover:not(:disabled) { filter: brightness(0.96); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.toggle:disabled + .sw-state { opacity: 0.45; }
/* 꺼진 토글의 바탕 — 패널 바탕에 묻히지 않을 만큼 진하게 */
:root { --toggle-off: #b7c3ce; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --toggle-off: #4a5866; }
}
:root[data-theme="dark"] { --toggle-off: #4a5866; }
@media (prefers-reduced-motion: reduce) {
  .toggle, .toggle::after { transition: none; }
}

/* 관리자: 날짜별 사용량 */
.daily-row { cursor: pointer; }
.daily-row:hover td { background: var(--inset); }
.daily-row.sel td { background: var(--inset); font-weight: 600; }
.daily-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.daily-table .mini-bar { display: inline-block; vertical-align: middle; width: 48px; height: 6px; margin-right: 8px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--w, 0%), var(--border) var(--w, 0%)); }
.day-detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.day-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-detail-head .sub-h { margin: 0; }
.day-h { margin: 14px 0 6px; font-size: 0.9rem; }

/* 공부 탭 — 국시원 임상표현과 사이트 주제 대응표 */
.khpi { margin-top: 18px; }
.khpi h4 { margin: 14px 0 6px; }
.khpi-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.khpi-list li { break-inside: avoid; padding: 3px 0; font-size: .9rem; }
.khpi-num { display: inline-block; min-width: 2.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
.khpi-none { color: var(--muted); font-size: .8rem; }
/* 묶인 번호 — "2" 옆에 2-1·2-2 를 겹쳐 적는다 */
.khpi-list > li:has(> .khpi-sub) { display: flex; align-items: flex-start; }
.khpi .khpi-sub { list-style: none; padding: 0; margin: 0; }
.khpi .khpi-sub li { padding: 0 0 3px; margin: 0; }
.khpi .khpi-sub li:last-child { padding-bottom: 0; }
.khpi-sub .khpi-num { min-width: 2.6em; }
@media (max-width: 560px) { .khpi-list { columns: 1; } }

/* ===== 자매 사이트 MedMantle 링크 (위쪽 오른편, 테마 버튼 왼쪽) ===== */
.sister-link {
  margin-left: 14px; padding: 4px 9px; flex: 0 0 auto; white-space: nowrap;
  font-size: 0.85rem; font-weight: 600; color: var(--accent); text-decoration: none;
  border: 1px solid var(--border); border-radius: 4px;
  display: inline-flex; align-items: center; gap: 6px;
}
.sister-link b { font-weight: inherit; }
.sister-mark { width: 16px; height: 16px; flex: none; }
.sister-link:hover { color: var(--accent-hover); border-color: var(--accent); }
#navAuthed.hidden + .sister-link { margin-left: auto; }
@media (max-width: 420px) {
  .sister-link { margin-left: 8px; padding: 4px 6px; font-size: 0.78rem; }
  .sister-link span { display: none; }
  .topbar nav a { white-space: nowrap; }
}
/* 아주 좁은 폰: 로그인 후 줄이 넘치지 않게 사이 간격만 줄인다 */
@media (max-width: 370px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar nav { gap: 6px; }
  .sister-link { margin-left: 6px; padding: 4px 5px; }
  .theme-toggle { margin-left: 6px; }
}
/* 좁은 폰(380px 이하)에서 로그인 후에는 글자를 빼고 마크만 둔다 */
@media (max-width: 380px) {
  #navAuthed:not(.hidden) + .sister-link b { display: none; }
}
