/* ==========================================================================
   내신메이트 — 디자인 시스템
   라이트/다크 테마, 모바일(하단 탭) ↔ 데스크톱(사이드바) 반응형
   ========================================================================== */

:root {
  /* 표면/잉크 */
  --bg: #f9f9f7;
  --card: #fcfcfb;
  --card-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --line: #e1e0d9;
  --line-soft: #ecebe5;
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 16px rgba(11,11,11,.05);

  /* 브랜드 */
  --accent: #c9264e;
  --accent-strong: #a91b3f;
  --on-accent: #ffffff;
  --accent-soft: rgba(201,38,78,.09);
  --accent-soft-2: rgba(201,38,78,.16);

  /* 상태 */
  --good: #0ca30c;
  --good-text: #006300;
  --warn: #fab219;
  --danger: #d03b3b;
  --danger-soft: rgba(208,59,59,.10);

  /* 과목 팔레트 (검증된 카테고리 8색) */
  --c1: #2a78d6; --c2: #1baf7a; --c3: #eda100; --c4: #008300;
  --c5: #4a3aa7; --c6: #e34948; --c7: #e87ba4; --c8: #eb6834;

  /* 학습 잔디 순차 램프 (파랑 단일 색상, 밝음→진함) */
  --hm1: #9ec5f4; --hm2: #5598e7; --hm3: #256abf; --hm4: #0d366b;

  --radius: 16px;
  --radius-s: 10px;
  --tap: 44px;
  --font: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Segoe UI",
          Roboto, "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

[data-theme="dark"] {
  --bg: #0d0d0d;
  --card: #1a1a19;
  --card-2: #242422;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --line: #2c2c2a;
  --line-soft: #232321;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 18px rgba(0,0,0,.35);

  --accent: #f06a8c;
  --accent-strong: #f587a2;
  --on-accent: #300a15;
  --accent-soft: rgba(240,106,140,.13);
  --accent-soft-2: rgba(240,106,140,.22);

  --good: #0ca30c;
  --good-text: #4cc24c;
  --danger: #e66767;
  --danger-soft: rgba(230,103,103,.14);

  --c1: #3987e5; --c2: #199e70; --c3: #c98500; --c4: #008300;
  --c5: #9085e9; --c6: #e66767; --c7: #d55181; --c8: #d95926;

  /* 다크에서는 어두운 배경 대비 밝을수록 '많음' */
  --hm1: #184f95; --hm2: #2a78d6; --hm3: #5598e7; --hm4: #9ec5f4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 레이아웃 ---------- */
#app { min-height: 100dvh; }
#main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0)); }
#view { max-width: 760px; margin: 0 auto; outline: none; }

#sidenav { display: none; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
}
.tab-link {
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 4px; border-radius: 12px;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.tab-link .ic { width: 23px; height: 23px; }
.tab-link.active { color: var(--accent); }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 232px 1fr; }
  #tabbar { display: none; }
  #main { padding: 28px 32px 60px; }
  #sidenav {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100dvh;
    border-right: 1px solid var(--line);
    background: var(--card);
    padding: 20px 12px;
  }
  .side-links { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; flex: 1; }
  .side-foot { border-top: 1px solid var(--line-soft); padding-top: 10px; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8f1f6b);
  color: #fff; font-weight: 800; font-size: 16px;
  display: grid; place-items: center;
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px;
}
.nav-link:hover { background: var(--card-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .ic { width: 20px; height: 20px; }

.ic { width: 18px; height: 18px; fill: none; flex: none; }

/* ---------- 공통 컴포넌트 ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.page-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; flex: 1; }
.page-head .sub { color: var(--ink-3); font-size: 13px; font-weight: 500; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 11px; cursor: pointer;
  background: transparent; color: var(--ink-2);
  display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn .ic { width: 21px; height: 21px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card + .card, .card + .section, .section + .card { margin-top: 12px; }
.card.pad-s { padding: 12px 14px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card-title .spacer, .row .spacer { flex: 1; }
.section { margin-top: 20px; }
.section-title {
  font-size: 13px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em; margin: 0 2px 8px;
  display: flex; align-items: center; gap: 6px;
}
.section-title .spacer { flex: 1; }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-weight: 700; font-size: 14.5px; cursor: pointer;
  transition: transform .05s ease, background .15s ease;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 5px; }
.btn.small .ic { width: 15px; height: 15px; }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .ic { width: 17px; height: 17px; }

.input, .select, .textarea {
  width: 100%; min-height: var(--tap);
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 10px 13px;
  font-size: 15px;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

.seg { display: flex; background: var(--card-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  min-height: 36px; border-radius: 9px; font-weight: 700; font-size: 13.5px;
  color: var(--ink-3); padding: 0 10px; white-space: nowrap;
}
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(11,11,11,.10); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--card-2); color: var(--ink-2);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { background: rgba(12,163,12,.12); color: var(--good-text); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 800; display: inline-grid; place-items: center;
}

.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
  min-height: 52px;
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.list-item .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.list-item.clickable { cursor: pointer; border-radius: 10px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.list-item.clickable:hover { background: var(--card-2); }

.empty {
  text-align: center; color: var(--ink-3); padding: 28px 12px;
  font-size: 14px; line-height: 1.7;
}
.empty .big-emoji { font-size: 34px; display: block; margin-bottom: 8px; }

.progress { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }

.check {
  width: 26px; height: 26px; border-radius: 9px; flex: none;
  border: 2px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: transparent;
}
.check .ic { width: 16px; height: 16px; }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.done-text { text-decoration: line-through; color: var(--ink-3) !important; }

/* 스탯 타일 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow);
}
.tile .t-label { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.tile .t-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.tile .t-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* D-Day 히어로 */
.hero {
  border-radius: 20px; padding: 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #8f1f6b 100%);
  color: #fff; box-shadow: var(--shadow);
}
.hero .h-label { font-size: 13px; font-weight: 700; opacity: .85; }
.hero .h-dday { font-size: 40px; font-weight: 900; letter-spacing: -.03em; line-height: 1.15; }
.hero .h-sub { font-size: 13.5px; opacity: .9; margin-top: 2px; }
.hero .h-row { display: flex; align-items: flex-end; gap: 12px; }
.hero .h-row .spacer { flex: 1; }
.hero .h-chip {
  background: rgba(255,255,255,.18); border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 700; backdrop-filter: blur(4px);
}

/* 모달 */
#modal-root:empty { display: none; }
.modal-veil {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11,11,11,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .16s ease;
}
@media (min-width: 640px) { .modal-veil { align-items: center; padding: 24px; } }
.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0));
  max-height: 88dvh; overflow-y: auto;
  animation: slideup .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 20px; padding: 24px; } }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.modal h2 .spacer { flex: 1; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@keyframes fadein { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(24px); opacity: .6; } }

/* 토스트 */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom, 0)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { #toast-root { bottom: 28px; } }
.toast {
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(11,11,11,.25);
  animation: toastin .22s ease;
}
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- 학습 도구 ---------- */
/* 빈칸(클로즈) */
.cloze-text { font-size: 16.5px; line-height: 2.1; overflow-wrap: anywhere; }
.cloze-text.kor { line-height: 2.2; }
.blank {
  display: inline-block; min-width: 46px; text-align: center;
  border: none; border-bottom: 2.5px solid var(--accent);
  background: var(--accent-soft); border-radius: 7px 7px 0 0;
  padding: 0 7px; margin: 0 2px; cursor: pointer;
  font-weight: 700; color: transparent; user-select: none; -webkit-user-select: none;
  transition: background .12s ease;
}
.blank.revealed { color: var(--accent); background: transparent; cursor: default; }
.blank.correct { color: var(--good-text); border-color: var(--good); background: transparent; }
.blank.wrong { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.blank.active { background: var(--accent-soft-2); box-shadow: 0 0 0 2px var(--accent); }
.blank-answer-correct { color: var(--good-text); font-weight: 800; margin-left: 3px; }

.choice-bar {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom, 0)); z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px; margin-top: 14px; box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; gap: 7px; justify-content: center;
}
@media (min-width: 900px) { .choice-bar { bottom: 12px; } }
.choice-bar .btn { flex: 1 1 40%; min-height: 42px; }

/* 문장 순서 배열 */
.order-slot { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; min-height: 40px; }
.order-chip {
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 9px 13px; cursor: pointer;
  font-size: 14.5px; text-align: left; line-height: 1.5; width: 100%;
}
.order-chip:hover { border-color: var(--accent); }
.order-chip.picked { background: var(--accent-soft); border-color: var(--accent); }
.order-chip.ok { border-color: var(--good); background: rgba(12,163,12,.08); }
.order-chip.bad { border-color: var(--danger); background: var(--danger-soft); }
.order-num { font-weight: 800; color: var(--accent); margin-right: 7px; }

/* 플래시카드 */
.flash {
  min-height: 300px; border-radius: 20px; padding: 26px 20px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; cursor: pointer; gap: 12px;
}
.flash .f-tag { font-size: 12px; font-weight: 800; color: var(--ink-3); letter-spacing: .06em; }
.flash .f-front { font-size: 21px; font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.flash .f-back { font-size: 17px; color: var(--ink-2); line-height: 1.6; border-top: 1px dashed var(--line); padding-top: 14px; width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; }
.flash .f-hint { font-size: 12.5px; color: var(--ink-3); }
.grade-row { display: flex; gap: 7px; margin-top: 12px; }
.grade-row .btn { flex: 1; flex-direction: column; gap: 1px; min-height: 54px; }
.grade-row .g-sub { font-size: 10.5px; font-weight: 600; opacity: .65; }

/* 타이머 */
.timer-clock { text-align: center; padding: 26px 0 8px; }
.timer-clock .t-time {
  font-size: 58px; font-weight: 900; letter-spacing: .01em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.timer-clock .t-mode { font-size: 13px; font-weight: 700; color: var(--ink-3); margin-top: 4px; }
.timer-clock.focus .t-time { color: var(--accent); }
.timer-live {
  display: flex; align-items: center; gap: 7px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px; padding: 5px 13px; font-weight: 800; font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 차트 */
.chart-wrap { overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-svg text { font-family: var(--font); }
.axis-label { fill: var(--ink-3); font-size: 11px; }
.bar-label { fill: var(--ink-2); font-size: 11px; font-weight: 700; }
.gridline { stroke: var(--line-soft); stroke-width: 1; }
.baseline { stroke: var(--line); stroke-width: 1; }

/* 회독 트래커 */
.round-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.round-dot {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card);
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  color: var(--ink-3); cursor: pointer;
}
.round-dot.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* 백지 복습 */
.blank-paper {
  min-height: 260px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: repeating-linear-gradient(transparent, transparent 31px, var(--line-soft) 31px, var(--line-soft) 32px);
  padding: 8px 13px; width: 100%; font-size: 15px; line-height: 32px; resize: vertical;
}
.blank-paper:focus { outline: none; border-color: var(--accent); }
.compare-grid { display: grid; gap: 10px; }
@media (min-width: 640px) { .compare-grid { grid-template-columns: 1fr 1fr; } }

/* 과목 카드 */
.subject-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; box-shadow: var(--shadow); width: 100%; text-align: left;
}
.subject-card:hover { border-color: var(--accent); }
.subject-swatch {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-size: 20px;
  color: #fff; font-weight: 800;
}
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-height: 92px;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card .t-emoji { font-size: 22px; }
.tool-card .t-name { font-weight: 800; font-size: 14.5px; }
.tool-card .t-desc { font-size: 12px; color: var(--ink-3); line-height: 1.45; }

/* 결과 화면 */
.result-hero { text-align: center; padding: 22px 0 10px; }
.result-hero .r-score { font-size: 46px; font-weight: 900; letter-spacing: -.02em; }
.result-hero .r-sub { color: var(--ink-3); font-weight: 600; margin-top: 2px; }

/* 스피드 트레이닝 */
.speed-q { text-align: center; padding: 20px 0; }
.speed-q .q-text { font-size: 30px; font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.speed-q .q-timer { font-size: 13px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; margin-bottom: 8px; }

/* 기타 */
.kbd { background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; border: none; }
.muted { color: var(--ink-3); }
.small-text { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0 !important; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.w-auto { width: auto; }
.fab {
  position: fixed; right: 18px; bottom: calc(96px + env(safe-area-inset-bottom, 0)); z-index: 35;
  width: 56px; height: 56px; border-radius: 18px; border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px rgba(201,38,78,.4);
  display: grid; place-items: center;
}
.fab .ic { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { bottom: 32px; right: 32px; } }

/* ---------- 시험지 (학교 템플릿 · 인쇄) ---------- */
.paper-actions { display: flex; gap: 8px; align-items: center; max-width: 210mm; margin: 0 auto 10px; }
.paper {
  background: #fff; color: #111;
  max-width: 210mm; margin: 0 auto;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 11mm 9mm; border-radius: 4px;
}
.paper-head { border: 3px double #111; padding: 10px 12px 9px; margin-bottom: 15px; text-align: center; }
.ph-school { font-size: 12px; text-align: left; min-height: 14px; color: #333; }
.ph-year { font-size: 14px; letter-spacing: .06em; margin-top: 1px; }
.ph-subject { font-size: 26px; font-weight: 900; letter-spacing: .18em; margin: 5px 0 9px; }
.ph-info { width: 100%; border-collapse: collapse; font-size: 11px; }
.ph-info td { border: 1px solid #111; padding: 4px 6px; text-align: center; }
.ph-info .ph-name { text-align: left; width: 38%; }
.ph-info .ph-score { width: 52px; }
.paper-body { list-style: none; counter-reset: pq; padding: 0; margin: 0; }
.cols-2 .paper-body { column-count: 2; column-gap: 8mm; column-rule: 1px solid #aaa; }
.pq { break-inside: avoid; margin-bottom: 15px; font-size: 13px; line-height: 1.65; counter-increment: pq; }
.pq-stem { white-space: pre-wrap; }
.pq-stem::before { content: counter(pq) ". "; font-weight: 800; }
.pq-pts { font-size: 11px; }
.pq-choices { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 3px 16px; }
.pq-answerline { margin-top: 8px; letter-spacing: .04em; }
.pq-essaybox { margin-top: 8px; height: 66px; border: 1px solid #999; border-radius: 3px; }
.paper-foot { text-align: center; font-size: 11px; margin-top: 20px; color: #444; }
.answer-sheet { break-before: page; page-break-before: always; margin-top: 26px; border-top: 2px solid #111; padding-top: 12px; }
.as-title { font-weight: 800; margin-bottom: 8px; font-size: 14px; }
.as-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.as-table th, .as-table td { border: 1px solid #555; padding: 4px 6px; vertical-align: top; text-align: left; }
.as-src { color: #555; font-size: 10.5px; }
.fs-s .pq { font-size: 11.5px; }
.fs-l .pq { font-size: 15px; }
@media screen and (max-width: 700px) {
  .cols-2 .paper-body { column-count: 1; } /* 좁은 화면 미리보기는 1단 */
}

@media print {
  @page { size: A4; margin: 12mm; }
  #tabbar, #sidenav, .fab, .btn, .no-print, #toast-root { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
  #main { padding: 0 !important; }
  #view { max-width: none !important; }
  .paper { border: none; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .cols-2 .paper-body { column-count: 2 !important; }
}

/* ============ 로그인 게이트 · 계정 ============ */
#auth-root[hidden] { display: none; }
.auth-veil {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg); overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px; padding: 26px 22px;
  animation: auth-in .25s ease;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.auth-brand b { font-size: 20px; font-weight: 800; }
.auth-sub { text-align: center; margin: 0 0 16px; line-height: 1.6; }
.auth-card .field { margin-bottom: 12px; }
.auth-switch { width: 100%; margin-top: 10px; font-size: 13px; }
.auth-err {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-s); padding: 9px 12px; font-size: 13px;
  margin-bottom: 12px; line-height: 1.5;
}
.auth-notice {
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: var(--radius-s); padding: 10px 12px; font-size: 13px;
  margin-bottom: 14px; line-height: 1.6;
}
.auth-loading { text-align: center; padding: 30px 0 14px; }
.auth-pending { text-align: center; }
.auth-pending .big-emoji { font-size: 40px; display: block; margin-bottom: 6px; }
.auth-pending .btn { width: 100%; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 태그 배지 (관리자·상태) */
.tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; margin-left: 5px; vertical-align: middle;
}
.tag.admin { background: var(--accent-soft-2); color: var(--accent-strong); }
.tag.ok    { background: color-mix(in srgb, var(--c2) 20%, transparent); color: var(--c2); }
.tag.wait  { background: color-mix(in srgb, var(--c3) 22%, transparent); color: var(--c3); }

/* 관리자 가입자 목록 */
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line-soft);
}
.user-row:first-of-type { border-top: none; }
.user-main b { font-size: 14px; }
.user-actions { flex: none; }
