:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --ink: #0f172a;
  --muted: #647084;
  --line: #dbe3ee;
  --line-strong: #bdc9d8;
  --brand: #2563eb;
  --brand-soft: #dbeafe;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --success: #16a34a;
  --danger: #dc2626;
  --code-bg: #0f172a;
  --code-ink: #e2e8f0;
  --shadow: 0 22px 70px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 12px 36px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  --radius-sm: 8px;
  --topbar: 58px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d18;
  --surface: #111827;
  --surface-2: #172033;
  --surface-3: #1e293b;
  --ink: #e5edf8;
  --muted: #99a7bd;
  --line: #243146;
  --line-strong: #37455c;
  --brand: #60a5fa;
  --brand-soft: rgba(96, 165, 250, 0.15);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --success: #4ade80;
  --danger: #f87171;
  --code-bg: #020617;
  --code-ink: #e2e8f0;
  --shadow: 0 24px 76px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.26);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
body.has-feedback-flyout { overflow: hidden; }
body, input, button, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-svg { fill: currentColor; stroke: none; }
.brand-svg path { fill: currentColor; stroke: none; }
#app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  min-height: var(--topbar);
  padding: 8px 18px;
  background: color-mix(in srgb, var(--surface) 90%, transparent 10%);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.top-actions { display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: max-content; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 43px;
  height: 43px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-soft);
}
.brand-copy { display: inline-grid; line-height: 1.1; }
.brand-copy strong { font-size: 1rem; }
.brand-copy small { color: var(--muted); font-size: 0.75rem; margin-top: 3px; }

.top-actions { justify-content: flex-end; }
.locale-menu { position: relative; }
.locale-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 82px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 850;
}
.locale-trigger:hover,
.locale-menu.is-open .locale-trigger {
  background: var(--surface-3);
  border-color: var(--line-strong);
}
.locale-trigger svg:last-child {
  width: 15px;
  height: 15px;
  transition: transform 160ms ease;
}
.locale-menu.is-open .locale-trigger svg:last-child { transform: rotate(180deg); }
.locale-flyout {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  display: none;
  width: 230px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.locale-menu.is-open .locale-flyout { display: grid; gap: 4px; }
.locale-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.locale-option:hover { background: var(--surface-2); border-color: var(--line); }
.locale-option.is-active {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
}
.locale-option-main {
  min-width: 0;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.locale-option-short {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}
.locale-option svg { color: var(--brand); width: 16px; height: 16px; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
}
.icon-button:hover { background: var(--surface-3); }
.feedback-top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}
.feedback-top-button:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.main-home {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 58px 0 72px;
}
.home-shell { display: grid; gap: 28px; }
.home-hero {
  display: grid;
  gap: 22px;
}
.track-card,
.sidebar,
.doc-page {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.home-hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.25rem);
  line-height: 0.96;
  letter-spacing: 0;
}
.home-media {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.home-media img { width: 100%; height: auto; }
.hero-lead {
  margin: 0;
  max-width: 760px;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.8;
}
.hero-hint {
  margin: 16px 0 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.75;
}
.primary-action,
.ghost-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 850;
}
.primary-action { background: linear-gradient(135deg, var(--brand), #4f46e5); color: #fff; }
.ghost-action { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }

.track-list { display: grid; gap: 10px; }
.track-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
}
.track-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.track-card.is-disabled { color: color-mix(in srgb, var(--ink) 72%, var(--muted) 28%); }
.mod-logo-box {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.mod-logo-box img {
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  object-fit: contain;
}
.mod-logo-fallback {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}
.track-body { min-width: 0; }
.track-card h2 { margin: 0; font-size: 1.16rem; letter-spacing: 0; }
.track-card p { margin: 5px 0 0; color: var(--muted); line-height: 1.55; }
.track-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.track-open,
.track-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}
.track-open {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand);
  text-decoration: none;
}
.track-open:hover { border-color: var(--line-strong); background: var(--surface-3); }
.track-open.external { color: var(--ink); }
.track-status { color: var(--muted); }

.feedback-section {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}
.feedback-section.is-open { display: block; }
.feedback-flyout__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(15, 23, 42, 0.34);
  cursor: default;
}
.feedback-section__inner {
  position: absolute;
  top: calc(var(--topbar) + 10px);
  right: 18px;
  bottom: 10px;
  width: min(1440px, calc(100vw - 36px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: auto;
}
.feedback-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.feedback-section h2 {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: 0;
}
.feedback-section__description {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.feedback-flyout__close {
  flex: 0 0 auto;
}
.feedback-tags {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.feedback-tags__label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}
.feedback-tags__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.feedback-tag {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.88rem;
  font-weight: 850;
}
.feedback-tag:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}
.feedback-tags__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}
.giscus {
  min-height: 520px;
  overflow: hidden;
}

.layout {
  width: min(1980px, calc(100% - 20px));
  margin: 0 auto;
  padding: 22px 0 40px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: calc(var(--topbar) + 18px);
  max-height: calc(100vh - var(--topbar) - 34px);
  overflow: auto;
  padding: 14px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.back-link:hover { color: var(--ink); }
.doc-nav { display: grid; gap: 8px; }
.doc-nav-link {
  display: grid;
  gap: 5px;
  padding: 13px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.doc-nav-link:hover { background: var(--surface-2); border-color: var(--line); }
.doc-nav-link.is-active {
  background: var(--surface-3);
  border-color: var(--line-strong);
  box-shadow: inset 3px 0 0 var(--brand);
}
.doc-nav-link span { font-weight: 800; }
.doc-nav-link small { color: var(--muted); font-size: 0.8rem; line-height: 1.44; }
.section-nav-link span { font-size: 0.96rem; }
.section-nav-link small {
  display: block;
  max-width: 100%;
}

.content { min-width: 0; }
.doc-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 216px;
  gap: 12px;
  align-items: start;
}
.doc-page { min-width: 0; overflow: hidden; }
.doc-page-head {
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.doc-page-head h1 {
  margin: 0;
  font-size: clamp(1.85rem, 2.8vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: 0;
}
.doc-page-body { padding: 34px 32px 46px; }
.doc-page-body > :first-child { margin-top: 0; }
.doc-page-body > :last-child { margin-bottom: 0; }
.doc-page-body h2,
.doc-page-body h3,
.doc-page-body h4 {
  scroll-margin-top: calc(var(--topbar) + 24px);
  line-height: 1.22;
  letter-spacing: 0;
}
.doc-page-body h2 { margin: 36px 0 14px; font-size: 1.78rem; }
.doc-page-body h3 { margin: 28px 0 12px; font-size: 1.28rem; }
.doc-page-body h4 { margin: 20px 0 10px; font-size: 1.08rem; }
.doc-page-body p,
.doc-page-body li,
.doc-page-body blockquote {
  color: color-mix(in srgb, var(--ink) 86%, var(--muted) 14%);
  line-height: 1.85;
}
.doc-page-body p { margin: 14px 0; }
.doc-page-body ul,
.doc-page-body ol { margin: 14px 0; padding-left: 24px; }
.doc-page-body li + li { margin-top: 6px; }
.doc-page-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.doc-page-body code {
  padding: 0.18em 0.42em;
  border-radius: 8px;
  background: var(--surface-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.doc-page-body pre {
  margin: 18px 0;
  padding: 18px 20px;
  overflow: auto;
  border-radius: 16px;
  background: var(--code-bg);
  color: var(--code-ink);
}
.doc-page-body pre code { padding: 0; background: transparent; color: inherit; }
.table-wrap {
  margin: 18px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.doc-page-body table { width: 100%; border-collapse: collapse; background: var(--surface); }
.doc-page-body th,
.doc-page-body td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.doc-page-body th { background: var(--surface-2); font-size: 0.88rem; }
.doc-page-body tbody tr:last-child td { border-bottom: 0; }
.doc-page-body blockquote {
  margin: 18px 0;
  padding: 1px 18px;
  border-left: 4px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 14px 14px 0;
}
.doc-page-body hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.callout {
  margin: 20px 0;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.callout-title { margin-bottom: 8px; font-weight: 900; }
.callout.tip { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); }
.callout.warning { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.callout.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

.doc-follow-nav {
  position: sticky;
  top: calc(var(--topbar) + 22px);
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.doc-follow-count {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
}
.doc-follow-links {
  display: grid;
  gap: 8px;
}
.doc-follow-link {
  display: grid;
  gap: 5px;
  min-height: 62px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-decoration: none;
}
.doc-follow-link:hover { background: var(--surface-3); }
.doc-follow-link span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}
.doc-follow-link strong {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.32;
}
.doc-follow-link.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

@media (max-width: 1280px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .track-card { grid-template-columns: 74px minmax(0, 1fr); }
  .track-actions { grid-column: 2; justify-content: flex-start; }
  .layout { width: min(100%, calc(100% - 16px)); grid-template-columns: 1fr; }
  .doc-shell { grid-template-columns: minmax(0, 1fr) 206px; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: auto;
  }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 10px 12px; }
  .top-actions { justify-content: flex-end; }
  .top-actions { width: auto; margin-left: auto; gap: 7px; }
  .locale-trigger { min-width: 72px; padding: 0 8px; }
  .feedback-top-button { width: 40px; padding: 0; }
  .feedback-top-button span { display: none; }
  .locale-flyout {
    right: 0;
    width: min(230px, calc(100vw - 24px));
  }
  .main-home { width: min(100%, calc(100% - 20px)); padding-top: 22px; }
  .feedback-section__inner {
    top: calc(var(--topbar) + 10px);
    right: 10px;
    bottom: 10px;
    width: min(100%, calc(100% - 20px));
    padding: 18px;
  }
  .feedback-section__header { gap: 12px; }
  .track-card,
  .doc-page-head,
  .doc-page-body,
  .sidebar { padding-left: 18px; padding-right: 18px; }
  .track-card { grid-template-columns: 1fr; }
  .track-actions { grid-column: auto; justify-content: flex-start; }
  .track-open,
  .track-status { justify-content: flex-start; }
  .doc-shell { grid-template-columns: 1fr; }
  .doc-follow-nav {
    position: static;
    order: -1;
    grid-template-columns: 1fr;
  }
  .doc-follow-links { grid-template-columns: 1fr; }
  .doc-page-head { padding-top: 24px; padding-bottom: 24px; }
  .doc-page-body { padding-top: 24px; padding-bottom: 30px; }
}
