:root {
  color-scheme: light dark;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #efede7;
  --text: #191b21;
  --muted: #63656f;
  --line: #d8d5cc;
  --accent: #5a4fd0;
  --accent-2: #147d69;
  --quote: #ece9ff;
  --focus: #b76800;
  --shadow: 0 18px 45px rgb(24 25 32 / 9%);
  --content: 46rem;
  --wide: 76rem;
  --radius: 1.25rem;
  font-family: Inter, Pretendard, "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  --bg: #0f1118;
  --surface: #171a23;
  --surface-soft: #20242f;
  --text: #efeee9;
  --muted: #adafba;
  --line: #333846;
  --accent: #a99fff;
  --accent-2: #62d3bd;
  --quote: #24213b;
  --focus: #ffc369;
  --shadow: 0 20px 55px rgb(0 0 0 / 28%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1118;
    --surface: #171a23;
    --surface-soft: #20242f;
    --text: #efeee9;
    --muted: #adafba;
    --line: #333846;
    --accent: #a99fff;
    --accent-2: #62d3bd;
    --quote: #24213b;
    --focus: #ffc369;
    --shadow: 0 20px 55px rgb(0 0 0 / 28%);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 3%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 30rem),
    var(--bg);
  color: var(--text);
  line-height: 1.75;
}

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .13em; }
a:focus-visible, button:focus-visible { outline: .2rem solid var(--focus); outline-offset: .2rem; }
img, svg { max-width: 100%; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  transform: translateY(-180%);
  border-radius: .5rem;
  padding: .65rem .9rem;
  background: var(--text);
  color: var(--bg);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.nav {
  width: min(calc(100% - 2rem), var(--wide));
  min-height: 4.35rem;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -.02em;
}
.brand img { width: 2rem; height: 2rem; }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.nav-links a { color: var(--muted); font-size: .94rem; text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--text); font-weight: 700; }

.theme-toggle {
  min-width: 2.6rem;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.language-switcher { display: flex; gap: .3rem; align-items: center; }
.language-switcher a {
  min-width: 2.2rem;
  border-radius: 999px;
  padding: .25rem .45rem;
  text-align: center;
  white-space: nowrap;
}
.language-switcher a[aria-current="true"] { background: var(--surface-soft); color: var(--text); }

main { width: min(calc(100% - 2rem), var(--wide)); margin: 0 auto; }
.hero { padding: clamp(4.5rem, 10vw, 8.5rem) 0 3.5rem; }
.eyebrow { color: var(--accent-2); font-size: .82rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 {
  max-width: 14ch;
  margin: .5rem 0 1.25rem;
  font-family: ui-serif, Georgia, "Noto Serif KR", "Noto Serif JP", "Noto Serif SC", serif;
  font-size: clamp(2.7rem, 7vw, 5.6rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.hero p { max-width: 43rem; color: var(--muted); font-size: clamp(1.05rem, 2.2vw, 1.3rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.hero .project-disclosure {
  max-width: 58rem;
  margin-top: 1.5rem;
  border-left: .2rem solid var(--accent-2);
  padding-left: .9rem;
  font-size: .9rem;
  line-height: 1.6;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .55rem 1rem;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
:root[data-theme="dark"] .button.primary { color: #11131a; }

.essay-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  padding: 0 0 5rem;
}
.essay-card {
  display: flex;
  min-height: 21rem;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.35rem, 4vw, 2.2rem);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
}
.essay-card .number { color: var(--accent-2); font-variant-numeric: tabular-nums; font-weight: 800; }
.essay-card h2 { margin: auto 0 .8rem; font-family: ui-serif, Georgia, serif; font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.25; }
.essay-card p { color: var(--muted); }
.essay-card a { margin-top: auto; align-self: flex-start; font-weight: 750; }

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 4rem; align-items: start; }
.article { width: 100%; max-width: var(--content); padding: 4.5rem 0 6rem; }
.article-layout > .article { grid-column: 1; grid-row: 1; }
.article-header { margin-bottom: 3.4rem; }
.article-header h1 {
  margin: .65rem 0 1.25rem;
  font-family: ui-serif, Georgia, "Noto Serif KR", "Noto Serif JP", "Noto Serif SC", serif;
  font-size: clamp(2.35rem, 6vw, 4.45rem);
  line-height: 1.13;
  letter-spacing: -.04em;
}
.article-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; color: var(--muted); font-size: .92rem; }
.article-body { font-family: ui-serif, Georgia, "Noto Serif KR", "Noto Serif JP", "Noto Serif SC", serif; font-size: clamp(1.04rem, 1.9vw, 1.16rem); }
.article-body h2, .article-body h3 { scroll-margin-top: 6rem; color: var(--text); line-height: 1.35; }
.article-body h2 { margin: 4.8rem 0 1.25rem; font-size: clamp(1.65rem, 3vw, 2.15rem); }
.article-body h3 { margin: 3rem 0 1rem; font-size: 1.35rem; }
.article-body p { margin: 1.2em 0; }
.article-body blockquote {
  margin: 2.1rem 0;
  border-left: .25rem solid var(--accent);
  border-radius: 0 .8rem .8rem 0;
  padding: .8rem 1.25rem;
  background: var(--quote);
  color: color-mix(in srgb, var(--text) 92%, var(--accent));
}
.article-body blockquote > :first-child { margin-top: 0; }
.article-body blockquote > :last-child { margin-bottom: 0; }
.article-body hr { width: 5rem; margin: 4rem auto; border: 0; border-top: .18rem solid var(--line); }
.article-body pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: 1rem;
  background: var(--surface-soft);
  font-size: .88rem;
  line-height: 1.55;
}
.article-body code { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
.headerlink { margin-left: .4em; color: var(--muted); opacity: 0; text-decoration: none; }
h2:hover .headerlink, h3:hover .headerlink, .headerlink:focus { opacity: 1; }

.toc-panel {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 6rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  margin-top: 4.5rem;
  border-left: 1px solid var(--line);
  padding-left: 1.2rem;
  font-size: .84rem;
}
.toc-title { margin: 0 0 .6rem; color: var(--text); font-weight: 800; cursor: pointer; }
.toc-panel ul { margin: 0; padding-left: 0; list-style: none; }
.toc-panel ul ul { margin-left: .8rem; }
.toc-panel li { margin: .42rem 0; }
.toc-panel a { color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc-panel a:hover { color: var(--accent); }

.translation-notice {
  margin-top: 1rem;
  border-left: .2rem solid var(--accent-2);
  padding-left: .85rem;
  color: var(--muted);
  font-size: .9rem;
}

.article-pagination { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 4.5rem; border-top: 1px solid var(--line); padding-top: 2rem; }
.article-pagination a { border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; color: var(--text); text-decoration: none; }
.article-pagination a:last-child { text-align: right; }
.article-pagination small { display: block; color: var(--muted); }

.prose-page { width: min(100%, var(--content)); padding: 5rem 0 7rem; }
.prose-page h1 { font-family: ui-serif, Georgia, serif; font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.15; }
.prose-page h2 { margin-top: 3rem; }
.language-list { display: flex; flex-wrap: wrap; gap: .75rem; padding: 0; list-style: none; }
.language-list a { display: block; border: 1px solid var(--line); border-radius: .75rem; padding: .7rem 1rem; background: var(--surface); }

.site-footer { border-top: 1px solid var(--line); }
.footer-inner { width: min(calc(100% - 2rem), var(--wide)); margin: auto; padding: 2rem 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .9rem; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 1rem; }

@media (max-width: 58rem) {
  .article-layout { display: block; }
  .article { margin: auto; }
  .toc-panel { position: static; max-height: none; margin: 0 auto 3rem; border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.2rem; }
  .toc-panel[open] .toc-title { margin-bottom: .7rem; }
}

@media (max-width: 43rem) {
  .nav { flex-wrap: wrap; gap: .45rem .8rem; padding: .55rem 0; }
  .brand { margin-right: auto; }
  .theme-toggle { margin-left: auto; }
  .language-switcher { order: 3; width: 100%; overflow-x: auto; padding-bottom: .1rem; }
  .nav-links { order: 4; width: 100%; margin: 0; justify-content: space-between; overflow-x: auto; }
  .essay-grid { grid-template-columns: 1fr; }
  .essay-card { min-height: 17rem; }
  .article { padding-top: 3rem; }
  .article-pagination { grid-template-columns: 1fr; }
  .article-pagination a:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  :root { --bg: white; --text: black; --muted: #444; }
  body { background: white; font-size: 11pt; }
  .site-header, .site-footer, .toc-panel, .article-pagination, .skip-link { display: none !important; }
  main, .article, .article-layout { display: block; width: auto; max-width: none; margin: 0; padding: 0; }
  .article-header { margin-bottom: 2rem; }
  .article-body { font-size: 11pt; line-height: 1.55; }
  .article-body h2 { break-after: avoid; margin-top: 2rem; }
  .article-body p, .article-body blockquote { orphans: 3; widows: 3; }
  .article-body a { color: black; text-decoration: none; }
  .article-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; word-break: break-all; }
}
