:root {
  --bg: #f7f7f5;
  --scrollbar-track: var(--bg);
  --scrollbar-thumb: #8f8475;
  --scrollbar-thumb-hover: #7d7264;
  --bg-warm: rgba(255, 180, 150, 0.1);
  --surface: #ffffff;
  --surface-muted: #fafaf8;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --text: #171717;
  --text-secondary: #6b6b67;
  --text-tertiary: #777772;
  --accent: #db2777;
  --accent-soft: rgba(219, 39, 119, 0.12);
  /* Semantic roles coexist with page-specific legacy tokens during migration. */
  --color-canvas: var(--bg);
  --color-surface: #fffdf8;
  --color-surface-muted: #f5f1e8;
  --color-ink: #1e1d1a;
  --color-ink-muted: #6d665e;
  --color-accent: #be185d;
  --color-accent-wash: #fce7f3;
  --color-divider: #ded6c9;
  --color-focus: #1e1d1a;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --container-reading: 720px;
  --container-tool: 960px;
  --container-editorial: 1200px;
  --border: rgba(20, 20, 20, 0.08);
  --border-strong: rgba(20, 20, 20, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(20, 20, 20, 0.04);
  --shadow-md: 0 10px 30px rgba(20, 20, 20, 0.06);
  --shadow-float: 0 18px 50px rgba(20, 20, 20, 0.1);
  --nav-h: 52px;
  --nav-top: 0px;
  --ease: 180ms cubic-bezier(0.22, 1, 0.36, 1);
  --content: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

/* Viewport colors belong on the root; body variables do not inherit upward.
   Magazine keeps its existing paper surface, including nested scroll areas. */
html:has(body.page-home),
body.page-home {
  --scrollbar-track: #f5f1e8;
}

html:has(body.mg-body),
body.mg-body {
  --bg: #f7f4ee;
  --scrollbar-track: var(--bg);
}

/* Retain native width and system high-contrast scrollbars in Firefox. */
@media (forced-colors: none) {
  * {
    scrollbar-width: auto;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }

  /* Modern Chromium also supports scrollbar-color, which otherwise overrides
     these parts. Use parts here for the matching corner and subtle hover. */
  @supports selector(::-webkit-scrollbar) {
    * { scrollbar-color: auto; }
    ::-webkit-scrollbar {
      width: 16px;
      height: 16px;
      background: var(--scrollbar-track);
    }
    ::-webkit-scrollbar-track,
    ::-webkit-scrollbar-corner {
      background: var(--scrollbar-track);
    }
    ::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border: 3px solid var(--scrollbar-track);
      border-radius: 16px;
      min-height: 32px;
      min-width: 32px;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: var(--scrollbar-thumb-hover);
    }
  }
}

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  overflow-x: hidden;
  position: relative;
  background: var(--bg);
  /* No bottom padding or UA margin: the footer ends the page on every route, so no
     strip of canvas shows below it (the footer used to float on some pages only). */
  margin: 0;
  padding: 64px 0 0;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 176, 148, 0.18), transparent 42%),
    radial-gradient(circle at 75% 10%, var(--bg-warm), transparent 35%),
    var(--bg);
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.scroll-progress-wrap {
  position: relative;
  height: 3px;
  width: 100%;
  flex-shrink: 0;
  z-index: 2;
  background: var(--color-surface);
  overflow: hidden;
}

/* Brand accent (original): the holographic gradient shared with the wordmark. */
.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ec4899, #a855f7, #6366f1);
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
  transition: width 0.08s ease-out;
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.site-nav-inner {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  padding: var(--space-1) max(12px, env(safe-area-inset-right)) var(--space-1) max(12px, env(safe-area-inset-left));
  min-height: 44px;
  height: auto;
  background: var(--color-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: none;
  border-bottom: 1px solid var(--color-divider);
  border-radius: 0;
  box-shadow: none;
}

.site-nav-wordmark {
  justify-self: start;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 6px 10px;
  min-height: 44px;
  font-weight: 900;
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  font-size: clamp(0.72rem, 2.25vw, 0.86rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  /* The Babdoduk brand mark keeps its original holographic gradient
     (owner decision); only its size and 44px target are new. */
  background: linear-gradient(
    110deg,
    #6366f1 0%,
    #a855f7 18%,
    #ec4899 36%,
    #06b6d4 55%,
    #8b5cf6 72%,
    #db2777 100%
  );
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: wordmark-holo 6s ease-in-out infinite;
  filter: none;
}

.site-nav-wordmark::before {
  content: none;
  display: none;
}

@keyframes wordmark-holo {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.site-nav-wordmark:hover {
  filter: brightness(1.08);
  color: transparent;
}

.site-nav-item {
  flex: 0 1 auto;
  font-size: clamp(0.62rem, 2.4vw, 0.72rem);
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  opacity: 0.88;
  transition: opacity 0.15s;
  white-space: nowrap;
  text-align: center;
}

.site-nav-item:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--color-ink);
}

.site-nav-item.is-current {
  opacity: 1;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-nav-lang {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  color: inherit;
}

.site-nav-item.site-nav-lang {
  justify-self: end;
  align-self: center;
  padding: 6px 10px;
  min-height: 44px;
  font-size: clamp(0.64rem, 2.25vw, 0.76rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  opacity: 0.92;
  border-radius: 0;
}

.site-nav-item.site-nav-lang:hover {
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nav-mega-row {
  justify-self: center;
  align-self: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 10px;
  row-gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.site-nav-direct {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 10px;
  color: var(--color-ink);
  font-size: clamp(0.68rem, 2.25vw, 0.78rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 8px;
}

.site-nav-direct:hover,
.site-nav-direct:focus-visible,
.site-nav-direct.is-current {
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-nav-wordmark:focus-visible,
.site-nav-direct:focus-visible,
.nav-mega-trigger:focus-visible,
.site-nav-item.site-nav-lang:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.nav-mega {
  position: relative;
}

.nav-mega-trigger {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 6px 10px;
  margin: 0;
  min-height: 44px;
  font-family: inherit;
  font-size: clamp(0.64rem, 2.25vw, 0.76rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  cursor: pointer;
  opacity: 0.88;
  border-radius: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.nav-mega-trigger:hover,
.nav-mega.is-open .nav-mega-trigger,
.nav-mega-trigger.is-current {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
}

.nav-mega-trigger::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 3px;
  border: solid transparent;
  border-width: 3px 3px 0 3px;
  border-top-color: var(--color-ink-muted);
  vertical-align: 2px;
  opacity: 0.75;
}

.nav-mega-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 11.5rem;
  max-width: min(18rem, calc(100vw - 24px));
  padding: 6px 0;
  background: var(--color-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 12px;
  border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-md);
  z-index: 10002;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, visibility 0.18s, transform 0.18s ease;
}

.nav-mega.is-open .nav-mega-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-mega-link {
  display: block;
  padding: 12px 14px;
  min-height: 44px;
  font-size: clamp(0.68rem, 2.2vw, 0.78rem);
  font-weight: 500;
  color: var(--color-ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  line-height: 1.35;
  transition: background 0.12s;
}

.nav-mega-link:hover,
.nav-mega-link:focus-visible {
  background: var(--color-accent-wash);
}

.nav-mega-link:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
}

/* A direct link with a long label shows a short one on phones (only one is ever rendered). */
.nav-label-short {
  display: none;
}

@media (max-width: 520px) {
  .nav-label-long {
    display: none;
  }

  .nav-label-short {
    display: inline;
  }

  .site-nav-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 2px;
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  .site-nav-wordmark,
  .site-nav-item.site-nav-lang {
    padding-left: 2px;
    padding-right: 2px;
    font-size: 0.75rem;
  }

  .nav-mega-row {
    flex-wrap: nowrap;
    column-gap: 0;
  }

  .site-nav-direct,
  .nav-mega-trigger {
    min-height: 44px;
    padding-left: 4px;
    padding-right: 4px;
    font-size: 0.75rem;
  }

  /* More now sits right of three direct links: its panel opens toward the left edge. */
  .nav-mega-panel {
    left: auto;
    right: 0;
    transform: translateY(-4px);
  }

  .nav-mega.is-open .nav-mega-panel {
    transform: translateY(0);
  }
}

/* The narrowest phones (under 380px): three direct links, More and the language switch still fit
   on one row without touching. */
@media (max-width: 379px) {
  .site-nav-wordmark,
  .site-nav-item.site-nav-lang,
  .site-nav-direct,
  .nav-mega-trigger {
    padding-left: 2px;
    padding-right: 2px;
    letter-spacing: -0.05em;     /* the text stays 12px (site guardian) */
  }
}

@media (max-width: 339px) {
  .site-nav-wordmark,
  .site-nav-item.site-nav-lang {
    padding-left: 0;
    padding-right: 0;
  }

  .nav-mega-trigger::after {
    margin-left: 2px;
  }
}

/* Page head: an index number and a one-line title. Pages speak through titles,
   dates, images, short metadata and actions, not lead paragraphs (DESIGN_SYSTEM.md). */
.page-head {
  padding: var(--space-8) 0 0;
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.045em;
  color: var(--color-ink);
  word-break: keep-all;
}

.page-num {
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

/* Section title followed by a thin rule: "지금 ────". */
.page-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}

.page-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-divider);
}

.site-footer {
  /* Stack above the fixed body::before canvas, like .page-fill. The footer has
     no surface of its own: on every page it sits on the page canvas, separated by
     the same rule, so it never reads as a slab on one page and not another. */
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: var(--space-12);
  background: transparent;
  color: var(--color-ink-muted);
  padding: 0 0 max(28px, env(safe-area-inset-bottom));
}

.site-footer-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
}

.footer-apple-hr {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: 0 0 16px;
}

.footer-apple-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px 16px;
  align-items: start;
  font-size: 0.75rem;
  line-height: 1.5;
}

.footer-apple-col--left {
  justify-self: start;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2px;
}

.footer-apple-col--center {
  justify-self: center;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0;
}

.footer-apple-col--right {
  justify-self: end;
  text-align: right;
  color: var(--color-ink-muted);
  font-weight: 500;
}

.footer-apple-copy {
  color: var(--color-ink-muted);
  word-break: keep-all;
}

.footer-apple-a {
  color: var(--color-ink);
}

.footer-apple-email-plain {
  color: var(--color-ink-muted);
  user-select: text;
}

.footer-apple-pipe {
  color: var(--color-divider);
  margin: 0 5px;
  user-select: none;
}

.footer-apple-a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  text-decoration: none;
  white-space: nowrap;
}

.footer-apple-a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.footer-apple-a:hover {
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-apple-fine {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-divider);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--color-ink-muted);
}

@media (max-width: 800px) {
  .footer-apple-main {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .footer-apple-col--left,
  .footer-apple-col--center,
  .footer-apple-col--right {
    justify-self: center;
    text-align: center;
    justify-content: center;
  }

  .footer-apple-col--left { order: 1; }
  .footer-apple-col--center { order: 2; }
  .footer-apple-col--right { order: 3; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn[aria-disabled="true"],
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--color-ink);
  color: var(--color-surface);
}

.btn-secondary {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--border-strong);
}

.page-fill {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:hover { transform: none; }
  .site-nav-wordmark,
  .scroll-progress-bar { animation: none; }
  .explore-card,
  .btn,
  .nav-mega-panel {
    transition: none !important;
  }
}
