/* =========================================================
   Woojae Joo — Developer Note
   Design system: refined dark + light, editorial tech blog
   ========================================================= */

/* Smooth cross-page navigation (progressive enhancement; supported in Chromium). */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.28s;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

:root {
  color-scheme: light;

  --bg: #fbfaf7;
  --bg-tint: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --ink: #15171c;
  --ink-soft: #3a3f48;
  --muted: #6d7480;
  --faint: #9aa0aa;
  --line: #e7e3da;
  --line-strong: #d8d3c7;

  --accent: #0071e3;
  --accent-ink: #0062c4;
  --accent-soft: #eaf3fe;
  --on-accent: #ffffff;
  --code-ink: #d92d3a;

  /* liquid glass */
  --glass: color-mix(in srgb, var(--surface) 62%, transparent);
  --glass-strong: color-mix(in srgb, var(--surface) 78%, transparent);
  --glass-edge: rgba(237, 241, 248, 0.85);
  --header-edge: rgba(240, 244, 250, 0.92);
  --glass-shade: rgba(21, 23, 28, 0.06);
  --blur: blur(22px) saturate(180%);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(21, 23, 28, 0.04), 0 2px 8px rgba(21, 23, 28, 0.04);
  --shadow-md: 0 8px 30px rgba(21, 23, 28, 0.08);
  --shadow-lg: 0 28px 60px rgba(21, 23, 28, 0.14);

  --max: 1120px;
  --header-h: 82px;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0b0e;
  --bg-tint: #0f1115;
  --surface: #131519;
  --surface-2: #1a1d23;
  --ink: #f4f4f6;
  --ink-soft: #f0f1f4;
  --muted: #e2e5ea;
  --faint: #c2c8d2;
  --line: #23262d;
  --line-strong: #2e323b;

  --accent: #0a84ff;
  --accent-ink: #4aa3ff;
  --accent-soft: #0e1a2b;
  --on-accent: #ffffff;
  --code-ink: #d92d3a;

  --glass: color-mix(in srgb, var(--surface) 55%, transparent);
  --glass-strong: color-mix(in srgb, var(--surface) 72%, transparent);
  --glass-edge: rgba(255, 255, 255, 0.1);
  --header-edge: rgba(255, 255, 255, 0.12);
  --glass-shade: rgba(0, 0, 0, 0.4);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle film grain overlay for depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] body::before {
  opacity: 0.05;
}

/* Soft ambient color washes so glass surfaces have depth */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 36% at 14% 4%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(36% 32% at 90% 12%, color-mix(in srgb, #34c0d6 14%, transparent), transparent 70%),
    radial-gradient(44% 40% at 78% 92%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%);
}

:root[data-theme="dark"] body::after {
  opacity: 0.8;
}

main,
.site-header,
.site-footer {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.shell {
  width: min(100% - 40px, var(--max));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 60;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  overflow-wrap: break-word;
}

/* ============================ Header ============================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(100% - 40px, var(--max));
  margin-inline: auto;
  height: var(--header-h);
  padding-inline: 22px;
}

/* Floating "liquid glass" capsule that sits within the header band. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 10px 0;
  border-radius: 20px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 58%, transparent),
    color-mix(in srgb, var(--surface) 44%, transparent)
  );
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border: 1px solid var(--header-edge);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  z-index: -1;
  transition: background 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.site-header[data-scrolled]::before {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 82%, transparent),
    color-mix(in srgb, var(--surface) 70%, transparent)
  );
  border-color: var(--header-edge);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* Light theme reads glass via crisp highlights + a soft float, not refraction —
   so give the light capsule brighter specular edges and a cooler drop shadow. */
[data-theme="light"] .site-header::before {
  box-shadow:
    0 12px 34px rgba(24, 36, 60, 0.1),
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -7px 16px rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .site-header[data-scrolled]::before {
  box-shadow:
    0 18px 46px rgba(24, 36, 60, 0.14),
    inset 0 1px 1px rgba(255, 255, 255, 1),
    inset 0 -7px 16px rgba(255, 255, 255, 0.45);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-name {
  font-weight: 650;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.site-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.site-nav a {
  position: relative;
  z-index: 1;
  padding: 9px 16px;
  border-radius: 999px;
  color: var(--ink); /* black in light theme, white in dark theme */
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.32s ease;
}

/* Hover, keyboard focus, or the current item: text picks up the accent blue. */
.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a.is-active {
  color: var(--accent-ink);
}

/* One frosted-glass capsule that slides between items (Apple dock style). */
.nav-glass {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.16)
  );
  -webkit-backdrop-filter: blur(8px) brightness(1.04);
  backdrop-filter: blur(8px) brightness(1.04);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.85),
    inset 0 -2px 4px rgba(255, 255, 255, 0.28),
    0 5px 16px rgba(0, 0, 0, 0.13);
  transition:
    transform 0.45s cubic-bezier(0.32, 1.12, 0.4, 1),
    width 0.45s cubic-bezier(0.32, 1.12, 0.4, 1),
    height 0.3s ease,
    opacity 0.3s ease;
  will-change: transform, width;
}

/* No slide on first placement or on resize. */
.nav-glass.no-anim {
  transition: none;
}

[data-theme="dark"] .nav-glass {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.06)
  );
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.28),
    inset 0 -2px 4px rgba(255, 255, 255, 0.08),
    0 6px 18px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .site-nav a {
    transition: color 0.2s ease;
  }
  .nav-glass {
    transition: opacity 0.2s ease;
  }
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--glass-edge);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.icon-button:hover {
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  transform: translateY(-1px);
}

/* Mobile menu button (injected by palette.js) — a bottom-right FAB on mobile; hidden on
   desktop, where the full nav shows. (.fab.nav-toggle beats .fab's own display.) */
.fab.nav-toggle {
  display: none;
}

/* ============================ Buttons ============================ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.button.primary {
  position: relative;
  overflow: hidden;
  background: var(--accent);
  color: var(--on-accent);
}

/* Light-blue top-edge gradient on hover — the blue button's take on the card effect. */
.button.primary::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, #5bc8ff, transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 38%, transparent);
}

.button.primary:hover::before {
  opacity: 1;
}

.button.ghost {
  position: relative;
  overflow: hidden;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-color: var(--glass-edge);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  color: var(--ink);
}

/* White-gradient top edge on hover — the white button's take on the same effect. */
.button.ghost::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.95), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.button.ghost:hover {
  border-color: var(--header-edge);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 95%, transparent),
    color-mix(in srgb, var(--surface) 62%, transparent)
  );
  box-shadow: var(--shadow-md), inset 0 1px 1px rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
}

.button.ghost:hover::before {
  opacity: 1;
}

/* ============================ Hero ============================ */

.hero {
  position: relative;
  margin-top: calc(var(--header-h) * -1);
  padding: calc(var(--header-h) + 64px) 0 72px;
  overflow: hidden;
  isolation: isolate;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(50% 60% at 14% 6%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    radial-gradient(46% 54% at 92% 0%, color-mix(in srgb, #34c0d6 12%, transparent), transparent 58%);
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, var(--bg) 100%);
}

/* per-element hover reactions */
.hero h1 {
  transition: text-shadow 0.35s ease;
}

.hero h1:hover {
  text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 42%, transparent);
}

.hero-note {
  width: fit-content;
  transition: filter 0.3s ease;
}

.hero-note strong {
  transition: text-shadow 0.3s ease;
}

.hero-note:hover {
  filter: brightness(1.2);
}

.hero-note:hover strong {
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 65%, transparent);
}

.trade-off-art {
  transform-origin: center;
  transition: transform 0.4s ease, filter 0.4s ease;
}

.trade-off-art:hover {
  transform: scale(1.025);
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 30%, transparent));
}

/* chart nodes react on hover — the node itself grows a little */
.trade-off-art .node {
  cursor: pointer;
  outline: none;
  transition: color 0.3s ease;
}

.trade-off-art .node-dot,
.trade-off-art .node-glow {
  transition: r 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.trade-off-art .node-label {
  transition: fill 0.25s ease;
}

.trade-off-art .node:hover,
.trade-off-art .node:focus-visible {
  color: var(--accent-ink);
}

.trade-off-art .node:hover .node-dot,
.trade-off-art .node:focus-visible .node-dot {
  r: 8.5px;
}

.trade-off-art .node:hover .node-glow,
.trade-off-art .node:focus-visible .node-glow {
  r: 20px;
}

.trade-off-art .node:hover .node-label,
.trade-off-art .node:focus-visible .node-label {
  font-weight: 700;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 40px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.3rem, 5vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.hero h1 em {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent-ink);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-note {
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.hero-note strong {
  color: var(--accent-ink);
  font-weight: 700;
}

.hero-art {
  display: grid;
  place-items: center;
}

.trade-off-art {
  width: 100%;
  max-width: 460px;
  height: auto;
  color: var(--ink);
}

.trade-off-art .art-label {
  fill: currentColor;
  font-family: var(--font-sans);
  font-size: 13px;
}

.trade-off-art .art-label.strong {
  font-weight: 600;
}

.trade-off-art .art-label.axis {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  opacity: 0.55;
}

/* Dark mode: brighten the chart axes and their labels toward white. */
[data-theme="dark"] .trade-off-art path[stroke="currentColor"] {
  stroke-opacity: 0.72;
}

[data-theme="dark"] .trade-off-art .art-label.axis {
  opacity: 0.9;
}

@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }

  .hero-art {
    display: none;
  }
}

/* ============================ Stat bar ============================ */

.metrics {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 36px;
  padding: 18px 26px;
  margin-bottom: 28px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  transition:
    transform 0.35s cubic-bezier(0.34, 1.2, 0.5, 1),
    box-shadow 0.35s ease,
    background 0.35s ease,
    border-color 0.35s ease;
}

/* Liquid-glass response on hover: the glass lifts and brightens (no sweep). */
.metrics:hover {
  transform: translateY(-2px);
  border-color: var(--header-edge);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 70%, transparent),
    color-mix(in srgb, var(--surface) 38%, transparent)
  );
  box-shadow:
    var(--shadow-md),
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    inset 0 -4px 10px rgba(255, 255, 255, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  .metrics {
    transition: box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
  }
  .metrics:hover {
    transform: none;
  }
}

.metrics div {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.metrics strong {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.metrics span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================ Sections ============================ */

.section {
  margin: 104px auto;
}

.section-heading {
  max-width: 640px;
  margin-bottom: 36px;
}

.section-heading h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.12;
}

.section-heading p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

/* ============================ Toolbar / filters ============================ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  max-width: 340px;
}

.search-box::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 1.1rem;
}

.search-box input {
  width: 100%;
  min-height: 46px;
  padding: 0 16px 0 38px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 1px rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 72%, transparent),
    color-mix(in srgb, var(--surface) 30%, transparent)
  );
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow:
    var(--shadow-sm),
    inset 0 1px 1px rgba(255, 255, 255, 0.8),
    inset 0 -2px 5px rgba(255, 255, 255, 0.14);
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, transform 0.2s ease;
}

/* Hover: the glass simply lifts and clears — neutral, no accent tint, no sweep. */
/* Blue top-edge gradient on hover — same effect as the cards. */
.filter-button::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.filter-button:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow:
    var(--shadow-md),
    inset 0 1px 1px rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}

[data-theme="dark"] .filter-button:hover {
  box-shadow:
    var(--shadow-md),
    inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.filter-button:hover::before {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .filter-button {
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  }
  .filter-button:hover {
    transform: none;
  }
}

.filter-button[aria-pressed="true"] {
  border-color: transparent;
  color: var(--on-accent);
  background: var(--accent);
}

/* ============================ Post grid ============================ */

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-md);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.post-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.post-card:hover,
.post-card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
}

.post-card:hover::before,
.post-card:focus-visible::before {
  opacity: 1;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.cat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.cat::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

/* Clickable tag chips on cards (filter by tag without following the card link). */
.badge[data-tag] {
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.badge[data-tag]:hover,
.badge[data-tag]:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}

/* "Filtering by #tag" indicator above the post grid. */
.active-tag[hidden] {
  display: none;
}

.active-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 0.86rem;
  color: var(--muted);
}

.active-tag-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.active-tag strong {
  color: var(--ink);
  font-weight: 650;
}

.active-tag-clear {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 11px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.active-tag-clear:hover {
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.post-card h3 {
  font-size: 1.22rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.post-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
}

.empty-state {
  padding: 40px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  text-align: center;
}

/* ============================ Topics ============================ */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.topic-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-md);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

/* Blue top-edge gradient that fades in on hover — same as the post cards. */
.topic-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.topic-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
}

.topic-card:hover::before {
  opacity: 1;
}

.topic-card strong {
  font-size: 1rem;
  font-weight: 650;
}

.topic-card span {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}

/* ============================ About ============================ */

.about-section {
  scroll-margin-top: 90px;
}

.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  align-items: start;
}

.about-main {
  min-width: 0;
}

.about-content {
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.8;
}

.about-content > :first-child {
  margin-top: 0;
}

.about-content h2 {
  margin: 36px 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.5rem;
}

.about-content h3 {
  margin: 28px 0 10px;
  font-size: 1.12rem;
  font-weight: 650;
}

.about-content p {
  margin: 14px 0;
}

.about-content ul,
.about-content ol {
  margin: 14px 0;
  padding-left: 22px;
}

.about-content li {
  margin: 6px 0;
}

.about-content a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

.about-content hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.about-aside {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 18px;
}

.profile-card {
  padding: 24px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
  text-align: center;
}

.avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Profile photo — matched exactly to the Notion page icon (124px square, cover crop, 4px radius) */
.avatar.has-photo {
  width: 124px;
  height: 124px;
  border-radius: 4px;
  overflow: hidden;
}

.avatar.has-photo img {
  object-fit: cover;
  object-position: 50% 50%;
}

.profile-card .name {
  font-size: 1.15rem;
  font-weight: 650;
}

.profile-card .role {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.profile-links {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.profile-links a {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-sm);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.profile-links a::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.profile-links a:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
  transform: translateY(-2px);
}

.profile-links a:hover::before {
  opacity: 1;
}

.facts-card {
  padding: 20px 24px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-lg);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
}

.facts-card h4 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}

.facts-card .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* "Writing about" chips wear the accent blue (informational, not filters). */
.facts-card .chips .badge {
  color: var(--accent-ink);
}

/* ============================ Footer ============================ */

.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  width: min(100% - 40px, var(--max));
  margin-inline: auto;
  padding: 40px 0 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}

.footer-inner a:hover {
  color: var(--accent-ink);
}

.footer-links {
  display: flex;
  gap: 18px;
}

/* ============================ Article (post page) ============================ */

.article-shell {
  width: min(100% - 40px, var(--max));
  margin: 56px auto 110px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  column-gap: 56px;
  row-gap: 24px;
  align-items: start;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent-ink);
}

.article {
  min-width: 0;
}

.article h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.article-meta .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--faint);
}

/* Clickable tag links in the post header meta. */
.meta-tag {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.16s ease;
}

.meta-tag:hover {
  color: var(--accent-ink, var(--accent));
}

.article-summary {
  margin: 28px 0 0;
  padding: 20px 24px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 1.06rem;
  line-height: 1.7;
}

.article-divider {
  margin: 36px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* A divider as the very last content block is redundant before the share bar. */
.article-content > hr:last-child {
  display: none;
}

/* Author box at the end of the article. */
.author-box {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 44px;
  padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 14px;
  background: transparent;
}

.author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.author-info {
  min-width: 0;
}

.author-name {
  display: block;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
}

.author-bio {
  margin: 4px 0 9px;
  font-size: 0.88rem;
  color: var(--muted);
}

.author-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.author-links a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-ink, var(--accent));
  text-decoration: none;
}

.author-links a:hover {
  text-decoration: underline;
}

/* Share bar at the end of the article. */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.share-label {
  margin-right: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.share-btn[hidden] {
  display: none;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.16s ease;
}

.share-btn:hover {
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transform: translateY(-1px);
}

.share-btn.share-kakao {
  background: #fee500;
  border-color: #fee500;
  color: #191600;
}

.share-btn.share-kakao:hover {
  background: #fdd835;
  border-color: #fdd835;
  color: #191600;
}

/* X (Twitter) — black brand pill */
.share-btn.share-x {
  background: #000;
  border-color: #000;
  color: #fff;
}

.share-btn.share-x:hover {
  background: #222;
  border-color: #222;
  color: #fff;
}

[data-theme="dark"] .share-btn.share-x {
  border-color: rgba(255, 255, 255, 0.22);
}

/* LinkedIn — brand blue pill */
.share-btn.share-li {
  background: #0a66c2;
  border-color: #0a66c2;
  color: #fff;
}

.share-btn.share-li:hover {
  background: #00568f;
  border-color: #00568f;
  color: #fff;
}

.article-content {
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.95;
}

/* Brighter body text in dark mode for readability. */
[data-theme="dark"] .article-content {
  color: #ebedf1;
}

/* Reading font-size preference (set on <html data-reading>). */
[data-reading="sm"] .article-content {
  font-size: 0.96rem;
}

[data-reading="lg"] .article-content {
  font-size: 1.2rem;
}

.reading-size {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.reading-size button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  line-height: 1;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.reading-size button + button {
  border-left: 1px solid var(--line);
}

.reading-size button:nth-child(1) { font-size: 0.78rem; }
.reading-size button:nth-child(2) { font-size: 0.95rem; }
.reading-size button:nth-child(3) { font-size: 1.12rem; }

.reading-size button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--ink);
}

.article-content > :first-child {
  margin-top: 0;
}

.article-content h2 {
  margin: 48px 0 16px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.6em; /* em → scales with the reading font-size control */
  color: var(--ink);
  scroll-margin-top: 90px;
}

.article-content h3 {
  margin: 36px 0 12px;
  font-size: 1.2em; /* em → scales with the reading font-size control */
  font-weight: 650;
  color: var(--ink);
  scroll-margin-top: 90px;
}

/* Notion heading_3 → h4 (and a deeper h5 if ever present); smaller sub-levels. */
.article-content h4 {
  margin: 28px 0 10px;
  font-size: 1.05em;
  font-weight: 650;
  color: var(--ink);
  scroll-margin-top: 90px;
}

.article-content h5 {
  margin: 22px 0 8px;
  font-size: 0.95em;
  font-weight: 650;
  color: var(--ink-soft);
  scroll-margin-top: 90px;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content pre,
.article-content blockquote,
.article-content figure {
  margin: 24px 0;
}

.article-content ul,
.article-content ol {
  padding-left: 26px;
}

.article-content li {
  margin: 10px 0;
}

.article-content a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

.article-content blockquote {
  margin-inline: 0;
  padding: 4px 20px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-style: italic;
}

.article-content :not(pre) > code {
  padding: 2px 7px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid color-mix(in srgb, var(--code-ink) 55%, #ffffff);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.84em;
  font-weight: 400;
}

.article-content pre {
  overflow-x: auto;
  padding: 20px;
  border-radius: var(--r-md);
  background: #0d1117;
  border: 1px solid #1c2230;
  color: #e6edf3;
  font-size: 0.88rem;
  line-height: 1.65;
}

.article-content pre code,
.article-content pre code.hljs {
  padding: 0;
  background: transparent;
  font-family: var(--font-mono);
}

.article-content figure {
  text-align: center;
}

.article-content img {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  /* With width/height attrs (added by scripts/add-image-dims.mjs) the browser reserves
     the correct aspect-ratio box before load → no layout shift. height:auto keeps it
     responsive within max-width:100%. */
  height: auto;
}

.article-content figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* "그림 N." prefix on captioned figures (added by post.js numberFigures) */
.article-content figcaption .fig-number {
  color: var(--accent-ink);
  font-weight: 650;
}

/* Auto-numbered display equations: (N) down the right margin (post.js numberEquations) */
.article-content .katex-display {
  position: relative;
}

.article-content .katex-display > .eq-number {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.article-content .callout {
  display: flex;
  gap: 12px;
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.article-content .callout-icon {
  font-size: 1.15rem;
  line-height: 1.5;
}

.article-content .callout-body > :first-child {
  margin-top: 0;
}

.article-content .callout-body > :last-child {
  margin-bottom: 0;
}

.article-content details.toggle {
  margin: 20px 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.article-content details.toggle summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.article-content details.toggle[open] summary {
  margin-bottom: 12px;
}

.article-content ul.todo-list {
  list-style: none;
  padding-left: 2px;
}

.article-content ul.todo-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.article-content ul.todo-list input {
  margin-top: 7px;
  accent-color: var(--accent);
}

.article-content .table-wrap {
  overflow-x: auto;
  margin: 22px 0;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.article-content th,
.article-content td {
  padding: 10px 13px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.article-content th {
  background: var(--surface-2);
  font-weight: 650;
  color: var(--ink);
}

.article-content tbody tr:nth-child(even) td,
.article-content table tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.article-content .columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
  margin: 22px 0;
}

.article-content .column > :first-child {
  margin-top: 0;
}

.article-content .math-block {
  overflow-x: auto;
  margin: 26px 0;
  text-align: center;
}

.article-side {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 4px;
}

.article-side strong {
  display: block;
  margin-bottom: 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.article-side a {
  display: block;
  padding: 7px 0 7px 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.4;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.article-side a:hover {
  color: var(--ink);
  border-left-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

/* Current section while scrolling — clearly highlighted. */
.article-side a.is-active {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 650;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 0 7px 7px 0;
}

.article-side a.lvl-3 {
  padding-left: 24px;
  font-size: 0.82rem;
}

.article-side a.lvl-4 {
  padding-left: 40px;
  font-size: 0.8rem;
}

.article-side a.lvl-5 {
  padding-left: 54px;
  font-size: 0.78rem;
}

.article-side a.toc-comment {
  margin-top: 12px;
  font-weight: 650;
  color: var(--ink-soft);
}

.article-side a.toc-comment::before {
  content: "💬";
  margin-right: 6px;
  font-size: 0.8em;
}

/* Reading progress bar */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width 0.1s linear;
}

/* Floating action buttons (back-to-top + jump-to-comments) */
.fab-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.fab[hidden] {
  display: none;
}

.fab:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.fab svg {
  width: 21px;
  height: 21px;
}

@media (max-width: 600px) {
  .fab-stack {
    right: 16px;
    bottom: 16px;
  }
  .fab {
    width: 44px;
    height: 44px;
  }
}

/* Mobile bottom-sheet TOC, opened from the floating 목차 button (.toc-fab). The
   sticky sidebar stays for desktop; phones use the drawer instead. */
.toc-fab {
  display: none;
}

.toc-drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
}

.toc-drawer[hidden] {
  display: none;
}

.toc-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: toc-fade 0.2s ease;
}

.toc-drawer-panel {
  position: relative;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px 28px;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--glass-edge);
  box-shadow: 0 -16px 40px rgba(8, 10, 14, 0.28);
  animation: toc-slide-up 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.toc-drawer-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 10px;
  margin-bottom: 4px;
  background: var(--surface);
}

.toc-drawer-head strong {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.toc-drawer-x {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.toc-drawer-links a {
  display: block;
  padding: 11px 12px;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
}

.toc-drawer-links a.lvl-3 {
  padding-left: 26px;
  font-size: 0.9rem;
  color: var(--muted);
}

.toc-drawer-links a.lvl-4 {
  padding-left: 44px;
  font-size: 0.88rem;
  color: var(--muted);
}

.toc-drawer-links a.lvl-5 {
  padding-left: 60px;
  font-size: 0.86rem;
  color: var(--muted);
}

.toc-drawer-links a.is-active {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 650;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 0 7px 7px 0;
}

.toc-drawer-links a.toc-comment {
  margin-top: 8px;
  font-weight: 650;
}

@keyframes toc-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes toc-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .toc-fab {
    display: grid;
  }
  .article-side {
    display: none;
  }
}

@media (min-width: 901px) {
  .toc-drawer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toc-drawer-panel,
  .toc-drawer-backdrop {
    animation: none;
  }
}

/* Code block — window-chrome (dots + language + copy button) with line-number gutter */
.code-block {
  margin: 24px 0;
  border: 1px solid #1c2230;
  border-radius: var(--r-md);
  background: #0d1117;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #161b22;
  border-bottom: 1px solid #1c2230;
}

.code-dots {
  display: flex;
  gap: 7px;
}

.code-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.code-dots i:nth-child(1) { background: #ff5f56; }
.code-dots i:nth-child(2) { background: #ffbd2e; }
.code-dots i:nth-child(3) { background: #27c93f; }

.code-lang {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8b98a8;
}

.copy-btn {
  margin-left: auto;
  padding: 4px 11px;
  border: 1px solid #2a313c;
  border-radius: var(--r-sm);
  background: #21262d;
  color: #b3bdc9;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.copy-btn:hover {
  color: #fff;
  border-color: #3b434f;
  background: #2a313c;
}

/* Light mode: the copy button matches the light code card. */
[data-theme="light"] .copy-btn {
  border-color: #d0d7de;
  background: #ffffff;
  color: #57606a;
}

[data-theme="light"] .copy-btn:hover {
  color: #1f2328;
  border-color: #b8c0ca;
  background: #eef1f4;
}

.code-scroll {
  display: flex;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.65;
}

.code-gutter {
  flex: none;
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 16px 12px 16px 16px;
  text-align: right;
  white-space: pre;
  font-family: var(--font-mono);
  color: #4b5563;
  background: #0d1117;
  border-right: 1px solid #1c2230;
  user-select: none;
}

.article-content .code-block pre {
  margin: 0;
  padding: 16px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  font-size: inherit;
  line-height: inherit;
}

/* Heading anchor links (reveal on hover) */
.heading-anchor {
  margin-left: 8px;
  color: var(--faint);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.article-content h2:hover .heading-anchor,
.article-content h3:hover .heading-anchor,
.article-content h4:hover .heading-anchor,
.article-content h5:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent);
}

/* Image lightbox */
.article-content img.zoomable {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(10, 11, 14, 0.86);
  cursor: zoom-out;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.lightbox.is-open {
  display: grid;
}

.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

/* Mermaid diagrams */
.article-content .mermaid {
  margin: 24px 0;
  text-align: center;
}

/* ============================ Responsive ============================ */

/* ⌘K command palette */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14vh;
}

.cmdk[hidden] {
  display: none;
}

.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.cmdk-panel {
  position: relative;
  width: min(92vw, 560px);
  max-height: 64vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.cmdk-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 16px 18px;
  outline: none;
}

.cmdk-input::placeholder {
  color: var(--faint);
}

.cmdk-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}

.cmdk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.cmdk-item.is-active {
  background: var(--surface-2);
}

.cmdk-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmdk-item-cat {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.cmdk-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Archive page */
.archive-count {
  font-family: var(--font-mono);
  font-size: 0.5em;
  color: var(--faint);
  vertical-align: middle;
}

.archive-year {
  margin-top: 44px;
}

.archive-year h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-strong);
}

.archive-year h2 span {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--faint);
}

.archive-year ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-year li a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.16s ease;
}

.archive-year li a:hover .archive-post-title {
  color: var(--accent-ink, var(--accent));
}

.archive-post-title {
  font-size: 1rem;
  font-weight: 500;
  transition: color 0.16s ease;
}

.archive-date {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--faint);
}

@media (max-width: 900px) {
  .fab.nav-toggle {
    display: grid;
  }

  /* Nav opens as a panel just above the bottom-right menu button. */
  .site-nav {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 74px;
    z-index: 45;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 190px;
    padding: 8px;
    border-radius: 16px;
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--header-edge);
    box-shadow: var(--shadow-lg);
    transform-origin: bottom right;
    animation: nav-pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .site-header[data-nav-open] .site-nav {
    display: flex;
  }

  .site-nav a {
    padding: 11px 16px;
    border-radius: 10px;
  }

  @keyframes nav-pop {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .site-nav {
      animation: none;
    }
  }

  /* The sliding-glass indicator is desktop-only. */
  .nav-glass {
    display: none;
  }

  .post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .about-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .about-aside {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .article-shell {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .article-side {
    position: static;
    border-top: 1px solid var(--line);
    padding-top: 24px;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 600px) {
  .section {
    margin: 72px auto;
  }

  .metrics {
    border-radius: var(--r-lg);
    gap: 12px;
    flex-direction: column;
  }

  .post-grid,
  .topic-grid,
  .about-aside {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ============================ Comments ============================ */

.comments {
  grid-column: 1 / 2;
  min-width: 0;
  margin-top: 16px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.comments-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.giscus,
.giscus-frame {
  width: 100%;
}

/* Related posts + prev/next navigation */
.post-nav {
  grid-column: 1 / 2;
  min-width: 0;
  margin-top: 16px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.post-nav-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-bottom: 16px;
}

.related-list {
  list-style: none;
  margin: 0 0 36px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.related-list a {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.related-list a::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.related-list a:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md);
}

.related-list a:hover::before {
  opacity: 1;
}

.related-cat {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.related-title {
  font-weight: 600;
  color: var(--ink);
}

.post-nav-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.post-nav-link {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.post-nav-link::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.post-nav-link:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md);
}

.post-nav-link:hover::before {
  opacity: 1;
}

.post-nav-link.next {
  text-align: right;
}

.post-nav-link span {
  font-size: 0.78rem;
  color: var(--muted);
}

.post-nav-link strong {
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 600px) {
  .post-nav-links {
    grid-template-columns: 1fr;
  }
  .post-nav-link.next {
    text-align: left;
  }
}

/* "Load more" button on the post list */
.load-more {
  position: relative;
  overflow: hidden;
  display: block;
  margin: 28px auto 0;
  padding: 11px 28px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.3, 0.5, 1);
}

.load-more::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.load-more:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--glass-edge));
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
  transform: translateY(-2px);
}

.load-more:hover::before {
  opacity: 1;
}

.load-more[hidden] {
  display: none;
}

/* Series box (multi-part posts) */
.series-box {
  margin: 0 0 32px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}

.series-box > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.series-box > summary::-webkit-details-marker {
  display: none;
}

.series-progress {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.series-list {
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
  display: grid;
  gap: 2px;
}

.series-list a,
.series-list li.is-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ink-soft);
}

.series-list a:hover {
  background: var(--surface);
  color: var(--ink);
}

.series-list li.is-current {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.series-num {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.series-list li.is-current .series-num {
  background: var(--accent);
  color: var(--on-accent);
}

/* ============================ CV page ============================ */
.cv-block-title {
  margin: 34px 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.4rem;
}

.about-main > .cv-block-title:first-child {
  margin-top: 0;
}

.cv-metrics {
  margin-top: 28px;
}

/* CV header row: eyebrow on the left, a "Last updated" pill on the right. */
.cv-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  max-width: none;
}

.cv-heading .eyebrow {
  margin: 0;
}

/* Glass pill showing this CV's own revision date (Notion About modified). */
.cv-updated {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.cv-updated[hidden] {
  display: none;
}

.cv-updated-dot {
  position: relative;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.cv-updated-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: 0;
  animation: cv-updated-pulse 2.8s ease-out infinite;
}

@keyframes cv-updated-pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.5);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.cv-updated-label {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.cv-updated time {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .cv-updated-dot::after {
    animation: none;
  }
}

/* "Writing about" chips: accent-blue text with an upright (non-italic) count. */
[data-cv-focus] .badge {
  color: var(--accent-ink);
}

[data-cv-focus] .badge em {
  font-style: normal;
  margin-left: 5px;
  font-weight: 600;
}

/* ============================ Breadcrumb ============================ */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 0.8rem;
}

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

.breadcrumb a:hover {
  color: var(--accent-ink);
}

.breadcrumb .bc-sep {
  color: var(--faint);
}

/* ===================== In-article search (TOC) ===================== */
.toc-search {
  position: relative;
  margin-bottom: 14px;
}

.toc-search input {
  width: 100%;
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
}

.toc-search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--glass-edge));
}

.toc-search-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--faint);
  pointer-events: none;
}

mark.search-hit {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  border-radius: 3px;
}

mark.search-hit.current {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ===================== Footnotes (active when a post uses them) ===================== */
.article-content sup a,
.article-content a.fn-ref {
  text-decoration: none;
  color: var(--accent-ink);
  font-weight: 600;
  padding: 0 1px;
}

.article-content .footnotes,
.article-content ol[id^="fn"] {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

.fn-flash {
  animation: fn-flash 1.2s ease;
  border-radius: 4px;
}

@keyframes fn-flash {
  0%,
  30% {
    background: color-mix(in srgb, var(--accent) 24%, transparent);
  }
  100% {
    background: transparent;
  }
}

/* ===================== Cite modal & keyboard help ===================== */
.cite-modal[hidden],
.kbd-help[hidden] {
  display: none;
}

.cite-modal,
.kbd-help {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.cite-backdrop,
.kbd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 14, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.cite-panel,
.kbd-panel {
  position: relative;
  width: min(100% - 24px, 560px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px 22px 22px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.cite-head,
.kbd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cite-head strong,
.kbd-head strong {
  font-size: 1.02rem;
}

.cite-x,
.kbd-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.cite-x:hover,
.kbd-x:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.cite-block + .cite-block {
  margin-top: 16px;
}

.cite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cite-row span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.cite-copy {
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 3px 12px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.cite-copy:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--glass-edge));
}

.cite-modal pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.kbd-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.kbd-list li {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kbd-list kbd {
  flex: none;
  min-width: 64px;
  text-align: center;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink);
}

.kbd-list span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ===================== Light-mode syntax theme ===================== */
[data-theme="light"] .code-block {
  background: #ffffff;
  border-color: #d8dee4;
}

[data-theme="light"] .code-head {
  background: #f3f5f8;
  border-bottom-color: #d8dee4;
}

[data-theme="light"] .code-lang {
  color: #57606a;
}

[data-theme="light"] .code-gutter {
  background: #f6f8fa;
  color: #8c959f;
  border-right-color: #e6e9ee;
}

[data-theme="light"] .article-content .hljs {
  color: #1f2328;
}

[data-theme="light"] .hljs-comment,
[data-theme="light"] .hljs-quote {
  color: #6e7781;
}

[data-theme="light"] .hljs-keyword,
[data-theme="light"] .hljs-selector-tag,
[data-theme="light"] .hljs-literal,
[data-theme="light"] .hljs-doctag {
  color: #cf222e;
}

[data-theme="light"] .hljs-string,
[data-theme="light"] .hljs-regexp,
[data-theme="light"] .hljs-meta .hljs-string {
  color: #0a3069;
}

[data-theme="light"] .hljs-number,
[data-theme="light"] .hljs-built_in,
[data-theme="light"] .hljs-attr,
[data-theme="light"] .hljs-variable,
[data-theme="light"] .hljs-template-variable,
[data-theme="light"] .hljs-symbol,
[data-theme="light"] .hljs-bullet,
[data-theme="light"] .hljs-link {
  color: #0550ae;
}

[data-theme="light"] .hljs-title,
[data-theme="light"] .hljs-section,
[data-theme="light"] .hljs-name,
[data-theme="light"] .hljs-title.function_,
[data-theme="light"] .hljs-title.class_ {
  color: #8250df;
}

[data-theme="light"] .hljs-type,
[data-theme="light"] .hljs-tag {
  color: #116329;
}

[data-theme="light"] .hljs-attribute,
[data-theme="light"] .hljs-meta {
  color: #953800;
}

/* ============================ Print / PDF ============================ */
/* Strip the UI chrome and force a clean black-on-white article for
   printing or "Save as PDF" — works even when printing from dark mode. */
@media print {
  :root,
  :root[data-theme="dark"] {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f4f4;
    --ink: #111111;
    --ink-soft: #1a1a1a;
    --muted: #444444;
    --faint: #666666;
    --line: #cccccc;
    --line-strong: #bbbbbb;
    --accent-ink: #0a4fb0;
  }

  body {
    background: #ffffff !important;
    color: #111111 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide everything that isn't the article body. */
  .site-header,
  .site-footer,
  .fab-stack,
  .read-progress,
  .article-side,
  .toc-drawer,
  .comments,
  .share-bar,
  .reading-size,
  .back-link,
  .related-list,
  .related-title,
  .post-nav,
  .author-box,
  .series-box,
  .skip-link,
  .hero-art,
  body::before,
  body::after {
    display: none !important;
  }

  .article-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .article {
    max-width: 100%;
  }

  .article-content {
    color: #111111 !important;
    font-size: 11.5pt;
    line-height: 1.6;
  }

  .article-content a {
    color: #0a4fb0 !important;
    text-decoration: underline;
  }

  /* Flatten glassy panels for paper. */
  .article-content pre,
  .article-content blockquote,
  .article-content table {
    background: #f5f5f5 !important;
    box-shadow: none !important;
    border: 1px solid #dddddd !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  /* Wrap long code lines so nothing is cut off at the page edge. */
  .article-content pre,
  .article-content code {
    white-space: pre-wrap !important;
    word-break: break-word;
  }

  /* Sensible page breaks. */
  .article-content h1,
  .article-content h2,
  .article-content h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .article-content pre,
  .article-content img,
  .article-content table,
  .article-content figure {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .article-content img {
    max-width: 100% !important;
  }
}
