/* ============================================================
   시험 준비 모듈 — 비전트리 색상 변수(--forest 등)를 그대로 사용
   ============================================================ */
.exam-root {
  display: block;
  /* 작은 글자용 진한 변형 (흰 배경 대비 4.5:1 이상) */
  --exam-gold-text: #7a5c22;
  --exam-clay-text: #a14b2a;
  --exam-leaf-text: #4a684b;
  --exam-accent-text: #6d4b86;
  font-variant-numeric: tabular-nums;
}
.exam-locked { color: var(--muted); font-size: 14px; padding: 28px 12px; text-align: center; margin: 0; }
.exam-locked strong { color: var(--ink); }
.exam-hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 6px 0 14px; }
.exam-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 10px 0 0; }
.exam-h { margin: 28px 0 10px; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.exam-h.is-first { margin-top: 0; }
.exam-h small, .exam-sub { color: var(--muted); font-weight: 500; font-size: 13px; }

.exam-primary {
  min-height: 40px; border: 0; border-radius: 8px; background: var(--forest); color: var(--cream);
  padding: 0 18px; font-weight: 800; font-size: 14px;
}
.exam-link {
  border: 0; background: none; color: var(--forest); font-weight: 700; font-size: 13px;
  padding: 8px 0; min-height: 36px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(75, 31, 99, 0.3);
}

/* 탭 */
.exam-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.exam-tab {
  min-height: 38px; font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 0 16px;
  border-radius: 8px; background: var(--soft); border: 1px solid var(--line);
}
.exam-tab.is-active { background: var(--forest); color: var(--cream); border-color: var(--forest); }

/* 설정 */
/* fieldset에 직접 grid를 걸면 Safari에서 칸이 눌려 글자가 세로로 쌓인다 → 안쪽 div에 건다 */
.exam-setup fieldset, .exam-errform fieldset {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 0 0 14px; min-width: 0;
}
.exam-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); gap: 12px; }
@media (max-width: 640px) { .exam-fields .exam-span { grid-column: 1 / -1; } }
.exam-setup legend, .exam-errform legend { font-weight: 800; font-size: 13px; color: var(--forest); padding: 0 6px; }
.exam-setup label, .exam-errform label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); min-width: 0; word-break: keep-all; }
.exam-setup input, .exam-setup select, .exam-errform input, .exam-errform select, .exam-errform textarea, .exam-output textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; min-height: 40px; color: var(--ink); background: #fff; width: 100%;
}
.exam-errform textarea, .exam-output textarea { padding: 10px 12px; line-height: 1.55; resize: vertical; }
.exam-setup input:focus-visible, .exam-setup select:focus-visible, .exam-errform input:focus-visible,
.exam-errform select:focus-visible, .exam-errform textarea:focus-visible, .exam-output textarea:focus-visible {
  outline-offset: 0; border-color: var(--forest);
}
::placeholder { color: #8d8094; }

/* 요약 */
.exam-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.exam-summary div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); display: grid; gap: 3px; }
.exam-summary small { color: var(--muted); font-size: 12px; }
.exam-summary strong { font-size: 15px; }
@media (max-width: 640px) { .exam-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 시간 배분 */
.exam-alloc { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.exam-alloc li {
  display: grid; grid-template-columns: 140px 1fr 52px 58px 76px; gap: 12px; align-items: center; font-size: 14px;
}
.exam-alloc-name small { color: var(--muted); font-size: 12px; }
.exam-alloc-min { font-weight: 800; text-align: right; }
.exam-alloc-score { color: var(--muted); font-size: 12px; text-align: right; }
.exam-bar { height: 8px; border-radius: 8px; background: var(--soft); overflow: hidden; }
.exam-bar i { display: block; height: 100%; background: var(--forest); border-radius: 8px; }
.exam-bar.is-general i { background: var(--gold); }
.exam-pri { font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: 8px; text-align: center; }
.exam-pri.is-high { color: var(--exam-clay-text); background: rgba(191, 107, 74, 0.12); }
.exam-pri.is-mid { color: var(--rose); background: rgba(159, 79, 115, 0.1); }
.exam-pri.is-low { color: var(--exam-leaf-text); background: rgba(111, 138, 112, 0.12); }
@media (max-width: 640px) {
  .exam-alloc { gap: 14px; }
  .exam-alloc li { grid-template-columns: 1fr auto auto; gap: 6px 10px; }
  .exam-alloc .exam-bar { grid-column: 1 / -1; grid-row: 2; }
  .exam-alloc-score { display: none; }
}

/* 주차·날짜 */
.exam-week { margin-top: 24px; }
.exam-week header { display: grid; gap: 3px; margin-bottom: 10px; }
.exam-week header strong { font-size: 15px; color: var(--forest); }
.exam-week header small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.exam-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 640px) { .exam-days { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.exam-day {
  display: grid; gap: 4px; text-align: left; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); padding: 9px 9px 8px; font-size: 12.5px; color: var(--ink); min-height: 64px; align-content: start;
}
.exam-day small { color: var(--muted); font-size: 11.5px; }
.exam-day.is-rest { background: var(--soft); color: var(--muted); }
.exam-day.is-check small, .exam-day.is-final small { color: var(--exam-clay-text); font-weight: 700; }
.exam-day.is-today { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.exam-day.is-done { border-color: var(--leaf); }
.exam-day-bar { display: block; height: 4px; border-radius: 4px; background: var(--soft); overflow: hidden; margin-top: 2px; }
.exam-day-bar b { display: block; height: 100%; background: var(--leaf); }

/* 하루 세션 */
.exam-dayhead { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 10px; text-align: center; }
.exam-dayhead div { display: grid; gap: 3px; }
.exam-dayhead h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.exam-dayhead small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.exam-nav {
  min-height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 0 12px; font-size: 13px; color: var(--forest); font-weight: 700; white-space: nowrap;
}
.exam-nav:disabled { opacity: 0.4; cursor: default; }
.exam-daystatus { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.exam-daystatus strong { color: var(--ink); }
.exam-daystatus.is-done { color: var(--exam-leaf-text); font-weight: 800; }
.exam-rest { color: var(--muted); text-align: center; padding: 30px 0; margin: 0; }

.exam-act { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 14px 16px 12px; margin-bottom: 12px; }
.exam-act.is-done { border-color: rgba(111, 138, 112, 0.55); background: #fbfcfa; }
.exam-act header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 10px; align-items: center; }
.exam-check { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 15px; min-height: 36px; cursor: pointer; }
.exam-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--leaf); flex: none; cursor: pointer; }
.exam-act.is-done .exam-check span { color: var(--muted); }
.exam-act-meta { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.exam-kind { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.exam-kind.is-exam { color: var(--forest); background: rgba(75, 31, 99, 0.08); }
.exam-kind.is-general { color: var(--exam-gold-text); background: rgba(183, 150, 91, 0.16); }
.exam-ref, .exam-tasks { font-size: 13px; margin: 6px 0 0; }
.exam-ref small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.exam-tasks { color: var(--exam-accent-text); font-weight: 700; }
.exam-steps { margin: 10px 0; padding-left: 22px; font-size: 14px; line-height: 1.65; }
.exam-steps li.is-lead { color: var(--forest); font-weight: 700; }
.exam-act.is-done .exam-ref small { display: none; }
.exam-output { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.exam-act a { color: var(--forest); font-weight: 700; font-size: 13.5px; text-underline-offset: 3px; }

/* 풀이 전략 · 연습 문제 */
.exam-guide { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin: 4px 0 8px; }
.exam-guide > summary {
  cursor: pointer; list-style-position: inside; padding: 9px 12px; min-height: 40px;
  font-size: 13px; font-weight: 700; color: var(--exam-accent-text);
}
.exam-guide[open] > summary { border-bottom: 1px solid var(--line); }
.exam-guide-limit { margin: 10px 12px 0; font-size: 12.5px; font-weight: 700; color: var(--exam-clay-text); }
.exam-guide-list { margin: 8px 0 0; padding: 0 14px 0 30px; font-size: 13.5px; line-height: 1.65; }
.exam-guide-practice { margin: 10px 12px 12px; padding: 10px 12px; border-radius: 8px; background: var(--soft); }
.exam-guide-practice > strong { font-size: 13px; }
.exam-guide-practice > strong small { color: var(--muted); font-weight: 500; font-size: 11.5px; margin-left: 4px; }
.exam-pre { white-space: pre-line; margin: 6px 0 0; font-size: 13.5px; line-height: 1.65; }
.exam-guide-answer { margin-top: 8px; }
.exam-guide-answer summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--forest); min-height: 32px; display: flex; align-items: center; width: fit-content; }
.exam-guide-explain { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }

/* AI 피드백 */
.exam-ai { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 8px 0 2px; }
.exam-ai-label { font-size: 12.5px; font-weight: 800; color: var(--exam-accent-text); margin-right: 2px; }
.exam-ai-btn {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--forest); font-size: 13px; font-weight: 700; text-decoration: none;
  transition: transform 140ms var(--ease-out), border-color 150ms ease;
}
.exam-ai-btn:active { transform: scale(0.97); }
.exam-ai-msg { flex-basis: 100%; font-size: 12.5px; color: var(--exam-leaf-text); min-height: 0; }
.exam-ai-msg:empty { display: none; }
.exam-ai-fallback { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--ink); background: var(--soft); resize: vertical; }
.exam-fb { margin: 6px 0 2px; }
.exam-fb summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted); min-height: 32px; display: flex; align-items: center; width: fit-content; }
.exam-fb textarea { margin-top: 6px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; line-height: 1.55; color: var(--ink); background: #fff; resize: vertical; }
.exam-fb textarea:focus-visible { outline-offset: 0; border-color: var(--forest); }

/* 오류·복습 */
.exam-errform { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.exam-errform .is-wide { grid-column: 1 / -1; }
.exam-errform .exam-primary { justify-self: start; }
.exam-errform .exam-tagpick { margin: 0; }
.exam-errform .exam-tagpick .exam-fields { grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr)); gap: 4px 12px; }
.exam-errform .exam-tagpick label { display: flex; gap: 8px; align-items: center; color: var(--ink); min-height: 32px; cursor: pointer; }
.exam-errform .exam-tagpick input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--forest); }
@media (max-width: 640px) { .exam-errform { grid-template-columns: 1fr; } }
.exam-err { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; background: var(--panel); }
.exam-err header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; font-size: 12.5px; font-weight: 800; color: var(--forest); }
.exam-err header small { color: var(--muted); font-weight: 500; }
.exam-err p { margin: 6px 0 0; font-size: 14px; line-height: 1.55; }
.exam-err-orig { text-decoration: line-through; text-decoration-color: var(--clay); color: var(--muted); }
.exam-err-fix { color: var(--exam-leaf-text); font-weight: 700; }
.exam-err-tags span { display: inline-block; font-size: 11.5px; color: var(--rose); background: rgba(159, 79, 115, 0.1); padding: 2px 8px; border-radius: 8px; margin-right: 4px; }
.exam-err-note { color: var(--muted); font-size: 13px !important; }
.exam-err-actions { display: flex; gap: 8px; margin-top: 10px; }
.exam-err-actions button {
  min-height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 0 14px; font-size: 13.5px; font-weight: 700; color: var(--forest);
}

.exam-footer { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.exam-footer p { margin: 4px 0; }
.exam-footer a { color: var(--forest); text-underline-offset: 3px; }

@media (pointer: coarse) {
  .exam-tab, .exam-nav, .exam-primary, .exam-err-actions button, .exam-check, .exam-link, .exam-ai-btn, .exam-fb summary, .exam-guide > summary, .exam-guide-answer summary { min-height: 44px; }
}
@media (max-width: 640px) {
  .exam-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .exam-tab { padding: 0 4px; font-size: 13px; }
}

/* ============================================================
   인터랙션 — 누름 피드백, 완료 접힘, 완료 메시지
   ============================================================ */
.exam-root { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); }

/* 누르면 바로 반응한다 */
.exam-primary, .exam-tab, .exam-nav, .exam-day, .exam-err-actions button, .exam-link {
  transition: transform 140ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.exam-primary:active, .exam-tab:active, .exam-nav:active:not(:disabled), .exam-err-actions button:active { transform: scale(0.97); }
.exam-day:active { transform: scale(0.96); }
.exam-check input { transition: transform 140ms var(--ease-out); }
.exam-check input:active { transform: scale(0.88); }

/* 완료하면 단계 목록이 부드럽게 접힌다 (레이아웃 점프 방지) */
.exam-collapsible {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows 240ms var(--ease-out), opacity 160ms ease;
}
.exam-collapsible > div { overflow: hidden; min-height: 0; }
.exam-act.is-done .exam-collapsible { grid-template-rows: 0fr; opacity: 0; }
.exam-act { transition: background-color 200ms ease, border-color 200ms ease; }
.exam-check span { transition: color 200ms ease; }
.exam-output small { color: var(--muted); font-weight: 500; opacity: 0.8; }

/* 하루를 모두 마쳤을 때 한 번 */
.exam-daystatus.is-done {
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(4px); }
}

/* hover는 마우스에서만 (터치 기기에서 색이 남지 않게) */
@media (hover: hover) and (pointer: fine) {
  .exam-primary:hover { background: #3d1851; }
  .exam-link:hover { text-decoration-color: currentColor; }
  .exam-tab:not(.is-active):hover { color: var(--forest); border-color: rgba(75, 31, 99, 0.3); }
  .exam-day:hover, .exam-nav:hover:not(:disabled), .exam-err-actions button:hover, .exam-ai-btn:hover { border-color: var(--forest); }
  .exam-fb summary:hover, .exam-guide > summary:hover { color: var(--forest); }
}

@media (prefers-reduced-motion: reduce) {
  .exam-primary, .exam-tab, .exam-nav, .exam-day, .exam-err-actions button, .exam-check input { transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
  .exam-primary:active, .exam-tab:active, .exam-nav:active, .exam-err-actions button:active, .exam-day:active, .exam-check input:active { transform: none; }
  .exam-collapsible { transition: opacity 160ms ease; }
  .exam-daystatus.is-done { transition: opacity 200ms ease; @starting-style { opacity: 0; transform: none; } }
}

/* 접는 칸 표시 (summary에 flex를 쓰면 기본 ▸가 사라진다) */
.exam-fb summary::before, .exam-guide-answer summary::before {
  content: ""; width: 0; height: 0; margin-right: 7px;
  border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform 160ms var(--ease-out);
}
.exam-fb[open] > summary::before, .exam-guide-answer[open] > summary::before { transform: rotate(90deg); }
.exam-fb summary::-webkit-details-marker, .exam-guide-answer summary::-webkit-details-marker { display: none; }

/* 암기 표현집 */
.exam-ph-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 10px; }
.exam-ph-chip {
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--exam-line, #d8dde4); background: var(--exam-surface, #fff); color: inherit;
}
.exam-ph-chip:hover { border-color: var(--exam-accent, #2f5d8a); }
.exam-ph-chip.is-active { background: var(--exam-accent, #2f5d8a); border-color: var(--exam-accent, #2f5d8a); color: #fff; }
.exam-ph-search { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 600; margin-bottom: 8px; }
.exam-ph-search input { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--exam-line, #d8dde4); width: 100%; }
.exam-ph-count { font-size: 0.78rem; opacity: 0.72; margin: 0 0 10px; }
.exam-ph-list { display: grid; gap: 8px; }
.exam-ph {
  border: 1px solid var(--exam-line, #d8dde4); border-radius: 10px;
  padding: 11px 13px; background: var(--exam-surface, #fff); min-width: 0;
}
.exam-ph-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.exam-ph-id { font-weight: 700; font-size: 0.78rem; letter-spacing: 0.04em; opacity: 0.6; font-variant-numeric: tabular-nums; }
.exam-ph-fn { font-weight: 600; font-size: 0.9rem; }
.exam-ph-core {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; padding: 1px 7px; border-radius: 4px;
  background: var(--exam-accent-soft, #e7eef6); color: var(--exam-accent, #2f5d8a);
}
.exam-ph-frame { margin: 0 0 5px; font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.exam-ph-ex { margin: 0 0 2px; font-size: 0.88rem; overflow-wrap: anywhere; }
.exam-ph-ko { margin: 0 0 6px; font-size: 0.82rem; opacity: 0.75; overflow-wrap: anywhere; }
.exam-ph-note {
  margin: 0; font-size: 0.79rem; opacity: 0.8; padding-top: 6px;
  border-top: 1px dashed var(--exam-line, #d8dde4);
}
.exam-ph-caution { font-size: 0.76rem; opacity: 0.72; margin: 12px 0 0; line-height: 1.6; }
@media (max-width: 480px) {
  .exam-ph-chip { font-size: 0.78rem; padding: 5px 10px; }
}

/* 계획 만들기 위 입력 요약 (3차) */
.exam-summary { margin: 14px 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.exam-summary-title { margin: 0 0 6px; font-size: 13px; font-weight: 800; color: var(--ink); }
.exam-summary dl { display: grid; gap: 4px; margin: 0; }
.exam-summary dl div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; font-size: 13px; line-height: 1.5; }
.exam-summary dt { color: var(--muted); font-weight: 700; }
.exam-summary dd { margin: 0; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
