/* ==========================================================================
   정보보안기사 실기 문제은행 — 디자인 시스템
   ========================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Malgun Gothic", "맑은 고딕", sans-serif;
  --mono: "Consolas", "SFMono-Regular", Menlo, monospace;

  --navy-950: #0a1128;
  --navy-900: #0f1b3d;
  --navy-800: #16234f;
  --navy-700: #1d2e63;

  --accent: #c9a227;       /* 뱃지 골드 */
  --accent-ink: #7a5f0f;
  --accent-soft: #fbf1d3;

  --blue: #2f6fed;
  --blue-soft: #e8f0ff;
  --orange: #d97a2b;
  --orange-soft: #fbead9;

  --bg: #eef1f7;
  --bg-elevated: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e1e6f0;
  --border-strong: #ccd4e3;

  --text: #16213e;
  --text-muted: #64708a;
  --text-faint: #9aa4ba;

  --success: #1f9d55;
  --success-bg: #e6f7ec;
  --success-border: #b9e6c8;
  --danger: #d64545;
  --danger-bg: #fdeaea;
  --danger-border: #f3bfbf;
  --warning: #d97a2b;
  --warning-bg: #fbead9;
  --trick: #b0355c;
  --trick-bg: #fbe6ee;

  --radius-sm: 7px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 51, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 51, 0.08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 51, 0.14);

  --sidebar-w: 268px;
  --topbar-h: 60px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

:root[data-theme="dark"] {
  --bg: #0a0f1e;
  --bg-elevated: #0e1526;
  --surface: #131b30;
  --surface-2: #182241;
  --border: #232f4d;
  --border-strong: #2c3a5e;

  --text: #e7ebf5;
  --text-muted: #9aa6c4;
  --text-faint: #6c789c;

  --blue-soft: #182a4d;
  --orange-soft: #3a2513;
  --accent-soft: #3a3010;

  --success-bg: rgba(31, 157, 85, 0.16);
  --success-border: rgba(31, 157, 85, 0.35);
  --danger-bg: rgba(214, 69, 69, 0.16);
  --danger-border: rgba(214, 69, 69, 0.35);
  --warning-bg: rgba(217, 122, 43, 0.18);
  --trick-bg: rgba(176, 53, 92, 0.2);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1e;
    --bg-elevated: #0e1526;
    --surface: #131b30;
    --surface-2: #182241;
    --border: #232f4d;
    --border-strong: #2c3a5e;
    --text: #e7ebf5;
    --text-muted: #9aa6c4;
    --text-faint: #6c789c;
    --blue-soft: #182a4d;
    --orange-soft: #3a2513;
    --accent-soft: #3a3010;
    --success-bg: rgba(31, 157, 85, 0.16);
    --success-border: rgba(31, 157, 85, 0.35);
    --danger-bg: rgba(214, 69, 69, 0.16);
    --danger-border: rgba(214, 69, 69, 0.35);
    --warning-bg: rgba(217, 122, 43, 0.18);
    --trick-bg: rgba(176, 53, 92, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font-family: inherit; }
::selection { background: rgba(47, 111, 237, 0.25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------------------------- Topbar ---------------------------------- */
#topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(120deg, var(--navy-950), var(--navy-900) 55%, var(--navy-800));
  color: #fff;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 20;
  -webkit-app-region: drag;
}
#topbar .brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #a5800f);
  display: flex; align-items: center; justify-content: center;
  color: #241c02;
  box-shadow: 0 2px 8px rgba(201, 162, 39, 0.4), inset 0 1px 0 rgba(255,255,255,.35);
  flex: 0 0 auto;
}
.brand-badge svg { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text .brand-title { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text .brand-sub { font-size: 11px; color: rgba(255,255,255,0.55); letter-spacing: 0.3px; }

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  -webkit-app-region: no-drag;
}
.global-search {
  display: flex; align-items: center; gap: 8px;
  width: min(420px, 40vw);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  color: rgba(255,255,255,0.9);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.global-search:focus-within { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.global-search svg { flex: 0 0 auto; opacity: 0.7; }
.global-search input {
  background: none; border: none; outline: none; color: #fff; font-size: 13px; width: 100%;
}
.global-search input::placeholder { color: rgba(255,255,255,0.45); }

.topbar-actions { display: flex; align-items: center; gap: 8px; -webkit-app-region: no-drag; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s var(--ease), transform .1s var(--ease);
}
.icon-btn:hover { background: rgba(255,255,255,0.16); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------------------------- Shell ---------------------------------- */
#shell { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .18s var(--ease);
}
#sidebar.collapsed { width: 72px; }
#sidebarScroll { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  text-transform: uppercase;
  padding: 14px 10px 6px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.navitem {
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  position: relative;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.navitem .ic { flex: 0 0 auto; display: flex; color: var(--text-muted); }
.navitem:hover { background: var(--surface-2); }
.navitem.active { background: var(--blue-soft); color: var(--blue); }
.navitem.active .ic { color: var(--blue); }
.navitem .badge-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.navitem.active .badge-count { background: rgba(47,111,237,0.15); color: var(--blue); }
.navitem.danger-flavor:hover { background: var(--danger-bg); color: var(--danger); }

/* subject tree */
.subject-block { margin-bottom: 4px; border-radius: var(--radius-sm); overflow: hidden; }
.subject-head {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 10px;
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  transition: background .12s var(--ease);
}
.subject-head:hover { background: var(--surface-2); }
.subject-head.active { background: var(--surface-2); }
.subject-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px var(--surface); }
.subject-head .s-label { flex: 1; text-align: left; }
.subject-head .s-count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.subject-head .chevron { display: flex; color: var(--text-faint); transition: transform .15s var(--ease); }
.subject-head.open .chevron { transform: rotate(90deg); }
.subject-progress { height: 3px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 0 10px 6px; }
.subject-progress > span { display: block; height: 100%; border-radius: 999px; transition: width .3s var(--ease); }

.unit-list { display: none; flex-direction: column; padding: 2px 4px 6px 14px; gap: 1px; }
.unit-list.open { display: flex; }
.unit-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  border-left: 2px solid transparent;
}
.unit-item:hover { background: var(--surface-2); color: var(--text); }
.unit-item.active { background: var(--blue-soft); color: var(--blue); border-left-color: var(--blue); font-weight: 600; }
.unit-item .count { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.unit-item.active .count { color: var(--blue); }

/* ---------------------------------- Content ---------------------------------- */
#content { flex: 1; overflow-y: auto; min-width: 0; }
.view { max-width: 1180px; margin: 0 auto; padding: 26px 30px 60px; animation: viewIn .18s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.view-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.view-header h1 { font-size: 21px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.2px; }
.view-header .view-sub { font-size: 13px; color: var(--text-muted); margin: 0; }
.view-header-actions { display: flex; gap: 8px; }

/* ---------------------------------- Buttons ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .12s var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--text-faint); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(47,111,237,0.3); }
.btn.primary:hover { background: #2560d6; border-color: #2560d6; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn.danger:hover { background: var(--danger-border); }
.btn.lg { padding: 12px 22px; font-size: 14px; border-radius: var(--radius-md); }
.btn.block { width: 100%; justify-content: center; }

/* ---------------------------------- Dashboard ---------------------------------- */
.hero {
  background: linear-gradient(120deg, var(--navy-950), var(--navy-800) 70%);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  color: #fff;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: "";
  position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,39,0.28), transparent 70%);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; position: relative; z-index: 1; }
.hero-greeting { font-size: 12px; letter-spacing: 0.4px; color: rgba(255,255,255,0.55); margin: 0 0 6px; }
.hero-title { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
.hero-desc { font-size: 13px; color: rgba(255,255,255,0.65); margin: 0; max-width: 480px; line-height: 1.6; }
.hero-date { font-size: 12px; color: rgba(255,255,255,0.5); text-align: right; white-space: nowrap; }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-actions .btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); color: #fff; }
.hero-actions .btn:hover { background: rgba(255,255,255,0.18); }
.hero-actions .btn.primary { background: var(--accent); border-color: var(--accent); color: #241c02; box-shadow: 0 4px 14px rgba(201,162,39,0.35); }
.hero-actions .btn.primary:hover { background: #dcb433; }

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-card .stat-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.stat-card .stat-icon svg { width: 15px; height: 15px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-card .stat-foot { font-size: 11.5px; color: var(--text-faint); }
.stat-card .stat-foot.up { color: var(--success); }

.section-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; margin-bottom: 10px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-sm); }

.subject-progress-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.subject-progress-row:last-child { border-bottom: none; }
.subject-progress-row .sp-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.subject-progress-row .sp-main { flex: 1; min-width: 0; }
.subject-progress-row .sp-label { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; margin-bottom: 6px; }
.subject-progress-row .sp-label .sp-pct { color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.subject-progress-row .sp-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.subject-progress-row .sp-bar > span { display: block; height: 100%; border-radius: 999px; }

.wrong-mini-list { display: flex; flex-direction: column; gap: 8px; }
.wrong-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.wrong-mini:hover { background: var(--surface-2); border-color: var(--border-strong); }
.wrong-mini .wm-ic { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; background: var(--danger-bg); color: var(--danger); display: flex; align-items: center; justify-content: center; }
.wrong-mini .wm-ic svg { width: 13px; height: 13px; }
.wrong-mini .wm-text { flex: 1; min-width: 0; }
.wrong-mini .wm-title { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrong-mini .wm-meta { font-size: 11px; color: var(--text-faint); }
.empty-mini { padding: 24px 10px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 10px; }
.quick-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px; cursor: pointer; text-align: left;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), border-color .12s var(--ease);
  display: flex; flex-direction: column; gap: 10px;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.quick-card .qc-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.quick-card .qc-icon svg { width: 17px; height: 17px; }
.quick-card .qc-title { font-size: 13.5px; font-weight: 700; }
.quick-card .qc-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------------------------------- Filter bar (list view) ---------------------------------- */
#filterbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
#filterbar select, #filterbar .search-wrap {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 12.5px; background: var(--surface); color: var(--text);
}
#filterbar select { cursor: pointer; }
.search-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 160px; }
.search-wrap svg { color: var(--text-faint); flex: 0 0 auto; }
.search-wrap input { border: none; outline: none; background: none; font-size: 12.5px; width: 100%; color: var(--text); }
.chip-group { display: flex; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-muted);
  transition: all .12s var(--ease);
}
.chip:hover { border-color: var(--text-faint); color: var(--text); }
.chip.active { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.chk input { accent-color: var(--blue); }
.filter-spacer { flex: 1; }
.result-count { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* ---------------------------------- Question cards ---------------------------------- */
#cardList { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease);
}
.card:hover { border-color: var(--border-strong); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.card-tags { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); flex-wrap: wrap; }
.subject-chip { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 11px; }
.tag.medium { background: var(--blue-soft); color: var(--blue); }
.tag.hard { background: var(--warning-bg); color: var(--warning); }
.tag.trick { background: var(--trick-bg); color: var(--trick); }
.tag.wordplay { background: var(--accent-soft); color: var(--accent-ink); }
.card-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.card-actions button {
  border: none; background: none; cursor: pointer; font-size: 15px;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.card-actions button:hover { background: var(--surface-2); color: var(--text); }
.card-actions button.fav-active { color: var(--accent); }
.card-actions button.del-btn:hover { color: var(--danger); background: var(--danger-bg); }

.card-question { font-size: 14.5px; line-height: 1.6; margin-bottom: 12px; white-space: pre-wrap; font-weight: 500; }
.choices { display: flex; flex-direction: column; gap: 7px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background .1s var(--ease), border-color .1s var(--ease);
  position: relative;
}
.choice:hover { background: var(--surface-2); border-color: var(--border-strong); }
.choice input { display: none; }
.choice .ci-mark {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.choice .ci-text { flex: 1; line-height: 1.5; }
.choice.correct { border-color: var(--success-border); background: var(--success-bg); }
.choice.correct .ci-mark { background: var(--success); border-color: var(--success); color: #fff; }
.choice.wrong-selected { border-color: var(--danger-border); background: var(--danger-bg); }
.choice.wrong-selected .ci-mark { background: var(--danger); border-color: var(--danger); color: #fff; }
.choice.disabled { cursor: default; }
.choice.disabled:hover { background: inherit; }

.explanation {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-left: 3px solid var(--navy-800);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text-muted);
}
.explanation .exp-verdict { font-weight: 700; color: var(--text); margin-right: 4px; }
.explanation.is-correct { border-left-color: var(--success); }
.explanation.is-wrong { border-left-color: var(--danger); }

#pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 20px 0 4px; }
#pagination button {
  padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text);
}
#pagination button:hover:not(:disabled) { background: var(--surface-2); }
#pagination button:disabled { opacity: 0.4; cursor: default; }
#pagination .page-info { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-faint); }
.empty-state svg { margin-bottom: 10px; opacity: 0.5; }
.empty-state .es-title { font-size: 13.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.empty-state .es-sub { font-size: 12px; }

/* ---------------------------------- Exam setup ---------------------------------- */
.exam-setup-card {
  max-width: 640px; margin: 10px auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-md);
}
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.option-btn {
  padding: 10px 8px; text-align: center; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  transition: all .12s var(--ease);
}
.option-btn:hover { border-color: var(--text-faint); }
.option-btn.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.exam-hint { font-size: 12px; color: var(--text-faint); margin-top: 10px; text-align: center; }
.exam-hint strong { color: var(--blue); font-variant-numeric: tabular-nums; }

/* ---------------------------------- Exam run ---------------------------------- */
.exam-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 5;
}
.exam-progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.exam-progress-bar { flex: 1; height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; }
.exam-progress-bar > span { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width .2s var(--ease); }
.exam-progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.exam-timer { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--navy-900); font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .exam-timer { color: var(--text); }
.exam-timer svg { width: 14px; height: 14px; color: var(--text-faint); }

.exam-question-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 26px 28px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.exam-q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.exam-q-index { font-size: 12px; color: var(--blue); font-weight: 700; }

.q-fav-btn {
  border: none; background: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); flex: 0 0 auto;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.q-fav-btn:hover { background: var(--surface-2); }
.q-fav-btn.fav-active { color: var(--accent); }
.review-fav-btn { margin-left: auto; }
.exam-q-text { font-size: 16px; font-weight: 600; line-height: 1.65; margin-bottom: 20px; white-space: pre-wrap; }
.exam-choice {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; margin-bottom: 9px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; transition: all .1s var(--ease);
}
.exam-choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.exam-choice.selected { border-color: var(--blue); background: var(--blue-soft); }
.exam-choice .ci-mark { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; color: var(--text-muted); }
.exam-choice.selected .ci-mark { border-color: var(--blue); background: var(--blue); color: #fff; }

.exam-nav-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.exam-navigator {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; margin-top: 16px; box-shadow: var(--shadow-sm);
}
.nav-cell {
  aspect-ratio: 1; border-radius: 7px; border: 1.5px solid var(--border-strong);
  background: var(--surface); font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .1s var(--ease);
}
.nav-cell:hover { border-color: var(--text-faint); }
.nav-cell.answered { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.nav-cell.current { outline: 2px solid var(--navy-900); outline-offset: 1px; }
:root[data-theme="dark"] .nav-cell.current { outline-color: var(--accent); }

/* ---------------------------------- Exam result ---------------------------------- */
.result-hero {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--navy-950), var(--navy-800));
  border-radius: var(--radius-lg); padding: 28px; color: #fff; margin-bottom: 20px; box-shadow: var(--shadow-lg);
}
.score-ring { width: 128px; height: 128px; flex: 0 0 auto; position: relative; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.15); stroke-width: 10; }
.score-ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.score-ring .ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .ring-pct { font-size: 24px; font-weight: 800; }
.score-ring .ring-sub { font-size: 10px; color: rgba(255,255,255,0.6); }
.result-summary { flex: 1; min-width: 200px; }
.result-summary h2 { margin: 0 0 6px; font-size: 20px; }
.result-summary p { margin: 0; color: rgba(255,255,255,0.6); font-size: 12.5px; }
.result-stats { display: flex; gap: 20px; margin-top: 14px; flex-wrap: wrap; }
.result-stats .rs-item { text-align: left; }
.result-stats .rs-val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-stats .rs-label { font-size: 11px; color: rgba(255,255,255,0.5); }
.result-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.review-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.review-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer;
}
.review-head .rv-badge { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.review-head .rv-badge.ok { background: var(--success-bg); color: var(--success); }
.review-head .rv-badge.no { background: var(--danger-bg); color: var(--danger); }
.review-head .rv-badge svg { width: 13px; height: 13px; }
.review-head .rv-text { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-head .chevron { color: var(--text-faint); transition: transform .15s var(--ease); flex: 0 0 auto; }
.review-item.open .chevron { transform: rotate(90deg); }
.review-body { display: none; padding: 0 16px 16px; }
.review-item.open .review-body { display: block; }

/* ---------------------------------- Toasts ---------------------------------- */
#toastHost { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--navy-950); color: #fff;
  padding: 11px 16px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s var(--ease);
  min-width: 220px;
}
.toast.success { background: #14532d; }
.toast.danger { background: #7f1d1d; }
.toast svg { flex: 0 0 auto; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.leaving { animation: toastOut .18s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(8px); } }

/* ---------------------------------- Generate view ---------------------------------- */
.gen-warning {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warning-bg); border: 1px solid var(--warning); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12px; color: var(--text); line-height: 1.6; margin-bottom: 18px;
}
.gen-warning svg { flex: 0 0 auto; color: var(--warning); margin-top: 1px; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin .7s linear infinite; flex: 0 0 auto;
}
.spinner.dark { border-color: var(--border-strong); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

.gen-log {
  background: var(--navy-950); color: #cdd6ee;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 16px;
}
.gen-log:empty { display: none; }
.gen-log .log-line-err { color: #ff8a8a; }

.gen-result-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius-md); margin-top: 16px;
  font-size: 13px; font-weight: 600;
}
.gen-result-banner.ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.gen-result-banner.fail { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.gen-result-banner .grb-icon { flex: 0 0 auto; }
.gen-result-banner .grb-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------- Misc ---------------------------------- */
.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 10.5px; font-family: var(--mono); color: var(--text-muted); background: var(--surface-2); }

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

/* ==========================================================================
   실기(서술형·자가채점) 전용 추가 스타일
   ========================================================================== */
textarea { font-family: inherit; }

/* 사이드바: 카테고리 이름이 길어 한 줄 말줄임 처리 */
.subject-head .s-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.subject-progress-row { cursor: pointer; }
.subject-progress-row .sp-label { gap: 12px; }
.subject-progress-row .sp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.subject-progress-row .sp-pct { flex: 0 0 auto; }

/* 유형·배점 태그 */
.tag.short { background: var(--blue-soft); color: var(--blue); }
.tag.essay { background: var(--warning-bg); color: var(--warning); }
.tag.practical { background: var(--trick-bg); color: var(--trick); }
.tag.calc { background: var(--accent-soft); color: var(--accent-ink); }
.tag.points { background: none; border: 1px solid var(--border-strong); color: var(--text-muted); flex: 0 0 auto; }
.tag-cat { color: var(--text-muted); }
.tag-src { color: var(--text-faint); }
.chip-group { flex-wrap: wrap; }
#filterbar select { max-width: 260px; }

/* 문제/답안 본문(제한된 HTML: 표·코드블록 포함) */
.rich { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich table { border-collapse: collapse; margin: 10px 0; font-size: 13px; font-weight: 400; white-space: normal; }
.rich th, .rich td { border: 1px solid var(--border-strong); padding: 6px 11px; text-align: left; vertical-align: top; }
.rich th { background: var(--surface-2); font-weight: 700; }
.rich pre {
  background: var(--navy-950); color: #d6def2;
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0;
  font-family: var(--mono); font-size: 12.5px; font-weight: 400; line-height: 1.55;
  white-space: pre; overflow-x: auto;
}
.rich code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.rich pre code { background: none; border: none; padding: 0; font-size: inherit; }
.rich ul, .rich ol { margin: 6px 0; padding-left: 22px; white-space: normal; }

/* 답안 입력 */
.answer-input {
  display: block; width: 100%; resize: vertical; min-height: 64px;
  padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 13.5px; line-height: 1.6;
  outline: none; transition: border-color .12s var(--ease), background .12s var(--ease);
}
.answer-input:focus { border-color: var(--blue); background: var(--surface); }
.answer-input[readonly] { color: var(--text-muted); }
.answer-input::placeholder { color: var(--text-faint); }
.exam-answer { font-size: 14.5px; }

/* 모범답안 박스 */
.answer-box {
  margin-top: 12px; padding: 13px 15px;
  background: var(--surface-2); border-left: 3px solid var(--navy-800);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; line-height: 1.7; color: var(--text);
}
.answer-box strong { color: var(--blue); }
.answer-box.is-correct { border-left-color: var(--success); }
.answer-box.is-wrong { border-left-color: var(--danger); }

.verdict { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 5px 12px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.verdict.ok { background: var(--success-bg); color: var(--success); }
.verdict.no { background: var(--danger-bg); color: var(--danger); }

.solve-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.grade-label { font-size: 12px; color: var(--text-muted); margin-right: 4px; }
.btn.grade.ok { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.btn.grade.ok:hover, .btn.grade.ok.selected { background: var(--success); border-color: var(--success); color: #fff; }
.btn.grade.no { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn.grade.no:hover, .btn.grade.no.selected { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 모의고사 결과: 내 답안 / 채점 */
.review-head .rv-badge.pending { background: var(--surface-2); color: var(--text-faint); font-size: 12px; font-weight: 800; border: 1px dashed var(--border-strong); }
.review-head .review-fav-btn { margin-left: 0; }
.review-tags { margin-bottom: 10px; }
.my-answer { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 11px 13px; background: var(--surface); }
.my-answer .ma-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-faint); margin-bottom: 4px; letter-spacing: 0.3px; }
.my-answer .ma-text { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.my-answer.empty .ma-text { color: var(--text-faint); }

/* 설정 카드 / 폼 */
.exam-setup-card.wide { max-width: 820px; }
.option-grid.cat-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.option-grid.cat-grid .option-btn { text-align: left; padding: 9px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-count { color: var(--text-faint); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }
.label-note { font-weight: 400; color: var(--text-faint); }
.form-row label.chk { display: flex; font-weight: 500; margin-bottom: 0; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 110px; gap: 14px; }
.field {
  display: block; width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px; line-height: 1.6; outline: none;
}
.field:focus { border-color: var(--blue); }
textarea.field { resize: vertical; }

.tabs { display: flex; gap: 6px; max-width: 820px; margin: 0 auto 16px; border-bottom: 1px solid var(--border); }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.gen-warning { max-width: 820px; margin-left: auto; margin-right: auto; }

@media (max-width: 980px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* 모의고사 문항 번호판: 넓은 창에서 칸이 과하게 커지지 않도록 높이 고정 */
.exam-navigator { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
.nav-cell { aspect-ratio: auto; height: 38px; }

/* ==========================================================================
   API 연결 설정 패널 / 로그인
   ========================================================================== */
.llm-panel { max-width: 820px; margin: 0 auto 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.llm-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; border: none; background: none; cursor: pointer; color: var(--text); text-align: left; }
.llm-head:hover { background: var(--surface-2); }
.llm-title { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.llm-title svg { width: 15px; height: 15px; color: var(--blue); }
.llm-summary { flex: 1; min-width: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.llm-head .chevron { display: flex; color: var(--text-faint); transition: transform .15s var(--ease); }
.llm-panel.open .llm-head .chevron { transform: rotate(90deg); }
.llm-body { display: none; padding: 6px 16px 16px; border-top: 1px solid var(--border); }
.llm-panel.open .llm-body { display: block; }
.llm-body .form-row { margin: 12px 0 0; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
.field.mono { font-family: var(--mono); font-size: 12px; }
.llm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.llm-test { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.55; overflow-wrap: anywhere; }
.llm-test.ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.llm-test.fail { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.llm-note { margin: 12px 0 0; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }

#loginOverlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(140deg, var(--navy-950), var(--navy-800)); }
.login-card { width: min(360px, 100%); background: var(--surface); border-radius: var(--radius-lg); padding: 28px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.login-card .brand-badge { margin: 0 auto 4px; width: 46px; height: 46px; border-radius: 12px; }
.login-card .brand-badge svg { width: 25px; height: 25px; }
.login-card h2 { margin: 0; font-size: 17px; }
.login-card p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.login-error { min-height: 16px; font-size: 12px; color: var(--danger); }

/* ==========================================================================
   모바일 · 좁은 화면
   ========================================================================== */
#app { height: 100dvh; }
.menu-btn { display: none; flex: 0 0 auto; }
#sidebarBackdrop { display: none; }
#topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); gap: 12px; }
.rich table { max-width: 100%; }

@media (max-width: 860px) {
  :root { --topbar-h: 54px; }
  body { font-size: 14.5px; }
  /* 휴대폰: 가운데 영역을 따로 스크롤시키지 않고 페이지 전체가 스크롤되게 한다.
     (앱 WebView에서 상·하단 바와 키보드를 빼고 나면 안쪽 스크롤 영역이 아주 짧아지는 문제를 피한다.) */
  html, body { height: auto; min-height: 100%; }
  #app { height: auto; min-height: 100vh; min-height: 100dvh; }
  #shell { display: block; flex: none; }
  #content { overflow: visible; min-height: calc(100dvh - var(--topbar-h)); }
  #topbar { position: sticky; top: 0; z-index: 35; }
  body.kbd #bottomNav { display: none; }
  body.kbd #content { padding-bottom: 24px; }
  #topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .menu-btn { display: flex; }
  .brand-badge { display: none; }
  .brand-text .brand-sub { display: none; }
  .brand-text .brand-title { font-size: 14px; white-space: nowrap; }
  .topbar-center { justify-content: flex-end; min-width: 0; }
  .global-search { width: 100%; max-width: 260px; padding: 7px 12px; }
  .global-search input { font-size: 16px; } /* iOS가 입력 시 화면을 확대하지 않도록 16px 이상 */

  /* 사이드바 → 왼쪽에서 밀려 나오는 서랍 */
  #sidebar {
    position: fixed; z-index: 40; left: 0; bottom: 0;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform .22s var(--ease);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open #sidebarBackdrop {
    display: block; position: fixed; inset: 0; z-index: 30;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    background: rgba(8, 12, 28, 0.5);
  }
  .navitem, .subject-head { padding-top: 12px; padding-bottom: 12px; font-size: 14px; }
  .unit-item { padding: 10px 10px; font-size: 13px; }

  .view { padding: 16px 14px calc(48px + env(safe-area-inset-bottom)); }
  .view-header { margin-bottom: 14px; }
  .view-header h1 { font-size: 19px; }

  .hero { padding: 20px 18px; border-radius: var(--radius-md); }
  .hero-title { font-size: 20px; }
  .hero-date { display: none; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .stat-value { font-size: 22px; }
  .panel { padding: 14px 14px; }

  #filterbar { padding: 10px; gap: 8px; }
  #filterbar select { max-width: none; width: 100%; font-size: 16px; padding: 9px 10px; }
  .chip-group { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
  .chip-group::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; padding: 8px 13px; }
  .search-wrap { flex: 1 1 100%; }
  .search-wrap input { font-size: 16px; }
  .filter-spacer { display: none; }
  .result-count { margin-left: auto; }

  .card { padding: 14px 14px; }
  .card-head { align-items: flex-start; }
  .card-actions button, .q-fav-btn { width: 38px; height: 38px; }
  .card-question { font-size: 15px; }
  .answer-input, .field { font-size: 16px; }
  .rich table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rich pre { font-size: 12px; }
  .solve-actions .btn { padding: 11px 16px; }
  .solve-actions .grade-label { flex: 1 1 100%; }
  .solve-actions .btn.grade { flex: 1 1 0; justify-content: center; }

  .exam-setup-card, .exam-setup-card.wide { padding: 18px 16px; border-radius: var(--radius-md); }
  .option-grid.cat-grid { grid-template-columns: 1fr; }
  .option-btn { padding: 12px 8px; }
  .form-grid, .form-grid.two { grid-template-columns: 1fr; gap: 0; }
  .form-grid.four { grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .tabs { overflow-x: auto; }
  .llm-summary { display: none; }
  .llm-title { flex: 1; }

  .exam-topbar { padding: 10px 12px; gap: 10px; }
  .exam-question-card { padding: 18px 16px; border-radius: var(--radius-md); }
  .exam-q-text { font-size: 15.5px; }
  .exam-nav-footer .btn { flex: 1; justify-content: center; padding: 12px 10px; }
  .exam-navigator { padding: 10px; }
  .exam-hint .kbd { display: none; }

  .result-hero { padding: 20px 18px; gap: 18px; justify-content: center; border-radius: var(--radius-md); }
  .result-stats { gap: 16px; }
  .result-actions .btn { flex: 1 1 auto; justify-content: center; }
  .review-head { padding: 12px 12px; gap: 8px; }
  .review-body { padding: 0 12px 14px; }

  .gen-result-banner { flex-wrap: wrap; }
  .gen-result-banner .grb-actions { margin-left: 0; width: 100%; }
  .gen-result-banner .grb-actions .btn { flex: 1; justify-content: center; }
  #toastHost { left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; }
}

@media (max-width: 420px) {
  .stat-card .stat-foot { font-size: 11px; }
  .quick-card { padding: 14px; }
}

/* grid 칸이 내용 때문에 화면보다 넓어지지 않도록 */
.dash-grid > *, .quick-actions > *, .stat-grid > *, .form-grid > * { min-width: 0; }
#content { overflow-x: hidden; }

/* ==========================================================================
   기출문제
   ========================================================================== */
.tag.past { background: var(--navy-900); color: #f3d77a; }
:root[data-theme="dark"] .tag.past { background: var(--accent-soft); color: var(--accent); }
.round-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.round-chip {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 68px; padding: 8px 12px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: all .12s var(--ease);
}
.round-chip:hover { border-color: var(--text-faint); }
.round-chip .rc-name { font-size: 13px; font-weight: 700; }
.round-chip .rc-count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.round-chip.done .rc-count { color: var(--success); }
.round-chip.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.round-chip.active .rc-count { color: var(--blue); }
@media (max-width: 860px) {
  .round-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .round-bar::-webkit-scrollbar { display: none; }
  .round-chip { flex: 0 0 auto; }
  .view-header-actions { width: 100%; }
  .view-header-actions .btn { flex: 1; justify-content: center; }
}

/* ==========================================================================
   오늘의 카드 · 자동 채점 결과
   ========================================================================== */

.today-view { max-width: 760px; margin: 0 auto; }
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.today-date { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.today-title { margin: 2px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.today-streak { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: var(--radius-pill); background: var(--orange-soft); color: var(--orange); font-size: 13px; font-weight: 700; }
.today-streak b { font-size: 16px; }

.today-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 12px; }
.today-tabs .tt { border: 0; background: none; padding: 9px 8px; border-radius: 9px; font: inherit; font-size: 14px; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.today-tabs .tt span { font-weight: 600; font-size: 12.5px; margin-left: 4px; opacity: 0.8; }
.today-tabs .tt.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.today-tabs .tt:disabled { opacity: 0.45; cursor: default; }
.today-note { font-size: 12.5px; color: var(--text-muted); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 8px 11px; margin-bottom: 12px; }

.deck-dots { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 14px; }
.deck-dots .dot { width: 26px; height: 8px; border-radius: 4px; border: 0; padding: 0; background: var(--border-strong); cursor: pointer; transition: transform 0.15s var(--ease); }
.deck-dots .dot.cur { outline: 2px solid var(--blue); outline-offset: 2px; }
.deck-dots .dot.ok { background: var(--success); }
.deck-dots .dot.partial { background: #7cc79a; }
.deck-dots .dot.partial-no { background: var(--warning); }
.deck-dots .dot.no { background: var(--danger); }

.today-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 18px 18px 14px; }
.tc-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.tc-num { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-right: 4px; font-variant-numeric: tabular-nums; }
.tag.new { background: var(--success-bg); color: var(--success); }
.tc-fav { margin-left: auto; border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: 4px; }
.tc-fav.fav-active { color: var(--accent); }
.tc-cat { font-size: 12px; color: var(--text-muted); margin: 8px 0 10px; }
.tc-question { font-size: 16px; line-height: 1.7; color: var(--text); word-break: keep-all; overflow-wrap: anywhere; }
.tc-question pre, .gp-answers pre { overflow-x: auto; max-width: 100%; }
.tc-question table { display: block; overflow-x: auto; max-width: 100%; }
.tc-answer { width: 100%; box-sizing: border-box; margin-top: 14px; padding: 12px 13px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); font: inherit; font-size: 15.5px; line-height: 1.6; resize: none; min-height: 56px; }
.tc-answer:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.tc-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 10px; }
.tc-actions .btn { justify-content: center; padding: 12px; font-size: 15px; }
.tc-nav { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.tc-nav .prevBtn svg { transform: rotate(180deg); }
.today-finish { margin-top: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-md); background: var(--success-bg); color: var(--success); font-weight: 700; font-size: 14px; }

.grade-panel { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; background: var(--surface-2); }
.grade-panel.ok { border-color: var(--success-border); }
.grade-panel.no { border-color: var(--danger-border); }
.gp-head { display: flex; align-items: center; gap: 14px; }
.mini-ring { position: relative; width: 64px; height: 64px; flex: 0 0 auto; }
.mini-ring svg { transform: rotate(-90deg); }
.mini-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 7; }
.mini-ring .ring-fg { fill: none; stroke: var(--blue); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.mini-ring.ok .ring-fg { stroke: var(--success); }
.mini-ring.partial .ring-fg { stroke: #3fae6c; }
.mini-ring.partial-no .ring-fg { stroke: var(--warning); }
.mini-ring.no .ring-fg { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 21px; font-variant-numeric: tabular-nums; }
.ring-text b { font-size: 17px; }
.ring-text span { font-size: 11px; color: var(--text-muted); }
.gp-verdict { font-size: 18px; font-weight: 800; }
.grade-panel.ok .gp-verdict, .grade-panel.partial .gp-verdict { color: var(--success); }
.grade-panel.partial-no .gp-verdict { color: var(--warning); }
.grade-panel.no .gp-verdict { color: var(--danger); }
.gp-sub { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.gr-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--blue-soft); color: var(--blue); }
.gr-chip.claude { background: var(--accent-soft); color: var(--accent-ink); }
.gr-chip.keyword, .gr-chip.disputed { background: var(--warning-bg); color: var(--warning); }
.gr-chip.self { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border-strong); }
.gr-prev { font-size: 11.5px; color: var(--text-faint); }
:root[data-theme="dark"] .gr-chip.claude { color: var(--accent); }

.gp-items { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.gp-items li { display: flex; gap: 10px; padding: 10px 11px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.gi-mark { flex: 0 0 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #fff; }
.gp-items li.hit .gi-mark { background: var(--success); }
.gp-items li.half .gi-mark { background: var(--warning); }
.gp-items li.miss .gi-mark { background: var(--danger); }
.gi-body { min-width: 0; flex: 1; }
.gi-label { font-size: 13.5px; font-weight: 700; line-height: 1.45; }
.gi-pts { font-weight: 600; color: var(--text-muted); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.gi-comment { font-size: 13px; color: var(--text-muted); margin-top: 3px; line-height: 1.55; }
.gi-evidence { font-size: 12.5px; color: var(--text); margin-top: 5px; padding-left: 9px; border-left: 3px solid var(--border-strong); line-height: 1.5; overflow-wrap: anywhere; }

.gp-block { margin-top: 14px; }
.gp-label { display: block; font-size: 12px; font-weight: 800; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.gp-label.sub { margin-top: 12px; }
.gp-missing { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.6; color: var(--danger); }
.gp-feedback { margin: 0; font-size: 14px; line-height: 1.7; }
.gp-answers summary { cursor: pointer; font-size: 13px; font-weight: 800; color: var(--blue); padding: 4px 0; }
.gp-answers .answer-box { margin-top: 8px; }
.gp-better { white-space: pre-wrap; font-size: 14px; line-height: 1.7; padding: 11px 12px; border-radius: var(--radius-sm); background: var(--success-bg); border: 1px solid var(--success-border); }
.gp-myanswer { margin-top: 14px; }
.gp-mytext { white-space: pre-wrap; font-size: 14px; line-height: 1.6; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); overflow-wrap: anywhere; }
.gp-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-top: 12px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

@media (max-width: 860px) {
  .today-card { padding: 15px 14px 12px; border-radius: var(--radius-md); }
  .tc-question { font-size: 15.5px; }
  .today-title { font-size: 21px; }
}

/* 휴대폰 하단 탭 */
#bottomNav { display: none; }
@media (max-width: 860px) {
  #bottomNav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  #bottomNav .navitem { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 4px 0; margin: 0; width: auto; font: inherit; font-size: 11px; font-weight: 700; color: var(--text-faint); border-radius: 8px; }
  #bottomNav .navitem.active { color: var(--blue); background: none; }
  #content { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.exam-grade .grading-wait { display: flex; align-items: center; gap: 8px; padding: 14px 4px; color: var(--text-muted); font-size: 13.5px; }
.empty-state.small { padding: 14px; font-size: 12.5px; }

/* 휴대폰: 위쪽 규칙의 overflow-x: hidden이 세로 스크롤 영역을 만들지 않도록 마지막에 다시 지정 */
@media (max-width: 860px) {
  #content { overflow: visible; overflow-x: clip; }
  /* 기본 규칙의 body { overflow: hidden }이 남아 있으면 손가락으로 페이지가 스크롤되지 않는다 */
  html, body { overflow: visible; overflow-x: clip; }
}

/* ---------- 편의성 개선 ---------- */
.font-btn { font-weight: 800; font-size: 15px; }
.tc-question, .tc-answer, .gp-feedback, .gp-better, .gp-mytext, .card-question { font-size: calc(16px * var(--qfs, 1)); }
.tc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tc-chips + .tc-answer { margin-top: 8px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; min-width: 40px; padding: 7px 11px; border-radius: var(--radius-pill); cursor: pointer; touch-action: manipulation; }
.chip:active { background: var(--blue-soft); border-color: var(--blue); }
.chip.ghost { color: var(--text-muted); font-weight: 600; }
.today-finish { flex-direction: column; align-items: stretch; gap: 6px; color: var(--text); background: var(--success-bg); border: 1px solid var(--success-border); }
.tf-score b { font-size: 28px; color: var(--success); font-variant-numeric: tabular-nums; }
.tf-score span { margin-left: 8px; color: var(--text-muted); font-size: 14px; font-weight: 700; }
.tf-text { font-size: 13.5px; font-weight: 600; line-height: 1.55; }
.today-finish .btn { align-self: flex-start; }
@media (max-width: 860px) {
  /* 다음 카드 버튼은 길게 스크롤한 뒤에도 하단 탭 바로 위에 붙어 있게 한다 */
  .today-card.graded .tc-nav { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--surface); margin-left: -14px; margin-right: -14px; padding: 10px 14px; z-index: 5; box-shadow: 0 -6px 12px -8px rgba(0,0,0,.25); }
  body.kbd .today-card.graded .tc-nav { bottom: 0; }
}

/* 기출 회차 */
.back-link { border: 0; background: none; color: var(--blue); font: inherit; font-size: 14px; font-weight: 700; padding: 0 0 8px; cursor: pointer; }
.round-list { display: grid; gap: 10px; }
.round-card { text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow-sm); }
.round-card:active { border-color: var(--blue); }
.rc-top { display: flex; align-items: center; gap: 8px; }
.rc-top b { font-size: 17px; }
.rc-no { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.rc-st { margin-left: auto; font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); }
.rc-st.full { background: var(--success-bg); color: var(--success); }
.rc-st.partial { background: var(--blue-soft); color: var(--blue); }
.rc-st.topics { background: var(--warning-bg); color: var(--warning); }
.rc-mid { margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.rc-bot { margin-top: 4px; font-size: 13px; }
.rc-bot b { color: var(--blue); }
.round-foot { margin-top: 16px; font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }

/* 노트 · 암기 */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.note-search { width: 100%; margin-top: 6px; }
.note-list { display: grid; gap: 6px; }
.note-item { display: flex; justify-content: space-between; gap: 10px; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer; }
.note-item b { font-size: 14.5px; font-weight: 700; }
.note-item span { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.note-title { margin-bottom: 8px; }
.note-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.note-block { margin-top: 18px; display: grid; gap: 6px; }
.note-block h3 { margin: 0 0 2px; font-size: 14px; }
.note-q { text-align: left; font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; }
.md { font-size: calc(15px * var(--qfs, 1)); line-height: 1.75; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4, .md h5 { margin: 20px 0 6px; line-height: 1.4; }
.md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4, .md h5 { font-size: 14.5px; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 20px; margin: 8px 0; }
.md li.d1 { margin-left: 18px; list-style: circle; }
.md code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-family: var(--mono); font-size: 0.9em; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md-table { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.ref-chip { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--blue); font: inherit; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-right: 3px; cursor: pointer; }
.callout { border-left: 4px solid var(--blue); background: var(--blue-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 8px 13px; margin: 12px 0; }
.callout .co-title { font-weight: 800; font-size: 13px; margin-bottom: 2px; }
.callout p, .callout ul { margin: 4px 0; }
.callout.c-암기 { border-color: var(--success); background: var(--success-bg); }
.callout.c-함정 { border-color: var(--danger); background: var(--danger-bg); }
.callout.c-팁 { border-color: var(--accent); background: var(--accent-soft); }
.callout.c-시험 { border-color: var(--orange); background: var(--orange-soft); }
.memo-progress { text-align: center; font-size: 12.5px; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; }
.memo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 22px 20px; min-height: 260px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.memo-domain { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.memo-title { font-size: 20px; font-weight: 800; margin: 10px 0 14px; letter-spacing: -0.01em; }
.memo-hint { margin-top: auto; margin-bottom: auto; color: var(--text-faint); font-size: 13.5px; }
.memo-acrostic { font-size: 34px; font-weight: 900; color: var(--blue); letter-spacing: 0.08em; margin: 4px 0 12px; }
.memo-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: 100%; text-align: left; }
.memo-items li { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 15px; }
.memo-items b { color: var(--blue); display: inline-block; min-width: 22px; }
.memo-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 14px; }
.memo-actions .block { grid-column: 1 / -1; }
.memo-actions .btn { justify-content: center; padding: 13px; font-size: 15px; }
.gp-explain { margin-top: 10px; font-size: 14px; line-height: 1.7; }
.gp-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.gp-notes button { border: 1px solid var(--border-strong); background: var(--surface); color: var(--blue); font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer; }

/* 질문하기(챗) */
.chat-view { padding-bottom: 8px; }
.chat-threads { width: 100%; margin: 4px 0 10px; }
.chat-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.chat-u { align-self: flex-end; max-width: 86%; }
.chat-u > div { background: var(--blue); color: #fff; padding: 10px 14px; border-radius: 18px 18px 4px 18px; font-size: calc(15px * var(--qfs, 1)); line-height: 1.6; overflow-wrap: anywhere; }
.chat-a { align-self: flex-start; max-width: 96%; background: var(--surface); border: 1px solid var(--border); padding: 11px 14px; border-radius: 18px 18px 18px 4px; box-shadow: var(--shadow-sm); }
.chat-a .md { font-size: calc(15px * var(--qfs, 1)); }
.chat-a .md > :first-child { margin-top: 0; } .chat-a .md > :last-child { margin-bottom: 0; }
.chat-caret { display: inline-block; width: 7px; height: 16px; margin-left: 2px; vertical-align: -2px; background: var(--blue); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-src { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.chat-src span { font-size: 11.5px; font-weight: 800; color: var(--text-muted); }
.chat-src button, .chat-src i { font: inherit; font-size: 11.5px; font-style: normal; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--blue); cursor: pointer; }
.chat-src i { color: var(--text-muted); cursor: default; }
.chat-empty { text-align: center; color: var(--text-muted); padding: 28px 8px; font-size: 14px; line-height: 1.7; }
.chat-sugg { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.chat-sugg .chip { text-align: left; font-weight: 600; }
.chat-form { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 4px; background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 6; }
.chat-form textarea { flex: 1; resize: none; font: inherit; font-size: 16px; line-height: 1.5; padding: 11px 13px; border: 1.5px solid var(--border-strong); border-radius: 18px; background: var(--surface); color: var(--text); max-height: 140px; }
.chat-form textarea:focus { outline: none; border-color: var(--blue); }
.chat-form .btn { height: 44px; padding: 0 16px; }
body.kbd .chat-form { bottom: 0; }
@media (min-width: 861px) { .chat-form { bottom: 0; } }

/* 마이페이지 */
.my-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.my-avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), #7c5cff); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; flex: 0 0 auto; }
.my-title { flex: 1; min-width: 0; }
.my-title .today-title { font-size: 21px; }
.my-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.my-stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.my-stats b { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.my-stats span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.my-h { margin: 22px 0 8px; font-size: 14px; }
.my-h small { font-weight: 600; color: var(--text-muted); margin-left: 6px; font-size: 11.5px; }
.my-bars { display: flex; align-items: flex-end; gap: 4px; height: 96px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 10px 4px; }
.mb { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0; }
.mb i { display: block; width: 100%; max-width: 18px; background: var(--blue); border-radius: 4px 4px 2px 2px; min-height: 4px; }
.mb span { font-size: 9.5px; color: var(--text-faint); }
.my-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 18px 8px; width: 100%; }
.my-weak { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 6px; cursor: pointer; }
.mw-name { flex: 0 0 42%; font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.mw-bar i { display: block; height: 100%; border-radius: 4px; }
.mw-bar i.lo { background: var(--danger); } .mw-bar i.mid { background: var(--warning); } .mw-bar i.hi { background: var(--success); }
.my-weak b { font-size: 12.5px; width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.my-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.my-links button { text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.my-links b { font-size: 14px; } .my-links span { font-size: 12px; color: var(--text-muted); }
.my-set { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.ms-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.ms-row:last-child { border-bottom: 0; }
.ms-val { color: var(--text-muted); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-muted); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--blue); color: #fff; }

[hidden] { display: none !important; }

/* 로그인 · 회원가입 */
#loginOverlay { overflow-y: auto; align-items: flex-start; }
.auth-card { width: min(400px, 100%); margin: auto; background: var(--surface); border-radius: var(--radius-lg); padding: 24px 22px 26px; box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 14px; }
.auth-brand .brand-badge { display: flex; margin: 0 auto 8px; width: 46px; height: 46px; border-radius: 12px; }
.auth-brand .brand-badge svg { width: 25px; height: 25px; }
.auth-brand h2 { margin: 0; font-size: 17px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.auth-tabs button { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 800; color: var(--text-muted); padding: 9px; border-radius: 9px; cursor: pointer; }
.auth-tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 800; color: var(--text-muted); text-align: left; }
.auth-form .field { font-size: 16px; font-weight: 500; color: var(--text); width: 100%; }
.auth-row { display: flex; gap: 8px; }
.auth-row .field { flex: 1; min-width: 0; }
.auth-row .btn { white-space: nowrap; }
.auth-msg { min-height: 16px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.auth-msg.ok { color: var(--success); }
.auth-msg.err { color: var(--danger); }
.pw-rules { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0; margin: 0; font-size: 11.5px; font-weight: 700; color: var(--text-faint); }
.pw-rules li.ok { color: var(--success); }
.pw-rules li.no { color: var(--danger); }
.auth-consent { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-weight: 600 !important; line-height: 1.5; }
.auth-consent input { margin-top: 3px; }
.auth-consent a { color: var(--blue); }

/* 마이페이지 계정 */
.ms-form { display: grid; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ms-form .field { width: 100%; font-size: 15px; }
.ms-form .btn { justify-self: end; }
.ms-msg { font-size: 12px; font-weight: 600; min-height: 14px; color: var(--text-muted); }
.ms-msg.err { color: var(--danger); } .ms-msg.ok { color: var(--success); }
.btn.danger-ghost { color: var(--danger); }
.ms-lbl { font-size: 12.5px; font-weight: 800; color: var(--text-muted); }
.my-foot { text-align: center; margin: 18px 0 4px; font-size: 12px; } .my-foot a { color: var(--text-muted); }
.auth-row.birth select { padding-left: 8px; padding-right: 4px; font-size: 15px; }
.auth-row.birth select:first-child { flex: 1.3; }
.auth-consent small { color: var(--text-faint); font-weight: 600; }

/* 개인정보 처리방침 창 */
#policyModal { position: fixed; inset: 0; z-index: 400; background: rgba(6, 10, 24, 0.72); display: flex; align-items: flex-end; justify-content: center; }
.policy-card { width: min(640px, 100%); max-height: 88vh; background: var(--surface); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.policy-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 15px; }
.policy-body { overflow-y: auto; padding: 6px 18px 28px; font-size: 14px; line-height: 1.7; }
.policy-body h1 { display: none; } .policy-body .sub { color: var(--text-muted); font-size: 12.5px; margin: 8px 0 12px; }
.policy-body section { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.policy-body h2 { font-size: 14px; margin: 0 0 4px; } .policy-body p, .policy-body li { margin: 3px 0; font-size: 13.5px; }
.policy-body table { border-collapse: collapse; width: 100%; font-size: 12.5px; } .policy-body th, .policy-body td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
@media (min-width: 700px) { #policyModal { align-items: center; } .policy-card { border-radius: 20px; } }
