/* ╔══════════════════════════════════════════════════════════
   ║  기출해체분석기 — Stylesheet
   ║  Editorial · sleek · monochrome with a single blue accent
   ╚══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* surfaces (warm stone) */
  --bg:            #fafaf9;
  --surface:       #ffffff;
  --surface-2:     #f7f7f5;
  --surface-hover: #f4f4f1;

  /* borders */
  --line:        #ebeae6;
  --line-soft:   #f3f2ee;
  --line-strong: #d8d6cf;

  /* ink */
  --ink:    #0c0a09;
  --ink-2:  #2c2a27;
  --ink-3:  #57534e;
  --ink-4:  #8a8580;
  --ink-5:  #b8b4ad;
  --ink-6:  #e0ddd6;

  /* accents — Apple Action Blue */
  --pop:        #0066cc;
  --pop-soft:   #e6f0fa;
  --pop-darker: #0058b3;

  /* mobile sheet tokens */
  --sheet-radius:   20px;
  --sheet-max-h:    85vh;
  --sheet-shadow:   0 -16px 48px rgba(12,10,9,0.18);
  --backdrop:       rgba(12,10,9,0.42);
  --tap:            44px;       /* 모바일 최소 터치 영역 */

  /* CTA card tokens (다크모드 대비 — :root 한 곳에서 관리) */
  --cta-radius:        18px;
  --cta-eyebrow:       var(--ink-4);
  --cta-dark-bg:       var(--ink);
  --cta-dark-bg-hover: #1a1815;
  --cta-dark-fg:       #fafaf9;
  --cta-dark-sub:      rgba(250,250,249,0.66);
  --cta-dark-line:     rgba(250,250,249,0.10);
  --cta-light-bg:      var(--surface);
  --cta-light-bg-hover:var(--surface);
  --cta-light-fg:      var(--ink);
  --cta-light-sub:     var(--ink-3);
  --cta-light-line:    var(--line);
  /* shadows — UI 에는 거의 안 쓰고, 사진/문서(PDF page)에만 사용 */
  --sh-xs: 0 1px 2px rgba(12,10,9,.04);
  --sh-sm: 0 1px 2px rgba(12,10,9,.04);
  --sh-md: 0 2px 8px rgba(12,10,9,.05);
  --sh-lg: 0 8px 24px rgba(12,10,9,.06);
  /* Apple 식 product shadow — PDF 페이지 등 "물체가 표면 위에 놓인" 인상 */
  --sh-paper: 0 5px 30px rgba(0,0,0,0.18);

  /* layout */
  --max-w:      1280px;
  --sidebar-w:  236px;
  --header-h:   56px;
  --nav-h:      78px;

  /* motion */
  --ease:    cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t:        180ms var(--ease);
}

/* ═══ Base ════════════════════════════════════════════════ */
html {
  -webkit-text-size-adjust: 100%;
  /* 페이지 콘텐츠 양에 따라 스크롤바가 나타났다 사라지면 콘텐츠가
     좌우로 밀리는 현상이 생김 → 항상 스크롤바 자리를 예약해서 고정 */
  scrollbar-gutter: stable;
  /* 모바일에서 어떤 자식이 viewport를 넘쳐도 가로 스크롤이 생기지 않도록 봉쇄.
     'clip'은 fixed/sticky 잠금이 'hidden'보다 안전 */
  overflow-x: clip;
}
body { overflow-x: clip; }

/* 모바일 탭 시 회색 하이라이트 제거 */
a, button, [role="button"], [role="tab"] { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Pretendard Variable', 'Pretendard', 'Apple SD Gothic Neo',
               'Noto Sans KR', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
}

/* ═══ Header ══════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  height: var(--header-h);
  background: rgba(250, 250, 249, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}
.brand__mark {
  display: inline-flex;
  color: var(--ink);
}
.brand__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  transition: var(--t);
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--line-strong); }

/* ═══ Curriculum Nav ══════════════════════════════════════ */
.curriculum-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 70;
  height: var(--nav-h);
  background: rgba(250, 250, 249, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.curriculum-nav__inner {
  height: 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;            /* 그룹 사이 간격 — 18px → 10px (sep 포함 약 21px) */
  padding-bottom: 8px;
  padding-top: 8px;
  overflow-x: hidden;
  min-width: 0;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* 그룹은 자신의 콘텐츠 폭만 차지 (자라지 않음).
     폭이 부족하면 줄어들면서 안에서 가로 스와이프. */
  flex: 0 1 auto;
  min-width: 0;
}
.nav-group__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 4px;
  align-self: flex-start;
}
.nav-group__tabs {
  display: flex;
  gap: 4px;
  /* 그룹 단위 가로 스크롤 — 메인탭/분류탭 스와이프 분리 */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.nav-group__tabs::-webkit-scrollbar { display: none; }
.nav-group__tabs > .nav-tab { scroll-snap-align: start; }

.nav-sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 4px 0;
  flex-shrink: 0;
}

.nav-tab {
  flex-shrink: 0;
  /* 카테고리 박스 폭 통일 — 모든 탭이 같은 폭으로 정렬되어 일관된 인상.
     데스크톱에서만 적용; 모바일은 콤팩트 모드에서 자연 폭. */
  min-width: 132px;
  padding: 7px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
  color: var(--ink-3);
  transition: background var(--t), color var(--t);
}
.nav-tab:hover { background: var(--surface-2); color: var(--ink); }
.nav-tab.is-active {
  background: var(--ink);
  color: #fff;
}
.nav-tab__title { font-size: 13px; font-weight: 600; letter-spacing: -0.1px; }
.nav-tab__sub   { font-size: 10.5px; font-weight: 500; opacity: 0.62; letter-spacing: 0.2px; }

/* placeholder 탭 — 데이터가 아직 없는 카테고리 (고2/고1/검정고시/논술/입시자료).
   클릭은 가능, 시각적으로 흐리게 처리해 "곧 오는 영역" 임을 신호. */
.nav-tab.is-placeholder { color: var(--ink-5); }
.nav-tab.is-placeholder .nav-tab__sub { opacity: 0.55; }
.nav-tab.is-placeholder:hover { color: var(--ink-3); background: var(--surface-2); }
.nav-tab.is-placeholder.is-active { background: var(--ink-3); color: #fff; }

/* ═══ Main Layout ═════════════════════════════════════════ */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 36px;
  padding-top: 28px;
  padding-bottom: 64px;
  align-items: start;
}

/* ═══ Filter Sidebar ══════════════════════════════════════ */
/* 사이드바는 sticky 만 — 자체 스크롤 영역 X. 휠은 항상 페이지 전체 스크롤로 자연스럽게 흘러감.
   페이지 본문이 사이드바보다 길기 때문에 사이드바가 잘릴 일은 거의 없음. */
.filter {
  position: sticky;
  top: calc(var(--header-h) + var(--nav-h) + 28px);
  display: flex;
  flex-direction: column;
  gap: 28px;

  /* 사이드바 자체 독립 스크롤
     - max-height: viewport 에서 sticky top 영역 뺀 높이 (dvh: 모바일 주소창 변동 정확).
     - overscroll-behavior: none — 사이드바 안에서 휠/스크롤이 페이지로 chain 되는
       것을 완전 차단. (사이드바 영역에 마우스 있으면 사이드바만 스크롤 — 본문 영향 0).
     - touch momentum.
     - scroll-padding-top — 키보드 탐색 시 sticky top 가려짐 방지.
   */
  max-height: calc(100dvh - var(--header-h) - var(--nav-h) - 28px - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: 8px;

  /* 스크롤바: gutter stable 로 column 폭 변동·시각 어긋남 방지.
     padding-right 는 두지 않음 — gutter 가 자동으로 6px 확보. */
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-gutter: stable;
}
.filter::-webkit-scrollbar { width: 6px; }
.filter::-webkit-scrollbar-track { background: transparent; }
.filter::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
.filter::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

.filter__section { display: flex; flex-direction: column; gap: 10px; }

.filter__title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.filter__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink-4);
}

.filter__hint {
  font-size: 10.5px;
  color: var(--ink-5);
  font-weight: 500;
}

/* ── Pill (chip) ───────────────────────────────────── */
/* 칩을 균일 그리드로 깔아 '전체'와 라벨 길이가 다른 칩이 섞여도 정렬이 맞도록 */
.pill-row {
  display: grid;
  /* 기본은 짧은 라벨용 (전체/평가원/교육청 등) */
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
}

/* 시험 종류(subtype) 칩 — 한 줄 2칸 고정으로 라벨 길이 차이를 흡수 */
#typeFilter.pill-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  font-family: inherit;
  transition: background 140ms var(--ease),
              border-color 140ms var(--ease),
              color 140ms var(--ease),
              box-shadow 140ms var(--ease),
              transform 120ms var(--ease);
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
}
.pill:hover {
  border-color: var(--ink-6);
  background: var(--surface-2);
  color: var(--ink);
}
.pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--pop-soft);
  border-color: var(--pop);
}
.pill.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.pill.is-active:hover { background: var(--ink-2); border-color: var(--ink-2); }

/* group pill carries its own color when active */
.pill.is-group.is-active {
  background: var(--pill-color, var(--ink));
  border-color: var(--pill-color, var(--ink));
}

/* ── Subtype expand ───────────────────────────────── */
.subtype-row {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows .22s var(--ease);
}
.subtype-row.is-open { grid-template-rows: 1fr; }
.subtype-row__inner { min-height: 0; padding-top: 6px; }

/* ── Year row ─────────────────────────────────────── */
/* 학년도 칩: 균일 폭 그리드 — '전체'와 'NN학년도' 길이가 달라도 칸 정렬 유지 */
.year-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 6px;
}
.year-row .pill {
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 8px;
}

/* 학년도 칩 그룹 헤더 — "고3" 처럼 여러 curriculum 합치는 탭에서
   "── 2015 개정 ──" / "── 2009 개정 ──" 식 구분 (B안). 첫 헤더는 위 마진 0. */
.year-row__header {
  grid-column: 1 / -1;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink-4);
  padding: 6px 2px 2px;
  margin-top: 6px;
}
.year-row__header:first-child { margin-top: 0; padding-top: 0; }

/* ── Subject ──────────────────────────────────────── */
.subject-list { display: flex; flex-direction: column; gap: 2px; }
.subject-item { display: flex; flex-direction: column; }

.subject-row {
  width: 100%;
  display: grid;
  grid-template-columns: 8px 1fr 22px 10px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  background: none;
  text-align: left;
  color: var(--ink-2);
  transition: background var(--t), color var(--t);
  height: 34px;
  font: inherit;
}
.subject-row:hover { background: var(--surface-2); color: var(--ink); }
.subject-row.is-active { background: var(--surface-hover); color: var(--ink); }

.subject-row__dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--subject-color, var(--ink-5));
  flex-shrink: 0;
}
.subject-row__name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-row.is-active .subject-row__name { font-weight: 600; }

.subject-row__count {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

.subject-row__caret {
  width: 10px;
  font-size: 11px;
  color: var(--ink-4);
  transition: transform var(--t);
  line-height: 1;
  text-align: center;
}
.subject-row:not(.has-subs) .subject-row__caret { visibility: hidden; }
.subject-row.is-open .subject-row__caret { transform: rotate(90deg); color: var(--ink-2); }

.subject-subs {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows .22s var(--ease);
}
.subject-subs.is-open { grid-template-rows: 1fr; }
.subject-subs__inner {
  min-height: 0;
  padding: 2px 0 4px 26px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sub-row {
  padding: 6px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  text-align: left;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  transition: var(--t);
}
.sub-row:hover { background: var(--surface-2); color: var(--ink); }
.sub-row.is-active { color: var(--ink); font-weight: 600; background: var(--surface-hover); }

/* ═══ Content ═════════════════════════════════════════════ */
.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Toolbar ──────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search__icon {
  position: absolute;
  left: 12px;
  color: var(--ink-4);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
#searchInput::placeholder { color: var(--ink-4); }
#searchInput:focus {
  border-color: var(--pop);
  box-shadow: 0 0 0 3px var(--pop-soft);
}

.search__clear {
  position: absolute;
  right: 8px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-hover);
  border-radius: 99px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1;
}
.search__clear:hover { background: var(--ink-6); color: var(--ink); }

.toolbar__right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.count {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-text {
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: var(--t);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.btn-text:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.btn-text:focus-visible {
  outline: 2px solid var(--pop);
  outline-offset: 2px;
}

/* ── Active tags ──────────────────────────────────── */
.active-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.active-tags:empty { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  transition: background 160ms var(--ease);
}
.tag:hover { background: var(--ink-2); }
.tag button {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms var(--ease);
}
.tag button:hover { background: rgba(255,255,255,.36); }

/* ═══ Cards Grid ══════════════════════════════════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* ── Card ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color 180ms var(--ease),
              box-shadow   220ms var(--ease-out),
              transform    220ms var(--ease-out),
              background   180ms var(--ease);
  position: relative;
  isolation: isolate;
  will-change: transform;
}
.card:hover {
  border-color: var(--ink-5);
  transform: translateY(-1px);
  background: var(--surface);
}
.card:focus-within { box-shadow: 0 0 0 3px var(--pop-soft); border-color: var(--pop); }

.card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chiplet {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.1px;
  font-variant-numeric: tabular-nums;
}
.chiplet--ink   { background: var(--surface-2); color: var(--ink-2); }
.chiplet--type  { background: var(--chip-bg, var(--pop-soft)); color: var(--chip-color, var(--pop)); }

.card__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__divider {
  margin: 14px 0 12px;
  height: 1px;
  background: var(--line-soft);
}

.card__actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

/* available emphasis — 보더만 살짝 강조 (파란 점은 시각 노이즈라 제거) */
.card.has-files { border-color: var(--ink-6); }

/* ═══ Buttons ═════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: var(--t);
  white-space: nowrap;
  flex: 1;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.btn:disabled, .btn[disabled] {
  background: var(--surface);
  color: var(--ink-5);
  cursor: not-allowed;
  border-color: var(--line-soft);
}

.btn--primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn--primary:hover { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn--primary:disabled, .btn--primary[disabled] {
  background: var(--surface-2);
  color: var(--ink-5);
  border-color: var(--line);
}

.btn--ghost { background: none; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }

/* ═══ Skeleton ════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -800px 0; }
  100% { background-position:  800px 0; }
}
@keyframes skel-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}
.skel-card {
  height: 168px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background:
    linear-gradient(90deg,
      transparent 0,
      rgba(255,255,255,0.55) 50%,
      transparent 100%) 0 0 / 800px 100% no-repeat,
    var(--surface-2);
  position: relative;
  overflow: hidden;
  animation: shimmer 1.4s infinite linear, skel-pulse 1.8s ease-in-out infinite;
}
.skel-card::before,
.skel-card::after {
  content: '';
  position: absolute;
  left: 16px;
  background: var(--surface);
  border-radius: 4px;
}
.skel-card::before { top: 18px; width: 56px;  height: 14px; }
.skel-card::after  { top: 44px; width: 130px; height: 18px; }
@media (prefers-reduced-motion: reduce) {
  .skel-card { animation: skel-pulse 1.6s ease-in-out infinite; }
}

/* ═══ Pagination ══════════════════════════════════════════ */
.pagination-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0 4px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pg-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: var(--t);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-btn:hover:not(:disabled):not(.is-active) {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}
.pg-btn.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 700;
}
.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pg-btn.pg-arrow {
  font-size: 16px;
  color: var(--ink-3);
}
.pg-ellipsis {
  min-width: 28px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}
.pg-info {
  font-size: 11.5px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* ═══ Empty state ═════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 72px 24px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty__illu {
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(12,10,9,0.04));
  animation: empty-float 4s ease-in-out infinite;
}
@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.empty__mark  { color: var(--ink-5); margin-bottom: 4px; }
.empty__title { font-size: 16px; font-weight: 700; color: var(--ink); }
.empty__sub   { font-size: 13px; color: var(--ink-4); max-width: 320px; line-height: 1.6; }
/* placeholder 탭: 일러스트만 살짝 더 흐리게 — "결과 없음" 과 톤 분리 */
.empty.is-placeholder .empty__illu { opacity: 0.6; }
.empty .btn   {
  margin-top: 14px;
  flex: unset;
  min-height: var(--tap);
  padding: 0 22px;
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .empty__illu { animation: none; }
}

/* ═══ Footer ══════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-4);
  background: var(--bg);
  line-height: 1.8;
}
.site-footer__sub { color: var(--ink-5); font-size: 11px; margin-top: 2px; }
.site-footer__legal {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-5);
}
.site-footer__legal a {
  color: var(--ink-3);
  text-decoration: none;
  margin: 0 4px;
}
.site-footer__legal a:hover { color: var(--ink-1); text-decoration: underline; }
.site-footer--landing { padding: 18px 0; border-top: none; }

/* ═══ Legal pages (privacy / terms) ═══════════════════════ */
.legal {
  max-width: 760px;
  padding: 32px 24px 80px;
  line-height: 1.75;
  color: var(--ink-2);
}
.legal__head { margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.legal__title { font-size: 28px; font-weight: 700; color: var(--ink-1); margin: 0 0 6px; }
.legal__sub { font-size: 13px; color: var(--ink-5); margin: 0; }
.legal__section { margin: 28px 0; }
.legal__section h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-1);
  margin: 0 0 10px;
}
.legal__section p { margin: 8px 0; font-size: 14.5px; }
.legal__section ul { margin: 8px 0 8px 20px; padding: 0; }
.legal__section li { margin: 4px 0; font-size: 14.5px; }
.legal__section a { color: var(--accent); text-decoration: underline; }
.legal__section a:hover { opacity: 0.8; }
@media (max-width: 600px) {
  .legal { padding: 24px 18px 60px; }
  .legal__title { font-size: 22px; }
  .legal__section h2 { font-size: 16px; }
}

/* ═══ Responsive ══════════════════════════════════════════ */
@media (max-width: 960px) {
  .main {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 48px;
    padding-bottom: 40px;
  }

  .filter {
    position: static;
    max-height: none;
    overflow: visible;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
  }

  .icon-btn { display: inline-flex; }
  .container { padding: 0 18px; }
}

@media (max-width: 600px) {
  .container { padding: 0 14px; }
  .filter { grid-template-columns: 1fr; }
  /* .grid / .nav-tab 모바일 규칙은 파일 후반 통합 모바일 블록에서 정의 */
}

/* ╔══════════════════════════════════════════════════════════
   ║  Landing Page (index.html) — minimal
   ╚══════════════════════════════════════════════════════════ */

.page-landing { background: var(--bg); }

.landing-min {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  padding: 60px 0;
}

.hero-min {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 0 28px;
}

.hero-min__eyebrow {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-4);
  margin-bottom: 18px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.hero-min__title {
  font-size: clamp(56px, 10vw, 128px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.055em;
  color: var(--ink);
  margin-bottom: 52px;
}

.hero-min__line {
  display: block;
}

/* 두 번째 라인에 그라데이션 포인트 */
.hero-min__line--accent {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink) 38%, var(--pop) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* CTA 카드 (메인) */
.cta-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 760px;
}

.cta-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 26px 26px 28px;
  border-radius: var(--cta-radius);
  text-decoration: none;
  isolation: isolate;
  transition:
    transform   220ms var(--ease-out),
    box-shadow  220ms var(--ease-out),
    border-color 180ms var(--ease),
    background  180ms var(--ease);
  will-change: transform;
}

.cta-card:focus-visible {
  outline: 2px solid var(--pop);
  outline-offset: 3px;
}

.cta-card__eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.55;
}

.cta-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}

.cta-card__icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(127,127,127,0.10);
  color: currentColor;
  transition: background 180ms var(--ease), transform 220ms var(--ease-out);
}

.cta-card__arrow {
  color: currentColor;
  opacity: 0.5;
  transition: transform 220ms var(--ease-out), opacity 180ms var(--ease);
}

.cta-card:hover .cta-card__arrow,
.cta-card:focus-visible .cta-card__arrow {
  opacity: 1;
  transform: translateX(6px);
}

.cta-card__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: currentColor;
  line-height: 1.2;
}

.cta-card__sub {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.55;
  color: currentColor;
  opacity: 0.72;
}

/* 테마 변형 */
.cta-card--dark {
  background: var(--cta-dark-bg);
  color: var(--cta-dark-fg);
  border: 1px solid var(--cta-dark-bg);
}
.cta-card--dark .cta-card__icon-wrap { background: rgba(255,255,255,0.08); }
.cta-card--dark .cta-card__sub       { color: var(--cta-dark-sub); opacity: 1; }
.cta-card--dark:hover {
  background: var(--cta-dark-bg-hover);
  transform: translateY(-2px);
}
.cta-card--dark:hover .cta-card__icon-wrap { background: rgba(255,255,255,0.14); }

.cta-card--light {
  background: var(--cta-light-bg);
  color: var(--cta-light-fg);
  border: 1px solid var(--cta-light-line);
}
.cta-card--light .cta-card__sub { color: var(--cta-light-sub); opacity: 1; }
.cta-card--light:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}
.cta-card--light:hover .cta-card__icon-wrap { background: rgba(12,10,9,0.06); }

/* 모션 줄이기 — 시스템 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  .cta-card,
  .cta-card__arrow,
  .cta-card__icon-wrap { transition: none; }
  .cta-card:hover { transform: none; }
  .cta-card:hover .cta-card__arrow { transform: none; }
}

@media (max-width: 600px) {
  .landing-min { padding: 40px 0; }
  .hero-min { padding: 0 18px; }
  .hero-min__eyebrow { margin-bottom: 14px; font-size: 11.5px; }
  .hero-min__title { margin-bottom: 36px; }
  .cta-cards { grid-template-columns: 1fr; max-width: 480px; gap: 12px; }
}

/* ╔══════════════════════════════════════════════════════════
   ║  Header Nav (archive/gradecut 페이지 공통)
   ╚══════════════════════════════════════════════════════════ */
.header-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.header-nav a {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  transition: var(--t);
}
.header-nav a:hover { color: var(--ink); background: var(--surface-2); }
.header-nav a.is-active { color: var(--ink); background: var(--surface-2); }

/* ╔══════════════════════════════════════════════════════════
/* ╔══════════════════════════════════════════════════════════
   ║  Grade Cut Calculator — 시험 전체 입력 + 영역별 + 종합
   ╚══════════════════════════════════════════════════════════ */
.page-gradecut { background: var(--bg); }

/* 시험 미선택 안내 */
.gc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 100px 20px;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 420px;
}
.gc-empty__icon { color: var(--ink-5); margin-bottom: 8px; }
.gc-empty__title { font-size: 16px; font-weight: 700; color: var(--ink); }
.gc-empty__sub   { font-size: 13px; color: var(--ink-4); }

/* 시험 선택 후 wrapper */
.gc-exam-wrap { display: flex; flex-direction: column; gap: 18px; }

.gc-exam-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.gc-exam-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.gc-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  font-family: inherit;
  transition: var(--t);
}
.gc-reset-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }

/* ── 영역 카드 그리드 ───────────────────────────────────── */
.subj-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.subj-card--multi { grid-column: span 2; }

@media (max-width: 720px) {
  .subj-grid { grid-template-columns: 1fr; }
  .subj-card--multi { grid-column: span 1; }
}

.subj-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}

.subj-card__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.subj-card__icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}
.subj-card__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.subj-card__body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.subj-card--multi .subj-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
  padding: 16px 18px 18px;
}
@media (max-width: 720px) {
  .subj-card--multi .subj-card__body { grid-template-columns: 1fr; }
}

/* ── 슬롯 (개별 입력 단위) ───────────────────────────────── */
.subj-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.subj-card--multi .subj-slot:not(:first-child) {
  border-left: 1px solid var(--line-soft);
  padding-left: 22px;
}
@media (max-width: 720px) {
  .subj-card--multi .subj-slot:not(:first-child) {
    border-left: none;
    border-top: 1px solid var(--line-soft);
    padding-left: 0;
    padding-top: 14px;
  }
}

.subj-slot__num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink-4);
}

.subj-slot__subs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.subj-slot__subs .pill {
  padding: 4px 10px;
  font-size: 11.5px;
}
.subj-slot__subs .pill.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.subj-slot__input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.subj-input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}
.subj-input:focus {
  border-color: var(--pop);
  box-shadow: 0 0 0 3px var(--pop-soft);
}
.subj-input:disabled {
  background: var(--surface-2);
  color: var(--ink-5);
  cursor: not-allowed;
}
.subj-input::-webkit-outer-spin-button,
.subj-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.subj-input__unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-4);
  white-space: nowrap;
}

.subj-slot__result {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.subj-result__grade {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.subj-result__suffix { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.subj-result__sep    { color: var(--ink-5); }
.subj-result__pct    { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.subj-slot__hint {
  font-size: 12px;
  color: var(--ink-4);
  font-style: italic;
  padding: 4px 0;
}

/* ── Mini Linear Bar (영역 카드 안) ──────────────────────── */
.mini-bar {
  margin-top: 4px;
  padding-bottom: 4px;
}
.mini-bar__track {
  position: relative;
  height: 8px;
  background: linear-gradient(to right,
    rgba(220,38,38,0.18) 0%,
    rgba(234,88,12,0.18) 30%,
    rgba(202,138,4,0.18) 50%,
    rgba(101,163,13,0.18) 70%,
    rgba(21,128,61,0.20) 100%);
  border-radius: 99px;
}
.mini-bar__tick {
  position: absolute;
  top: -2px;
  width: 1px;
  height: 12px;
  background: var(--ink-5);
  transform: translateX(-50%);
  opacity: 0.6;
}
.mini-bar__marker {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  transition: left .25s var(--ease-out);
  pointer-events: none;
}
.mini-bar__dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 99px;
  background: var(--marker-color, var(--ink));
  border: 3px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.mini-bar__axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10px;
  color: var(--ink-5);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── 종합 분석 카드 ─────────────────────────────────────── */
.total-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 22px 24px;
  margin-top: 6px;
}
.total-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.total-card__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.total-card__hint {
  font-size: 12px;
  color: var(--ink-4);
  font-weight: 500;
}

.total-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 16px 0 22px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}
.total-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.total-stat__num {
  font-size: clamp(36px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.total-stat__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-4);
}
.total-stat__divider { width: 1px; height: 56px; background: var(--line); }

/* 영역별 막대 */
.total-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.total-bar {
  display: grid;
  grid-template-columns: 130px 1fr 100px;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  .total-bar { grid-template-columns: 1fr; gap: 4px; }
}
.total-bar__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.total-bar__track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.total-bar__fill {
  height: 100%;
  border-radius: 99px;
  transition: width .3s var(--ease-out);
}
.total-bar__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
  font-variant-numeric: tabular-nums;
}
.total-bar__grade {
  font-size: 13px;
  font-weight: 700;
}
.total-bar__pct {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 500;
}

/* gradecut 페이지는 curriculum-nav 가 없으니 .filter sticky 위치 보정 */
.page-gradecut .filter {
  top: calc(var(--header-h) + 28px);
}

/* ═══════════════════════════════════════════════════════════
   Motion & Polish — card stagger · micro-interactions · VT
   ═══════════════════════════════════════════════════════════ */

/* Card entrance — delay set inline via JS */
@keyframes card-enter {
  from { opacity: 0; translate: 0 14px; }
  to   { opacity: 1; translate: 0 0;   }
}
#cardsGrid .card {
  animation: card-enter 0.45s var(--ease-out) both;
}

/* Micro-interactions — press feedback (Apple system-wide 0.95) */
.pill:active                { scale: 0.95; }
.nav-tab:active             { scale: 0.95; }
.btn:active:not([disabled]) { scale: 0.95; }
.cta-card:active            { scale: 0.99; }
.pg-btn:active:not(:disabled):not(.is-active) { scale: 0.95; }
.qa-cell:active             { scale: 0.97; }

/* View Transition — curriculum tab switch */
.main { view-transition-name: main-content; }

::view-transition-old(main-content) {
  animation: 160ms ease-in both _vt-out;
}
::view-transition-new(main-content) {
  animation: 360ms var(--ease-out) 60ms both _vt-in;
}
@keyframes _vt-out { to   { opacity: 0; transform: translateY(-5px); } }
@keyframes _vt-in  { from { opacity: 0; transform: translateY(8px);  } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #cardsGrid .card { animation: none !important; opacity: 1; }
  .pill:active, .nav-tab:active, .btn:active,
  .cta-card:active, .pg-btn:active, .qa-cell:active { scale: 1; }
  .main { view-transition-name: none; }
}

/* ═══════════════════════════════════════════════════════════
   Responsive Polish
   ═══════════════════════════════════════════════════════════ */

/* Curriculum nav — 가로 스크롤 있음을 오른쪽 fade로 표시
   (position: sticky가 이미 containing block 역할 → relative 추가 불필요) */
.curriculum-nav::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  z-index: 2;
}

/* ╔═══════════════════════════════════════════════════════
   ║  Filter sheet head / actions (모바일 바텀시트 전용 UI)
   ║  데스크톱(961px+)에서는 숨김
   ╚═══════════════════════════════════════════════════════ */
.filter__sheet-head,
.filter__sheet-actions { display: none; }

@media (max-width: 960px) {
  .filter__sheet-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 6px 4px 14px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 4px;
    position: relative;
  }
  .filter__sheet-handle {
    grid-column: 2;
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--line-strong);
    margin: 0 auto 10px;
  }
  .filter__sheet-title {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
  }
  .filter__sheet-close {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    width: var(--tap);
    height: var(--tap);
    border: none;
    background: transparent;
    color: var(--ink-3);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 140ms var(--ease), color 140ms var(--ease);
  }
  .filter__sheet-close:hover { background: var(--surface-2); color: var(--ink); }

  .filter__sheet-actions {
    display: flex;
    gap: 8px;
    padding: 12px 0 4px;
    margin-top: auto;
    border-top: 1px solid var(--line-soft);
    position: sticky;
    bottom: 0;
    background: var(--surface);
  }
  .filter__sheet-actions .btn { flex: 1; min-height: var(--tap); }
  .filter__sheet-actions .btn--ghost { flex: 0 0 auto; min-width: 96px; }
}

/* ╔═══════════════════════════════════════════════════════
   ║  Bottom Sheet — 모바일 (≤960px) 에서만 fixed sheet
   ║  닫힘: translateY(100%), 열림(.is-open): translateY(0)
   ╚═══════════════════════════════════════════════════════ */
.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease);
}
.filter-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 961px) {
  .filter-backdrop { display: none !important; }
}
@media (max-width: 960px) {
  /* 데스크톱 스타일을 덮어쓰기 — 모바일에서는 fixed sheet */
  .filter {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    z-index: 95;
    display: flex !important;
    flex-direction: column;
    grid-template-columns: none;
    width: 100%;
    max-width: none;
    max-height: var(--sheet-max-h);
    margin: 0;
    padding: 14px 18px 18px;
    border: none;
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    background: var(--surface);
    box-shadow: var(--sheet-shadow);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateY(100%);
    transition: transform 280ms var(--ease-out);
    gap: 22px;
  }
  .filter.is-open { transform: translateY(0); }
  /* iOS 노치 안전 영역 */
  .filter { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* body 스크롤 락 (모바일 시트 열렸을 때) */
body.is-sheet-open { overflow: hidden; touch-action: none; }
@media (min-width: 961px) {
  body.is-sheet-open { overflow: visible; touch-action: auto; }
}

/* Filter toggle 배지 — 활성 필터 수 표시 */
#filterToggle { position: relative; }
.filter-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  padding: 0 3px;
  border-radius: 99px;
  background: var(--pop);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* Inline filter toggle — 모바일 전용, 검색창 바로 옆 */
.filter-toggle-inline {
  display: none;
  position: relative;
  white-space: nowrap;
  padding: 0 16px;
  height: var(--tap);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  align-items: center;
}
@media (max-width: 960px) {
  .filter-toggle-inline { display: inline-flex; }
  /* archive 페이지(인라인 필터 버튼 존재)에서만 헤더 아이콘 버튼 숨김 */
  body:has(.filter-toggle-inline) #filterToggle { display: none; }
}

/* Toolbar — 모바일 한 줄: [검색 | 필터 | 초기화]. 4건 카운트는 검색 input 안 우측 */
@media (max-width: 600px) {
  .toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
  }
  .search                { flex: 1 1 auto; min-width: 0; }
  .filter-toggle-inline  { flex: 0 0 auto; padding: 0 12px; font-size: 12.5px; }
  .toolbar__right        {
    flex: 0 0 auto;
    gap: 6px;
    margin-left: 0;
  }
  .toolbar__right .count { font-size: 12px; color: var(--ink-5); }
  .toolbar__right .btn-text { padding: 0 8px; font-size: 12.5px; }

  /* 검색창↔카드는 타이트하게 — 카테고리↔검색창은 .main padding-top 으로 별도 컨트롤 */
  .content { gap: 10px; }
}

/* Sticky 영역 높이 — 모바일 nav 한 줄 압축 (sub 라벨 숨김 → 콘텐츠 overflow 방지) */
@media (max-width: 600px) {
  :root              { --nav-h: 44px; --header-h: 46px; }
  .brand__name       { font-size: 14px; }

  /* 카테고리 탭: 두 줄(title+sub) → 한 줄(title만) + 가로 스크롤 fade 강화
     padding-top/bottom 0 → height(44px) + align-items: center 로 자동 중앙 */
  .curriculum-nav__inner { gap: 8px; padding: 0 14px; align-items: center; }
  .nav-group         { flex-direction: row; align-items: center; gap: 2px; }
  .nav-group__label  { display: none; }
  .nav-group__tabs   { gap: 2px; }
  .nav-tab           { flex-direction: row; padding: 7px 9px; gap: 0; border-radius: 8px; min-width: 0; }
  .nav-tab__sub      { display: none; }
  .nav-tab__title    { font-size: 12px; line-height: 1.2; letter-spacing: -0.2px; }
  .nav-sep           { margin: 0; height: 14px; align-self: center; }
  /* 가로 스크롤 끝 fade를 좀 더 두껍게 — 잘림이 아닌 스크롤임을 시각적으로 알림 */
  .curriculum-nav::after { width: 28px; }
}

/* 모바일 터치 타겟 44×44 보장 — Apple/Google HIG 권장 */
@media (max-width: 960px) {
  .card__actions .btn { min-height: var(--tap); height: var(--tap); }
  .pg-btn             { min-height: var(--tap); min-width: var(--tap); }
  .btn-text           { min-height: var(--tap); padding: 0 14px; }
  #emptyResetBtn      { min-height: var(--tap); padding: 0 22px; }
  .icon-btn           { width: var(--tap); height: var(--tap); }
}

/* 카드 모바일 — 600px 이하 항상 2열 유지(다운로드 버튼이 가까이 보이도록).
   grid container chain(.main → .content → .grid)에 min-width: auto가 남아
   자식의 min-content가 부모 폭을 키우면 viewport를 넘침. cascade를 강제 차단 */
@media (max-width: 600px) {
  .main, .main > *, .content, .content > * { min-width: 0; max-width: 100%; }
  /* flex 1열 fix — 명시적 50% 폭으로 viewport 봉쇄 (minmax보다 강함) */
  .grid              { display: flex; flex-wrap: wrap; gap: 8px; }
  .grid > .card,
  .grid > .skel-card { flex: 0 0 calc(50% - 4px); width: calc(50% - 4px); min-width: 0; }
  .card              { padding: 12px 12px 10px; border-radius: 10px; }
  .card__title, .card__sub, .card__meta { min-width: 0; max-width: 100%; }
  .card__meta        { margin-bottom: 8px; }
  .card__title       { font-size: 14.5px; }
  .card__sub         { font-size: 11.5px; margin-top: 3px; }
  .card__divider     { margin: 10px 0 8px; }
  .card__actions     { gap: 4px; }
  .card__actions .btn { font-size: 11.5px; padding: 0 8px; min-height: 38px; height: 38px; }
}

/* 극소 화면 — 카드 1열로 가서 화면이 휑해지는 것 방지: 2열 유지 */
@media (max-width: 360px) {
  .grid          { gap: 6px; }
  .card          { padding: 10px 10px 9px; }
  .card__title   { font-size: 13.5px; }
  .card__actions .btn { padding: 0 6px; }
}

/* ╔══════════════════════════════════════════════════════════
   ║  Gradecut & 공통 모바일 최적화
   ╚══════════════════════════════════════════════════════════ */

/* gc-exam-head — 모바일에서 액션 버튼들이 줄바꿈 */
.gc-exam-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.gc-change-btn {
  display: none; /* 데스크탑에서 숨김 — 모바일에서만 노출 */
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.gc-empty__cta {
  display: none;
  margin-top: 14px;
  padding: 0 22px;
  height: 40px;
  font-size: 13px;
  font-weight: 600;
}

/* 모바일: 등급컷 시험 변경 버튼 + empty 페이지 CTA 노출 */
@media (max-width: 960px) {
  .gc-change-btn { display: inline-flex; align-items: center; }
  .gc-empty__cta { display: inline-flex; align-items: center; justify-content: center; }
}

/* 모바일 — 등급컷 페이지 콤팩트 타이포 + 패딩 */
@media (max-width: 720px) {
  .gc-exam-head      { flex-wrap: wrap; gap: 8px; }
  .gc-exam-title     { font-size: 18px; flex: 1 1 100%; }
  .gc-exam-head__actions { width: 100%; justify-content: flex-end; }

  .gc-empty          { padding: 60px 20px; min-height: 280px; }
  .gc-empty__title   { font-size: 15px; }
  .gc-empty__sub     { font-size: 12.5px; }

  .total-card        { padding: 18px 16px 20px; border-radius: 12px; }
  .total-stats       { gap: 16px; padding: 12px 0 18px; margin-bottom: 14px; }
  .total-stat__num   { font-size: clamp(28px, 9vw, 36px); }
  .total-card__head  { margin-bottom: 14px; }

  .subj-card                        { border-radius: 12px; }
  .subj-card__head                  { padding: 12px 14px 10px; }
  .subj-card__body                  { padding: 12px 14px 16px; gap: 12px; }
  .subj-card--multi .subj-card__body { padding: 14px 14px 16px; }
  .subj-card__title                 { font-size: 14px; }

  .subj-input        { font-size: 16px; height: 38px; }  /* iOS 16px = no zoom */
}

/* 더 작은 폰: 종합 통계 세로 배치 */
@media (max-width: 420px) {
  .total-stats        { flex-direction: column; gap: 14px; }
  .total-stat__divider { width: 56px; height: 1px; }
  .gc-exam-head__actions { flex-wrap: wrap; gap: 6px; }
}

/* 검색 인풋 iOS 자동 줌 방지 (16px 이상이면 줌 없음) */
@media (max-width: 600px) {
  #searchInput { font-size: 16px; }
  .subj-input  { font-size: 16px; }
}

/* 헤더 — 좁은 화면에서 nav 라벨이 폭을 잠식하는 문제 해결: nav 자체 숨김
   (등급컷은 index 카드/footer에서 진입) */
@media (max-width: 600px) {
  .site-header__inner { gap: 8px; }
  .header-nav         { display: none; }
  .icon-btn           { width: 36px; height: 36px; }
}

/* 활성 태그 줄바꿈 — 좁은 화면에서 readable */
@media (max-width: 600px) {
  .active-tags { gap: 5px; }
  .active-tags .tag { font-size: 11.5px; padding: 3px 8px; }
}

/* 랜딩 — Hero 글자 크기 + CTA 카드 */
@media (max-width: 600px) {
  .hero-min__title { font-size: clamp(48px, 14vw, 80px); margin-bottom: 28px; }
  .cta-card        { padding: 22px 22px 24px; }
  .cta-card__title { font-size: 18px; }
}

/* iOS Safari 100vh 이슈 회피 */
@supports (-webkit-touch-callout: none) {
  .landing-min { min-height: -webkit-fill-available; }
}

/* ╔══════════════════════════════════════════════════════════
   ║  Detail Page (exam.html) — 미리보기 + 빠른정답
   ╚══════════════════════════════════════════════════════════ */

/* archive 카드 전체 클릭 영역 — 카드 어느 곳을 눌러도 상세로 이동.
   텍스트/메타는 pointer-events: none 으로 클릭을 link 에 통과시키고,
   다운로드 버튼만 z-index 로 위에 올려 개별 클릭 보장 */
.card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  text-indent: -9999px;
  white-space: nowrap;
  overflow: hidden;
}
.card__link:focus-visible {
  outline: 2px solid var(--pop);
  outline-offset: 2px;
}
.card__meta,
.card__title,
.card__sub,
.card__divider { pointer-events: none; }
.card__actions  { position: relative; z-index: 2; }

/* ── exam 메인 레이아웃 — 좌(메타) / 우(미리보기) 2열 grid ─── */
.exam {
  padding-top: 14px;
  padding-bottom: 40px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  column-gap: 28px;
  align-items: start;
}

/* 좌측 사이드바 */
.exam__side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: calc(var(--header-h) + 14px);
  align-self: start;
  min-width: 0;
}

/* 우측 메인 */
.exam__main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* 뒤로가기 — 컴팩트하게 */
.exam__crumb { display: flex; align-items: center; }
.exam__back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.exam__back:hover { color: var(--ink); background: var(--surface-2); }

/* 헤드 — 사이드바 안 세로 스택 */
.exam__head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.exam__chips    { display: flex; flex-wrap: wrap; gap: 6px; }
.exam__title    {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.35;
  color: var(--ink);
  margin: 0;
}
.exam__sub      { font-size: 12.5px; color: var(--ink-4); margin: 0; }
/* 다운로드 버튼들 — 사이드바 폭에 맞춰 가로로 균등 분배 */
.exam__actions  { display: flex; flex-wrap: wrap; gap: 8px; }
.exam__actions .btn { flex: 1 1 0; min-height: 38px; }

/* chiplet — exam 페이지 전용 작은 chip */
.chiplet {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.1px;
}
.chiplet--ink   { background: var(--surface-2); color: var(--ink-2); }
.chiplet--type  { background: var(--chip-bg, var(--pop-soft)); color: var(--chip-color, var(--pop)); }
.chiplet--soft  { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }

/* KPI 메트릭 행 — 대시보드 스타일 */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 140ms var(--ease);
}
.kpi:hover { border-color: var(--ink-6); }
.kpi__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.kpi__value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
  line-height: 1.1;
  font-feature-settings: 'tnum' 1;
}

/* 본문 그리드 — 더 이상 사용하지 않음 (탭 기반으로 전환) */
.exam__grid {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 460px);
  gap: 32px;
  align-items: start;
  justify-content: center;
}

/* 탭 네비 — 사이드바 안 세로 스택 (각 탭이 가로 풀폭) */
.exam__tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}
.exam-tab {
  appearance: none;
  background: none;
  border: 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-4);
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  border-left: 2px solid transparent;
  transition: color 140ms var(--ease), background 140ms var(--ease), border-color 140ms var(--ease);
}
.exam-tab:hover { color: var(--ink-2); background: var(--surface-2); }
.exam-tab.is-active {
  color: var(--ink);
  background: var(--surface-2);
  border-left-color: var(--ink);
}
.exam-tab:focus-visible { outline: 2px solid var(--pop); outline-offset: 2px; }
.exam__tabs-hint {
  font-size: 11.5px;
  color: var(--ink-5);
  margin: 0;
  padding: 0 4px;
}

/* 탭 컨텐츠 — 가운데 정렬, 폭 일관 */
.exam-pane { display: flex; flex-direction: column; }
.exam-pane[hidden] { display: none !important; }   /* author display:flex 가 UA hidden 을 덮어쓰는 것 방지 */
.exam-pane[data-pane="paper"] { align-items: center; }
.exam-pane[data-pane="info"]  { gap: 18px; }
.exam-pane[data-pane="info"] > .exam-card,
.exam-pane[data-pane="info"] > .kpi-row {
  width: 100%;
  max-width: 720px;
  align-self: center;
}

/* 미리보기 영역 */
.exam__previews {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  align-self: center;
}
.preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.preview__title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0; }
.preview__meta  { font-size: 12px; color: var(--ink-5); }
.preview__viewer {
  padding: 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  /* 줌인 시 페이지가 컨테이너 폭 초과하면 가로 스크롤 허용 */
  overflow-x: auto;
}
.preview__page {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  /* 사이드바 분리 후엔 site-header + exam padding + preview head 만 빼면 됨 (~150px) */
  max-height: calc(100vh - 160px);
  /* 모바일 주소창 영향 받는 환경(Safari 등)에서 더 정확한 동적 viewport */
  max-height: calc(100dvh - 160px);
  background: #fff;
  /* Apple 식 product shadow — UI 에서 그림자가 나오는 유일한 곳.
     "종이 한 장이 회색 표면 위에 떠 있다" 느낌이 핵심 */
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--sh-paper);
  margin: 0 auto;
}
.preview__more {
  align-self: stretch;
  margin-top: 4px;
  padding: 12px 16px;
  border: 1px dashed var(--line-strong);
  background: var(--surface);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.preview__more:hover { background: var(--surface-hover); color: var(--ink); border-color: var(--ink-5); }
.preview__more:disabled { opacity: 0.6; cursor: progress; }
.preview__skeleton {
  height: 280px;
  background: linear-gradient(110deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: previewShimmer 1.4s linear infinite;
}
@keyframes previewShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.preview__error,
.preview__unsupported,
.preview__empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.preview__error-title,
.preview__unsupported-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0; }
.preview__error-sub,
.preview__unsupported-sub   { font-size: 12.5px; margin: 0; }
.preview__error-detail {
  font-size: 11.5px;
  color: var(--ink-5);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 6px;
  word-break: break-all;
  max-width: 100%;
}
.preview__empty p { font-size: 13px; color: var(--ink-4); margin: 0; }

/* 사이드 */
.exam__side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--header-h) + 18px);
  align-self: start;
}
.exam-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 18px;
}
.exam-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.exam-card__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--ink);
  margin: 0;
}
.exam-card__hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-5);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 99px;
}
.exam-card__body { display: flex; flex-direction: column; gap: 12px; }
.exam-card__sub {
  font-size: 12px;
  color: var(--ink-5);
  margin: 0;
  line-height: 1.55;
}
.exam-card--placeholder {
  background: var(--surface-2);
  border-style: dashed;
}

/* 정답별 응답률 차트 (placeholder 가능) */
.rate-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rate-chart--placeholder { opacity: 0.6; }
.rate-bar {
  display: grid;
  grid-template-columns: 14px 1fr 28px;
  align-items: center;
  gap: 10px;
}
.rate-bar__num {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  text-align: center;
}
.rate-bar__track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.rate-bar__fill {
  display: block;
  height: 100%;
  background: var(--ink-5);
  border-radius: inherit;
  transition: width 360ms var(--ease-out);
}
.rate-bar__pct {
  font-size: 11px;
  color: var(--ink-5);
  text-align: right;
  font-feature-settings: 'tnum' 1;
}

/* 빠른정답 grid — 격자형 깔끔 */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}
.qa-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 140ms var(--ease), background 140ms var(--ease), transform 140ms var(--ease);
}
.qa-cell:hover {
  border-color: var(--ink-5);
  background: var(--surface-2);
}
.qa-cell__num {
  font-size: 10.5px;
  color: var(--ink-5);
  font-weight: 600;
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0.2px;
}
.qa-cell__ans {
  font-size: 16px;
  color: var(--ink);
  font-weight: 700;
  margin-top: 2px;
  font-feature-settings: 'tnum' 1;
  line-height: 1.1;
}
.qa-cell--missing {
  border-style: dashed;
  background: var(--surface-2);
}
.qa-cell--missing .qa-cell__ans { color: var(--ink-5); }
.qa-loading {
  padding: 22px 14px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

/* 등급 분포 — 표준정규분포 히스토그램 (forest green 1등급 + warm stone scale) */
.grade-dist__svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
}
/* 9 등급 막대 색상.
   1등급 = 사이트 액센트 블루 (--pop-darker). 2~9등급 = warm ink-3 동일 톤.
   warm stone neutrals 위 cool blue 한 점 — NYT/Stripe 식 single-accent histogram. */
.grade-dist__bar          { fill: var(--ink-3); }
.grade-dist__bar--g1      { fill: var(--pop-darker); }

.grade-dist__baseline {
  stroke: var(--ink);
  stroke-width: 1;
}
.grade-dist__tick {
  stroke: var(--ink-4);
  stroke-width: 1;
}
.grade-dist__cut {
  text-anchor: middle;
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--ink);
  font-family: inherit;
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0.1px;
  pointer-events: none;
}
.grade-dist__num {
  text-anchor: middle;
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--ink-4);
  font-family: inherit;
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0.4px;
  pointer-events: none;
}
/* 1등급 라벨도 액센트 블루로 — 막대와 시각 연결 */
.grade-dist__num--g1 { fill: var(--pop-darker); font-weight: 700; }
.grade-dist__legend {
  margin: 12px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-5);
  letter-spacing: 0.1px;
}

/* 에러 박스 */
.exam__error {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
}
.exam__error { grid-column: 1 / -1; }
.exam__error-title { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0; }
.exam__error-sub   { font-size: 13px; color: var(--ink-4); margin: 6px 0 0; }

/* ── exam 모바일 — 사이드바 해제, 세로 스택 ──────────────── */
@media (max-width: 960px) {
  .exam {
    padding-top: 12px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .exam__side {
    position: static;
    gap: 10px;
  }
  /* 모바일에선 PDF가 viewport 세로 거의 다 차지하면 답답하니 cap 완화 */
  .preview__page { max-height: none; }
  /* 탭은 모바일에서 가로형 + 스크롤 시에도 보이도록 sticky */
  .exam__tabs {
    flex-direction: row;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    padding: 0 2px;
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    background: var(--bg);
  }
  .exam-tab {
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin-bottom: -1px;
    padding: 10px 14px;
    min-height: var(--tap, 44px);
  }
  .exam-tab:hover { background: transparent; }
  .exam-tab.is-active {
    background: transparent;
    border-bottom-color: var(--ink);
  }
  .exam__tabs-hint { display: none; }
  /* 다운로드 버튼 가로 균등 + 터치 영역 확보 */
  .exam__actions .btn { min-height: var(--tap, 44px); }
}
@media (max-width: 720px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px 14px 13px; gap: 6px; }
  .kpi__value { font-size: 18px; }
}
@media (max-width: 600px) {
  .exam { padding-top: 12px; gap: 12px; }
  .exam__title { font-size: 18px; }
  .exam__actions .btn { min-height: var(--tap); }

  .preview__head    { padding: 11px 14px; }
  .preview__viewer  { padding: 10px; min-height: 200px; gap: 10px; }
  .preview__title   { font-size: 13.5px; }
  .preview__page    { border-radius: 4px; }

  .qa-grid { gap: 4px; }
  .qa-cell { padding: 6px 2px; }
  .qa-cell__ans { font-size: 13px; }

  .exam-card { padding: 14px 14px 16px; }
}

/* ═══════════════════════════════════════════════════════════
   Exam Set — 시험 한 회차 (모든 영역 카드 그리드)
═══════════════════════════════════════════════════════════ */
.examset {
  padding-top: 14px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.examset__crumb { display: flex; align-items: center; }
.examset__back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.examset__back:hover { color: var(--ink); background: var(--surface-2); }

.examset__head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.examset__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.examset__title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
}
.examset__sub {
  font-size: 13px;
  color: var(--ink-4);
  margin: 0;
}
.examset__count {
  font-size: 12px;
  color: var(--ink-5);
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}

.examset__error {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
}
.examset__error-title { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0; }
.examset__error-sub   { font-size: 13px; color: var(--ink-4); margin: 6px 0 0; }

@media (max-width: 600px) {
  .examset { padding-top: 12px; gap: 12px; }
  .examset__title { font-size: 20px; }
}

/* ═══ Archive — exam-set 회차 진입 링크 ════════════════════ */
/* HTML hidden 속성이 display 선언을 이기도록 명시 (display:none이 hidden override 방지) */
.examset-link[hidden],
.exam__back[hidden] { display: none !important; }
.examset-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 4px 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease);
  align-self: flex-start;
}
.examset-link:hover {
  background: var(--surface-3, #f0f1f2);
  border-color: var(--ink-4, #94a3b8);
  color: var(--ink);
}
.examset-link:active { transform: scale(0.99); }
.examset-link__icon {
  display: inline-flex;
  color: var(--ink-3);
}
.examset-link__label { flex: 1; }
.examset-link__arrow {
  font-size: 14px;
  color: var(--ink-3);
  transition: transform 140ms var(--ease);
}
.examset-link:hover .examset-link__arrow { transform: translateX(2px); color: var(--ink); }

/* ═══════════════════════════════════════════════════════════
   Patchnotes — 사이트·입시 변경 기록
═══════════════════════════════════════════════════════════ */
.patchnotes { padding-top: 24px; padding-bottom: 56px; max-width: 760px; margin: 0 auto; }
.patchnotes__head { padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.patchnotes__title { font-size: 32px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.2; color: var(--ink); margin: 0; }
.patchnotes__sub { margin-top: 8px; color: var(--ink-3); font-size: 14px; line-height: 1.6; }
.patchnotes__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 24px; }

.patchnotes__entry {
  position: relative;
  padding: 18px 18px 20px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.patchnotes__entry:hover { border-color: var(--line-strong); }

.patchnotes__entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.patchnotes__date { font-size: 12px; font-weight: 500; color: var(--ink-4); letter-spacing: 0.2px; font-variant-numeric: tabular-nums; }
.patchnotes__entry-title { font-size: 18px; font-weight: 600; line-height: 1.4; color: var(--ink); margin: 0 0 6px; letter-spacing: -0.2px; }
.patchnotes__entry-summary { font-size: 14px; line-height: 1.6; color: var(--ink-2); margin: 0 0 8px; }
.patchnotes__entry-body { font-size: 13px; line-height: 1.65; color: var(--ink-3); margin: 0; }

.patchnotes__skeleton { height: 88px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.patchnotes__empty { padding: 28px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line-strong); border-radius: 12px; }

@media (max-width: 600px) {
  .patchnotes { padding-top: 16px; }
  .patchnotes__title { font-size: 26px; }
  .patchnotes__entry { padding: 14px; }
}

/* ═══════════════════════════════════════════════════════════
   PDF preview — zoom controls (데스크톱 상단 / 모바일 핀치 줌)
═══════════════════════════════════════════════════════════ */
.preview__head { display: flex; align-items: center; gap: 12px; }
.preview__zoom {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.preview__zoom-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms var(--ease);
}
.preview__zoom-btn:hover { background: var(--surface-hover); color: var(--ink); }
.preview__zoom-btn:active { transform: scale(0.96); }
.preview__zoom-pct {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
/* 모바일: 브라우저 핀치 줌 사용 → 버튼 숨김. */
@media (max-width: 600px) {
  .preview__zoom { display: none; }
  .preview__page { touch-action: pinch-zoom; }
}

/* ═══════════════════════════════════════════════════════════
   Ad Slots — AdSense / AdFit 공용
   - data-ad-position 속성으로 자동 렌더 (lib/ads.js).
   - ID 미설정 시 슬롯 자체가 hide → 빈 영역 안 차지.
═══════════════════════════════════════════════════════════ */
.ad-slot {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 24px 0;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.ad-slot::before {
  content: '광고';
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: 10px;
  color: var(--ink-5);
  font-weight: 500;
  letter-spacing: 0.4px;
  z-index: 1;
}
.ad-slot--inline { min-height: 100px; }
.ad-slot--banner { min-height: 90px; }
.ad-slot--sidebar { margin: 16px 0 0; min-height: 250px; }

/* 슬롯이 채워지면 placeholder 'AD' 라벨은 유지하되 background 투명 */
.ad-slot--filled { background: transparent; border-color: var(--line); }
