:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-2: #F3EFE7;
  --ink: #18181B;
  --ink-2: #3F3F46;
  --muted: #6B6B74;
  --border: #E5DFD3;
  --brand: #0F6B56;
  --brand-hover: #0B5645;
  --brand-soft: #E6F4F0;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --danger: #DC2626;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px rgba(24, 24, 27, 0.04);
  --shadow-hover: 0 6px 24px rgba(15, 107, 86, 0.11), 0 2px 6px rgba(24, 24, 27, 0.05);
  --radius: 16px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #111317;
  --surface: #181B21;
  --surface-2: #20242C;
  --ink: #F4F4F5;
  --ink-2: #D4D4D8;
  --muted: #9CA3AF;
  --border: #2A2F3A;
  --brand: #2DD4A8;
  --brand-hover: #14B88E;
  --brand-soft: rgba(45, 212, 168, 0.13);
  --amber: #FBBF24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-hover: 0 8px 28px rgba(45, 212, 168, 0.15);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 860px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 19px; font-weight: 700;
}
[data-theme="dark"] .brand-mark { color: #0B1915; }
.brand-badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); letter-spacing: 0.02em;
}

.main-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-link {
  padding: 7px 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
  color: var(--ink-2); text-decoration: none; transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--surface-2); color: var(--brand); text-decoration: none;
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 5px;
  border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .btn-primary { color: #091B15; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
[data-theme="dark"] .btn-primary:hover { color: #091B15; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-soft:hover { background: var(--brand); color: #fff; }
.btn.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .btn.is-active { color: #091B15; }

/* Hero */
.hero {
  padding: 52px 0 34px;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, var(--brand-soft), transparent 72%);
  border-bottom: 1px solid var(--border);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--brand);
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 14px; font-family: var(--font-serif);
  font-size: clamp(30px, 4.4vw, 48px); line-height: 1.16; letter-spacing: -0.025em;
}
.hero-lead { max-width: 720px; font-size: 17px; color: var(--muted); margin: 0 0 24px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.hero-stats strong { color: var(--ink); font-weight: 700; }

/* Workbench Search & Filters */
.workbench-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 10px; box-shadow: var(--shadow); max-width: 820px;
}
.search-input-wrap { flex: 1; min-width: 220px; position: relative; display: flex; align-items: center; }
.search-input {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid transparent;
  border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 15px; outline: none;
}
.search-input:focus { border-color: var(--brand); background: var(--surface); }

.filter-strip {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 22px 0 14px;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  cursor: pointer; text-decoration: none; transition: all 0.14s;
}
.pill:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .pill.active { color: #091B15; }
.pill-count { font-size: 11px; opacity: 0.78; }

/* Cards & Grids */
.section { padding: 34px 0; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.section-head h2 { margin: 0; font-family: var(--font-serif); font-size: 24px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }

.tool-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.cat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}
.tool-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
}
.tool-card:hover, .cat-card:hover {
  transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 50%, var(--border));
  box-shadow: var(--shadow-hover);
}
.tool-top { display: flex; align-items: flex-start; gap: 12px; }
.t-meta { min-width: 0; flex: 1; }
.tool-host a { color: var(--muted); }
.tool-desc {
  margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tool-avatar {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff; letter-spacing: -0.02em;
  position: relative; overflow: hidden;
}
.tool-title-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-name {
  font-size: 16px; font-weight: 700; color: var(--ink); text-decoration: none;
}
.tool-name:hover { color: var(--brand); text-decoration: none; }
.tool-host { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.tool-desc {
  margin: 0; font-size: 13.5px; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11.5px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); font-weight: 500;
}
.badge-os { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.badge-free { background: #E0F2FE; color: #0369A1; font-weight: 700; }
[data-theme="dark"] .badge-free { background: rgba(56, 189, 248, 0.16); color: #7DD3FC; }
.badge-freemium { background: var(--amber-soft); color: var(--amber); font-weight: 700; }
.badge-paid { background: var(--surface-2); color: var(--muted); font-weight: 700; }

.tool-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-top: 10px; border-top: 1px solid var(--border);
}
.tool-actions { display: flex; align-items: center; gap: 6px; }

/* Breadcrumb */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }

/* Detail Page */
.detail-hero { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .detail-hero { grid-template-columns: 1fr; } }
.meta-list { display: grid; gap: 10px; font-size: 13.5px; }
.meta-item { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }

/* Compare Table */
.compare-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.compare-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.compare-table th, .compare-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare-table th { width: 160px; background: var(--surface-2); font-size: 13px; color: var(--muted); font-weight: 700; }
.compare-table tr:last-child th, .compare-table tr:last-child td { border-bottom: 0; }

/* Article Prose */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .article-layout { grid-template-columns: 1fr; } }
.toc-box { position: sticky; top: 84px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.toc-box ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; font-size: 13px; }
.toc-box li.lvl-3 { padding-left: 12px; }
.prose h2 { font-family: var(--font-serif); margin-top: 28px; font-size: 22px; }
.prose h3 { margin-top: 22px; font-size: 18px; }
.prose p, .prose li { font-size: 15.5px; color: var(--ink-2); }
.prose code { font-family: var(--font-mono); font-size: 0.9em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }
.code-box { margin: 16px 0; border-radius: 12px; overflow: hidden; border: 1px solid #2A2F3A; background: #14171D; color: #E5E7EB; }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1D212A; font-size: 12px; }
.code-dots { display: inline-flex; gap: 5px; }
.code-dots i { width: 9px; height: 9px; border-radius: 50%; background: #4B5563; display: inline-block; }
.code-lang { font-family: var(--font-mono); color: #9CA3AF; }
.code-copy { border: 1px solid #374151; background: #262B36; color: #E5E7EB; border-radius: 6px; padding: 3px 9px; font-size: 11px; cursor: pointer; }
.code-box pre { margin: 0; padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.code-box pre code { background: transparent; padding: 0; color: inherit; }

/* Form */
.form-grid { display: grid; gap: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14.5px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.alert { padding: 12px 15px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; border: 1px solid var(--border); }
.alert-ok { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.alert-err { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }

/* Floating Stack Drawer & Command Palette */
.stack-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 999px;
  background: var(--brand); color: #fff; border: 0; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 30px rgba(15, 107, 86, 0.35); cursor: pointer;
}
[data-theme="dark"] .stack-fab { color: #091B15; }
.stack-fab[hidden] { display: none; }
.stack-drawer {
  position: fixed; right: 20px; bottom: 72px; z-index: 46;
  width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
.stack-drawer[hidden] { display: none; }
.stack-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(15, 18, 25, 0.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 20px;
}
.modal-backdrop[hidden] { display: none; }
.cmd-dialog {
  width: min(600px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.cmd-input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--ink); font-size: 16px; outline: none; }
.cmd-results { max-height: 360px; overflow: auto; padding: 8px; }
.cmd-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.cmd-row:hover { background: var(--surface-2); text-decoration: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

/* Footer */
.site-footer {
  margin-top: auto; border-top: 1px solid var(--border);
  background: var(--surface); padding: 40px 0 28px;
}
.footer-grid { display: grid; gap: 28px; grid-template-columns: 2fr 1fr 1fr 1.3fr; }
@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .main-nav { display: none; }
}
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; }
.footer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: 14px; }
.footer-list a { color: var(--ink-2); }
.footer-list a:hover { color: var(--brand); }
.footer-bottom {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted);
}
