:root {
  color-scheme: dark;
  --bg: #0b0c0a;
  --surface: #121410;
  --surface-raised: #171a15;
  --border: #2b2e27;
  --text: #f3f1e9;
  --muted: #aaa79e;
  --faint: #77766f;
  --accent: #57ddd1;
  --accent-ink: #071311;
  font-family: Inter, Pretendard, "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -12%, rgba(87, 221, 209, 0.12), transparent 31rem),
    var(--bg);
  color: var(--text);
}

a { color: inherit; text-underline-offset: 0.2em; }

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

.site-header,
.site-footer,
main {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(87, 221, 209, 0.45);
  border-radius: 9px;
  color: var(--accent);
  font: 800 1rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.brand span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 0.9rem; letter-spacing: -0.02em; }
.brand small { color: var(--faint); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }

.language-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.language-nav a {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--faint);
  font-size: 0.75rem;
  text-decoration: none;
}
.language-nav a:hover,
.language-nav a[aria-current="page"] { color: var(--text); background: var(--surface-raised); }

.hub-hero,
.lesson-hero {
  padding: clamp(72px, 10vw, 132px) 0 clamp(68px, 9vw, 112px);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 17px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1 {
  max-width: 960px;
  margin: 0;
  font-size: clamp(2.7rem, 7.4vw, 6.6rem);
  line-height: 0.98;
  letter-spacing: -0.062em;
}

.lesson-hero h1 { max-width: 900px; font-size: clamp(2.7rem, 7vw, 5.7rem); }

.hero-lead {
  max-width: 820px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.24rem);
  line-height: 1.78;
}

.course-meta {
  display: inline-flex;
  margin: 28px 0 0;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
}

.chapter-index {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.chapter-index a {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
}
.chapter-index a:nth-child(4n) { border-right: 0; }
.chapter-index a:nth-child(-n + 4) { border-bottom: 1px solid var(--border); }
.chapter-index a:hover { color: var(--text); background: var(--surface); }
.chapter-index span { color: var(--accent); font: 700 0.68rem/1 ui-monospace, monospace; }

.chapter { padding: clamp(68px, 9vw, 112px) 0; border-bottom: 1px solid var(--border); }
.chapter-heading { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 24px; margin-bottom: 42px; }
.chapter-heading > span { color: var(--accent); font: 700 0.76rem/1.5 ui-monospace, monospace; }
.chapter-heading h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.2rem); letter-spacing: -0.045em; }
.chapter-heading p { max-width: 760px; margin: 16px 0 0; color: var(--muted); line-height: 1.75; }
.chapter-heading small { display: inline-block; margin-top: 14px; color: var(--faint); }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 1px;
  list-style: none;
  background: var(--border);
}

.lesson-card { min-width: 0; background: var(--bg); }
.lesson-card a { min-height: 265px; display: flex; flex-direction: column; padding: 28px; text-decoration: none; }
.lesson-card a:hover { background: var(--surface); }
.lesson-number { color: var(--accent); font: 700 0.68rem/1 ui-monospace, monospace; }
.lesson-card h3 { margin: 32px 0 12px; font-size: 1.15rem; letter-spacing: -0.025em; }
.lesson-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.65; }
.text-link { margin-top: auto; padding-top: 24px; color: var(--accent); font-size: 0.78rem; font-weight: 750; text-decoration: none; }

.trust-grid { display: grid; grid-template-columns: repeat(3, 1fr); padding: clamp(72px, 10vw, 120px) 0; }
.trust-grid article { padding: 0 34px; border-right: 1px solid var(--border); }
.trust-grid article:first-child { padding-left: 0; }
.trust-grid article:last-child { padding-right: 0; border-right: 0; }
.trust-grid h2 { margin: 0 0 18px; font-size: 1.3rem; letter-spacing: -0.03em; }
.trust-grid p:not(.eyebrow) { margin: 0; color: var(--muted); line-height: 1.75; }
.trust-grid .text-link { display: inline-block; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 9px; padding: 30px 0 0; color: var(--faint); font-size: 0.76rem; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }

.primary-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
  padding: 14px 18px;
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 0.85rem;
  font-weight: 820;
  text-decoration: none;
}
.primary-cta:hover { filter: brightness(1.07); }

.story-section,
.notebook-section,
.chapter-lessons { display: grid; grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.55fr); gap: clamp(36px, 7vw, 100px); padding: clamp(72px, 9vw, 112px) 0; border-bottom: 1px solid var(--border); }
.section-intro h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.5rem); letter-spacing: -0.04em; }
.section-intro > p:last-child { margin: 18px 0 0; color: var(--muted); line-height: 1.75; }

.story-list { margin: 0; padding: 0; list-style: none; }
.story-list li { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 20px; padding: 24px 0; border-top: 1px solid var(--border); }
.story-list li:last-child { border-bottom: 1px solid var(--border); }
.story-list span { color: var(--accent); font: 700 0.68rem/1.6 ui-monospace, monospace; }
.story-list p { margin: 0; color: var(--text); line-height: 1.75; }

.notebook-section pre {
  max-height: 700px;
  margin: 0;
  padding: 28px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #090a08;
  color: #d9ded5;
  font: 0.82rem/1.72 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
}
.notebook-section .primary-cta { grid-column: 2; justify-self: start; margin-top: -60px; }

.chapter-lessons ol { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.chapter-lessons li { border-bottom: 1px solid var(--border); }
.chapter-lessons a { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 18px 4px; color: var(--muted); text-decoration: none; }
.chapter-lessons a:hover,
.chapter-lessons a[aria-current="page"] { color: var(--text); }
.chapter-lessons a[aria-current="page"] { padding-left: 12px; border-left: 2px solid var(--accent); }
.chapter-lessons span { color: var(--accent); font: 700 0.7rem/1.6 ui-monospace, monospace; }

.previous-next { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 1px; margin: 72px 0 112px; background: var(--border); }
.previous-next a { min-height: 130px; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 28px; background: var(--bg); text-decoration: none; }
.previous-next a:hover { background: var(--surface); }
.previous-next .next { align-items: flex-end; text-align: right; }
.previous-next small { color: var(--accent); }
.previous-next strong { font-size: 1rem; }

.site-footer { display: flex; justify-content: space-between; gap: 24px; padding: 36px 0 52px; border-top: 1px solid var(--border); color: var(--faint); font-size: 0.72rem; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 16px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }

@media (max-width: 850px) {
  .chapter-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter-index a:nth-child(n) { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .chapter-index a:nth-child(2n) { border-right: 0; }
  .lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trust-grid { grid-template-columns: 1fr; }
  .trust-grid article,
  .trust-grid article:first-child,
  .trust-grid article:last-child { padding: 32px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .story-section,
  .notebook-section,
  .chapter-lessons { grid-template-columns: 1fr; }
  .notebook-section .primary-cta { grid-column: auto; margin-top: 0; }
}

@media (max-width: 580px) {
  .site-header,
  .site-footer,
  main { width: min(100% - 30px, 1180px); }
  .site-header { align-items: flex-start; min-height: 0; padding: 20px 0; }
  .brand small { display: none; }
  .language-nav { gap: 2px; }
  .language-nav a { padding: 7px 6px; font-size: 0.68rem; }
  .hub-hero,
  .lesson-hero { padding: 64px 0; }
  h1 { font-size: clamp(2.4rem, 13vw, 4rem); }
  .chapter-index { grid-template-columns: 1fr; }
  .chapter-index a:nth-child(n) { min-height: 62px; border-right: 0; }
  .chapter-heading { grid-template-columns: 1fr; gap: 12px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-card a { min-height: 230px; }
  .story-list li { grid-template-columns: 34px minmax(0, 1fr); gap: 12px; }
  .notebook-section pre { margin-inline: -15px; border-radius: 0; }
  .previous-next { grid-template-columns: 1fr; }
  .previous-next span:empty { display: none; }
  .site-footer { flex-direction: column; }
  .site-footer nav { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
