/* Warship Workshop Static Guide - Light & Dark, Offline, Mobile-First (390px+) */
:root {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-muted: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #dbe3ee;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: #e0f2fe;
  --good: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --code-bg: #eef2f7;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --deck-fill: #38bdf8;
  --deck-stroke: #0369a1;
  --deck-empty: rgba(100, 116, 139, 0.14);
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --bg-elev: #111a2e;
    --bg-muted: #17233b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #25344f;
    --accent: #38bdf8;
    --accent-strong: #7dd3fc;
    --accent-soft: rgba(56, 189, 248, 0.14);
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --code-bg: #1e293b;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    --deck-fill: #38bdf8;
    --deck-stroke: #7dd3fc;
    --deck-empty: rgba(148, 163, 184, 0.12);
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --bg-elev: #111a2e;
  --bg-muted: #17233b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #25344f;
  --accent: #38bdf8;
  --accent-strong: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --code-bg: #1e293b;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --deck-fill: #38bdf8;
  --deck-stroke: #7dd3fc;
  --deck-empty: rgba(148, 163, 184, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  overflow-x: clip;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: var(--code-bg); padding: 0.12em 0.38em; border-radius: 4px; font-size: 0.88em; overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow-x: auto; max-width: 100%; }
pre code { background: none; padding: 0; font-size: 0.86em; }

.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 200;
}
.skip-link:focus { left: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1380px; margin: 0 auto;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: nowrap;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 1.02rem; text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-tag {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: var(--bg-muted); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 1.1rem; cursor: pointer;
}
.menu-btn { display: none; }

.header-search { position: relative; flex: 1 1 260px; max-width: 480px; min-width: 0; }
.header-search input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg-muted); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.94rem;
}
.header-search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 70vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); z-index: 150;
}
.search-results[hidden] { display: none; }
.sr-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover, .sr-item:focus { background: var(--accent-soft); text-decoration: none; }
.sr-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 0.93rem; }
.sr-kind { font-size: 0.72rem; padding: 1px 6px; border-radius: 4px; background: var(--bg-muted); color: var(--text-muted); flex-shrink: 0; }
.sr-sub { font-size: 0.82rem; color: var(--text-muted); }
.sr-empty { padding: 12px; color: var(--text-muted); font-size: 0.9rem; }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.hdr-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 12px;
  background: var(--bg-muted); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.hdr-btn:hover { border-color: var(--accent); text-decoration: none; }
.play-btn { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.play-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #ffffff; }

/* Layout */
.layout {
  max-width: 1380px; margin: 0 auto;
  display: grid; grid-template-columns: 272px minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 16px 12px 32px;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.sidebar-mobile-bar { display: none; }
.sidebar-backdrop { display: none; }
.nav-link {
  display: block; padding: 7px 10px; border-radius: 7px;
  color: var(--text); font-size: 0.91rem; line-height: 1.35;
}
.nav-link:hover { background: var(--bg-muted); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-group { margin-top: 8px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-weight: 700; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted); list-style: none;
}
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title:hover { background: var(--bg-muted); color: var(--text); }
.nav-count { font-size: 0.75rem; font-weight: 600; background: var(--bg-muted); padding: 1px 6px; border-radius: 999px; }
.nav-list { list-style: none; margin: 2px 0 6px; padding: 0 0 0 8px; border-left: 1px solid var(--border); }
.nav-list li { margin: 2px 0; }

/* Main column */
.main-col { padding: 24px 32px 48px; min-width: 0; max-width: 100%; }
.article { max-width: 920px; }
.breadcrumbs ol {
  display: flex; flex-wrap: wrap; gap: 6px; list-style: none;
  margin: 0 0 12px; padding: 0; font-size: 0.85rem; color: var(--text-muted);
}
.breadcrumbs li:not(:last-child)::after { content: "›"; margin-left: 6px; opacity: 0.6; }
.article-head { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.article-head h1 { margin: 0 0 8px; font-size: clamp(1.65rem, 3vw, 2.2rem); line-height: 1.22; letter-spacing: -0.01em; }
.article-lead { margin: 0; color: var(--text-muted); font-size: 1.02rem; }

.article-body h2 { margin: 28px 0 12px; font-size: 1.4rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); scroll-margin-top: 84px; }
.article-body h3 { margin: 22px 0 10px; font-size: 1.14rem; scroll-margin-top: 84px; }
.article-body h4 { margin: 16px 0 8px; font-size: 1rem; }
.article-body p { margin: 0 0 14px; }
.article-body ul, .article-body ol { margin: 0 0 14px; padding-left: 22px; }
.article-body li { margin: 4px 0; }
.h-anchor { opacity: 0; margin-left: 8px; font-weight: 400; color: var(--text-muted); }
.article-body h2:hover .h-anchor, .article-body h3:hover .h-anchor, .h-anchor:focus { opacity: 1; }

.page-toc {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 22px;
}
.toc-title { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.page-toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; }
.page-toc .toc-l3 { font-size: 0.85rem; opacity: 0.9; }

/* Tables */
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); }
table { width: 100%; border-collapse: collapse; font-size: 0.91rem; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--bg-muted); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* Blockquotes & Callouts */
blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 4px solid var(--accent); background: var(--bg-elev);
  border-radius: 0 8px 8px 0; color: var(--text-muted);
}
.callout { margin: 16px 0; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); border-left-width: 4px; background: var(--bg-elev); }
.callout-title { font-weight: 700; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.callout-note { border-left-color: var(--accent); }
.callout-tip { border-left-color: var(--good); }
.callout-important { border-left-color: #a855f7; }
.callout-warning, .callout-caution { border-left-color: var(--warn); }
.callout p:last-child { margin-bottom: 0; }

/* Home page */
.home-hero {
  background: linear-gradient(135deg, var(--bg-elev) 0%, var(--bg-muted) 100%);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; margin-bottom: 24px;
}
.hero-kicker { font-size: 0.82rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.hero-sub { font-size: 1.02rem; color: var(--text-muted); margin: 0 0 16px; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.hero-stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.hero-stat strong { font-size: 1.35rem; color: var(--accent); line-height: 1.2; }
.hero-stat span { font-size: 0.82rem; color: var(--text-muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 8px; font-weight: 700; font-size: 0.94rem; border: 1px solid var(--border); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg-elev); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }

.home-section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 14px 0 24px; }
.home-section-card {
  display: block; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; color: var(--text); transition: border-color 0.15s;
}
.home-section-card:hover { border-color: var(--accent); text-decoration: none; }
.hsc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hsc-top h3 { margin: 0; font-size: 1.05rem; }
.home-section-card p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

.ref-pill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; margin: 12px 0 24px; }
.ref-pill-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-weight: 600; font-size: 0.9rem;
}
.ref-pill-card:hover { border-color: var(--accent); text-decoration: none; }
.ref-pill-card img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }

/* Data Cards (Parts, Hulls, Tiers, Glossary) */
.measure-chip {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  background: var(--bg-muted); border: 1px dashed var(--warn);
  color: var(--warn); font-weight: 600; font-size: 0.86em;
}
.check-chip {
  display: inline-block; padding: 0 6px; border-radius: 5px;
  background: var(--accent-soft); border: 1px dashed var(--accent);
  color: var(--accent-strong); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600; font-size: 0.8em; vertical-align: baseline;
}
.card-stack { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.data-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; scroll-margin-top: 88px;
}
.data-card:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.part-icon { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--bg-muted); border: 1px solid var(--border); flex-shrink: 0; }
.part-icon-fallback { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--text-muted); }
.card-head-main { flex: 1; min-width: 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.card-title { margin: 0; font-size: 1.04rem; line-height: 1.3; }
.card-role, .glossary-alt { font-weight: 500; font-size: 0.86rem; color: var(--text-muted); }
.part-id { font-size: 0.76rem; color: var(--text-muted); font-weight: 500; }
.card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: 0.76rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-muted); border: 1px solid var(--border); color: var(--text);
}
.tier-badge { border-color: var(--tier-c, var(--accent)); color: var(--tier-c, var(--accent)); }
.card-anchor-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; min-height: 28px; padding: 0 6px;
  border-radius: 6px; background: var(--bg-muted); color: var(--text-muted);
  font-size: 0.82rem; font-weight: 700;
}
.card-anchor-btn:hover { color: var(--accent); text-decoration: none; }
.card-kv-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.86rem; color: var(--text-muted); margin-top: 4px; }
.card-kv-row strong { color: var(--text); }
.card-desc { margin: 10px 0 8px; font-size: 0.93rem; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stat-chip {
  display: inline-flex; gap: 5px; align-items: baseline;
  font-size: 0.78rem; padding: 3px 8px; border-radius: 6px;
  background: var(--bg-muted); border: 1px solid var(--border);
}
.stat-k { color: var(--text-muted); font-weight: 600; }
.stat-v { color: var(--text); font-weight: 700; }
.tone-dmg .stat-v { color: #f97316; }
.tone-shield .stat-v { color: var(--accent); }
.tone-def .stat-v { color: #6366f1; }
.tone-pwr .stat-v { color: #eab308; }
.tone-drv .stat-v { color: #14b8a6; }
.tone-sup .stat-v { color: var(--good); }
.tone-warn .stat-v { color: var(--warn); }

.card-mechs { margin: 8px 0 0; padding-left: 18px; font-size: 0.88rem; color: var(--text-muted); }
.card-counters { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 0.86rem; }
.c-good { color: var(--good); }
.c-bad { color: var(--bad); }

/* Inline macros */
.inline-chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 1px 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.9em;
}
.chip-meta { font-weight: 500; opacity: 0.85; font-size: 0.88em; }
.term-link { border-bottom: 1px dotted var(--accent); }

/* Hull SVG */
.hull-card-body { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
.hull-deck-box { background: var(--bg-muted); border: 1px solid var(--border); border-radius: 10px; padding: 10px; max-width: 100%; overflow-x: auto; }
.deck-svg { display: block; max-width: 100%; height: auto; }
.deck-cell { fill: var(--deck-fill); stroke: var(--deck-stroke); stroke-width: 1; }
.deck-empty { fill: var(--deck-empty); }
.deck-bow { fill: var(--warn); }
.hull-stats { flex: 1 1 240px; min-width: 0; }
.speciality-pill { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 0.9rem; }

/* Catalog filter bar */
.filter-bar {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin: 14px 0 16px; display: flex; flex-direction: column; gap: 10px;
}
.tier-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
  min-height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--bg-muted); color: var(--text);
  border: 1px solid var(--border); font-weight: 600; font-size: 0.84rem; cursor: pointer;
}
.filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-inputs { display: flex; flex-wrap: wrap; gap: 8px; }
.catalog-search, .catalog-select {
  height: 40px; padding: 0 10px; border-radius: 8px;
  background: var(--bg-muted); color: var(--text); border: 1px solid var(--border); font-size: 0.9rem;
}
.catalog-search { flex: 1 1 200px; min-width: 0; }
.catalog-select { flex: 0 1 auto; max-width: 100%; }
.catalog-count { font-size: 0.85rem; color: var(--text-muted); }
.catalog-list { display: flex; flex-direction: column; gap: 12px; }
.data-card[hidden] { display: none; }

/* Glossary pills */
.glossary-index { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 18px; }
.glossary-pill {
  font-size: 0.82rem; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
}
.glossary-pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Pager & Footer */
.pager {
  max-width: 920px; margin: 36px 0 24px; padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.pager-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
}
.pager-card:hover { border-color: var(--accent); text-decoration: none; }
.pager-next { text-align: right; }
.pager-dir { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.pager-title { font-weight: 700; font-size: 0.94rem; color: var(--accent); }
.site-footer { max-width: 920px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.86rem; color: var(--text-muted); }

/* Mobile & Tablet (fits 390px phone with zero horizontal overflow) */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(310px, 86vw); height: 100vh;
    z-index: 220; transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: var(--shadow); padding-top: 10px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 8px 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border);
    font-weight: 700;
  }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 210;
  }
  .sidebar-backdrop:not([hidden]) { display: block; }
  .main-col { padding: 18px 16px 40px; }
}

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .header-left { order: 1; flex: 1 1 auto; }
  .header-actions { order: 2; gap: 6px; }
  .header-search { order: 3; flex: 1 0 100%; max-width: none; }
  .header-search input { height: 44px; font-size: 16px; }
  .brand-tag { display: none; }
  .brand { font-size: 0.95rem; }
  .hdr-btn { min-height: 44px; padding: 0 10px; font-size: 0.84rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
  .part-icon { width: 48px; height: 48px; }
  .filter-pill { min-height: 40px; }
  .catalog-search, .catalog-select { width: 100%; flex: 1 0 100%; height: 44px; font-size: 16px; }
}
