/* =============================================
   Design System — CSS Custom Properties
   Theme: Apple Warm White (default)
   Switch to Linear: change data-theme on <html>
   ============================================= */

/* === Apple Warm White (default) === */
:root {
  --bg-page:        #f5f5f7;
  --bg-surface:     #ffffff;
  --bg-surface-alt: #fafafa;
  --bg-hover:       #f0f0f2;

  --text-primary:   #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary:  #aeaeb2;

  --border:         #e8e8ed;
  --border-light:   #f0f0f2;

  --accent:         #0071e3;
  --accent-hover:   #0077ed;
  --accent-subtle:  #e8f2fd;

  --red:            #e53935;
  --green:          #2e7d32;

  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;

  --shadow-sm:      0 1px 2px rgba(0,0,0,0.04);
  --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:      'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Font size scale — single source of truth for all type sizing */
  --fs-hero:    36px;
  --fs-display: 32px;
  --fs-h1:      28px;
  --fs-h2:      22px;
  --fs-h3:      18px;
  --fs-title:   16px;
  --fs-body:    16px;
  --fs-ui:      14px;
  --fs-small:   13px;
  --fs-tiny:    12px;

  /* Semantic aliases used by new shared components. */
  --color-page: var(--bg-page);
  --color-surface: var(--bg-surface);
  --color-surface-muted: var(--bg-surface-alt);
  --color-surface-elevated: #ffffff;
  --color-text: var(--text-primary);
  --color-text-muted: var(--text-secondary);
  --color-text-subtle: var(--text-tertiary);
  --color-border: var(--border);
  --color-border-strong: #c8c8ce;
  --color-accent: var(--accent);
  --color-accent-hover: var(--accent-hover);
  --color-accent-soft: var(--accent-subtle);
  --color-success: var(--green);
  --color-warning: #a66b00;
  --color-danger: var(--red);
  --color-info: var(--accent);
  --container-public: 1120px;
  --container-wide: 1280px;
  --container-reading: 720px;
  --container-admin: 1440px;
}

.article-body img {
  cursor: zoom-in;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: rgba(0, 0, 0, 0.86);
  overflow: hidden;
}
.image-lightbox-open { overflow: hidden; }
.image-lightbox-image {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.image-lightbox-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(92vw, 1200px);
  max-height: 88vh;
  padding: 24px;
  box-sizing: border-box;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: auto;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.image-lightbox-image.is-dragging,
.image-lightbox-svg.is-dragging { cursor: grabbing; }
.image-lightbox-svg svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(88vh - 48px);
}
.image-lightbox-close {
  position: absolute;
  top: 16px;
  right: 22px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox-hint {
  position: absolute;
  bottom: 18px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
}

/* === Semantic font-size classes (use these, not inline font-size) === */
.text-hero    { font-size: var(--fs-hero); }
.text-display { font-size: var(--fs-display); }
.text-h1      { font-size: var(--fs-h1); }
.text-h2      { font-size: var(--fs-h2); }
.text-h3      { font-size: var(--fs-h3); }
.text-title   { font-size: var(--fs-title); }
.text-body    { font-size: var(--fs-body); }
.text-ui      { font-size: var(--fs-ui); }
.text-small   { font-size: var(--fs-small); }
.text-tiny    { font-size: var(--fs-tiny); }

/* === Linear Cool Gray (add data-theme="linear" to <html>) === */
[data-theme="linear"] {
  --bg-page:        #fafafa;
  --bg-surface:     #ffffff;
  --bg-surface-alt: #f7f7f8;
  --bg-hover:       #f2f2f3;

  --text-primary:   #0a0a0a;
  --text-secondary: #5c5c5c;
  --text-tertiary:  #a0a0a0;

  --border:         #e5e5e5;
  --border-light:   #ededed;

  --accent:         #5e6ad2;
  --accent-hover:   #4f5ac7;
  --accent-subtle:  #f0f1fa;

  --red:            #e54d4d;
  --green:          #3b995b;

  --radius-sm:      4px;
  --radius-md:      6px;
  --radius-lg:      8px;
}

/* === Dark Theme (data-theme="dark" on <html>) === */
[data-theme="dark"] {
  --bg-page:        #0f1115;
  --bg-surface:     #171a21;
  --bg-surface-alt: #1d2129;
  --bg-hover:       #242933;

  --text-primary:   #f2f3f5;
  --text-secondary: #b0b6c0;
  --text-tertiary:  #7d8590;

  --border:         #2a303a;
  --border-light:   #222833;

  --accent:         #4d8ff7;
  --accent-hover:   #66a1f8;
  --accent-subtle:  #1e2f4d;

  --red:            #f0654d;
  --green:          #57ab5a;
  --color-surface-elevated: #20252e;
  --color-border-strong: #46505e;
  --color-warning: #e0aa45;
}

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

body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[x-cloak] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 8px;
  z-index: 100;
  padding: 8px 12px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform 0.15s;
}
.skip-link:focus { transform: translateY(0); }

::selection { background: var(--accent-subtle); color: var(--text-primary); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0b5; }

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.25;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--accent-hover); }

/* === Utility === */
.surface {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.surface-flat {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
}
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.mono { font-family: var(--font-mono); }

/* === Nav === */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245,245,247,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .site-nav { background: rgba(15,17,21,0.88); }
[data-theme="linear"] .site-nav {
  background: rgba(250,250,250,0.8);
}

.site-nav-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-nav-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.site-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}
.site-nav-links a {
  font-size: 13px;
  color: var(--text-tertiary);
  transition: color 0.15s;
}
.site-nav-links a:hover,
.site-nav-links a.active {
  color: var(--text-primary);
}
.site-nav-links a.active { position: relative; }
.site-nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  height: 2px;
  background: var(--accent);
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.icon-button:hover { color: var(--text-primary); }
.login-dialog {
  width: 340px;
  max-width: calc(100vw - 32px);
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 36px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

/* === Page header === */
.page-header {
  max-width: 1024px;
  margin: 0 auto;
  padding: 60px 24px 32px;
}
.page-header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.page-header p {
  font-size: 17px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

/* === Section box === */
.section-box {
  max-width: 1024px;
  margin: 0 auto 28px;
  padding: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.section-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-box-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-box-link {
  font-size: 12px;
  color: var(--accent);
}

/* === Article row (list style, not card) === */
.article-row {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  transition: opacity 0.15s;
  color: inherit;
  text-decoration: none;
}
.article-row:last-child { border-bottom: none; }
.article-row:hover { opacity: 0.7; }
.article-row-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.article-row-meta .tag {
  color: var(--accent);
}
.article-row-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.article-row-excerpt {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 3px;
  line-height: 1.5;
}

/* === Market data row === */
.market-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
}
.market-item {
  padding: 12px 0;
}
.market-item-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.market-item-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.market-item-change {
  font-size: 13px;
  font-weight: 500;
}
.market-item-change.up { color: var(--green); }
.market-item-change.down { color: var(--red); }

/* === News row === */
.news-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.news-row:last-child { border-bottom: none; }
.news-row-time { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; min-width: 52px; }
.news-row-cat {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-subtle);
  color: var(--accent);
  white-space: nowrap;
  font-weight: 500;
}
.news-row-title {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.news-row-title:hover { color: var(--accent); }
.news-row-summary {
  color: var(--text-tertiary);
  font-size: 11px;
}

/* === Filter tags === */
.filter-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-tag {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-tag:hover { border-color: var(--accent); color: var(--accent); }
.filter-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* === Split editor === */
.editor-container {
  display: flex;
  height: calc(100vh - 48px);
}
.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.editor-pane-left {
  border-right: 1px solid var(--border);
}
.editor-pane-header {
  padding: 10px 20px;
  font-size: var(--fs-tiny);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-alt);
}
.editor-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.editor-textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  background: transparent;
}
.editor-textarea::placeholder { color: var(--text-tertiary); }

.editor-preview {
  font-size: var(--fs-body);
  line-height: 1.8;
  color: var(--text-primary);
}
.editor-preview a {
  color: var(--accent);
  text-decoration: underline;
}
.editor-preview h1 { font-size: 28px; margin: 24px 0 12px; }
.editor-preview h2 { font-size: 22px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-light); }
.editor-preview h3 { font-size: 18px; margin: 16px 0 8px; }
.editor-preview p  { margin: 0 0 14px; }
.editor-preview pre {
  background: #2d2d2d;
  color: #e0e0e0;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.editor-preview code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-hover);
  padding: 2px 5px;
  border-radius: 3px;
}
.editor-preview pre code { background: none; padding: 0; color: inherit; }
.editor-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 14px;
}
.editor-preview th, .editor-preview td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.editor-preview th {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--text-primary);
}
.editor-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text-secondary);
  margin: 14px 0;
}
.editor-preview ul, .editor-preview ol { margin: 10px 0; padding-left: 22px; }
.editor-preview li { margin-bottom: 4px; }

/* Editor toolbar */
.editor-toolbar {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.editor-toolbar-left { display: flex; align-items: center; gap: 10px; }
.editor-toolbar-right { display: flex; align-items: center; gap: 8px; }

/* === Format toolbar (markdown insert buttons) === */
.fmt-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-wrap: wrap;
}
.fmt-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}
.fmt-toolbar button:hover { background: var(--bg-hover); color: var(--text-primary); }
.fmt-toolbar .fmt-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* === TOC Sidebar === */
.toc-wrap {
  display: flex;
  gap: 0;
  min-height: 0;
  flex: 1;
}
.toc-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  display: none;
}
.toc-sidebar.show { display: block; }
.toc-sidebar-title {
  font-size: var(--fs-tiny);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.toc-link {
  display: block;
  padding: 3px 0 3px 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.1s;
}
.toc-link:hover { color: var(--text-primary); }
.toc-link.toc-h2 { padding-left: 12px; }
.toc-link.toc-h3 { padding-left: 24px; }
.toc-link.toc-h4 { padding-left: 36px; }
.toc-link.active { color: var(--accent); font-weight: 500; }

/* === Mermaid === */
.mermaid {
  text-align: center;
  margin: 1.2rem 0;
  padding: 16px;
  background: var(--bg-page);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

/* === Article page layout with TOC === */
.article-layout {
  max-width: 1024px;
  margin: 0 auto;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.article-main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  order: 1;
}
.article-toc {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 0 8px;
  order: 2;
  border-left: 1px solid var(--border);
}
.article-toc .toc-link {
  font-size: 13px;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 12px;
  border-left: 2px solid transparent;
}
.article-toc .toc-link.toc-h2 { padding-left: 20px; }
.article-toc .toc-link.toc-h3 { padding-left: 28px; }
.article-toc .toc-link.toc-h4 { padding-left: 36px; }
.article-toc .toc-link.active { border-left-color: var(--accent); background: var(--accent-subtle); }
@media (max-width: 900px) {
  .article-layout { flex-direction: column; }
  .article-toc { display: none; }
  .toc-sidebar { display: none !important; }
}

/* === Buttons === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--text-primary);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--text-secondary); }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .refresh-link:focus-visible,
.avatar-change-btn:focus-visible, .comment-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--text-tertiary); }

/* === Form inputs === */
.form-input {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-tertiary); }

/* === Footer === */
.site-footer {
  max-width: 1024px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
}
.site-footer a { color: var(--text-tertiary); }
.site-footer a:hover { color: var(--text-secondary); }

/* === Editorial interaction details === */
.home-primary-button:focus-visible, .home-secondary-button:focus-visible,
.home-text-link:focus-visible, .article-list-row:focus-visible, .featured-article:focus-visible,
.library-row:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.refresh-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 3px 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  font: inherit;
  font-size: var(--fs-tiny);
  cursor: pointer;
}
.refresh-link:hover { color: var(--accent-hover); }
.refresh-link:disabled { color: var(--text-tertiary); cursor: wait; }
.refresh-link:disabled i { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.article-body { overflow-wrap: anywhere; }
.article-body > p, .article-body > ul, .article-body > ol, .article-body > blockquote { max-width: 68ch; }
.article-body p { line-height: 1.85; }
.article-body h2 { margin-top: 2.4em; padding-top: 0.5em; border-top: 1px solid var(--border-light); }
.article-body h3 { margin-top: 1.8em; }
.article-body blockquote { margin-left: 0; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--bg-surface-alt); }
.article-body pre { max-width: 100%; overflow-x: auto; }
.async-placeholder {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
}
.async-placeholder::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border: 1px solid var(--border-strong, var(--border));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.comment-input, .comment-textarea, .form-input { min-height: 44px; }
.comment-textarea { min-height: 112px; }
.comment-btn { min-height: 44px; }

/* Homepage specification overrides. */
:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8fafc;
  --bg-hover: #f8fafc;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #94a3b8;
  --border: #e5e7eb;
  --border-light: #eef0f3;
  --accent: #5b6ee1;
  --accent-hover: #4f61d2;
  --accent-subtle: #eef2ff;
  --green: #16a34a;
}
[data-theme="dark"] {
  --bg-page: #0f1115;
  --bg-surface: #171a21;
  --bg-surface-alt: #1d2129;
  --text-primary: #f2f3f5;
  --text-secondary: #b0b6c0;
  --text-tertiary: #7d8590;
  --border: #2a303a;
  --border-light: #222833;
  --accent: #7b89ee;
  --accent-hover: #91a0ff;
  --accent-subtle: #252d52;
}
.site-nav { height: 68px; background: var(--bg-surface); backdrop-filter: none; }
.site-nav-inner { max-width: 1180px; height: 68px; padding: 0 32px; }
.site-nav-brand { font-size: 17px; font-weight: 700; }
.site-nav-links { gap: 28px; }
.site-nav-links a { color: var(--text-secondary); font-size: 14px; }
.site-nav-links a.active { color: var(--text-primary); font-weight: 600; }
.site-nav-links a.active::after { bottom: -24px; height: 2px; background: var(--text-primary); }
.nav-secondary-link { display: inline-block; }
.nav-user-button { display: inline-flex; }
.home-page { width: min(1180px, calc(100% - 64px)); padding: 0 0 96px; }
.home-hero { min-height: 540px; grid-template-columns: 52% 48%; gap: 0; align-items: center; padding: 70px 0 80px; border-bottom: 0; }
.home-hero-copy { padding-right: 20px; }
.home-kicker { margin: 0 0 22px; color: var(--accent); font-family: var(--font-sans); font-size: 15px; font-weight: 500; }
.home-hero h1 { font-size: 56px; font-weight: 750; letter-spacing: -.03em; line-height: 1.08; }
.home-intro { margin: 25px 0 30px; color: var(--text-secondary); font-size: 17px; line-height: 1.75; }
.home-actions { gap: 20px; align-items: center; }
.home-primary-button, .home-secondary-button { height: 44px; display: inline-flex; gap: 24px; align-items: center; padding: 0 20px; border-radius: 9px; font-size: 14px; transition: background .18s ease-out, border-color .18s ease-out, color .18s ease-out; }
.home-primary-button { color: #fff; background: #111827; }
.home-primary-button:hover { color: #fff; background: var(--accent); }
.home-secondary-button { color: var(--text-primary); background: #fff; border: 1px solid var(--border); }
.home-secondary-button:hover { color: var(--text-primary); background: var(--bg-surface-alt); border-color: var(--text-muted, #94a3b8); }
.home-text-link { color: var(--accent); font-size: 14px; }
.home-text-link span, .home-section-header a span, .project-link span { display: inline-block; transition: transform .18s ease-out; }
.home-text-link:hover span, .home-section-header a:hover span, .project-link:hover span { transform: translateX(3px); }
.home-skills { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 42px; color: #64748b; font-size: 13px; }
.home-skills i { margin-right: 5px; color: #94a3b8; font-size: 12px; }
.home-contacts { margin-top: 20px; }
.network-visual { position: relative; height: 420px; opacity: .65; }
.network-visual svg { width: 100%; height: 100%; }
.network-lines { fill: none; stroke: #cbd5e1; stroke-width: 1.3; }
.network-nodes circle { fill: #94a3b8; }
.network-nodes .accent-node { fill: var(--accent); }
.network-caption { position: absolute; top: 47%; left: 44%; color: #94a3b8; font-family: var(--font-mono); font-size: 13px; line-height: 1.8; }
.home-section { padding-top: 0; margin-top: 0; }
.latest-writing, .projects-section, .observatory-section { margin-top: 76px; }
.home-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; padding-left: 14px; border-left: 2px solid var(--text-primary); }
.home-section-header h2 { color: var(--text-primary); font-size: 18px; font-weight: 700; letter-spacing: 0; }
.home-section-header a { color: var(--accent); font-size: 13px; }
.featured-article { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 12px 18px 12px 12px; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 30px rgba(15,23,42,.04); transition: transform .18s ease-out, box-shadow .18s ease-out; }
.featured-article:hover { color: var(--text-primary); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.07); }
.featured-cover { min-height: 130px; display: grid; place-items: center; overflow: hidden; color: #64748b; background: #f8fafc; border-radius: 10px; font-size: 14px; text-align: center; }
.featured-cover img { width: 100%; height: 100%; min-height: 130px; object-fit: cover; }
.featured-copy { display: flex; min-width: 0; flex-direction: column; padding: 7px 0; }
.article-meta { display: flex; gap: 16px; color: var(--text-muted, #94a3b8); font-size: 12px; }
.featured-copy h3 { margin: 14px 0 8px; color: var(--text-primary); font-size: 21px; }
.featured-copy p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.article-footer { display: flex; justify-content: space-between; align-items: end; margin-top: auto; padding-top: 16px; }
.article-tags { display: flex; gap: 9px; color: #64748b; font-size: 12px; }
.article-tags span { padding: 3px 7px; background: #f3f4f6; border-radius: 5px; }
.article-footer b { color: var(--accent); font-size: 20px; font-weight: 400; }
.article-list { margin-top: 16px; }
.article-list-row { display: grid; grid-template-columns: 100px 1fr 90px 20px; gap: 16px; align-items: center; padding: 18px 0; color: var(--text-primary); border-bottom: 1px solid var(--border-light); }
.article-list-row:hover { color: var(--accent); }
.article-list-row time, .article-list-row > span { color: var(--text-muted, #94a3b8); font-size: 12px; }
.article-list-row h3 { color: inherit; font-size: 15px; font-weight: 600; }
.article-list-row p { margin: 5px 0 0; color: #64748b; font-size: 12px; }
.article-list-row b { color: var(--accent); font-size: 18px; font-weight: 400; text-align: right; transition: transform .18s ease-out; }
.article-list-row:hover b { transform: translateX(3px); }
.home-project-grid, .observatory-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.home-project-card { overflow: hidden; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; transition: transform .18s ease-out, box-shadow .18s ease-out; }
.home-project-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.project-cover { height: 150px; display: grid; place-items: center; overflow: hidden; color: #64748b; background: #f8fafc; font-size: 15px; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.project-card-content { padding: 18px; }
.project-card-content h3 { color: var(--text-primary); font-size: 17px; }
.project-card-content p { min-height: 42px; margin: 8px 0 14px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.project-tech { color: #64748b; font-size: 12px; }
.project-link { display: block; margin-top: 18px; color: var(--accent); font-size: 13px; }
.observatory-grid { grid-template-columns: repeat(3, 1fr); }
.observatory-card { min-height: 150px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-surface); }
.observatory-card-header { display: flex; justify-content: space-between; margin-bottom: 18px; color: var(--accent); font-size: 12px; }
.observatory-card-header time { color: var(--text-muted, #94a3b8); }
.observatory-card > a { display: block; color: var(--text-primary); font-size: 14px; line-height: 1.55; }
.observatory-card > a:hover { color: var(--accent); }
.observatory-card p { margin: 9px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.site-footer { max-width: 1180px; min-height: 190px; margin-top: 0; padding: 48px 32px; display: grid; grid-template-columns: 2fr repeat(3, 1fr); align-items: start; gap: 32px; color: var(--text-secondary); background: var(--bg-surface); border-top: 1px solid var(--border); }
.footer-brand, .footer-column { display: grid; gap: 8px; align-content: start; }
.footer-brand strong { color: var(--text-primary); font-size: 17px; }
.footer-brand span, .footer-column a, .footer-column span { color: var(--text-secondary); font-size: 13px; }
.footer-column > strong { margin-bottom: 4px; color: var(--text-primary); font-size: 13px; }
.footer-column a:hover { color: var(--accent); }
@media (max-width: 1199px) and (min-width: 769px) { .home-page { width: calc(100% - 64px); } .home-hero { grid-template-columns: 55% 45%; } }
@media (max-width: 768px) {
  .site-nav { height: 68px; }
  .site-nav-inner { height: 68px; padding: 0 20px; }
  .site-nav-links { top: 68px; }
  .home-page { width: calc(100% - 40px); padding-bottom: 64px; }
  .home-hero { min-height: 0; grid-template-columns: 1fr; padding: 58px 0 54px; }
  .home-hero h1 { font-size: 40px; }
  .home-intro { font-size: 16px; }
  .home-skills { gap: 14px 20px; margin-top: 34px; }
  .network-visual { display: block; height: 300px; margin-top: 8px; }
  .network-visual svg { opacity: .55; }
  .home-signal-card { right: 4px; bottom: 0; width: min(245px, 82%); }
  .latest-writing, .projects-section, .observatory-section { margin-top: 52px; }
  .featured-article { grid-template-columns: 1fr; gap: 14px; padding: 12px; box-shadow: 6px 6px 0 color-mix(in srgb, var(--accent) 8%, transparent); }
  .featured-cover { min-height: 150px; }
  .article-list-row { grid-template-columns: 1fr 20px; gap: 8px; }
  .article-list-row time { grid-column: 1 / -1; }
  .article-list-row > span { display: none; }
  .home-project-grid, .observatory-grid { grid-template-columns: 1fr; }
  .site-footer { grid-template-columns: 1fr 1fr; padding: 40px 20px; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .home-page { width: calc(100% - 32px); }
  .home-hero { padding-top: 40px; }
  .home-hero h1 { font-size: 42px; }
  .home-actions { align-items: stretch; flex-direction: column; }
  .home-primary-button, .home-secondary-button, .home-text-link { justify-content: space-between; width: 100%; }
  .network-visual { height: 270px; margin-top: 20px; }
  .home-signal-card { width: 94%; }
  .home-section-header { align-items: flex-start; flex-direction: column; gap: 8px; }
}

/* === Public page consistency === */
.project-card-visual {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  font: 20px var(--font-mono);
}
.project-card-visual img { width: 100%; height: 100%; object-fit: cover; }
.project-card:hover .project-card-visual { background: var(--bg-hover); }
.project-article-kicker { margin-bottom: 16px; color: var(--accent); font: 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.project-article-cover { margin: 28px 0 36px; border: 1px solid var(--border); background: var(--bg-surface-alt); }
.project-article-cover img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.world-opinion-link { display: inline-flex; align-items: center; gap: 6px; }
.tools-page { max-width: 860px; }
.tool-card {
  display: grid;
  grid-template-columns: 48px 1fr 24px;
  gap: 16px;
  align-items: center;
  padding: 22px 0;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  transition: color .18s ease-out, padding .18s ease-out;
}
.tool-card:hover { color: var(--accent); padding-left: 8px; padding-right: 8px; background: var(--accent-subtle); }
.tool-card-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); border: 1px solid var(--border); font-size: 17px; }
.tool-card-copy { display: grid; gap: 5px; min-width: 0; }
.tool-card-copy strong { color: inherit; font-size: 17px; }
.tool-card-copy > span { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.tool-card-arrow { color: var(--accent); font-size: 20px; text-align: right; }
.reading-progress { position: fixed; top: 0; left: 0; z-index: 60; width: 0; height: 3px; background: var(--accent); transition: width .1s linear; }
.article-copy-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  color: var(--text-tertiary);
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.article-copy-link:hover { color: var(--accent); }
.article-toc-mobile { display: none; }
.observatory-weekly { margin-top: 48px; }
.observatory-insights { margin-top: 52px; border-top-color: var(--accent); }
.observatory-hot { margin-top: 58px; }
.observatory-feature > .section-box-header,
.observatory-column > .section-box-header { align-items: center; }

/* === Chat (kept minimal but adapted to light palette) === */
.chat-layout { height: calc(100vh - 48px); display: flex; }
.chat-sidebar {
  width: 260px; min-width: 260px;
  border-right: 1px solid var(--border);
  background: var(--bg-surface-alt);
  display: flex; flex-direction: column;
}
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-surface); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; }
.chat-input-area { border-top: 1px solid var(--border); padding: 14px 20px; background: var(--bg-surface); }

.msg-user .msg-bubble { background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg-ai .msg-bubble { background: var(--bg-page); color: var(--text-primary); border-radius: 14px 14px 14px 4px; }
.msg-bubble { max-width: 74%; padding: 12px 16px; font-size: 14px; line-height: 1.6; }
.msg-bubble p { margin: 0.4em 0; }
.msg-bubble p:first-child { margin-top: 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble pre { background: rgba(0,0,0,0.05); padding: 10px 14px; border-radius: 6px; overflow-x: auto; font-size: 13px; margin: 0.5em 0; }
.msg-bubble code { font-family: var(--font-mono); font-size: 0.85em; }
.msg-user .msg-bubble pre { background: rgba(0,0,0,0.15); }
.msg-user .msg-bubble code { color: rgba(255,255,255,0.9); }

.session-item {
  padding: 10px 16px; cursor: pointer; transition: background 0.1s;
  border-left: 3px solid transparent; color: var(--text-secondary); font-size: 13px;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: var(--accent-subtle); border-left-color: var(--accent); color: var(--text-primary); }

.source-card {
  background: var(--accent-subtle); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; margin-top: 6px;
  cursor: pointer; color: var(--text-secondary);
}
.source-snippet { display: none; font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.source-card.expanded .source-snippet { display: block; }

.quick-q {
  display: inline-block; padding: 6px 14px; border-radius: 16px;
  font-size: 12px; border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s; margin: 2px; background: var(--bg-surface);
}
.quick-q:hover { border-color: var(--accent); color: var(--accent); }

.role-btn {
  padding: 2px 10px; border-radius: 12px; font-size: 11px;
  border: 1px solid var(--border); color: var(--text-tertiary);
  background: transparent; cursor: pointer; transition: all 0.15s;
}
.role-btn:hover { border-color: var(--text-secondary); color: var(--text-secondary); }
.role-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === Article body (for rendered .md) === */
.article-body {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text-primary);
}
.article-body h1 { font-size: 28px; margin: 2rem 0 0.8rem; }
.article-body h2 { font-size: 22px; margin: 1.8rem 0 0.6rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 18px; margin: 1.4rem 0 0.5rem; }
.article-body p { margin: 0 0 1rem; }
.article-body a { color: var(--accent); }
.article-body strong { color: var(--text-primary); font-weight: 600; }
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 16px;
  margin: 1.2rem 0;
  color: var(--text-secondary);
}
.article-body pre {
  background: var(--bg-page);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 13px;
  margin: 1.2rem 0;
}
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-page);
  padding: 2px 5px;
  border-radius: 3px;
}
.article-body pre code { background: none; padding: 0; }
.article-body ul, .article-body ol { margin: 0.8rem 0; padding-left: 1.4rem; }
.article-body li { margin-bottom: 0.3rem; }
.article-body img { max-width: 100%; border-radius: var(--radius-md); margin: 1.2rem 0; }
.article-body hr { margin: 2rem 0; border: none; border-top: 1px solid var(--border); }
.article-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 14px; }
.article-body th, .article-body td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.article-body th { background: var(--bg-hover); font-weight: 600; color: var(--text-primary); }
.article-body table tr:nth-child(even) { background: var(--bg-surface-alt); }
.article-body table tr:hover { background: var(--bg-hover); }
.article-body pre {
  background: #2d2d2d;
  color: #e0e0e0;
}

/* === Dashboard === */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.stat-card-value { font-size: 28px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.stat-card-label { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* =============================================
   Responsive — Scroll the whole section at once
   ============================================= */

/* ---- Hamburger (base.html) ---- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  border: none;
  background: transparent;
  z-index: 60;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-tertiary);
  border-radius: 2px;
  transition: all 0.25s;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Hero avatar/text row (index) ---- */
.hero-section {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  padding: 48px 0 36px;
}

/* ---- Generic content+sidebar row ---- */
.content-with-sidebar {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

/* ---- Blog 3-col layout ---- */
.blog-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* ---- Dashboard layout ---- */
.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 48px);
}

/* === Mobile (max-width: 768px) === */
@media (max-width: 768px) {
  /* ------ Nav ------ */
  .hamburger { display: flex; }
  .site-nav-inner { padding: 0 16px; }
  .site-nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-page);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    flex-direction: column;
    padding: 16px 24px;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  }
  .site-nav-links.open { display: flex; }
  .site-nav-links a { font-size: 15px; }
  .site-nav-links a.active::after { display: none; }
  .site-nav-links a { min-height: 44px; display: flex; align-items: center; }

  /* ------ Chat ------ */
  .chat-sidebar { position: absolute; z-index: 20; width: 100%; min-width: 100%; height: 100%; transform: translateX(-100%); transition: transform 0.2s; }
  .chat-sidebar.open { transform: translateX(0); }
  .msg-bubble { max-width: 88%; }

  /* ------ Editor ------ */
  .editor-container { flex-direction: column; }
  .editor-pane-left { border-right: none; border-bottom: 1px solid var(--border); }
  .editor-pane { height: 50%; }

  /* ------ Stats (dashboard / homepage) ------ */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* ------ Page ------ */
  .page-header { padding: 32px 16px 20px; }
  .page-header h1 { font-size: 26px; }
  .page-header p { font-size: 15px; }
  .page-header-actions { flex-direction: column; align-items: flex-start; gap: 6px; }
  .page-inner { padding: 0 16px; }
  .page-header-bordered { padding-bottom: 16px; margin-bottom: 16px; }

  /* ------ Section box ------ */
  .section-box { padding: 20px 16px; margin-bottom: 16px; }
  .section-box-header { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* ------ Footer ------ */
  .site-footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 24px 16px 32px;
  }

  /* ------ Market rows ------ */
  .market-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* ------ Toolbar ------ */
  .toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* ------ Segmented control ------ */
  .segmented-control { overflow-x: auto; max-width: 100%; }

  /* ------ Article layout ------ */
  .article-layout { flex-direction: column; padding: 24px 16px 40px !important; }
  .article-toc { display: none; }
  .toc-sidebar { display: none !important; }
  .article-main { max-width: 100%; }
  .project-detail-page { width: calc(100% - 32px); padding-bottom: 48px; }
  .project-detail-back { padding-top: 20px; }
  .project-detail-header h1 { font-size: 34px; }
  .project-detail-actions { margin-bottom: 24px; }

  /* ------ Article meta row ------ */
  .article-main > div:first-child { flex-wrap: wrap; gap: 4px; }

  /* ------ Related articles ------ */
  .related-section { margin-top: 24px; }

  /* ------ Comments ------ */
  .comment-form-row { flex-direction: column; }
  .comment-avatar-col { flex-direction: row; width: auto; padding-top: 0; gap: 8px; align-items: center; }
  .comment-subrow { flex-direction: column; gap: 8px; }
  .comment-actions { flex-direction: column; align-items: stretch; }
  .comment-btn { text-align: center; }
  .comment-item { gap: 10px; }

  /* ------ Hero section (index) ------ */
  .hero-section { flex-direction: column; gap: 16px !important; padding: 28px 0 24px !important; }
  .hero-section img,
  .hero-section > div:first-child { width: 56px !important; height: 56px !important; font-size: 22px !important; }
  .hero-section h1 { font-size: var(--fs-h3) !important; }

  /* ------ Content+sidebar (index) ------ */
  .content-with-sidebar { flex-direction: column; gap: 24px; }

  /* ------ Blog layout (3-col → stack) ------ */
  .blog-layout { flex-direction: column; gap: 16px; }
  .blog-layout aside,
  .blog-layout > aside { width: 100% !important; position: static !important; }
  .blog-layout .layout-sidebar { width: 100% !important; position: static !important; }

  /* ------ Dashboard ------ */
  .dashboard-layout { flex-direction: column; }
  .dash-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding: 12px 0 !important;
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
  }
  .dash-sidebar nav { flex-direction: row !important; gap: 0; flex-wrap: nowrap; }
  .dash-sidebar > div:first-child { display: none; }
  .dash-sidebar button,
  .dash-sidebar nav button {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
  .dash-sidebar > div:last-child { display: none; }
  .dash-main {
    padding: 16px !important;
    overflow-y: visible !important;
  }

  /* ------ Dashboard sections ------ */
  .dash-main [style*="grid-template-columns"] { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .dash-main .section-box-header [style*="display: flex"] { flex-wrap: wrap; gap: 6px; }

  /* ------ Dashboard articles list items ------ */
  .dash-main [x-show="tab==='articles'"] > div:first-child {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-main [x-show="tab==='articles'"] > div:first-child input,
  .dash-main [x-show="tab==='articles'"] > div:first-child select {
    width: 100% !important;
  }
  .dash-main [x-show="tab==='articles'"] > div:first-child > div {
    flex-direction: column;
    gap: 8px;
  }

  /* ------ Dashboard settings ------ */
  .dash-main [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ------ World page grids ------ */
  .two-col-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .three-col-grid { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* ------ World page hot section ------ */
  .world-hot-grid { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* ------ Chat ------ */
  .chat-main [style*="overflow-x: auto"] { flex-wrap: wrap; gap: 4px; }
  #quick-questions { max-width: 100% !important; }

  /* ------ Price monitor ------ */
  .price-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* ------ Finance page ------ */
  .finance-price-grid { gap: 10px; }

  /* ------ Filter tags ------ */
  .filter-tags { gap: 4px; }
  .filter-tag { font-size: 11px; padding: 3px 10px; }

  /* ------ Pagination ------ */
  .pagination { flex-wrap: wrap; gap: 6px; }

  /* ------ Tag list ------ */
  .tag-list { flex-wrap: wrap; gap: 4px; }

  /* ------ Share bar ------ */
  .share-bar { flex-wrap: wrap; gap: 10px; }
}

@media (max-width: 480px) {
  .project-detail-actions .btn-primary { flex: 1 1 100%; justify-content: center; }
  .article-body p { font-size: 16px; }
  .comment-form-card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Redesign home: editorial publication + lab instrument === */
.home-page {
  width: min(var(--container-public), calc(100% - 64px));
  margin: 0 auto;
  padding: 72px 0 96px;
}
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 72px;
  align-items: end;
  padding: 30px 0 68px;
  border-bottom: 1px solid var(--border);
}
.eyebrow, .section-index, .panel-label, .status-grid span {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.eyebrow { display: flex; align-items: center; gap: 9px; margin-bottom: 34px; }
.eyebrow-dot, .observatory-pulse, .status-live i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); }
.home-identity { display: flex; align-items: center; gap: 22px; }
.home-avatar { width: 82px; height: 82px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.home-avatar-placeholder { display: grid; place-items: center; color: var(--text-tertiary); background: var(--bg-surface-alt); font-size: 25px; }
.home-kicker { margin: 0 0 6px; color: var(--accent); font-family: var(--font-mono); font-size: 13px; }
.home-hero h1 { font-size: clamp(38px, 5vw, 62px); font-weight: 700; letter-spacing: -.055em; line-height: 1.05; }
.home-bio { max-width: 700px; margin: 30px 0 28px; color: var(--text-secondary); font-size: 18px; line-height: 1.75; }
.home-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.home-action { display: inline-flex; gap: 22px; align-items: center; padding: 10px 13px; color: var(--text-primary); border: 1px solid var(--border); font-size: 13px; transition: background .15s, border-color .15s; }
.home-action:hover, .home-action:focus-visible { background: var(--bg-hover); border-color: var(--border-strong, var(--border)); }
.home-action-primary { color: var(--bg-surface); background: var(--text-primary); border-color: var(--text-primary); }
.home-action-primary:hover { color: var(--bg-surface); background: var(--accent); border-color: var(--accent); }
.home-contacts { display: flex; gap: 15px; margin-top: 26px; align-items: center; }
.home-contacts a, .home-contacts button { min-width: 32px; min-height: 32px; padding: 0; display: grid; place-items: center; color: var(--text-tertiary); background: transparent; border: 0; cursor: pointer; font-size: 17px; }
.home-contacts a:hover, .home-contacts button:hover { color: var(--accent); }
.home-copy-status { color: var(--green); font-family: var(--font-mono); font-size: 11px; }
.lab-status { padding: 25px; border: 1px solid var(--border); background: var(--bg-surface-alt); }
.panel-label { display: flex; justify-content: space-between; padding-bottom: 17px; border-bottom: 1px solid var(--border); }
.status-live { color: var(--green); font-size: 10px; letter-spacing: .08em; }
.status-live i { margin-right: 5px; vertical-align: 1px; }
.status-lead { padding: 25px 0 28px; color: var(--text-primary); font-size: 20px; line-height: 1.4; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 21px 14px; }
.status-grid span { display: block; margin-bottom: 5px; font-size: 10px; }
.status-grid strong { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.status-foot { display: flex; align-items: center; gap: 10px; margin-top: 28px; padding-top: 15px; border-top: 1px solid var(--border); color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; }
.status-bar { display: flex; gap: 3px; }
.status-bar i { width: 17px; height: 4px; display: block; background: var(--green); opacity: .8; }
.status-bar i:nth-child(4), .status-bar i:nth-child(5) { opacity: .25; }
.channel-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.channel-strip a { display: grid; grid-template-columns: 32px 1fr 28px; grid-template-rows: 1fr 1fr; column-gap: 8px; padding: 23px 20px; color: var(--text-primary); border-right: 1px solid var(--border); }
.channel-strip a:first-child { padding-left: 0; }
.channel-strip a:last-child { border-right: 0; }
.channel-strip a:hover { background: var(--bg-surface-alt); }
.channel-strip span, .channel-strip b { color: var(--accent); font-family: var(--font-mono); font-size: 11px; font-weight: 400; }
.channel-strip strong { font-size: 17px; font-weight: 600; }
.channel-strip small { grid-column: 2; color: var(--text-tertiary); font-size: 12px; }
.channel-strip b { grid-column: 3; grid-row: 1 / span 2; align-self: center; text-align: right; }
.home-section-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 68px; padding: 72px 0; border-bottom: 1px solid var(--border); }
.home-section-head, .observatory-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.home-section h2, .observatory-heading h2 { margin-top: 8px; color: var(--text-primary); font-size: 25px; letter-spacing: -.035em; }
.home-section-head > a, .observatory-heading > a { color: var(--accent); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.editorial-row, .project-item { display: grid; grid-template-columns: 86px 1fr 22px; gap: 15px; align-items: start; padding: 18px 0; color: var(--text-primary); border-top: 1px solid var(--border); }
.editorial-row:hover, .project-item:hover { color: var(--accent); }
.editorial-row time { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }
.editorial-row h3 { color: inherit; font-size: 15px; font-weight: 600; line-height: 1.4; }
.editorial-row p { display: -webkit-box; overflow: hidden; margin: 5px 0 0; color: var(--text-tertiary); font-size: 12px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.row-arrow { color: var(--accent); font-family: var(--font-mono); font-size: 13px; text-align: right; }
.project-item { grid-template-columns: 36px 1fr 22px; padding: 20px 0; }
.project-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--accent); border: 1px solid var(--accent); font-family: var(--font-mono); font-size: 12px; }
.project-copy { display: grid; gap: 5px; }
.project-copy strong { color: inherit; font-size: 15px; }
.project-copy small { color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
.project-copy em { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; font-style: normal; }
.home-empty { padding: 18px 0; color: var(--text-tertiary); font-size: 13px; }
.observatory-preview { padding: 48px 0 0; }
.observatory-heading { align-items: center; margin-bottom: 31px; }
.observatory-heading .section-index { margin-right: auto; }
.observatory-heading h2 { margin: 0 auto 0 0; }
.observatory-content { display: grid; grid-template-columns: .8fr 1.2fr; gap: 60px; }
.observatory-intro { padding: 22px 0; border-top: 2px solid var(--accent); }
.observatory-intro strong { margin-left: 10px; color: var(--text-primary); font-size: 16px; }
.observatory-intro p { max-width: 220px; margin: 16px 0; color: var(--text-tertiary); font-size: 13px; line-height: 1.6; }
.observatory-feed a { display: grid; grid-template-columns: 75px 1fr 20px; gap: 15px; align-items: start; padding: 14px 0; color: var(--text-primary); border-top: 1px solid var(--border); }
.observatory-feed a:hover { color: var(--accent); }
.observatory-feed a span { color: var(--accent); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; }
.observatory-feed a strong { font-size: 13px; font-weight: 500; line-height: 1.5; }
.observatory-feed a b { color: var(--accent); font-size: 13px; font-weight: 400; text-align: right; }

/* === Redesign library and workshop pages === */
.content-page { width: min(var(--container-public), calc(100% - 64px)); margin: 0 auto; padding: 72px 0 96px; }
.content-hero { padding: 28px 0 44px; border-bottom: 1px solid var(--border); }
.content-hero h1 { max-width: 760px; margin-top: 14px; font-size: clamp(38px, 5vw, 58px); letter-spacing: -.05em; }
.content-hero p { max-width: 650px; margin: 16px 0 0; color: var(--text-secondary); font-size: 16px; line-height: 1.7; }
.content-hero-compact { padding-bottom: 36px; }
.content-hero-compact h1 { font-size: 42px; }
.projects-toolbar, .library-meta { display: flex; justify-content: space-between; padding: 20px 0 12px; color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }
.toolbar-note { color: var(--text-tertiary); }
.project-card { display: grid; grid-template-columns: 50px 1fr 70px; gap: 22px; padding: 29px 0; border-top: 1px solid var(--border); }
.project-card-index { color: var(--accent); font-family: var(--font-mono); font-size: 11px; padding-top: 5px; }
.project-card-head { display: flex; align-items: center; gap: 15px; }
.project-card h2 { color: var(--text-primary); font-size: 23px; letter-spacing: -.03em; }
.project-status { color: var(--green); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; }
.project-status i { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--green); }
.project-tagline { margin: 9px 0 0; color: var(--text-primary); font-size: 15px; }
.project-description { max-width: 660px; margin: 8px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.project-card-foot { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-top: 23px; }
.project-tech { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; }
.project-card-foot a { color: var(--accent); font-family: var(--font-mono); font-size: 11px; }
.project-card-mark { width: 56px; height: 56px; display: grid; place-items: center; color: var(--accent); border: 1px solid var(--accent); font-family: var(--font-mono); font-size: 18px; }
.article-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.article-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip { padding: 7px 11px; color: var(--text-secondary); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 10px; }
.filter-chip:hover, .filter-chip.selected { color: var(--text-primary); border-color: var(--accent); background: var(--accent-subtle); }
.article-search { display: flex; border-bottom: 1px solid var(--border-strong, var(--border)); }
.article-search input { width: 170px; padding: 8px 0; color: var(--text-primary); background: transparent; border: 0; outline: 0; font-size: 13px; }
.article-search button { color: var(--accent); background: transparent; border: 0; cursor: pointer; }
.article-library-layout { display: grid; grid-template-columns: 1fr 220px; gap: 70px; }
.library-row { display: grid; grid-template-columns: 88px 1fr 22px; gap: 18px; padding: 25px 0; color: var(--text-primary); border-bottom: 1px solid var(--border); }
.library-row:hover { color: var(--accent); }
.library-row time { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }
.library-row h2 { color: inherit; font-size: 19px; letter-spacing: -.025em; }
.library-row p { display: -webkit-box; overflow: hidden; margin: 7px 0 11px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.library-row-tags { display: flex; gap: 10px; color: var(--accent); font-family: var(--font-mono); font-size: 10px; }
.library-row-arrow { color: var(--accent); text-align: right; }
.library-aside { padding-top: 22px; }
.library-aside h2 { margin: 10px 0 18px; font-size: 19px; }
.library-aside a { display: flex; justify-content: space-between; padding: 9px 0; color: var(--text-secondary); border-bottom: 1px solid var(--border-light); font-size: 13px; }
.library-aside a:hover { color: var(--accent); }
.library-aside small { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10px; }
.content-empty { display: grid; gap: 8px; padding: 65px 0; color: var(--text-tertiary); }
.content-empty strong { color: var(--text-primary); font-size: 18px; }
.content-empty span { font-size: 13px; }
.content-empty a { font-family: var(--font-mono); font-size: 11px; }
.library-pagination { display: flex; justify-content: space-between; padding-top: 23px; font-family: var(--font-mono); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.observatory-hero h1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.observatory-feature { margin: 44px 0; padding: 26px 0 0; border-top: 2px solid var(--text-primary); }
.observatory-feature .section-box-header, .observatory-column .section-box-header { margin-bottom: 20px; }
.observatory-column { padding-top: 26px; border-top: 2px solid var(--accent); }
.observatory-column .item-row, .observatory-feature .item-row { border-bottom-color: var(--border); }
.observatory-insights { border-top-color: var(--border-strong, var(--border)); }

@media (max-width: 768px) {
  .home-page { width: min(100% - 32px, var(--container-public)); padding: 40px 0 64px; }
  .home-hero { grid-template-columns: 1fr; gap: 38px; padding: 18px 0 42px; }
  .home-hero h1 { font-size: 42px; }
  .home-bio { font-size: 16px; margin-top: 24px; }
  .lab-status { padding: 20px; }
  .channel-strip { grid-template-columns: 1fr; }
  .channel-strip a, .channel-strip a:first-child { padding: 18px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .channel-strip a:last-child { border-bottom: 0; }
  .home-section-grid, .observatory-content { grid-template-columns: 1fr; gap: 48px; padding: 48px 0; }
  .observatory-preview { padding-top: 0; }
  .observatory-heading { flex-wrap: wrap; gap: 10px; }
  .observatory-heading h2 { width: 100%; order: 2; }
  .observatory-heading > a { order: 3; }
  .editorial-row { grid-template-columns: 1fr 20px; gap: 10px; }
  .editorial-row time { grid-column: 1 / -1; }
  .content-page { width: calc(100% - 32px); padding: 40px 0 64px; }
  .content-hero h1, .content-hero-compact h1 { font-size: 36px; }
  .project-card { grid-template-columns: 30px 1fr; gap: 12px; padding: 23px 0; }
  .project-card-mark { display: none; }
  .project-card-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .project-card h2 { font-size: 20px; }
  .project-card-foot { align-items: flex-start; flex-direction: column; gap: 10px; }
  .article-toolbar { align-items: flex-start; flex-direction: column; }
  .article-search { width: 100%; }
  .article-search input { width: 100%; }
  .article-library-layout { display: block; }
  .library-aside { display: none; }
  .library-row { grid-template-columns: 1fr 20px; gap: 10px; }
  .library-row time { grid-column: 1 / -1; }
  .observatory-feature { margin: 32px 0; }
  .observatory-column { margin-bottom: 12px; }
}

/* === Tablet (max-width: 1024px) — slight adjustments === */
@media (max-width: 1024px) and (min-width: 769px) {
  .page-header { padding: 40px 24px 24px; }
  .site-nav-inner { padding: 0 16px; }
  .page-inner { padding: 0 16px; }
  .section-box { padding: 24px 20px; }
  .article-layout { padding: 40px 16px 40px !important; }
  .dash-main { padding: 24px 20px !important; }
}

/* === Small phone (max-width: 480px) === */
@media (max-width: 480px) {
  .page-header h1 { font-size: 22px; }
  .section-box { padding: 16px 12px; }
  .stat-grid { grid-template-columns: 1fr; }
  .market-row { grid-template-columns: 1fr; gap: 8px; }
  .site-footer { font-size: 11px; }

  /* Chat */
  .msg-bubble { max-width: 95%; }
  .chat-messages { padding: 12px; }

  /* Finance / price monitor cards */
  .finance-price-grid .stat-card,
  .price-stat-grid .stat-card { padding: 12px !important; }

  /* Dashboard content list */
  .dash-main [x-for]:not([x-show]) { flex-wrap: wrap; }
  .dash-main [x-for]:not([x-show]) > div:last-child { margin-left: 0; }

  /* Price monitor product cards */
  .pm-card-grid { grid-template-columns: 1fr !important; }

  /* Filter items */
  a.filter-item { font-size: 12px; padding: 4px 8px; }

  /* Tools page */
  .tools-grid { grid-template-columns: 1fr; }
}

/* === ECharts dark container fix (light theme uses white bg) === */
.chart-container {
  width: 100%;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

/* =============================================
   Design Spec Additions — CSS 类补充
   ============================================= */

/* ---- Page inner (内容区容器) ---- */
.page-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Page Header variants ---- */
.page-header-bordered {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 28px;
}
.page-header-actions {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.page-header-actions h1 { margin-bottom: 0; }

/* ---- Item row (内容列表行) ---- */
.item-row {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { opacity: 0.7; }

.item-row-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.item-row-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.item-row-title a { color: inherit; text-decoration: none; }
.item-row-title a:hover { color: var(--accent); }
.item-row-summary {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 3px;
  line-height: 1.5;
}
.meta-sep {
  margin: 0 6px;
  color: var(--border);
}

/* ---- Section Box inner ---- */
.section-box-body {
  padding: 0;
}
.section-box-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ---- Filter sidebar items ---- */
a.filter-item {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}
a.filter-item:hover { background: var(--bg-hover); color: var(--text-primary); }
a.filter-item-active,
a.filter-item-active:hover {
  background: #1d1d1f;
  color: #fff;
}

/* ---- Tag pills ---- */
a.tag-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--bg-page);
  color: var(--text-secondary);
  text-decoration: none;
}
a.tag-pill:hover { background: var(--bg-hover); color: var(--text-primary); }
a.tag-pill-active,
a.tag-pill-active:hover {
  background: #1d1d1f;
  color: #fff;
}

/* ---- Segmented control (排序切换) ---- */
.segmented-control {
  display: inline-flex;
  background: var(--bg-page);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.segmented-control a {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  color: var(--text-tertiary);
  transition: all 0.12s;
}
.segmented-control a.seg-active {
  background: #fff;
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.segmented-control a:hover:not(.seg-active) { color: var(--text-secondary); }

/* ---- Toolbar (列表排序/操作栏) ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
}
.pagination-info {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 7px 12px;
}

/* ---- Empty state ---- */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

/* ---- Tag list （详情页标签区）---- */
.tag-list {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}
.tag-list a {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  text-decoration: none;
}

/* ---- Share bar ---- */
.share-bar {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-tertiary);
}
.share-bar a { color: var(--text-tertiary); }
.share-bar a:hover { color: var(--accent); }

/* =============================================
   Comments
   ============================================= */
.comments-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.comments-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 24px;
}

/* 写评论卡片 */
.comment-form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}
.comment-form-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* 表单行：头像列 + 右侧字段 */
.comment-form-row {
    display: flex;
    gap: 16px;
}

/* 头像列 */
.comment-avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    width: 60px;
    padding-top: 22px;
}
.avatar-preview-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
    background: var(--bg-page);
}
.avatar-change-btn {
    font-size: 11px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 1px 0;
    line-height: 1.2;
}
.avatar-change-btn:hover {
    opacity: 0.7;
}

/* 右侧字段区 */
.comment-fields {
    flex: 1;
    min-width: 0;
}
.comment-subrow {
    display: flex;
    gap: 12px;
}
.comment-field {
    flex: 1;
    min-width: 0;
}
.comment-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.comment-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.comment-textarea {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.comment-input:focus,
.comment-textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* 操作按钮行 */
.comment-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.comment-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 20px;
    background: var(--text-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}
.comment-btn:hover {
    opacity: 0.8;
}
.comment-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 评论列表 */
.comment-list {
    margin-bottom: 8px;
}
.comment-item {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}
.comment-item:last-child {
    border-bottom: none;
}
.comment-item-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-page);
}
.comment-item-body {
    flex: 1;
    min-width: 0;
}
.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.comment-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.comment-date {
    font-size: 11px;
    color: var(--text-tertiary);
}
.comment-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* === Project detail === */
.project-detail-page {
  width: min(var(--container-reading), calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 72px;
}
.project-detail-back { padding: 28px 0 20px; }
.project-detail-header { padding: 24px 0 28px; }
.project-detail-header h1 { font-size: clamp(34px, 5vw, 52px); letter-spacing: -.045em; }
.project-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 32px; }
.project-detail-description { margin-bottom: 36px; }
.project-detail-description > p { color: var(--text-secondary); font-size: 16px; line-height: 1.85; }
.project-detail-section { margin-bottom: 36px; padding-top: 24px; border-top: 1px solid var(--border); }
.project-detail-section h2 { font-size: 19px; margin-bottom: 14px; }
.project-detail-section ul { margin: 0; padding-left: 20px; }
.project-detail-section li { margin-bottom: 8px; line-height: 1.65; }
.project-detail-tech { margin-bottom: 0; }
.project-detail-spacer { display: none; }

/* Homepage implementation spec. Keep these final rules after legacy styles. */
.home-page { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 0 0 96px; }
.home-hero { min-height: 570px; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); gap: 48px; align-items: center; padding: 70px 0 78px; border-bottom: 1px solid var(--border); }
.home-hero-copy { padding: 24px 0; }
.home-kicker { margin: 0 0 22px; color: var(--accent); font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.home-hero h1 { color: var(--text-primary); font-size: clamp(48px, 6vw, 72px); font-weight: 750; letter-spacing: -.06em; line-height: 1.02; }
.home-intro { max-width: 520px; margin: 27px 0 32px; color: var(--text-secondary); font-size: 18px; line-height: 1.8; }
.home-actions { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: center; }
.home-primary-button, .home-secondary-button { height: 48px; display: inline-flex; gap: 28px; align-items: center; padding: 0 22px; border-radius: 9px; font-size: 16px; font-weight: 600; transition: background .18s ease-out, border-color .18s ease-out, color .18s ease-out; }
.home-primary-button { color: var(--bg-surface); background: var(--text-primary); }
.home-primary-button:hover { color: var(--bg-surface); background: var(--accent); }
.home-secondary-button { color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border); }
.home-secondary-button:hover { color: var(--text-primary); background: var(--bg-surface-alt); border-color: var(--color-border-strong); }
.home-text-link { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; color: var(--accent); font-size: 16px; font-weight: 600; }
.home-skills { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 38px; color: var(--text-secondary); font-family: var(--font-sans); font-size: 15px; font-weight: 500; }
.home-skills span { display: inline-flex; align-items: center; min-height: 32px; }
.home-skills i { margin-right: 7px; color: var(--accent); font-size: 14px; }
.home-contacts { margin-top: 22px; }
.network-visual { position: relative; display: block; height: 440px; opacity: .82; }
.network-visual svg { width: 100%; height: 100%; }
.network-lines { fill: none; stroke: var(--border-strong); stroke-width: 1.3; }
.network-nodes circle { fill: var(--text-tertiary); }
.network-nodes .accent-node { fill: var(--accent); }
.network-caption { position: absolute; top: 39%; left: 39%; color: var(--text-tertiary); font-family: var(--font-mono); font-size: 13px; line-height: 1.8; }
.home-signal-card { position: absolute; right: 0; bottom: 18px; width: 245px; padding: 18px; background: color-mix(in srgb, var(--bg-surface) 92%, transparent); border: 1px solid var(--border); box-shadow: 12px 12px 0 color-mix(in srgb, var(--accent) 9%, transparent); }
.home-signal-label { display: flex; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--text-tertiary); font: 10px var(--font-mono); letter-spacing: .1em; }
.home-signal-label i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.home-signal-card strong { display: block; padding: 18px 0; color: var(--text-primary); font-size: 16px; line-height: 1.45; }
.home-signal-grid { display: grid; grid-template-columns: 48px 1fr; gap: 7px 10px; padding: 12px 0; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); }
.home-signal-grid span, .home-signal-card small { color: var(--text-tertiary); font: 10px var(--font-mono); }
.home-signal-grid b { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.home-signal-card small { display: block; padding-top: 12px; }
.home-section { margin-top: 84px; padding: 0; }
.home-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; padding-left: 14px; border-left: 3px solid var(--accent); }
.home-section-header h2 { color: var(--text-primary); font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.home-section-header a { color: var(--accent); font-family: var(--font-mono); font-size: 11px; }
.featured-article { display: grid; grid-template-columns: 250px 1fr; gap: 28px; padding: 14px 22px 14px 14px; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 10px 10px 0 color-mix(in srgb, var(--accent) 8%, transparent); transition: transform .18s ease-out, box-shadow .18s ease-out, border-color .18s ease-out; }
.featured-article:hover { color: var(--text-primary); transform: translate(-2px, -2px); border-color: var(--accent); box-shadow: 14px 14px 0 color-mix(in srgb, var(--accent) 12%, transparent); }
.featured-cover { min-height: 150px; display: grid; place-items: center; overflow: hidden; color: var(--accent); background: var(--accent-subtle); border-radius: var(--radius-sm); font: 12px var(--font-mono); text-align: center; }
.featured-cover img { width: 100%; height: 100%; min-height: 130px; object-fit: cover; }
.featured-copy { display: flex; min-width: 0; flex-direction: column; padding: 7px 0; }
.featured-copy h3 { margin: 14px 0 8px; color: var(--text-primary); font-size: 23px; letter-spacing: -.025em; }
.featured-copy p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.7; }
.article-meta { display: flex; gap: 16px; color: #94a3b8; font-size: 12px; }
.article-footer { display: flex; justify-content: space-between; align-items: end; margin-top: auto; padding-top: 16px; }
.article-tags { display: flex; gap: 9px; color: #64748b; font-size: 12px; }
.article-tags span { padding: 3px 7px; background: #f3f4f6; border-radius: 5px; }
.article-footer b { color: #5b6ee1; font-size: 20px; font-weight: 400; }
.article-list { margin-top: 16px; }
.article-list-row { display: grid; grid-template-columns: 100px 1fr 90px 20px; gap: 16px; align-items: center; padding: 19px 12px; color: var(--text-primary); border-bottom: 1px solid var(--border-light); transition: color .18s ease-out, background .18s ease-out; }
.article-list-row:hover { color: var(--accent); background: var(--accent-subtle); }
.article-list-row time, .article-list-row > span { color: var(--text-tertiary); font: 11px var(--font-mono); }
.article-list-row h3 { color: inherit; font-size: 15px; font-weight: 600; }
.article-list-row p { margin: 5px 0 0; color: #64748b; font-size: 12px; }
.article-list-row b { color: #5b6ee1; font-size: 18px; font-weight: 400; transition: transform .18s ease-out; }
.article-list-row:hover b { transform: translateX(3px); }
.home-project-grid, .observatory-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.home-project-card { overflow: hidden; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); transition: transform .18s ease-out, box-shadow .18s ease-out, border-color .18s ease-out; }
.home-project-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 8px 8px 0 color-mix(in srgb, var(--accent) 10%, transparent); }
.project-cover { height: 150px; display: grid; place-items: center; overflow: hidden; color: #64748b; background: #f8fafc; font-size: 15px; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.project-card-content { padding: 18px; }
.project-card-content h3 { color: #111827; font-size: 17px; }
.project-card-content p { min-height: 42px; margin: 8px 0 14px; color: #4b5563; font-size: 13px; line-height: 1.6; }
.project-tech { color: #64748b; font-size: 12px; }
.project-link { display: block; margin-top: 18px; color: #5b6ee1; font-size: 13px; }
.observatory-grid { grid-template-columns: repeat(3, 1fr); }
.observatory-card { min-height: 150px; padding: 18px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .18s ease-out, background .18s ease-out; }
.observatory-card:hover { border-color: var(--accent); background: var(--accent-subtle); }
.observatory-card-header { display: flex; justify-content: space-between; margin-bottom: 18px; color: #5b6ee1; font-size: 12px; }
.observatory-card-header time { color: #94a3b8; }
.observatory-card > a { display: block; color: #111827; font-size: 14px; line-height: 1.55; }
.observatory-card > a:hover { color: #5b6ee1; }
.observatory-card p { margin: 9px 0 0; color: #4b5563; font-size: 12px; line-height: 1.5; }
.site-footer { max-width: 1180px; min-height: 190px; margin: 0 auto; padding: 48px 32px; display: grid; grid-template-columns: 2fr repeat(3, 1fr); align-items: start; gap: 32px; color: #4b5563; background: #fff; border-top: 1px solid #e5e7eb; }
.footer-brand, .footer-column { display: grid; gap: 8px; align-content: start; }
.footer-brand strong, .footer-column > strong { color: #111827; }
.footer-brand span, .footer-column a, .footer-column span { color: #4b5563; font-size: 13px; }
.footer-column a:hover { color: #5b6ee1; }
@media (max-width: 768px) {
  .home-page { width: calc(100% - 40px); padding-bottom: 64px; }
  .home-hero { min-height: 0; grid-template-columns: 1fr; padding: 52px 0 54px; }
  .home-hero h1 { font-size: 44px; }
  .network-visual { display: block; height: 300px; margin-top: 4px; }
  .home-section { margin-top: 52px; }
  .featured-article { grid-template-columns: 1fr; gap: 14px; padding: 12px; }
  .article-list-row { grid-template-columns: 1fr 20px; gap: 8px; }
  .article-list-row time { grid-column: 1 / -1; }
  .article-list-row > span { display: none; }
  .home-project-grid, .observatory-grid { grid-template-columns: 1fr; }
  .site-footer { grid-template-columns: 1fr 1fr; padding: 40px 20px; }
  .footer-brand { grid-column: 1 / -1; }
  .project-card-visual { width: 56px; height: 56px; }
  .article-toc-mobile { display: block; margin: 0 0 28px; padding: 16px; border: 1px solid var(--border); background: var(--bg-surface-alt); }
  .article-toc-mobile .toc-sidebar-title { margin-bottom: 8px; }
  .article-toc-mobile .toc-link { white-space: normal; }
  .article-copy-link { min-height: 32px; }
  .project-article-cover { margin: 24px 0 28px; }
  .tool-card { grid-template-columns: 42px 1fr 20px; gap: 12px; padding: 18px 0; }
  .tool-card-icon { width: 36px; height: 36px; }
}

/* === Final typography contract ===
   Content and controls stay readable; tiny type is reserved for labels only. */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --fs-hero: 56px;
  --fs-display: 40px;
  --fs-h1: 32px;
  --fs-h2: 24px;
  --fs-h3: 20px;
  --fs-title: 17px;
  --fs-body: 16px;
  --fs-ui: 15px;
  --fs-small: 14px;
  --fs-tiny: 12px;
}
body { font-size: var(--fs-body); }
.site-nav-links a { font-size: 15px; }
.site-nav-links .text-tiny { font-size: 13px; }
.page-header p, .content-hero p { font-size: 17px; }
.btn-primary, .btn-secondary { font-size: 14px; }
.home-section-header a { font-size: 13px; }
.article-list-row h3 { font-size: 17px; }
.article-list-row p { font-size: 14px; }
.article-list-row time, .article-list-row > span { font-size: 13px; }
.featured-copy p { font-size: 15px; }
.article-meta { font-size: 13px; }
.article-tags { font-size: 13px; }
.project-card h2 { font-size: 24px; }
.project-tagline { font-size: 16px; }
.project-description { font-size: 15px; }
.project-tech { font-size: 13px; }
.project-card-foot a { font-size: 13px; }
.project-status { font-size: 12px; }
.filter-chip { font-family: var(--font-sans); font-size: 14px; }
.article-search input { font-size: 16px; }
.library-row time { font-size: 13px; }
.library-row h2 { font-size: 21px; }
.library-row p { font-size: 14px; }
.library-row-tags { font-family: var(--font-sans); font-size: 13px; }
.library-aside a { font-size: 14px; }
.observatory-card > a { font-size: 15px; }
.observatory-card p { font-size: 14px; }
.observatory-card-header { font-size: 13px; }
.observatory-feature .text-small, .observatory-column .text-small { font-size: 15px; }
.observatory-feature .text-tiny, .observatory-column .text-tiny { font-size: 13px; }
.project-detail-back a { font-size: 13px; }
.project-detail-header p { font-size: 16px; }
.project-detail-section li { font-size: 15px; }
.comment-input, .comment-textarea { font-size: 16px; }
.comment-label, .comment-date { font-size: 13px; }
.comment-body { font-size: 15px; }
.comment-btn { font-size: 15px; }
.content-empty span { font-size: 14px; }
.content-empty a { font-family: var(--font-sans); font-size: 14px; }
.library-pagination { font-family: var(--font-sans); font-size: 13px; }
.home-signal-grid b { font-size: 13px; }
.home-signal-card small { font-size: 11px; }

@media (max-width: 768px) {
  .home-hero h1 { font-size: 44px; }
  .home-intro { font-size: 17px; }
  .home-primary-button, .home-secondary-button, .home-text-link { font-size: 16px; }
  .content-hero h1, .content-hero-compact h1 { font-size: 38px; }
  .library-row h2 { font-size: 20px; }
  .project-card h2 { font-size: 22px; }
  .article-body p, .project-detail-description > p { font-size: 16px; }
}

@media (max-width: 480px) {
  .site-nav-links a { font-size: 16px; }
  .home-hero h1 { font-size: 40px; }
  .content-hero h1, .content-hero-compact h1 { font-size: 34px; }
  .home-skills { font-size: 15px; }
}
