@import url('https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/style.css');

/* ============================================================
   Design Tokens — Light (default)
   ============================================================ */
:root {
  /* Backgrounds */
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-surface: #f5f5f5;
  --bg-tint: rgba(255,255,255,0.6);

  /* Foregrounds */
  --fg: #1a1a1a;
  --fg-muted: #555555;
  --fg-light: #888888;
  --fg-faint: #bbbbbb;

  /* Accent — refined blue-gold hybrid */
  --accent: #2563eb;
  --accent-soft: rgba(37,99,235,0.08);
  --accent-hover: #1d4ed8;

  /* Borders */
  --border: #e8e8e8;
  --border-strong: #d4d4d4;

  /* Cards & Shadows */
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.04), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-colored: 0 10px 30px -5px rgba(37,99,235,0.12);

  /* Typography — 系统兜底 */
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-system-serif: 'Georgia', 'Times New Roman', 'Songti SC', 'STSong', serif;
  --font-system-mono: 'SF Mono', 'Consolas', 'Courier New', monospace;

  /* 英文字体 */
  --font-inter: 'Inter', var(--font-system);
  --font-newsreader: 'Newsreader', var(--font-system-serif);
  --font-space-grotesk: 'Space Grotesk', var(--font-system);
  --font-plus-jakarta: 'Plus Jakarta Sans', var(--font-system);
  --font-merriweather: 'Merriweather', var(--font-system-serif);
  --font-lora: 'Lora', var(--font-system-serif);
  --font-playfair: 'Playfair Display', var(--font-system-serif);

  /* 等宽字体 */
  --font-jetbrains: 'JetBrains Mono', var(--font-system-mono);
  --font-fira-code: 'Fira Code', var(--font-system-mono);

  /* 中文字体 */
  --font-noto-sans-sc: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-noto-serif-sc: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-lxgw: 'LXGW WenKai', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', serif;

  /* 快捷搭配 — 改这里切换全局风格 */
  --font-body: var(--font-lxgw);
  --font-heading: var(--font-lxgw);
  --font-serif: var(--font-lxgw);
  --font-sans: var(--font-lxgw);
  --font-mono: var(--font-jetbrains);
  --font-ui: var(--font-inter);
  --font-display: var(--font-space-grotesk);
  --font-mono-cn: 'JetBrains Mono', 'Fira Code', 'LXGW WenKai', 'Noto Sans Mono CJK SC', monospace;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* ============================================================
   System Dark (when no explicit data-theme is set)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0a0a0a;
    --bg-elevated: #111111;
    --bg-surface: #1a1a1a;
    --bg-tint: rgba(255,255,255,0.03);

    --fg: #e5e5e5;
    --fg-muted: #a0a0a0;
    --fg-light: #666666;
    --fg-faint: #444444;

    --accent: #60a5fa;
    --accent-soft: rgba(96,165,250,0.1);
    --accent-hover: #3b82f6;

    --border: #2a2a2a;
    --border-strong: #3a3a3a;

    --card-bg: #141414;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
    --shadow-colored: 0 10px 30px -5px rgba(96,165,250,0.15);
  }
}

/* ============================================================
   Explicit Dark
   ============================================================ */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --bg-surface: #1a1a1a;
  --bg-tint: rgba(255,255,255,0.03);

  --fg: #e5e5e5;
  --fg-muted: #a0a0a0;
  --fg-light: #666666;
  --fg-faint: #444444;

  --accent: #60a5fa;
  --accent-soft: rgba(96,165,250,0.1);
  --accent-hover: #3b82f6;

  --border: #2a2a2a;
  --border-strong: #3a3a3a;

  --card-bg: #141414;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
  --shadow-colored: 0 10px 30px -5px rgba(96,165,250,0.15);
}

/* ============================================================
   Explicit Light (override for system-dark users who choose light)
   ============================================================ */
[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-surface: #f5f5f5;
  --bg-tint: rgba(255,255,255,0.6);

  --fg: #1a1a1a;
  --fg-muted: #555555;
  --fg-light: #888888;
  --fg-faint: #bbbbbb;

  --accent: #2563eb;
  --accent-soft: rgba(37,99,235,0.08);
  --accent-hover: #1d4ed8;

  --border: #e8e8e8;
  --border-strong: #d4d4d4;

  --card-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.04), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-colored: 0 10px 30px -5px rgba(37,99,235,0.12);
}

/* ============================================================
   Base
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.8;
  transition: background-color 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

::selection {
  background: var(--accent-soft);
  color: var(--fg);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--fg);
  color: var(--bg);
  z-index: 100;
  border-bottom: none;
  font-size: 0.8rem;
  transition: top 0.2s var(--ease-out);
}
.skip-link:focus { top: 0; }

/* Wrap */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ============================================================
   Masthead
   ============================================================ */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.masthead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

/* Logo / Mark */
.mark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-bottom: none;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--fg);
  transition: opacity 0.2s var(--ease-out);
}

.mark:hover { opacity: 0.7; }

.mark svg {
  width: 18px;
  height: 18px;
  stroke: var(--fg);
  stroke-width: 0.75px;
  fill: none;
  flex-shrink: 0;
}

.mark .ampersand {
  opacity: 0.5;
  font-weight: 300;
}

.handle {
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
}

/* Primary nav */
.primary {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.primary a {
  position: relative;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  border-bottom: none;
  color: var(--fg-muted);
  transition: color 0.25s var(--ease-out);
  padding: 0.25rem 0;
}

.primary a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--fg);
  transition: width 0.3s var(--ease-out);
}

.primary a:hover {
  color: var(--fg);
}

.primary a:hover::after {
  width: 100%;
}

/* Utility cluster */
.utility {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--fg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.theme-toggle:hover {
  color: var(--fg);
  background: var(--bg-surface);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

/* Pill button */
.btn-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-strong);
  transition: all 0.25s var(--ease-out);
  background: transparent;
}

.btn-pill:hover {
  border-color: var(--fg);
  color: var(--fg);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4.5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background 0.2s var(--ease-out);
}

.hamburger:hover { background: var(--bg-surface); }

.hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--fg);
  border-radius: 1px;
  transition: transform 0.25s var(--ease-out), opacity 0.2s var(--ease-out);
  transform-origin: center;
}

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100vh;
  background: var(--card-bg);
  z-index: 100;
  flex-direction: column;
  padding: var(--space-6);
  justify-content: center;
  align-items: center;
}

.mobile-nav-head {
  position: absolute;
  top: var(--space-6);
  left: var(--space-6);
  right: var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.ch {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--fg-light);
  text-transform: uppercase;
}

.mobile-nav-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--fg-muted);
  line-height: 1;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  transition: color 0.2s, background 0.2s;
}

.mobile-nav-close:hover {
  color: var(--fg);
  background: var(--bg-surface);
}

.mobile-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  align-items: center;
}

.mobile-nav-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mobile-nav-list .ch {
  font-size: 0.7rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  min-width: 1.5rem;
  text-align: right;
}

.mobile-nav-list a {
  font-size: clamp(1.5rem, 4vw, 2rem);
  border-bottom: none;
  color: var(--fg);
  padding: 0;
  display: block;
  transition: color 0.2s;
  font-family: var(--font-serif);
}

.mobile-nav-list a:hover { color: var(--accent); }

.mobile-nav-foot {
  position: absolute;
  bottom: var(--space-8);
  padding-top: 0;
  margin-top: 0;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: var(--space-24) 0 var(--space-16);
}

.hero-rubric {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-light);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  margin-bottom: var(--space-6);
  display: block;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) 1fr;
  gap: var(--space-8);
  align-items: start;
}

.hero-title {
  font-family: var(--font-newsreader);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.025em;
  white-space: pre-wrap;
  margin-bottom: var(--space-6);
  color: var(--fg);
}

.hero-title em {
  font-style: italic;
  color: var(--fg-muted);
  font-weight: 350;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--fg-muted);
  line-height: 1.8;
  max-width: 100%;
  margin-bottom: var(--space-10);
  white-space: nowrap;
  font-weight: 350;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Meta list */
.hero-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4) var(--space-8);
  margin-top: var(--space-8);
}

.hero-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hero-meta dt {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-light);
  font-family: var(--font-jetbrains);
}

.hero-meta dd {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Colophon Card
   ============================================================ */
.colophon-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  transition: box-shadow 0.4s var(--ease-out), transform 0.4s var(--ease-out);
}

.colophon-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 16px 32px rgba(0,0,0,0.04);
  transform: translateY(-2px);
}

.co-head {
  margin-bottom: var(--space-4);
}

.co-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-light);
  font-family: var(--font-jetbrains);
}

.co-poster {
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  aspect-ratio: 16/10;
}

.co-poster svg {
  width: 100%;
  height: auto;
  display: block;
}

.co-dl {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.co-dl-k {
  font-size: 0.75rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.co-dl-v {
  font-size: 0.9rem;
  color: var(--fg-muted);
  white-space: nowrap;
}

.co-body {
  margin-bottom: var(--space-4);
}

.co-line {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.co-line .k {
  color: var(--fg-light);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.co-line .l {
  color: var(--fg-muted);
  white-space: nowrap;
}

.co-foot {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.co-notes {
  padding: var(--space-4);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  margin-bottom: var(--space-4);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--fg-muted);
}

.co-notes p {
  margin: 0 0 0.5rem;
}

.co-notes p:last-child {
  margin-bottom: 0;
}

.co-stamp {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-light);
  font-family: var(--font-mono);
}

.co-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: var(--space-4) 0;
}

/* ============================================================
   Ticker (Marquee)
   ============================================================ */
.ticker {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  overflow: hidden;
  background: var(--bg-tint);
  position: relative;
}

.ticker::before,
.ticker::after {
  content: '';
  position: absolute;
  top: 0;
  width: 60px;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.ticker::before {
  left: 0;
  background: linear-gradient(to right, var(--bg), transparent);
}

.ticker::after {
  right: 0;
  background: linear-gradient(to left, var(--bg), transparent);
}

.track {
  display: flex;
  white-space: nowrap;
  width: max-content;
  animation: ticker-scroll 30s linear infinite;
  will-change: transform;
}

.track:hover {
  animation-play-state: paused;
}

.track span {
  font-size: 0.875rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  padding-right: var(--space-8);
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.track span:hover {
  opacity: 1;
  color: var(--fg-muted);
}

@keyframes ticker-scroll {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

/* ============================================================
   Chapter
   ============================================================ */
.chapter {
  padding: var(--space-32) 0 var(--space-24);
}

.chapter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-10);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.chapter-num {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--fg-light);
  text-transform: uppercase;
}

.bar {
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--fg-faint);
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3.2vw, 2.2rem);
  font-weight: 400;
  flex: 1;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.chapter-title em {
  font-style: italic;
  color: var(--fg-muted);
  font-weight: 350;
}

.all-link {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  border-bottom: none;
  color: var(--fg-muted);
  transition: color 0.2s var(--ease-out);
  position: relative;
}

.all-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--fg);
  transition: width 0.3s var(--ease-out);
}

.all-link:hover {
  color: var(--fg);
}

.all-link:hover::after {
  width: 100%;
}

/* ============================================================
   Article Cards
   ============================================================ */
.article-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.article-card {
  display: block;
  border-bottom: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
  will-change: transform;
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.article-card-cover {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg-surface);
  position: relative;
}

.article-card-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.04));
  pointer-events: none;
}

.article-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease-out);
  will-change: transform;
}

.article-card:hover .article-card-img {
  transform: scale(1.04);
}

.article-card-body {
  padding: var(--space-5);
}

.article-card-meta {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}

.date {
  font-size: 0.65rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.lang-badge {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  transition: border-color 0.2s, background 0.2s;
}

.lang-badge.both {
  color: var(--fg-muted);
  background: transparent;
}

.article-card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--fg);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.article-card:hover .article-card-title {
  color: var(--accent-hover);
}

/* ============================================================
   Bookshelf (Shelf)
   ============================================================ */
.shelf-wrap {
  padding: var(--space-16) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-tint);
  position: relative;
}

.shelf-rubric {
  font-size: 0.65rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}

.shelf {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  /* Smooth scroll for wheel events */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.shelf::-webkit-scrollbar { height: 3px; }
.shelf::-webkit-scrollbar-track { background: transparent; }
.shelf::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Spine */
.spine {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-3);
  background: linear-gradient(180deg, #f2f0eb 0%, #e8e5df 40%, #ddd8ce 100%);
  border: 1px solid #d4d0c6;
  border-radius: 2px 1px 1px 2px;
  color: #4a4540;
  font-size: 0.75rem;
  line-height: 1.5;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border-bottom: none;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
  position: relative;
  cursor: pointer;
  min-width: 36px;
}

.spine::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 2px;
  background: rgba(0,0,0,0.08);
  border-radius: 1px;
}

.spine::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 1.5px;
  background: rgba(0,0,0,0.06);
  border-radius: 1px;
}

.spine:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 8px 20px -4px rgba(0,0,0,0.12);
  z-index: 2;
}

.spine.short { height: 170px; }
.spine.mid { height: 210px; }
.spine.tall { height: 250px; }

.spine .num {
  font-size: 0.6rem;
  color: #888480;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* Spine color variants */
.spine.accent-1 { background: linear-gradient(180deg, #e8e0d5 0%, #ddd3c4 40%, #d0c4b0 100%); border-color: #c4b8a4; color: #5a4e40; }
.spine.accent-2 { background: linear-gradient(180deg, #d5e0e8 0%, #c4d3dd 40%, #b0c4d0 100%); border-color: #a4b8c4; color: #40505a; }
.spine.accent-3 { background: linear-gradient(180deg, #e8d5d5 0%, #ddc4c4 40%, #d0b0b0 100%); border-color: #c4a4a4; color: #5a4040; }
.spine.accent-4 { background: linear-gradient(180deg, #d5e8d8 0%, #c4ddc8 40%, #b0d0b4 100%); border-color: #a4c4a8; color: #405a44; }
.spine.accent-5 { background: linear-gradient(180deg, #e0d5e8 0%, #d3c4dd 40%, #c4b0d0 100%); border-color: #b8a4c4; color: #4e405a; }

/* ============================================================
   Community Strip
   ============================================================ */
.community-strip {
  padding: var(--space-20) 0;
}

.community-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-12);
}

.metric {
  text-align: center;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  transition: background 0.3s var(--ease-out);
}

.metric:hover {
  background: var(--bg-surface);
}

.unit {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  line-height: 1;
  margin-bottom: var(--space-3);
  color: var(--fg);
  letter-spacing: -0.03em;
  font-weight: 400;
}

.label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.desc {
  font-size: 0.8rem;
  color: var(--fg-light);
  line-height: 1.5;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-20) 0 var(--space-16);
}

.footer-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-6);
}

.footer-mark {
  color: var(--fg-faint);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.footer-blurb {
  font-size: 0.85rem;
  color: var(--fg-muted);
  max-width: 380px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.footer-nav {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-nav a {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--fg-light);
  border-bottom: none;
  transition: color 0.2s var(--ease-out);
  text-transform: uppercase;
}

.footer-nav a:hover { color: var(--fg); }

/* ============================================================
   Articles List Page
   ============================================================ */
.article-list-chapter { padding-top: var(--space-12); }

.articles-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.article-item {
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s;
}

.article-item:last-child { border-bottom: none; }

.article-date {
  font-size: 0.65rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.article-title {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  font-weight: 400;
  margin-bottom: var(--space-2);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.article-title a {
  border-bottom: none;
  color: var(--fg);
  transition: color 0.2s var(--ease-out);
}

.article-title a:hover { color: var(--accent); }

.article-excerpt {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.7;
  margin-bottom: var(--space-2);
  max-width: 560px;
}

.article-meta {
  font-size: 0.6rem;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

/* ============================================================
   Article Full Page
   ============================================================ */
.article-full { padding: var(--space-12) 0 var(--space-16); }

.article-header { margin-bottom: 2rem; text-align: center; }

.article-cover {
  max-width: 640px;
  margin: 0 auto var(--space-8);
  text-align: center;
}

.article-cover img {
  width: 100%;
  border-radius: 4px;
  display: block;
}

.section-marker {
  display: none;
}

.article-page-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 0.5rem;
  text-align: center;
}

.byline {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin: 0;
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.8;
  max-width: 640px;
  margin: 0 auto;
  color: var(--fg-muted);
}

.article-body p { margin-bottom: 1.3em; }

.article-body h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin: 2em 0 0.6em;
  line-height: 1.3;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.article-body h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  margin: 1.6em 0 0.5em;
  color: var(--fg);
}

.article-body blockquote {
  border-left: 2.5px solid var(--accent);
  padding-left: var(--space-5);
  margin: 1.8em 0;
  color: var(--fg-muted);
  font-style: italic;
}

.article-body blockquote p { margin-bottom: 0; }

.article-body ul,
.article-body ol {
  padding-left: 1.6em;
  margin-bottom: 1.3em;
}

.article-body li { margin-bottom: 0.35em; }

.article-body code {
  background: var(--bg-surface);
  padding: 0.15em 0.35em;
  border-radius: var(--radius-sm);
  font-size: 0.82em;
  font-family: var(--font-mono);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.article-body pre {
  background: var(--bg-elevated);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 1.3em;
  border: 1px solid var(--border);
}

.article-body pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 0.8em;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}

.article-body strong { font-weight: 600; color: var(--fg); }
.article-body em { font-style: italic; }

/* Article body tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3em 0;
  font-size: 0.95em;
}
.article-body th,
.article-body td {
  padding: 0.6em 0.8em;
  border: 1px solid var(--border);
  text-align: left;
}
.article-body th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--fg);
}
.article-body tr:nth-child(even) {
  background: var(--bg-tint);
}
.article-body table-wrapper {
  overflow-x: auto;
  display: block;
  margin: 1.3em 0;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-12);
  margin-top: var(--space-12);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.article-nav a {
  border-bottom: none;
  color: var(--fg-muted);
  transition: color 0.2s;
}

.article-nav a:hover { color: var(--fg); }

.article-nav-all {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

/* ============================================================
   Games Page
   ============================================================ */
.games-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.game-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
  will-change: transform;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.game-cover {
  aspect-ratio: 16/10;
  background: var(--bg-surface);
  overflow: hidden;
  position: relative;
}

.game-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.05));
  pointer-events: none;
}

.game-info { padding: var(--space-5); }

.game-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: var(--space-1);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.game-tags {
  font-size: 0.7rem;
  color: var(--fg-light);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
  letter-spacing: 0.03em;
}

.game-link {
  font-size: 0.8rem;
  color: var(--accent);
  border-bottom: none;
  transition: color 0.2s;
}

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

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-12);
}

.stat-item { text-align: center; }

.stat-number {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  line-height: 1;
  margin-bottom: var(--space-3);
  color: var(--fg);
  letter-spacing: -0.03em;
  font-weight: 400;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.stat-desc {
  font-size: 0.8rem;
  color: var(--fg-light);
  line-height: 1.5;
}

/* ============================================================
   Utility
   ============================================================ */
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* Focus styles */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Responsive — Tablet (<= 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .wrap { padding: 0 var(--space-6); }

  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-10);
  }

  .colophon-card {
    max-width: 420px;
  }

  .article-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .community-grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .games-list { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; gap: var(--space-8); }
}

/* ============================================================
   Responsive — Mobile (<= 768px)
   ============================================================ */
@media (max-width: 768px) {
  .wrap { padding: 0 var(--space-5); }

  .primary { display: none; }
  .hamburger { display: flex; }

  .hero { padding: var(--space-12) 0 var(--space-8); }

  .hero-title {
    font-size: clamp(2rem, 8vw, 2.8rem);
    line-height: 1.1;
  }

  .hero-sub {
    font-size: 1rem;
  }

  .hero-meta {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .article-cards {
    grid-template-columns: 1fr;
  }

  .ticker { padding: 0.6rem 0; }
  .track span { font-size: 0.8rem; }

  .chapter { padding: var(--space-16) 0; }
  .chapter-head { margin-bottom: var(--space-8); }

  .shelf-wrap { padding: var(--space-10) 0; }

  .community-strip { padding: var(--space-16) 0; }

  .spine.short { height: 150px; }
  .spine.mid { height: 180px; }
  .spine.tall { height: 210px; }

  .games-list { grid-template-columns: 1fr; }
  .article-full { padding: var(--space-8) 0 var(--space-12); }
  .article-nav { flex-direction: column; gap: var(--space-4); }

  /* Mobile article body */
  .article-body {
    font-size: 1rem;
    line-height: 1.75;
  }
  .article-body h2 {
    font-size: 1.3rem;
  }
  .article-body h3 {
    font-size: 1.05rem;
  }
  .article-body blockquote {
    padding-left: var(--space-4);
    margin: 1.4em 0;
  }
  .article-body pre {
    padding: var(--space-4);
    font-size: 0.8rem;
  }
  .article-body th,
  .article-body td {
    padding: 0.45em 0.5em;
    font-size: 0.9rem;
  }

  .article-cover {
    margin: 0 auto var(--space-6);
  }

  .article-page-title {
    font-size: 1.35rem;
  }
}

/* ============================================================
   Responsive — Small Mobile (<= 480px)
   ============================================================ */
@media (max-width: 480px) {
  html { font-size: 15px; }

  .wrap { padding: 0 var(--space-4); }

  .masthead-row { height: 48px; }

  .hero { padding: var(--space-10) 0 var(--space-6); }

  .hero-title {
    font-size: clamp(1.8rem, 7vw, 2.4rem);
  }

  .colophon-card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .chapter { padding: var(--space-12) 0; }

  .footer { padding: var(--space-12) 0 var(--space-10); }
  .footer-nav { gap: var(--space-4); }

  .article-body {
    font-size: 0.95rem;
  }
  .article-body h2 {
    font-size: 1.2rem;
  }
  .article-body h3 {
    font-size: 1rem;
  }
  .article-page-title {
    font-size: 1.2rem;
  }
  .byline {
    font-size: 0.8rem;
  }
}

/* ============================================================
   Dark mode component overrides
   ============================================================ */

[data-theme="dark"] .masthead {
  background: color-mix(in oklch, #0a0a0a 92%, transparent);
}

[data-theme="dark"] .spine {
  background: linear-gradient(180deg, #2a2a2a 0%, #222222 40%, #1a1a1a 100%);
  border-color: #3a3a3a;
  color: #b0b0b0;
}

[data-theme="dark"] .spine::before,
[data-theme="dark"] .spine::after {
  background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .spine.accent-1 {
  background: linear-gradient(180deg, #3a3228 0%, #2e2820 40%, #221e18 100%);
  border-color: #4a4238;
  color: #c8b8a8;
}

[data-theme="dark"] .spine.accent-2 {
  background: linear-gradient(180deg, #28323a 0%, #20282e 40%, #181e22 100%);
  border-color: #38424a;
  color: #a8b8c8;
}

[data-theme="dark"] .spine.accent-3 {
  background: linear-gradient(180deg, #3a2828 0%, #2e2020 40%, #221818 100%);
  border-color: #4a3838;
  color: #c8a8a8;
}

[data-theme="dark"] .spine.accent-4 {
  background: linear-gradient(180deg, #283a2c 0%, #202e24 40%, #18221a 100%);
  border-color: #384a3c;
  color: #a8c8a8;
}

[data-theme="dark"] .spine.accent-5 {
  background: linear-gradient(180deg, #32283a 0%, #28202e 40%, #1e1822 100%);
  border-color: #42384a;
  color: #b8a8c8;
}

[data-theme="dark"] .article-card:hover .article-card-title {
  color: var(--accent);
}

[data-theme="dark"] .ticker {
  background: var(--bg-tint);
}

[data-theme="dark"] .shelf-wrap {
  background: var(--bg-tint);
}

[data-theme="dark"] .article-card:hover,
[data-theme="dark"] .game-card:hover {
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
}

/* System dark overrides */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .masthead {
    background: color-mix(in oklch, #0a0a0a 92%, transparent);
  }

  :root:not([data-theme]) .spine {
    background: linear-gradient(180deg, #2a2a2a 0%, #222222 40%, #1a1a1a 100%);
    border-color: #3a3a3a;
    color: #b0b0b0;
  }

  :root:not([data-theme]) .spine::before,
  :root:not([data-theme]) .spine::after {
    background: rgba(255,255,255,0.06);
  }

  :root:not([data-theme]) .spine.accent-1 {
    background: linear-gradient(180deg, #3a3228 0%, #2e2820 40%, #221e18 100%);
    border-color: #4a4238;
    color: #c8b8a8;
  }

  :root:not([data-theme]) .spine.accent-2 {
    background: linear-gradient(180deg, #28323a 0%, #20282e 40%, #181e22 100%);
    border-color: #38424a;
    color: #a8b8c8;
  }

  :root:not([data-theme]) .spine.accent-3 {
    background: linear-gradient(180deg, #3a2828 0%, #2e2020 40%, #221818 100%);
    border-color: #4a3838;
    color: #c8a8a8;
  }

  :root:not([data-theme]) .spine.accent-4 {
    background: linear-gradient(180deg, #283a2c 0%, #202e24 40%, #18221a 100%);
    border-color: #384a3c;
    color: #a8c8a8;
  }

  :root:not([data-theme]) .spine.accent-5 {
    background: linear-gradient(180deg, #32283a 0%, #28202e 40%, #1e1822 100%);
    border-color: #42384a;
    color: #b8a8c8;
  }

  :root:not([data-theme]) .article-card:hover .article-card-title {
    color: var(--accent);
  }

  :root:not([data-theme]) .ticker {
    background: var(--bg-tint);
  }

  :root:not([data-theme]) .shelf-wrap {
    background: var(--bg-tint);
  }

  :root:not([data-theme]) .article-card:hover,
  :root:not([data-theme]) .game-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
  }
}

/* Article card excerpt */
.article-card-excerpt {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: var(--space-2);
  line-height: 1.5;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--fg-light);
  margin-bottom: var(--space-4);
}
.breadcrumb a {
  border-bottom: none;
  color: var(--fg-light);
}
.breadcrumb a:hover {
  color: var(--fg);
}

/* Related articles */
.related-articles {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
}
.related-articles h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: var(--space-4);
}

/* About grid */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-12);
  align-items: start;
}
@media (max-width: 900px) {
  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* Section desc */
.section-desc {
  color: var(--fg-muted);
  margin-bottom: var(--space-8);
  max-width: 600px;
  font-size: 1rem;
  line-height: 1.7;
}


/* ========== Mobile Nav Transitions (JS-driven) ========== */
.mobile-nav {
  display: flex;
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              visibility 0.3s;
  pointer-events: none;
}

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

.mobile-nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
  pointer-events: none;
}

.mobile-nav-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ========== Theme Toggle Hover / Active ========== */
.theme-toggle:hover .theme-toggle-track {
  border-color: hsl(207, 40%, 60%);
}

.theme-toggle:active .theme-toggle-track {
  transform: scale(0.96);
}


/* ============================================================
   Edit Mode
   ============================================================ */

/* 1. Edit target outline */
[data-edit-mode="true"] .edit-target {
  position: relative;
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  cursor: pointer;
  transition: outline-color 0.2s, background 0.2s;
}
[data-edit-mode="true"] .edit-target:hover {
  outline-color: #d4a373;
  background: rgba(176, 141, 87, 0.05);
}

/* 2. Edit icon (pencil) */
.edit-icon {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.2s, transform 0.2s var(--ease-out);
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
[data-edit-mode="true"] .edit-target:hover .edit-icon {
  opacity: 1;
  transform: scale(1);
}

/* 3. Floating edit panel */
.edit-panel {
  position: absolute;
  z-index: 9999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
  min-width: 280px;
  max-width: 420px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--fg);
}
.edit-panel::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  transform: rotate(45deg);
  z-index: -1;
}
.edit-panel[data-arrow="top"]::before {
  top: -6px;
  left: 50%;
  margin-left: -6px;
  border-bottom: none;
  border-right: none;
}
.edit-panel[data-arrow="bottom"]::before {
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border-top: none;
  border-left: none;
}
.edit-panel input[type="text"],
.edit-panel textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}
.edit-panel input[type="text"]:focus,
.edit-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.edit-panel textarea { min-height: 80px; }
.edit-panel .panel-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-4);
}
.edit-panel .btn-save,
.edit-panel .btn-cancel {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  border: 1px solid transparent;
}
.edit-panel .btn-save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.edit-panel .btn-save:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.edit-panel .btn-cancel {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border-strong);
}
.edit-panel .btn-cancel:hover {
  background: var(--bg-surface);
  color: var(--fg);
  border-color: var(--fg-light);
}

/* 4. Image picker modal */
.img-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.img-modal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.img-modal-header {
  padding: var(--space-5) var(--space-6) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.img-modal-header h4 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 0;
}
.img-modal-close {
  background: none;
  border: none;
  color: var(--fg-light);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background 0.2s, color 0.2s;
}
.img-modal-close:hover {
  background: var(--bg-surface);
  color: var(--fg);
}
.img-gallery {
  padding: var(--space-4) var(--space-6);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  overflow-y: auto;
}
.img-gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s var(--ease-out);
}
.img-gallery-item:hover { transform: translateY(-2px); }
.img-gallery-item.is-selected { border-color: #d4a373; }
.img-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.img-upload-zone {
  margin: var(--space-4) var(--space-6) var(--space-6);
  padding: var(--space-8) var(--space-6);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--fg-muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.img-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 5. Bottom floating toolbar */
.edit-toolbar {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}
.edit-toolbar .toolbar-status {
  color: var(--fg-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  margin-right: var(--space-2);
}
.edit-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-muted);
}
.edit-toolbar .btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.edit-toolbar .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.edit-toolbar .btn-secondary:hover {
  background: var(--bg-surface);
  color: var(--fg);
  border-color: var(--border-strong);
}

/* 6. Article card "edit article" icon */
[data-edit-mode="true"] .article-card { position: relative; }
.card-edit-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  color: var(--fg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.2s, transform 0.2s var(--ease-out), color 0.2s, border-color 0.2s;
  z-index: 5;
}
.article-card:hover .card-edit-btn {
  opacity: 1;
  transform: scale(1);
}
.card-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* 7. Dark mode adaptations */
[data-theme="dark"] [data-edit-mode="true"] .edit-target:hover {
  background: rgba(212, 163, 115, 0.08);
}
[data-theme="dark"] .edit-panel input[type="text"],
[data-theme="dark"] .edit-panel textarea {
  background: var(--bg-surface);
}
[data-theme="dark"] .img-modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .card-edit-btn {
  background: var(--bg-elevated);
}

/* System dark when no explicit theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) [data-edit-mode="true"] .edit-target:hover {
    background: rgba(212, 163, 115, 0.08);
  }
  :root:not([data-theme]) .edit-panel input[type="text"],
  :root:not([data-theme]) .edit-panel textarea {
    background: var(--bg-surface);
  }
  :root:not([data-theme]) .img-modal-overlay {
    background: rgba(0, 0, 0, 0.6);
  }
  :root:not([data-theme]) .card-edit-btn {
    background: var(--bg-elevated);
  }
}

/* 8. Responsive */
@media (max-width: 640px) {
  .edit-panel {
    position: fixed;
    left: var(--space-4);
    right: var(--space-4);
    bottom: auto;
    top: 15vh;
    max-width: none;
    min-width: auto;
  }
  .edit-panel::before { display: none; }
  .img-gallery { grid-template-columns: repeat(3, 1fr); }
  .edit-toolbar {
    left: var(--space-4);
    right: var(--space-4);
    transform: none;
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    justify-content: center;
  }
  .edit-toolbar .toolbar-status {
    width: 100%;
    text-align: center;
    margin: 0 0 var(--space-2);
  }
}

/* Edit panel font and color selectors */
.edit-font-select,
.edit-color-input {
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 0.8rem;
}
.edit-font-select {
  width: 100%;
}
.edit-color-input {
  width: 40px;
  height: 28px;
  padding: 2px;
  cursor: pointer;
}

/* Section Control Bar */
[data-edit-mode="true"] section,
[data-edit-mode="true"] .ticker {
  position: relative;
}

.section-control-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 100;
  opacity: 1;
}
.sec-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.sec-btn:hover {
  background: var(--accent-hover);
}
.sec-slider-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.sec-slider-label {
  color: #fff;
  font-size: 10px;
  white-space: nowrap;
}
.sec-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
}

/* Selection Toolbar */
.selection-toolbar {
  position: absolute;
  z-index: 1000;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toolbar-pop 0.15s ease-out;
}
@keyframes toolbar-pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.sel-toolbar-font {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--fg);
  font-size: 0.75rem;
  cursor: pointer;
}
.sel-toolbar-color {
  width: 28px;
  height: 24px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
}
.sel-toolbar-btn {
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.sel-toolbar-btn:hover {
  background: var(--accent-hover);
}
