:root {
  --bg: #eef1f6;
  --bg-subtle: #f8f9fc;
  --surface: #fff;
  --text: #141820;
  --muted: #5c6578;
  --accent: #1d5bbf;
  --accent-hover: #164a99;
  --accent-soft: #e8f0fc;
  --border: #dce2ec;
  --term-highlight: #fef3c7;
  --success: #0d7a4e;
  --success-soft: #e6f6ef;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --warning: #9a6700;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 4%);
  --shadow-lg: 0 8px 28px rgb(15 23 42 / 10%);
  --header-h: 0px;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic",
    system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
}

body.webbook {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(
    ellipse 120% 80% at 50% -20%,
    #fff 0%,
    var(--bg) 55%
  );
  color: var(--text);
  line-height: 1.65;
  font-family: var(--font);
  font-size: 1rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10001;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.site-header {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.75rem;
}

.site-footer {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
}

.site-main {
  max-width: 56rem;
  margin: 0 auto 2rem;
  padding: 0 1.25rem 1rem;
}

.breadcrumb {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.page-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-lead {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 42rem;
}

.meta {
  font-size: 0.8125rem;
  color: var(--muted);
}

.meta code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--bg-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Sticky sub navigation */
.subnav-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 -1.25rem 1rem;
  padding: 0.5rem 1.25rem;
  background: rgb(238 241 246 / 85%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}

.subnav-wrap.is-stuck {
  border-bottom-color: var(--border);
}

.sibling-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sibling-nav a {
  font-size: 0.8125rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.sibling-nav a:hover {
  border-color: #93b4e8;
  background: var(--accent-soft);
}

.sibling-nav a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sibling-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Cards / sections */
.site-main section,
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  border: 1px solid rgb(255 255 255 / 60%);
}

.site-main section h2,
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 650;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.site-main section h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.975rem;
}

/* Summary layout + TOC */
.page-layout {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .page-layout--with-toc {
    grid-template-columns: minmax(0, 1fr) 11.5rem;
    align-items: start;
  }

  .page-toc {
    position: sticky;
    top: 4.5rem;
    order: 2;
  }

  .page-layout--with-toc .page-content {
    order: 1;
  }
}

.page-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.page-toc__title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8125rem;
}

.page-toc li {
  margin-bottom: 0.25rem;
}

.page-toc a {
  color: var(--text);
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
  border-radius: 4px;
}

.page-toc a:hover {
  color: var(--accent);
}

.page-toc a.is-active {
  color: var(--accent);
  font-weight: 600;
}

/* Directory index */
.hero {
  background: linear-gradient(135deg, #1d5bbf 0%, #3b82d6 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-lg);
}

.hero h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  border: none;
  padding: 0;
  color: inherit;
}

.hero p {
  margin: 0;
  opacity: 0.92;
  font-size: 0.9375rem;
}

.dir-grid {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 560px) {
  .dir-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
}

.dir-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dir-list li {
  margin-bottom: 0.5rem;
}

.dir-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.12s;
}

.dir-card:hover {
  border-color: #93b4e8;
  transform: translateY(-1px);
}

.dir-card__label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.dir-card__meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.item-kind {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

/* Medical terms */
.med-term {
  cursor: help;
  border-bottom: 1px dashed var(--accent);
  transition: background 0.12s ease;
  border-radius: 2px;
}

.med-term.is-highlighted {
  background: var(--term-highlight);
}

.med-term-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: 18rem;
  padding: 0.55rem 0.75rem;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.8125rem;
  line-height: 1.45;
  border-radius: var(--radius-sm);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.med-term-tooltip strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar__hint {
  flex: 1 1 100%;
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0;
}

@media (min-width: 640px) {
  .toolbar__hint {
    flex: 1 1 auto;
    margin: 0 0 0 0.5rem;
  }
}

.btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.btn:hover {
  border-color: #93b4e8;
  background: var(--accent-soft);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--ghost.is-active,
.mock-wrong-bar .btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.input-search {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: min(100%, 14rem);
  flex: 1;
}

.input-search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* Quiz */
.quiz-progress {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.quiz-item {
  margin-bottom: 1.25rem;
}

.quiz-item__stem {
  font-weight: 600;
  margin-bottom: 0.65rem;
}

.quiz-choices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.quiz-choices label {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.quiz-choices label:hover {
  border-color: #93b4e8;
  background: var(--bg-subtle);
}

.quiz-choices input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.quiz-choices label.is-correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.quiz-choices label.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.quiz-feedback {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  display: none;
}

.quiz-feedback.is-visible {
  display: block;
}

.quiz-feedback--ok {
  background: var(--success-soft);
  color: var(--success);
}

.quiz-feedback--bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.quiz-score {
  font-size: 1rem;
  font-weight: 650;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  margin-top: 1rem;
  display: none;
}

.quiz-score.is-visible {
  display: block;
}

/* Mock exam */
.mock-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.mock-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.mock-section-nav button {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.mock-section-nav button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mock-section-panel {
  display: none;
}

.mock-section-panel.is-active {
  display: block;
}

/* Glossary */
.glossary-intro {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.glossary-empty {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.glossary-table th,
.glossary-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
}

.glossary-table th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted);
}

.glossary-table tr:last-child td {
  border-bottom: none;
}

.glossary-table tr.is-hidden {
  display: none;
}

/* Jokbo */
.jokbo-question {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.jokbo-question h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.45;
  border: none;
  padding: 0;
}

.jokbo-choices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.jokbo-choices label {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.jokbo-choices label:hover {
  background: var(--bg-subtle);
}

.jokbo-choices label.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.jokbo-choices label.is-correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.jokbo-choices label.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.jokbo-choices input {
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.jokbo-explanation {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.9rem;
  display: none;
}

.jokbo-explanation.is-visible {
  display: block;
}

.jokbo-source {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.jokbo-source a {
  color: var(--accent);
}

.jokbo-results {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-weight: 600;
  display: none;
}

.jokbo-results.is-visible {
  display: block;
}

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 40;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media print {
  .subnav-wrap,
  .toolbar,
  .back-to-top,
  .page-toc,
  .skip-link {
    display: none !important;
  }

  body.webbook {
    background: #fff;
  }

  .site-main section {
    box-shadow: none;
    break-inside: avoid;
  }
}
