/* Design tokens. Every colour, size and font used by the site is defined here.
   light-dark() picks the light or dark value automatically from the visitor's
   setting: Light / Dark (data-theme on <html>) or System (the device default). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0f1418);
  --surface: light-dark(#f4f6f8, #171d23);
  --text: light-dark(#1b1f23, #e7eaed);
  --muted: light-dark(#4b5563, #aab2bb);
  --border: light-dark(#d3d9df, #2c353e);
  --link: light-dark(#0a58a8, #82b6ee);
  --link-visited: light-dark(#5b3e96, #bba5ea);
  --accent: light-dark(#12304f, #0b1a2b);
  --accent-text: light-dark(#ffffff, #e7eaed);
  --notice-bg: light-dark(#fff6dc, #2a2410);
  --notice-border: light-dark(#d9b44a, #7a6420);
  --focus: light-dark(#b4410c, #ffb066);
  /* buttons */
  --btn-bg: light-dark(var(--bg), var(--surface));
  --btn-fg: light-dark(var(--accent), var(--text));
  --btn-border: light-dark(transparent, var(--border));
  --cta-bg: light-dark(var(--accent), var(--link));
  --cta-fg: light-dark(var(--accent-text), #0f1418);
  --cta-quiet-fg: light-dark(var(--accent), var(--link));
  /* shape and layout */
  --radius: 6px;
  --wrap: 78rem;
  --measure: 46rem;
  --header-h: 7.75rem;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  --font-head: Georgia, 'Times New Roman', Times, 'Noto Serif KR', serif;
}
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--font-body);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding-block: 1.5rem 3rem;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1rem;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}
a:visited {
  color: var(--link-visited);
}
a:hover {
  text-decoration-thickness: 2px;
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  inset-inline-start: 0.5rem;
  top: -4rem;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  z-index: 10;
  border-radius: var(--radius);
}
.skip-link:focus {
  top: 0.5rem;
}

.muted {
  color: var(--muted);
}


/* Korean breaks lines between words, not inside them. */
:lang(ko) { word-break: keep-all; }

/* ---------- header ---------- */
.site-header {
  background: var(--accent);
  color: var(--accent-text);
}
.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 0.75rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
}
.brand:visited {
  color: inherit;
}
.brand-name {
  font: 700 1.5rem/1 var(--font-head);
  letter-spacing: 0.01em;
}
.logo-slot {
  flex: none;
  opacity: 0.85;
}

.header-search {
  display: flex;
  gap: 0.4rem;
  flex: 1 1 14rem;
  min-width: 0;
  max-width: 24rem;
}
@media (max-width: 32rem) {
  .header-search {
    flex-basis: 100%;
    max-width: none;
  }
}
input[type='search'] {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
}
button:hover {
  filter: brightness(0.95);
}

.main-nav {
  border-top: 1px solid rgb(255 255 255 / 0.18);
}
.main-nav ul {
  list-style: none;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
}
.main-nav a {
  display: block;
  padding: 0.7rem 0.8rem;
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}
.main-nav a:visited {
  color: var(--accent-text);
}
.main-nav a:hover {
  background: rgb(255 255 255 / 0.1);
}
.main-nav a[aria-current] {
  border-bottom-color: currentColor;
  font-weight: 700;
}
.site-header :focus-visible {
  outline-color: #ffd29a;
}


/* Theme switch */
.theme-switch {
  display: inline-flex;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: var(--radius);
  overflow: hidden;
  flex: none;
}
.theme-switch button {
  background: transparent;
  color: var(--accent-text);
  border: 0;
  border-radius: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 2.25rem;
}
.theme-switch button + button {
  border-inline-start: 1px solid rgb(255 255 255 / 0.35);
}
.theme-switch button[aria-pressed='true'] {
  background: var(--accent-text);
  color: var(--accent);
  font-weight: 700;
}


/* ---------- header: sticky at every width, menu button on small screens ---------- */
html { scroll-padding-top: 7.25rem; }
@media (min-width: 52rem) { html { scroll-padding-top: calc(var(--header-h) + 1rem); } }
.site-header { position: sticky; top: 0; z-index: 20; }
.menu-toggle {
  display: none;
  background: transparent;
  color: var(--accent-text);
  border: 1px solid rgb(255 255 255 / 0.35);
  padding: 0;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  flex: none;
}
.theme-switch .ico { display: none; }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; }
.menu-toggle .close { display: none; }
.site-header.is-open .menu-toggle .close { display: inline; }
.site-header.is-open .menu-toggle .bars { display: none; }

@media (max-width: 51.99rem) {
  .header-row { flex-wrap: wrap; gap: 0.5rem 0.6rem; padding-block: 0.5rem; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-name { font-size: 1.35rem; }
  .logo-slot { width: 32px; height: 32px; }
  .theme-switch { order: 2; }
  .theme-switch .ico { display: block; }
  .theme-switch .lbl { display: none; }
  .theme-switch button { padding: 0; width: 2.4rem; min-height: 2.4rem; }
  .menu-toggle { order: 3; display: inline-flex; }
  .header-search { order: 4; flex: 1 1 100%; max-width: none; }
  .header-search input[type='search'] { padding-block: 0.4rem; }
  .header-search button { padding-block: 0.4rem; }
  .main-nav ul { flex-direction: column; padding-inline: 0; }
  .main-nav a { padding: 0.85rem 1rem; border-bottom: 0; border-inline-start: 4px solid transparent; }
  .main-nav a[aria-current] { border-inline-start-color: currentColor; background: rgb(255 255 255 / 0.08); }
  .main-nav li + li { border-top: 1px solid rgb(255 255 255 / 0.12); }
  .js .main-nav { display: none; }
  .js .site-header.is-open .main-nav { display: block; }
  .site-header.is-open { max-height: 100dvh; overflow-y: auto; }
  .header-row { padding-bottom: 0.6rem; }
}
@media (min-width: 52rem) {
  .menu-toggle { display: none; }
}



/* ---------- language menu: flag + name, drops down from the header ---------- */
.flag { flex: none; display: block; border-radius: 3px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18); }
.lang-menu { position: relative; flex: none; }
.lang-menu summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.4rem;
  padding: 0 0.7rem;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: var(--radius);
  color: var(--accent-text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { background: rgb(255 255 255 / 0.1); }
.lang-menu .chev { opacity: 0.8; transition: transform 0.15s; }
.lang-menu[open] .chev { transform: rotate(180deg); }
.lang-menu ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.4rem);
  z-index: 30;
  min-width: 11.5rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.22);
}
.lang-menu li a, .lang-switch li a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.lang-menu li a:hover { background: var(--surface, rgb(127 127 127 / 0.12)); }
.lang-menu li a[aria-current], .lang-switch li a[aria-current] { font-weight: 700; }
.lang-switch ul { list-style: none; margin: 0; padding: 0; }
.lang-switch li a { padding-inline: 0; }
@media (max-width: 51.99rem) {
  .lang-menu { order: 2; }
  .lang-menu .lang-current { display: none; }
  .lang-menu summary { padding: 0 0.6rem; gap: 0.4rem; }
}
@media (max-width: 51.99rem) {
  .header-row { gap: 0.5rem 0.4rem; }
  .brand { gap: 0.45rem; }
  .brand-name { font-size: 1.2rem; }
  .theme-switch button { width: 2.15rem; }
  .lang-menu .chev { display: none; }
  .lang-menu summary { padding: 0 0.5rem; }
}

/* Slim bar offering the page in the visitor's browser language */
.lang-offer { background: var(--surface, rgb(127 127 127 / 0.1)); border-bottom: 1px solid var(--border); }
.lang-offer-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 0.55rem; }
.lang-offer a { display: inline-flex; align-items: center; gap: 0.65rem; font-weight: 600; text-decoration: none; }
.lang-offer a:hover span { text-decoration: underline; }
.lang-offer-close { background: transparent; border: 0; color: inherit; font-size: 1.4rem; line-height: 1; padding: 0.1rem 0.5rem; min-height: 2rem; cursor: pointer; opacity: 0.7; }
.lang-offer-close:hover { opacity: 1; }

/* ---------- page furniture ---------- */
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.breadcrumb li + li::before {
  content: '/';
  margin-inline-end: 0.25rem;
  color: var(--muted);
}

.entry-header {
  max-width: none;
  margin-bottom: 1rem;
}
.kicker {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  line-height: 1.25;
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0 0 0.5rem;
}
.lede {
  font-size: 1.2rem;
  color: var(--muted);
  margin: 0;
  max-width: 52rem;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-inline-start-width: 5px;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  max-width: var(--measure);
}
.notice p {
  margin: 0;
}
.notice h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

/* ---------- article body ---------- */
.prose {
  max-width: var(--measure);
}
.prose h2 {
  font-size: 1.6rem;
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.prose h3 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.4rem;
}
.prose h4 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.3rem;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0.75rem 0;
}
.prose li {
  margin: 0.25rem 0;
}
.anchor {
  font-family: var(--font-body);
  font-size: 0.8em;
  margin-inline-start: 0.3rem;
  text-decoration: none;
  opacity: 0;
}
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
.anchor:focus {
  opacity: 0.7;
}
blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  border-inline-start: 4px solid var(--border);
  color: var(--muted);
}
code {
  font-size: 0.92em;
  background: var(--surface);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.cite {
  font-size: 0.75em;
  line-height: 0;
}
.cite a {
  text-decoration: none;
  padding: 0 0.1em;
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  max-width: 100%;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-size: 0.97rem;
}
th,
td {
  text-align: start;
  vertical-align: top;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
}
thead th {
  background: var(--surface);
}
tbody th {
  font-weight: 600;
}

/* ---------- entry layout: contents | text | facts ---------- */
.entry { display: block; }
.entry-main { min-width: 0; }
.entry-head .notice { max-width: var(--measure); }
.toc--side, .toc-show { display: none; }

/* Quick facts and ads live in the rail */
.rail { margin: 0 0 1.25rem; }
.rail-stack { display: grid; gap: 1rem; align-content: start; }
.infobox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem 0.45rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
.infobox h2 { font-size: 1.05rem; margin: 0 0 0.4rem; }
.infobox dl { margin: 0; }
.infobox dl > div { padding: 0.35rem 0; border-top: 1px solid var(--border); }
.infobox dt { font-weight: 700; font-size: 0.8rem; color: var(--muted); }
.infobox dd { margin: 0; overflow-wrap: anywhere; }
.infobox-more { border-top: 1px solid var(--border); }
.infobox-more summary { cursor: pointer; padding: 0.45rem 0; color: var(--link); font-size: 0.88rem; }
.infobox-more dl > div:first-child { border-top: 1px solid var(--border); }

/* Contents bar (narrow screens) */
.toc--bar { margin: 0 0 1rem; max-width: var(--measure); }
.toc--bar details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.toc--bar summary { cursor: pointer; padding: 0.6rem 1rem; font-weight: 700; font-family: var(--font-head); }
.toc--bar ol { margin: 0; padding: 0 1rem 0.75rem 2.25rem; font-size: 0.95rem; }
.toc--bar ol ol { list-style: lower-alpha; }

/* Advertising slots: labelled, fixed height, never inside text */
.ad { margin: 0; }
.ad-label { margin: 0 0 0.25rem; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ad-box { display: grid; place-items: center; max-width: 336px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ad-box img { display: block; max-width: 100%; height: auto; }
.ad-preview { color: var(--muted); font-size: 0.85rem; }
.ad--article { margin: 1.5rem 0; }

@media (min-width: 66rem) {
  .entry { display: grid; grid-template-columns: minmax(0, 1fr) 17.5rem; column-gap: 2.5rem; align-items: start; }
  .entry-head { grid-column: 1 / -1; }
  .toc--bar { grid-column: 1; grid-row: 2; }
  .entry-main { grid-column: 1; grid-row: 3; }
  .rail { grid-column: 2; grid-row: 2 / span 2; align-self: stretch; margin: 0; }
  .entry:not(.has-toc) .entry-main { grid-row: 2; }
  .entry:not(.has-toc) .rail { grid-row: 2; }
  .rail-stack { position: sticky; top: calc(var(--header-h) + 1rem); }
  /* With an ad: Quick facts scroll away normally and the ad stays in view beside the text. */
  .rail--ad .rail-stack { position: static; height: 100%; grid-template-rows: auto 1fr; }
  .rail--ad .ad--rail { align-self: start; position: sticky; top: calc(var(--header-h) + 1rem); }
  .ad--article { display: none; }
}
@media (min-width: 78rem) {
  .entry.has-toc { grid-template-columns: 13rem minmax(0, 1fr) 17.5rem; column-gap: 2rem; }
  .entry.has-toc .entry-head { grid-column: 2 / -1; grid-row: 1; }
  .entry.has-toc .toc--bar { display: none; }
  .entry.has-toc .toc--side { display: block; grid-column: 1; grid-row: 1 / span 2; align-self: stretch; font-size: 0.9rem; }
  .toc-inner { position: sticky; top: calc(var(--header-h) + 1rem); max-height: calc(100vh - var(--header-h) - 2rem); overflow-y: auto; padding-inline-end: 0.5rem; }
  .entry.has-toc .entry-main { grid-column: 2; grid-row: 2; }
  .entry.has-toc .rail { grid-column: 3; grid-row: 2; }
  /* hidden by the visitor */
  .entry.has-toc.toc-hidden { grid-template-columns: minmax(0, 1fr) 17.5rem; column-gap: 2.5rem; }
  .entry.has-toc.toc-hidden .toc--side { display: none; }
  .entry.has-toc.toc-hidden .entry-head { grid-column: 1 / -1; }
  .entry.has-toc.toc-hidden .entry-main { grid-column: 1; }
  .entry.has-toc.toc-hidden .rail { grid-column: 2; }
  .entry.has-toc.toc-hidden .toc-show:not([hidden]) { display: inline-block; }
}

/* Contents column */
.toc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 0.4rem; }
.toc-title { font-size: 1rem; margin: 0; }
.toc-hide, .toc-show {
  font: inherit; font-size: 0.78rem; font-weight: 500; padding: 0.1rem 0.5rem; line-height: 1.5;
  background: var(--surface); color: var(--link); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.toc-show { margin-top: 0.5rem; }
.toc--side ol { list-style: none; margin: 0; padding: 0; }
.toc--side li { margin: 0; }
.toc--side a { display: block; padding: 0.28rem 0 0.28rem 0.7rem; border-inline-start: 2px solid transparent; text-decoration: none; line-height: 1.35; }
.toc--side a:hover { text-decoration: underline; }
.toc--side ol ol a { padding-inline-start: 1.5rem; font-size: 0.86rem; }
.toc--side li.is-current > a { border-inline-start-color: var(--link); font-weight: 700; color: var(--text); }
.js .toc--side ol ol { display: none; }
.js .toc--side li.is-current > ol { display: block; }

/* ---------- lists & cards ---------- */
.card-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: grid;
  gap: 0.75rem;
}
.card-list > li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: var(--bg);
}
.card-list--grid {
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
.card-link {
  font: 700 1.1rem/1.3 var(--font-head);
}
.meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-inline-start: 0.4rem;
}
.card-summary {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.97rem;
}
.plain-list {
  padding-inline-start: 1.2rem;
}

.related,
.sources,
.backlinks {
  max-width: var(--measure);
  margin-top: 2rem;
}
.related h2,
.sources h2,
.backlinks h2 {
  font-size: 1.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}
.sources ol {
  padding-inline-start: 1.5rem;
  font-size: 0.97rem;
}
.sources li:target {
  background: var(--notice-bg);
}
.entry-footer {
  max-width: var(--measure);
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}


/* ---------- footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}
.footer-grid {
  display: grid;
  gap: 1.5rem;
  padding-block: 1.5rem;
}
@media (min-width: 40rem) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}
.footer-title {
  font-weight: 700;
  margin: 0 0 0.4rem;
}
.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer p {
  margin: 0.25rem 0;
}
.footer-base {
  border-top: 1px solid var(--border);
  padding-block: 0.75rem;
  color: var(--muted);
}

@media print {
  .site-header,
  .site-footer,
  .skip-link,
  .breadcrumb,
  .anchor {
    display: none !important;
  }
  body {
    font-size: 11pt;
  }
  a {
    color: inherit;
  }
  .infobox {
    float: none;
  }
}


.index-group { margin: 2rem 0 .75rem; font-size: 1.25rem; }
.index-group:first-of-type { margin-top: 1.5rem; }

.index-region { margin: 1.5rem 0 .5rem; font-size: 1.1rem; }
.index-city { margin: 1.1rem 0 .4rem; font-size: 1rem; }
nav.toc ul ul { margin-top: .25rem; }

.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.25rem 0 0; }
.button { display: inline-block; background: var(--cta-bg); color: var(--cta-fg); padding: .55rem 1rem; border-radius: 4px; text-decoration: none; font-weight: 600; border: 1px solid var(--cta-bg); }
.button--quiet { background: transparent; color: var(--cta-quiet-fg); }
.button:visited { color: var(--cta-fg); }
.button--quiet:visited { color: var(--cta-quiet-fg); }
.button:hover { text-decoration: underline; }
.section-note { margin: .1rem 0 .75rem; font-size: .95rem; }
.chip-list { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-list a { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .85rem; text-decoration: none; }
.chip-list a:hover { border-color: var(--accent); text-decoration: underline; }


.chip-group { margin: 0.75rem 0; }
.chip-label { margin: 0 0 0.25rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.chip-group .chip-list { margin: 0.25rem 0 0; }

/* School finder */
.finder { margin: 1rem 0 1.25rem; max-width: 40rem; }
.finder-label { display: block; font: 700 1.05rem var(--font-head); margin-bottom: 0.35rem; }
.finder-row { display: flex; gap: 0.5rem; }
.finder-row input[type='search'] { padding: 0.7rem 0.9rem; font-size: 1.05rem; }
.finder-row button { background: var(--accent); color: var(--accent-text); padding-inline: 1.25rem; }
.finder-status { margin: 0.5rem 0; }
.finder-status:empty, .finder-results:empty { display: none; }
.place-block { margin: 0 0 0.75rem; }
.index-group a, .index-region a { color: inherit; text-decoration-color: var(--border); }
.index-group a:visited, .index-region a:visited { color: inherit; }
#finder-browse[hidden] { display: none; }

/* Lineage links and chart */
.lineage { max-width: var(--measure); margin-top: 2rem; }
.lineage h2 { font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.lineage dl { margin: 0.5rem 0; }
.lineage dl > div { display: grid; grid-template-columns: 9rem 1fr; gap: 0.5rem; padding: 0.3rem 0; }
.lineage dt { font-weight: 700; color: var(--muted); font-size: 0.9rem; }
.lineage dd { margin: 0; }
@media (max-width: 30rem) { .lineage dl > div { grid-template-columns: 1fr; gap: 0; } }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-inline-start: 0.6rem; padding-inline-start: 1.1rem; border-inline-start: 2px solid var(--border); }
.tree li { margin: 0.35rem 0; position: relative; }
.tree ul > li::before { content: ''; position: absolute; left: -1.1rem; top: 0.85rem; width: 0.8rem; border-top: 2px solid var(--border); }
.tree-kwan > a { font: 700 1.1rem var(--font-head); }
.tree .meta { font-size: 0.85rem; color: var(--muted); }
.tree-school::after { content: ' · school'; font-size: 0.8rem; color: var(--muted); }

/* ---------- home ---------- */
.hero {
  padding: clamp(1.25rem, 4vw, 2.5rem);
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.15;
}
.hero .lede {
  max-width: 48rem;
}
main > section.notice {
  max-width: none;
}
.hero-search {
  display: flex;
  gap: 0.5rem;
  margin: 1.25rem 0;
  max-width: 34rem;
}
.hero-search button {
  background: var(--accent);
  color: var(--accent-text);
}
main > section > h2 {
  font-size: 1.5rem;
  margin: 2rem 0 0.25rem;
}


/* ---------- design layer: colour, depth, motion, footer, language menu ----------
   Loaded last, so it refines the base styles. Change the tokens here and every page follows. */
:root {
  --red: light-dark(#c8102e, #ff5d73);
  --gold: light-dark(#b98a1b, #e6b94a);
  --accent-2: light-dark(#1d4e7e, #12304f);
  --surface-2: light-dark(#eaf0f6, #1c252e);
  --shadow-sm: 0 1px 2px rgb(10 30 55 / 0.06), 0 2px 8px rgb(10 30 55 / 0.06);
  --shadow-md: 0 2px 4px rgb(10 30 55 / 0.08), 0 12px 28px rgb(10 30 55 / 0.14);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --radius: 10px;
}
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
::selection { background: color-mix(in srgb, var(--red) 28%, transparent); }

/* never break a name across lines */
.wl, .card-link, .chip-list a, .infobox th, tbody th { overflow-wrap: normal; }
.wl { white-space: nowrap; }
.chip-list a, .lang-switch a { white-space: nowrap; }
tbody th { white-space: nowrap; }
tbody th:lang(ja), tbody th:lang(zh) { white-space: normal; }
td { min-width: 6rem; }
td:last-child { min-width: 9rem; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(115deg, #0b1a2b 0%, var(--accent-2) 100%);
  border-bottom: 3px solid var(--red);
  box-shadow: 0 4px 18px rgb(10 30 55 / 0.25);
}
.brand-name { letter-spacing: 0.02em; }

/* ---------- headings & prose ---------- */
h1, h2, h3 { letter-spacing: -0.01em; }
.prose h2, .entry-main h2 { position: relative; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.prose h2::after, .entry-main h2::after { content: ''; position: absolute; inset-inline-start: 0; bottom: -1px; width: 3.5rem; height: 3px; background: var(--red); border-radius: 2px; }
a { text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.breadcrumb { font-size: 0.88rem; }

/* ---------- tables ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--bg); }
table { border-collapse: separate; border-spacing: 0; min-width: 34rem; }
th, td { border: 0; border-bottom: 1px solid var(--border); }
tbody tr:last-child > * { border-bottom: 0; }
thead th { background: var(--surface-2); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tbody tr:hover > * { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* ---------- notices, infobox, TOC ---------- */
.notice { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.infobox { border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.infobox h2, .infobox caption { background: linear-gradient(115deg, #0b1a2b, var(--accent-2)); color: #fff; }

/* ---------- buttons & chips ---------- */
.button, .hero-search button { transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s; }
.button:hover, .hero-search button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.chip-list a { background: var(--bg); transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease), box-shadow 0.15s; }
.chip-list a:hover { background: var(--surface-2); border-color: var(--red); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ---------- cards ---------- */
.card-list > li {
  position: relative;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem 1rem 1.25rem;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}
.card-list > li::before { content: ''; position: absolute; inset-block: 0.8rem; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--red); opacity: 0.85; }
.card-list > li:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.card-link { text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ---------- home hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  border: 0;
  border-radius: 16px;
  padding: clamp(1.75rem, 6vw, 4rem);
  background:
    radial-gradient(60rem 30rem at 0% 0%, rgb(255 255 255 / 0.08), transparent 60%),
    linear-gradient(125deg, #0b1a2b 0%, #14395f 55%, #1d4e7e 100%);
  box-shadow: var(--shadow-md);
}
.hero::before {
  /* taegeuk-inspired disc */
  content: '';
  position: absolute;
  z-index: -1;
  inset-inline-end: clamp(-9rem, -8vw, -3rem);
  top: 50%;
  width: clamp(16rem, 38vw, 30rem);
  aspect-ratio: 1;
  transform: translateY(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 25%, #1d4e7e 0 24%, transparent 25%),
    radial-gradient(circle at 50% 75%, #c8102e 0 24%, transparent 25%),
    linear-gradient(180deg, #c8102e 50%, #1d4e7e 50%);
  opacity: 0.32;
  filter: saturate(0.9);
}
.hero h1 { color: #fff; font-size: clamp(2.1rem, 5.5vw, 3.6rem); letter-spacing: -0.02em; max-width: 20ch; text-wrap: balance; }
.hero .lede { color: rgb(255 255 255 / 0.86); font-size: clamp(1.02rem, 2vw, 1.2rem); }
.hero a:not(.button) { color: #bcd9f7; }
.hero-search input[type='search'] { border: 0; box-shadow: 0 2px 10px rgb(0 0 0 / 0.25); padding: 0.75rem 1rem; border-radius: 999px; color: #1b1f23; background: #fff; }
.hero-search button { background: var(--red); color: #fff; border-radius: 999px; padding-inline: 1.4rem; border: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.hero .button { background: #fff; color: #0b1a2b; border-color: #fff; border-radius: 999px; }
.hero .button--quiet { background: transparent; color: #fff; border: 1px solid rgb(255 255 255 / 0.55); }
main > section > h2 { font-size: 1.6rem; margin-top: 2.75rem; }

/* ---------- language menu: compact, ~10 rows visible, then scrolls ---------- */
.lang-menu ul {
  min-width: 12.5rem;
  max-height: min(21.5rem, calc(100vh - var(--header-h, 6rem) - 1rem));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
  scrollbar-gutter: stable;
  padding: 0.3rem 0.15rem 0.3rem 0.3rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.lang-menu ul::-webkit-scrollbar { width: 8px; }
.lang-menu ul::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 8px; }
.lang-menu li a { padding: 0.3rem 0.55rem; gap: 0.6rem; min-height: 2rem; line-height: 1.2; white-space: nowrap; }
.lang-menu li a .flag { width: 22px; height: auto; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 4rem;
  background: linear-gradient(180deg, #0b1a2b 0%, #0a1624 100%);
  color: #c9d4df;
  border-top: 3px solid var(--red);
  font-size: 0.95rem;
}
.site-footer a { color: #e6eef7; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .muted { color: #93a3b4; }
.footer-grid { padding-block: 2.5rem 1.75rem; gap: 2rem; }
@media (min-width: 40rem) { .footer-grid { grid-template-columns: 1.6fr 1fr 1fr; gap: 3rem; } }
.footer-name { font: 700 1.5rem/1.2 var(--font-head); margin: 0 0 0.4rem; }
.footer-title { color: #fff; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 0.75rem; }
.site-footer ul { display: grid; gap: 0.5rem; }
.site-footer .lang-switch { padding-block: 1.25rem 1.5rem; border-top: 1px solid rgb(255 255 255 / 0.1); }
.lang-switch ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.4rem 0.75rem; }
.lang-switch li a { padding: 0.3rem 0.5rem; border-radius: 8px; color: #dbe6f1; gap: 0.6rem; }
.lang-switch li a:hover { background: rgb(255 255 255 / 0.08); text-decoration: none; }
.lang-switch li a[aria-current] { background: rgb(255 255 255 / 0.12); color: #fff; }
.lang-switch .flag { width: 22px; height: auto; }
.site-footer .footer-base {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-top: 1px solid rgb(255 255 255 / 0.1); color: #93a3b4; padding-block: 1.1rem 1.5rem; font-size: 0.88rem;
}
.footer-legal p { margin: 0.2rem 0; }
.to-top { flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 1px solid rgb(255 255 255 / 0.25); transition: background 0.15s, transform 0.15s var(--ease); }
.to-top:hover { background: rgb(255 255 255 / 0.12); transform: translateY(-2px); text-decoration: none !important; }
@media (max-width: 39.99rem) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---------- home: stat strip and library tiles ---------- */
.hero-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; margin: 2rem 0 0; padding: 1.25rem 0 0; border-top: 1px solid rgb(255 255 255 / 0.18); }
.hero-stats strong { display: block; font: 700 clamp(1.6rem, 4vw, 2.2rem)/1 var(--font-head); color: #fff; }
.hero-stats span { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: rgb(255 255 255 / 0.7); }
.card-list > li > .tile-icon { display: block; margin-bottom: 0.5rem; padding: 0.55rem; width: 2.6rem; height: 2.6rem; box-sizing: border-box; color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: 12px; }

/* ---------- wide tables on phones: each row becomes a labelled card ---------- */
@media (max-width: 40rem) {
  .table-wrap { overflow: visible; border: 0; box-shadow: none; background: transparent; }
  .table-wrap table { min-width: 0; display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-wrap tbody, .table-wrap tr { display: block; }
  .table-wrap tr { margin: 0 0 0.85rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
  .table-wrap tbody th { display: block; white-space: normal; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 1.02rem; }
  .table-wrap td { display: grid; grid-template-columns: 7rem 1fr; gap: 0.75rem; min-width: 0; padding: 0.5rem 0.75rem; }
  .table-wrap td::before { content: attr(data-label); font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding-top: 0.15rem; }
  .table-wrap td:has(> .cell:empty) { display: none; }
}
