/* ============================================================
   Yoghurt321 · notes
   Handcrafted, framework-free. Material 3 light/dark.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --font-sans: "Roboto", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "Roboto Mono", "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Material 3 color roles — dark */
  --md-primary: #9bcbff;
  --md-on-primary: #003354;
  --md-primary-container: #004b74;
  --md-on-primary-container: #cde5ff;
  --md-secondary: #b7c9d9;
  --md-on-secondary: #22323f;
  --md-secondary-container: #384956;
  --md-on-secondary-container: #d3e5f5;
  --md-tertiary: #80d5d9;
  --md-on-tertiary: #003639;
  --md-tertiary-container: #004f52;
  --md-on-tertiary-container: #9cf1f5;
  --md-error: #ffb4ab;
  --md-on-error: #690005;
  --md-error-container: #93000a;
  --md-on-error-container: #ffdad6;
  --md-surface: #101418;
  --md-surface-dim: #0b0e12;
  --md-surface-bright: #363a3f;
  --md-surface-container-lowest: #0b0e12;
  --md-surface-container-low: #181c20;
  --md-surface-container: #1c2024;
  --md-surface-container-high: #262a2f;
  --md-surface-container-highest: #31353a;
  --md-on-surface: #e1e2e8;
  --md-on-surface-variant: #c1c7ce;
  --md-outline: #8b9198;
  --md-outline-variant: #41474e;
  --md-inverse-surface: #e1e2e8;
  --md-inverse-on-surface: #2e3135;
  --md-inverse-primary: #00639b;
  --md-success: #6dd58c;
  --md-warning: #ffb95c;
  --md-warning-container: #5c3c00;
  --md-on-warning-container: #ffddb3;
  --md-scrim: rgba(0, 0, 0, 0.55);

  /* Material 3 shape & motion */
  --shape-xs: 8px;
  --shape-sm: 12px;
  --shape-md: 16px;
  --shape-lg: 24px;
  --shape-xl: 28px;
  --shape-full: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* semantic aliases used by components */
  --bg: var(--md-surface);
  --bg-soft: var(--md-surface-container-low);
  --panel: var(--md-surface-container);
  --panel-solid: var(--md-surface-container-high);
  --fg: var(--md-on-surface);
  --muted: var(--md-on-surface-variant);
  --muted-2: var(--md-outline);
  --border: var(--md-outline-variant);
  --success: var(--md-success);
  --nav-bg: rgba(16, 20, 24, 0.96);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --shadow-2: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
  --max: 1180px;
  color-scheme: dark;

  /* code surfaces stay dark in both themes (Material inverse surface) */
  --code-bg: #0b0e12;
  --code-surface: #181c20;
  --code-fg: #e1e2e8;
  --code-muted: #8b9198;
  --code-border: #31353a;
  --code-key: #9bcbff;
  --code-str: #80d5d9;
  --code-ok: #6dd58c;
}

:root[data-theme="light"] {
  --md-primary: #00639b;
  --md-on-primary: #ffffff;
  --md-primary-container: #cde5ff;
  --md-on-primary-container: #001d32;
  --md-secondary: #50606e;
  --md-on-secondary: #ffffff;
  --md-secondary-container: #d3e5f5;
  --md-on-secondary-container: #0c1d29;
  --md-tertiary: #00696d;
  --md-on-tertiary: #ffffff;
  --md-tertiary-container: #9cf1f5;
  --md-on-tertiary-container: #002022;
  --md-error: #ba1a1a;
  --md-on-error: #ffffff;
  --md-error-container: #ffdad6;
  --md-on-error-container: #410002;
  --md-surface: #f8f9ff;
  --md-surface-dim: #d8dae0;
  --md-surface-bright: #f8f9ff;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #f2f3fa;
  --md-surface-container: #eceef4;
  --md-surface-container-high: #e6e8ee;
  --md-surface-container-highest: #e1e2e9;
  --md-on-surface: #191c20;
  --md-on-surface-variant: #41474e;
  --md-outline: #71787f;
  --md-outline-variant: #c1c7ce;
  --md-inverse-surface: #2e3135;
  --md-inverse-on-surface: #eff0f7;
  --md-inverse-primary: #9bcbff;
  --md-success: #146c43;
  --md-warning: #8a5300;
  --md-warning-container: #ffddb3;
  --md-on-warning-container: #2a1800;
  --md-scrim: rgba(0, 0, 0, 0.4);
  --nav-bg: rgba(248, 249, 255, 0.96);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 2px 6px 2px rgba(0, 0, 0, 0.07);
  --shadow-2: 0 4px 8px 3px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.14);
  --code-bg: #1b1b1f;
  --code-surface: #26262b;
  --code-fg: #f3f0f4;
  --code-muted: #cac4d0;
  --code-border: #3f3f46;
  --code-key: #a9c7ff;
  --code-str: #8be0e4;
  --code-ok: #8be0a8;
  color-scheme: light;
}

/* Article code keeps a light GitHub-like surface in the light theme.
   The terminal card keeps the dark --code-* root values. */
:root[data-theme="light"] .code-block {
  --code-bg: #f6f8fa;
  --code-surface: #eef1f4;
  --code-fg: #1f2328;
  --code-muted: #57606a;
  --code-border: #d0d7de;
  --code-key: #0550ae;
  --code-str: #0a3069;
  --code-ok: #116329;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button,
input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
::selection { background: rgba(155, 203, 255, 0.4); color: var(--fg); }
:root[data-theme="light"] ::selection { background: rgba(0, 99, 155, 0.28); }

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

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--md-outline-variant);
  border-radius: var(--shape-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--md-outline); }

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 3000;
  padding: 10px 16px;
  border-radius: var(--shape-sm);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- atmosphere ---------- */
.aurora {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 720px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 460px at 14% -8%, rgba(155, 203, 255, 0.09), transparent 68%),
    radial-gradient(680px 420px at 86% 0%, rgba(128, 213, 217, 0.06), transparent 66%);
}
:root[data-theme="light"] .aurora {
  background:
    radial-gradient(760px 460px at 14% -8%, rgba(0, 99, 155, 0.08), transparent 68%),
    radial-gradient(680px 420px at 86% 0%, rgba(0, 105, 109, 0.055), transparent 66%);
}
:root[data-theme="light"] .card-cover.placeholder::before {
  background-image:
    linear-gradient(rgba(17, 20, 34, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 20, 34, 0.05) 1px, transparent 1px);
}
:root[data-theme="light"] .card-cover.placeholder .card-no { color: var(--md-outline); text-shadow: none; }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  background: var(--nav-bg);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: var(--md-surface-container);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav {
    background: color-mix(in srgb, var(--md-surface) 70%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    backdrop-filter: blur(18px) saturate(1.35);
    border-bottom-color: color-mix(in srgb, var(--border) 55%, transparent);
  }
  .nav.scrolled {
    background: color-mix(in srgb, var(--md-surface-container) 78%, transparent);
    border-bottom-color: color-mix(in srgb, var(--border) 80%, transparent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }
}
.nav-inner {
  max-width: var(--max);
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-text {
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-text em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 400;
}
.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; margin-right: 4px; }
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--shape-full);
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-links a svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}
.nav-links a:hover { color: var(--fg); background: var(--md-surface-container-high); }
.nav-links a:hover svg,
.nav-links a.active svg { opacity: 1; }
.nav-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: var(--shape-full);
  border: 0;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s var(--ease);
}
.icon-btn:hover { color: var(--fg); background: var(--md-surface-container-high); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.search-trigger { padding: 0 14px; background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }
.mobile-dir { display: none; }
.search-trigger:hover { background: var(--md-surface-container-highest); }
.search-label { font-size: 0.82rem; }
.search-kbd {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--md-on-surface-variant);
  border: 0;
  border-radius: var(--shape-xs);
  padding: 2px 6px;
  line-height: 1.5;
  background: var(--md-surface-container-lowest);
}
.theme-toggle { position: relative; width: 40px; padding: 0; }
.theme-toggle svg { position: absolute; transition: opacity 0.3s ease, transform 0.3s var(--ease); }
.icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
:root[data-theme="light"] .icon-sun { opacity: 1; transform: none; }
:root[data-theme="light"] .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }

/* ---------- shared ---------- */
.view { position: relative; z-index: 1; }
.glass {
  background: var(--panel);
  border: 1px solid var(--border);
}
.gradient-text {
  color: var(--md-primary);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--shape-full);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--md-primary) 92%, var(--md-on-primary) 8%);
  box-shadow: var(--shadow);
}
.btn-primary svg { transition: transform 0.2s var(--ease); }
.btn-primary:hover svg { transform: translateX(2px); }
.btn-ghost {
  background: transparent;
  border-color: var(--md-outline);
  color: var(--md-primary);
}
.btn-ghost:hover {
  background: color-mix(in srgb, var(--md-primary) 8%, transparent);
  border-color: var(--md-primary);
}
.btn:active { transform: scale(0.98); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--shape-xs);
  border: 1px solid transparent;
  background: var(--md-surface-container-high);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ---------- hero ---------- */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 150px 24px 54px;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  align-items: center;
  gap: 56px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  margin-bottom: 24px;
  border: 0;
  border-radius: var(--shape-full);
  background: var(--md-surface-container-high);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--md-on-surface-variant);
}
.pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
}
.hero h1 {
  font-size: clamp(2.6rem, 5.4vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin-bottom: 22px;
}
:lang(zh) .hero h1 { letter-spacing: -0.015em; }
.lede {
  max-width: 34rem;
  color: var(--md-on-surface-variant);
  font-size: 1.02rem;
  line-height: 1.7;
}
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 30px 0 42px; }

.stats { display: flex; gap: 38px; flex-wrap: wrap; }
.stats > div { display: flex; flex-direction: column-reverse; gap: 2px; }
.stats dt { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--md-outline); }
.stats dd {
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats dd small { font-size: 0.72rem; color: var(--muted); font-weight: 400; margin-left: 4px; letter-spacing: 0; }

/* hero art */
.hero-art { position: relative; display: flex; justify-content: center; padding: 20px 0; }
.profile-card {
  position: relative;
  z-index: 2;
  width: min(100%, 370px);
  padding: 18px;
  border-radius: var(--shape-xl);
  box-shadow: var(--shadow);
}
.profile-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar-wrap {
  flex: none;
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--md-primary-container);
  padding: 2px;
}
.avatar-wrap img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--panel-solid); }
.avatar-wrap.big { width: 90px; height: 90px; }
.profile-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.profile-id strong { font-size: 1rem; letter-spacing: -0.01em; }
.profile-id span { font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); letter-spacing: 0.02em; }
.status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--md-on-tertiary-container);
  background: var(--md-tertiary-container);
  border: 0;
  border-radius: var(--shape-full);
  padding: 4px 9px;
  white-space: nowrap;
}
.status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.terminal {
  border-radius: var(--shape-md);
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  overflow: hidden;
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--code-border);
  background: var(--code-surface);
}
.term-bar i { width: 8px; height: 8px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: auto; font-family: var(--font-mono); font-size: 0.6rem; color: var(--code-muted); }
.terminal pre {
  margin: 0;
  padding: 14px 15px 16px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.75;
  color: var(--code-fg);
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.c-p { color: var(--code-key); }
.c-b { color: var(--code-str); }
.c-g { color: var(--code-ok); }
.profile-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
}
.profile-foot b { color: var(--fg); font-weight: 500; }
.profile-foot .dot { color: var(--muted-2); }

/* ---------- sections ---------- */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 70px 24px 24px;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}
.section-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--md-primary);
  margin-bottom: 10px;
}
.section-title {
  font-size: clamp(1.75rem, 3.4vw, 2.4rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.section-note { max-width: 30rem; color: var(--md-on-surface-variant); font-size: 0.9rem; padding-bottom: 5px; }

.inline-search {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(100%, 300px);
  height: 48px;
  padding: 0 16px;
  border-radius: var(--shape-full);
  border: 1px solid transparent;
  background: var(--md-surface-container-high);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.inline-search:focus-within { background: var(--md-surface-container-highest); box-shadow: 0 0 0 2px var(--md-primary); }
.inline-search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.inline-search input { width: 100%; border: 0; background: none; outline: none; font-size: 0.88rem; }
.inline-search input::placeholder { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--shape-xs);
  border: 1px solid var(--md-outline);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.chip-btn:hover { color: var(--fg); background: var(--md-surface-container-high); }
.chip-btn.active {
  color: var(--md-on-secondary-container);
  border-color: transparent;
  background: var(--md-secondary-container);
}
.chip-btn .n { font-family: var(--font-mono); font-size: 0.66rem; color: currentColor; margin-left: 6px; opacity: 0.7; }
.chip-btn.active .n { color: var(--md-on-secondary-container); }

/* ---------- directory page ---------- */
.nav-links a.active {
  color: var(--md-on-secondary-container);
  background: var(--md-secondary-container);
}
.mobile-dir.active {
  color: var(--md-on-secondary-container);
  background: var(--md-secondary-container);
}
.directory-view { padding: 108px 24px 40px; }
.directory-page { max-width: 980px; margin: 0 auto; }
.directory-head { margin-bottom: 34px; }
.directory-head .back-link { margin-bottom: 26px; }
.dir-title {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin-bottom: 10px;
}
.dir-intro { color: var(--md-on-surface-variant); font-size: 1rem; line-height: 1.75; }
.dir-intro code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}
.dir-intro strong { color: var(--md-on-surface); font-weight: 600; }
.dir-sections { display: flex; flex-direction: column; gap: 20px; }
.dir-section {
  overflow: hidden;
  border-radius: var(--shape-lg);
  border: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
}
.dir-heading { margin: 0; font: inherit; }
.dir-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  text-align: left;
  border-radius: inherit;
  transition: background 0.15s ease;
}
.dir-toggle:hover { background: var(--md-surface-container); }
.dir-code {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: var(--shape-md);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dir-heading-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.dir-name { font-size: 1.18rem; font-weight: 600; letter-spacing: -0.01em; }
.dir-path {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--md-outline);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dir-count {
  flex: none;
  padding: 4px 9px;
  border-radius: var(--shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  white-space: nowrap;
}
.dir-chevron {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--md-outline);
  transition: transform 0.25s var(--ease), color 0.2s ease, background 0.2s ease;
}
.dir-chevron svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dir-toggle:hover .dir-chevron { background: var(--md-surface-container-high); }
.dir-section.open .dir-chevron { transform: rotate(180deg); color: var(--md-primary); }
.dir-section-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s var(--ease);
}
.dir-section.open .dir-section-body { grid-template-rows: 1fr; }
.dir-section-inner { min-height: 0; overflow: hidden; }
.dir-section-inner > .dir-links { border-top: 1px solid var(--md-outline-variant); padding: 12px 20px 18px; }
.dir-links { column-count: 2; column-gap: 14px; }
.dir-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--shape-sm);
  break-inside: avoid;
  opacity: 0;
  transform: translateY(8px);
  transition: background 0.15s ease;
}
.dir-section.open .dir-link {
  animation: dir-item-in 0.24s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 14ms);
}
@keyframes dir-item-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.dir-link:hover { background: var(--md-surface-container-high); }
.dir-link-main { min-width: 0; }
.dir-link-main strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dir-link-meta {
  margin-left: auto;
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--md-outline);
  white-space: nowrap;
}
.dir-link-arrow {
  flex: none;
  color: var(--md-outline);
  transition: color 0.15s ease, transform 0.2s var(--ease);
}
.dir-link-arrow svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dir-link:hover .dir-link-arrow { color: var(--md-primary); transform: translateX(2px); }
.directory-page > .back-link.bottom { margin-top: 28px; }

/* ---------- categories page ---------- */
.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 2px 0 30px;
}
.category-tags .chip-btn {
  height: 36px;
  padding: 0 15px;
  font-size: 0.82rem;
}
.category-result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-top: 24px;
  border-top: 1px solid var(--md-outline-variant);
}
.category-result-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.category-result-count {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--md-outline);
}

/* ---------- article grid ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--shape-lg);
  border: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
  overflow: hidden;
  min-height: 100%;
  transition: transform 0.25s var(--ease), border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--md-outline);
  background: var(--md-surface-container);
  box-shadow: var(--shadow);
}
.card-cover { position: relative; aspect-ratio: 16 / 8.6; overflow: hidden; background: var(--bg-soft); }
.card-cover.placeholder {
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 100% at 85% 0%, var(--c1, rgba(155, 203, 255, 0.16)), transparent 58%),
    radial-gradient(90% 90% at 10% 100%, var(--c2, rgba(80, 213, 217, 0.1)), transparent 62%),
    var(--bg-soft);
}
.card-cover.placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 50% 50%, #000, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000, transparent 78%);
}
.card-cover .glyph {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--md-primary);
  opacity: 0.9;
}
.card-cover .card-no {
  position: absolute;
  top: 13px; right: 15px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.08em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.card-cat {
  position: absolute;
  left: 14px; bottom: 12px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  color: #fff;
  padding: 4px 9px;
  border-radius: var(--shape-xs);
  background: rgba(0, 0, 0, 0.45);
}
.card-body { display: flex; flex-direction: column; flex: 1; padding: 18px 19px 17px; }
.card-body h3 {
  font-size: 1.02rem;
  line-height: 1.45;
  letter-spacing: -0.01em;
  font-weight: 600;
  margin-bottom: 8px;
  transition: color 0.2s ease;
}
.card:hover .card-body h3 { color: var(--md-primary); }
.card-excerpt {
  font-size: 0.83rem;
  line-height: 1.65;
  color: var(--md-on-surface-variant);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}
.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--md-outline);
  padding-top: 13px;
  border-top: 1px solid var(--md-outline-variant);
}
.card-foot .sep { opacity: 0.5; }
.card-foot .arrow {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: transparent;
  color: var(--md-on-surface-variant);
  transition: background 0.2s ease, color 0.2s ease;
}
.card-foot .arrow svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card:hover .card-foot .arrow { background: var(--md-primary-container); color: var(--md-on-primary-container); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 80px 20px;
  border: 1px dashed var(--md-outline);
  border-radius: var(--shape-lg);
  text-align: center;
  color: var(--muted);
}
.empty-glyph { font-family: var(--font-mono); font-size: 2.4rem; letter-spacing: 0.1em; color: var(--md-outline); }

/* ---------- topics ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.topic {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border-radius: var(--shape-lg);
  border: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
  text-align: left;
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.topic::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(280px 140px at var(--mx, 50%) var(--my, 50%), rgba(155, 203, 255, 0.1), transparent 70%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.topic:hover {
  background: var(--md-surface-container);
  border-color: var(--md-outline);
  box-shadow: var(--shadow);
}
.topic:hover::before { opacity: 1; }
.topic-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: var(--shape-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--md-on-primary-container);
  background: var(--md-primary-container);
  border: 0;
  letter-spacing: -0.03em;
}
.topic-info { display: flex; flex-direction: column; min-width: 0; }
.topic-info strong { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }
.topic-info span { font-family: var(--font-mono); font-size: 0.66rem; color: var(--md-on-surface-variant); }
.topic-arrow { margin-left: auto; color: var(--md-outline); transition: transform 0.2s var(--ease), color 0.2s ease; }
.topic-arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topic:hover .topic-arrow { color: var(--md-primary); transform: translateX(2px); }

/* ---------- about ---------- */
.about-wrap { padding-bottom: 20px; }
.about {
  position: relative;
  padding: 46px;
  border-radius: var(--shape-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.about::before {
  content: "";
  position: absolute;
  width: 480px; height: 480px;
  right: -140px; top: -220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155, 203, 255, 0.1), transparent 65%);
  pointer-events: none;
}
:root[data-theme="light"] .about::before {
  background: radial-gradient(circle, rgba(0, 99, 155, 0.08), transparent 65%);
}
.about-head { display: flex; align-items: center; gap: 22px; margin-bottom: 24px; }
.about-head .section-kicker { margin-bottom: 6px; }
.about-text { max-width: 62ch; color: var(--md-on-surface-variant); font-size: 1.02rem; line-height: 1.8; }
.about-points { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 30px 0 32px; }
.about-points li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--shape-sm);
  border: 0;
  background: var(--md-surface-container-high);
  font-size: 0.86rem;
  color: var(--md-on-surface-variant);
}
.about-points span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--md-on-primary-container);
  background: var(--md-primary-container);
  border: 0;
  border-radius: var(--shape-xs);
  padding: 2px 6px;
}
.about-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- footer ---------- */
.footer { max-width: var(--max); margin: 70px auto 0; padding: 30px 24px 40px; border-top: 1px solid var(--md-outline-variant); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--md-outline); }
.footer a { color: var(--md-on-surface-variant); border-bottom: 1px solid var(--md-outline-variant); transition: color 0.2s ease, border-color 0.2s ease; }
.footer a:hover { color: var(--md-primary); border-color: var(--md-primary); }
.footer-meta { font-family: var(--font-mono); font-size: 0.68rem; }

/* ---------- post ---------- */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  width: 100%;
  height: 3px;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.read-progress.on { opacity: 1; }
.read-progress i { display: block; width: 100%; height: 100%; background: var(--md-primary); transform: scaleX(0); transform-origin: left center; will-change: transform; }

.post-view { padding: 106px 24px 40px; }
.post-shell {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 800px);
  gap: 40px;
  justify-content: center;
}
.post-aside { position: sticky; top: 100px; align-self: start; max-height: calc(100vh - 122px); overflow: auto; padding-right: 4px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--md-on-surface-variant);
  padding: 8px 12px;
  border-radius: var(--shape-full);
  transition: color 0.2s ease, background 0.2s ease, gap 0.2s var(--ease);
}
.back-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.back-link:hover { color: var(--md-primary); background: var(--md-surface-container-high); gap: 10px; }
.back-link.bottom { margin-top: 40px; }
.toc { margin-top: 22px; }
.toc-title { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.16em; color: var(--md-outline); margin-bottom: 8px; padding-left: 8px; }
.toc-tree,
.toc-children { list-style: none; margin: 0; padding: 0; }
.toc-children { margin-left: 10px; padding-left: 4px; border-left: 1px solid var(--md-outline-variant); }
.toc-children.toc-open > .toc-node {
  animation: toc-child-in 0.22s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
@keyframes toc-child-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}
.toc-node { margin: 0; }
.toc-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--shape-xs);
  transition: background 0.15s ease;
}
.toc-row:hover { background: var(--md-surface-container-high); }
.toc-row.active { background: var(--md-secondary-container); }
.toc-row.context { background: var(--md-primary-container); }
.toc-link {
  flex: 1;
  min-width: 0;
  padding: 7px 4px 7px 9px;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: left;
  color: var(--md-on-surface-variant);
  border: 0;
  border-radius: var(--shape-xs);
  background: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}
.toc-row[data-depth="0"] .toc-link { color: var(--md-on-surface); font-weight: 600; }
.toc-row[data-depth="1"] .toc-link { font-size: 0.84rem; }
.toc-row[data-depth="2"] .toc-link { font-size: 0.81rem; color: var(--md-outline); }
.toc-row[data-depth="3"] .toc-link { font-size: 0.78rem; color: var(--md-outline); }
.toc-row.active .toc-link { color: var(--md-on-secondary-container); }
.toc-row.context .toc-link { color: var(--md-on-primary-container); }
.toc-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  margin-right: 3px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-outline);
  transition: color 0.15s ease;
}
.toc-row.active .toc-toggle { color: var(--md-on-secondary-container); }
.toc-row.context .toc-toggle { color: var(--md-on-primary-container); }
.toc-toggle:hover { color: var(--md-on-surface); }
.toc-toggle svg {
  width: 15px; height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s var(--ease);
}
.toc-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.post-main { min-width: 0; }
.post-head { margin-bottom: 34px; }
.post-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 0.72rem; color: var(--md-on-surface-variant); margin-bottom: 18px; }
.post-meta .chip { color: var(--md-on-tertiary-container); background: var(--md-tertiary-container); }
.post-head h1 {
  font-size: clamp(2.05rem, 4.4vw, 3.15rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 650;
  margin-bottom: 14px;
  word-break: break-word;
}
.post-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.post-empty { color: var(--md-on-surface-variant); font-size: 1rem; line-height: 1.75; }
.post-tags .chip { cursor: default; }

.post-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0;
  color: var(--md-on-surface-variant);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-top: 1px solid var(--md-outline-variant);
}
.loader { width: 14px; height: 14px; border: 2px solid var(--md-outline-variant); border-top-color: var(--md-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* prose */
.prose {
  font-size: 1.06rem;
  line-height: 1.85;
  color: var(--md-on-surface-variant);
  overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  color: var(--md-on-surface);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.32;
  margin: 2em 0 0.7em;
}
.prose h1 { font-size: 1.95rem; }
.prose h2 {
  font-size: 1.58rem;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--md-outline-variant);
}
.prose h3 { font-size: 1.3rem; }
.prose h4 { font-size: 1.12rem; }
.prose h5, .prose h6 { font-size: 1rem; color: var(--md-on-surface-variant); }
.prose p { margin: 1.05em 0; }
.prose strong { color: var(--md-on-surface); font-weight: 600; }
.prose em { color: var(--md-on-surface); }
.prose a {
  color: var(--md-primary);
  border-bottom: 1px solid color-mix(in srgb, var(--md-primary) 35%, transparent);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.prose a:hover { color: var(--md-primary); border-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.prose ul, .prose ol { margin: 1.05em 0; padding-left: 1.6em; }
.prose li { margin: 0.42em 0; padding-left: 0.1em; }
.prose li > ul, .prose li > ol { margin: 0.35em 0 0.5em; }
.prose li::marker { color: var(--md-primary); }
.prose input[type="checkbox"] { margin: 0 0.5em 0 0; accent-color: var(--md-primary); vertical-align: -0.08em; }
.prose hr { border: 0; height: 1px; margin: 2.4em 0; background: var(--md-outline-variant); }
.prose img {
  display: block;
  max-width: 100%;
  margin: 1.6em auto;
  border-radius: var(--shape-sm);
  border: 1px solid var(--md-outline-variant);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: transform 0.2s var(--ease), border-color 0.2s ease;
}
.prose img:hover { border-color: var(--md-outline); }
.prose figure { margin: 1.7em 0; }
.prose figure img { margin: 0 auto; }
.prose figcaption { margin-top: 9px; text-align: center; font-family: var(--font-mono); font-size: 0.7rem; color: var(--md-outline); }
.prose blockquote {
  position: relative;
  margin: 1.6em 0;
  padding: 15px 19px 15px 20px;
  border-radius: var(--shape-sm);
  border: 0;
  border-left: 3px solid var(--md-primary);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
}
.prose blockquote p { margin: 0.4em 0; }
.prose blockquote p:first-child { margin-top: 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote.callout-note { border-left-color: var(--md-secondary); background: var(--md-secondary-container); }
.prose blockquote.callout-tip { border-left-color: var(--md-tertiary); background: var(--md-tertiary-container); }
.prose blockquote.callout-warning { border-left-color: var(--md-warning); background: var(--md-warning-container); }
.prose blockquote.callout-important,
.prose blockquote.callout-caution { border-left-color: var(--md-error); background: var(--md-error-container); }
.callout-label { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 5px; color: var(--md-on-secondary-container); }
.callout-warning .callout-label { color: var(--md-on-warning-container); }
.callout-important .callout-label,
.callout-caution .callout-label { color: var(--md-on-error-container); }
.callout-note .callout-label { color: var(--md-on-secondary-container); }
.callout-tip .callout-label { color: var(--md-on-tertiary-container); }

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  padding: 0.14em 0.4em;
  border-radius: 6px;
  background: var(--md-surface-container-highest);
  border: 0;
  color: var(--md-on-surface);
  word-break: break-word;
}
.prose :not(pre) > code::selection { background: #1f6feb; color: #fff; }
:root[data-theme="light"] .prose :not(pre) > code::selection { background: #b6d7ff; color: #1f2328; }
.code-block {
  margin: 1.6em 0;
  border-radius: var(--shape-md);
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px 7px 14px;
  border-bottom: 1px solid var(--code-border);
  background: var(--code-surface);
}
.code-lang { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--code-muted); }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--shape-full);
  border: 0;
  background: transparent;
  color: var(--code-muted);
  font-size: 0.66rem;
  transition: color 0.2s ease, background 0.2s ease;
}
.copy-btn:hover { color: var(--code-fg); background: color-mix(in srgb, var(--code-fg) 10%, transparent); }
.copy-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copy-btn.copied { color: var(--code-ok); }
.code-block pre {
  margin: 0;
  padding: 16px 18px 18px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--code-fg);
  tab-size: 4;
  font-variant-ligatures: none;
}
.code-block pre code { font-family: inherit; background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.code-block ::selection { background: #1f6feb; color: #ffffff; }
:root[data-theme="light"] .code-block ::selection { background: #b6d7ff; color: #1f2328; }

.table-wrap { margin: 1.6em 0; overflow-x: auto; border: 1px solid var(--md-outline-variant); border-radius: var(--shape-sm); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 420px; }
.prose th, .prose td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--md-outline-variant); }
.prose th { background: var(--md-surface-container-high); font-weight: 600; color: var(--md-on-surface); white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: var(--md-surface-container); }

.post-switcher { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.switch-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border-radius: var(--shape-md);
  border: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
}
.switch-card:hover { border-color: var(--md-outline); background: var(--md-surface-container); box-shadow: var(--shadow); }
.switch-card.next { text-align: right; align-items: flex-end; }
.switch-card small { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.1em; color: var(--md-outline); text-transform: uppercase; }
.switch-card strong { font-size: 0.9rem; font-weight: 600; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- palette ---------- */
.palette {
  position: fixed;
  inset: 0;
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  margin: 10vh auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--shape-xl);
  background: transparent;
  color: var(--fg);
  overflow: visible;
}
.palette::backdrop { background: var(--md-scrim); backdrop-filter: blur(6px); }
.palette[open] { animation: palette-in 0.24s var(--ease); }
@keyframes palette-in { from { opacity: 0; transform: translateY(-8px) scale(0.985); } }
.palette-box {
  border-radius: var(--shape-xl);
  border: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-high);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.palette-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--md-outline-variant); }
.palette-head svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--md-on-surface-variant); stroke-width: 1.8; stroke-linecap: round; }
.palette-head input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 1.06rem; }
.palette-head input::placeholder { color: var(--md-on-surface-variant); }
kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--md-on-surface-variant);
  border: 0;
  border-radius: 6px;
  padding: 2px 6px;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--md-surface-container-highest);
}
.palette-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: var(--shape-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}
.palette-item[aria-selected="true"] { background: var(--md-secondary-container); }
.palette-item .p-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--shape-xs);
  border: 0;
  background: var(--md-primary-container);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--md-on-primary-container);
}
.palette-item .p-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.palette-item .p-main strong { font-size: 1rem; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-main span { font-family: var(--font-mono); font-size: 0.76rem; line-height: 1.4; color: var(--md-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item[aria-selected="true"] .p-main span { color: var(--md-on-secondary-container); }
.palette-item mark { background: none; color: var(--md-primary); font-weight: 600; }
.palette-empty { padding: 34px 16px; text-align: center; color: var(--md-on-surface-variant); font-size: 0.96rem; }
.palette-foot { display: flex; align-items: center; gap: 16px; padding: 11px 18px; border-top: 1px solid var(--md-outline-variant); font-size: 0.74rem; color: var(--md-outline); }
.palette-foot #searchCount { margin-left: auto; font-family: var(--font-mono); }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- lightbox / toast / to-top ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: var(--md-scrim);
  backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
  cursor: zoom-out;
}
@keyframes fade-in { from { opacity: 0; } }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: var(--shape-sm); box-shadow: var(--shadow-2); object-fit: contain; }
.lightbox-close {
  position: absolute;
  top: 20px; right: 22px;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  transition: background 0.2s ease, transform 0.2s ease;
}
.lightbox-close:hover { background: var(--md-surface-container-highest); transform: rotate(90deg); }
.lightbox-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 600;
  transform: translate(-50%, 16px);
  padding: 12px 18px;
  border-radius: var(--shape-xs);
  border: 0;
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  box-shadow: var(--shadow-2);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.to-top {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: var(--shape-md);
  border: 0;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s var(--ease), background 0.2s ease;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--md-primary); color: var(--md-on-primary); }
.to-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero { gap: 36px; padding-top: 136px; }
  .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-shell { grid-template-columns: 210px minmax(0, 720px); gap: 40px; }
}

@media (max-width: 860px) {
  .nav-links { display: none; }
  .mobile-dir { display: inline-flex; }
  .hero {
    grid-template-columns: 1fr;
    padding-top: 118px;
    padding-bottom: 46px;
    gap: 54px;
  }
  .hero-art { order: 2; }
  .stats { gap: 28px; }
  .section { padding-top: 54px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 18px; }
  .directory-view { padding-top: 92px; }
  .dir-links { column-count: 1; }
  .inline-search { width: 100%; }
  .about { padding: 32px; }
  .about-points { grid-template-columns: 1fr; gap: 9px; }
  .post-view { padding-top: 92px; }
  .post-shell { display: block; }
  .post-aside { position: static; max-height: none; overflow: visible; margin-bottom: 24px; }
  .post-aside .toc { display: none; }
}

@media (max-width: 640px) {
  .aurora { height: 600px; }
  .nav-inner { padding: 0 16px; height: 60px; }
  .brand-text em { display: none; }
  .search-label, .search-kbd, .mobile-dir-label { display: none; }
  .search-trigger { width: 40px; padding: 0; }
  .mobile-dir { width: 40px; padding: 0; }
  .hero { padding-left: 18px; padding-right: 18px; }
  .hero h1 { font-size: clamp(2.3rem, 11vw, 2.95rem); }
  .cta .btn { flex: 1; }
  .stats { justify-content: space-between; gap: 16px; }
  .stats dd { font-size: 1.4rem; }
  .terminal pre { font-size: 0.64rem; }
  .section { padding-left: 18px; padding-right: 18px; }
  .directory-view { padding: 88px 18px 30px; }
  .dir-toggle { padding: 14px 16px; gap: 12px; }
  .dir-code { width: 42px; height: 42px; border-radius: var(--shape-sm); font-size: 0.66rem; }
  .dir-name { font-size: 1.05rem; }
  .dir-count { padding: 3px 8px; font-size: 0.62rem; }
  .dir-section-inner > .dir-links { padding: 10px 16px 14px; }
  .dir-link-meta { display: none; }
  .article-grid { grid-template-columns: 1fr; gap: 16px; }
  .topic-grid { grid-template-columns: 1fr; }
  .about { padding: 24px 20px; border-radius: var(--shape-lg); }
  .about-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .about-head .avatar-wrap { width: 68px; height: 68px; }
  .footer { padding-left: 18px; padding-right: 18px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .post-view { padding: 88px 18px 30px; }
  .post-head h1 { font-size: clamp(1.95rem, 8vw, 2.6rem); }
  .prose { font-size: 1.01rem; }
  .prose h2 { font-size: 1.4rem; }
  .code-block pre { font-size: 0.84rem; }
  .post-switcher { grid-template-columns: 1fr; }
  .palette { width: calc(100vw - 22px); margin-top: 8vh; }
  .to-top { right: 14px; bottom: 14px; width: 44px; height: 44px; }
}

body:has(dialog[open]) { overflow: hidden; }

/* ---------- motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .dir-section.open .dir-link { animation-delay: 0s !important; }
  .toc-children.toc-open > .toc-node { animation: none !important; }
}

@media print {
  .nav, .aurora, .to-top, .read-progress, .floating, .toast, .post-aside, .post-switcher { display: none !important; }
  body { background: #fff; color: #111; }
  .post-view { padding: 0; }
  .prose { color: #222; }
  .prose a { color: #1d4ed8; }
  .code-block { border: 1px solid #ddd; background: #f7f7f7; }
  .code-block pre { color: #111; }
}
