:root {
  --brand: #163aa9;
  --brand-deep: #091d61;
  --accent: #f27b16;
  --canvas: #f2f4f9;
  --surface: #ffffff;
  --surface-soft: #f7f8fc;
  --ink: #11182a;
  --muted: #657087;
  --line: #dfe4ee;
  --code: #0b1530;
  --success: #16854a;
  --danger: #c83232;
  --shadow: 0 16px 48px rgba(15, 23, 42, .09);
}

html[data-theme="dark"] {
  --canvas: #0b1020;
  --surface: #131b2d;
  --surface-soft: #192238;
  --ink: #f4f6ff;
  --muted: #aab4cb;
  --line: #2d3852;
  --code: #080d1a;
  --shadow: 0 18px 55px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 108px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
button { font: inherit; }

.reading-progress { position: fixed; inset: 0 auto auto 0; z-index: 100; width: 0; height: 3px; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .08s linear; }
.spec-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 82px;
  padding: 0 clamp(18px, 4vw, 52px);
  display: grid;
  grid-template-columns: 170px 1fr auto;
  align-items: center;
  gap: 24px;
  color: #fff;
  background: rgba(8, 19, 46, .96);
  border-bottom: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(16px);
}
.spec-logo { width: 126px; height: 58px; padding: 5px 10px; display: grid; place-items: center; border-radius: 11px; background: #fff; text-decoration: none; overflow: hidden; }
.spec-logo img { width: auto; max-width: 100%; height: auto; max-height: 100%; }
.spec-header-title { padding-left: 24px; border-left: 1px solid rgba(255,255,255,.16); line-height: 1.3; }
.spec-header-title span, .spec-header-title strong { display: block; }
.spec-header-title span { color: rgba(255,255,255,.46); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.spec-header-title strong { margin-top: 2px; font-size: 15px; }
.spec-header-actions { display: flex; align-items: center; gap: 9px; }
.theme-toggle, .back-link { height: 44px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13); border-radius: 11px; text-decoration: none; cursor: pointer; }
.theme-toggle { width: 44px; font-size: 20px; }.back-link { padding: 0 16px; font-size: 12px; font-weight: 750; }
.theme-toggle:hover, .back-link:hover { background: rgba(255,255,255,.13); }

.spec-layout { width: min(1420px, 100%); margin: 0 auto; padding: 42px clamp(18px, 4vw, 52px) 90px; display: grid; grid-template-columns: 260px minmax(0, 880px); justify-content: center; gap: clamp(40px, 6vw, 84px); }
.spec-nav { position: sticky; top: 112px; height: calc(100vh - 140px); display: flex; flex-direction: column; }
.spec-nav-head > span { display: block; margin-bottom: 12px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .14em; }
#tocToggle { display: none; }
#specToc { padding-right: 12px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#specToc a { min-height: 38px; padding: 8px 10px; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); border-left: 2px solid var(--line); text-decoration: none; font-size: 11px; line-height: 1.4; transition: .18s ease; }
#specToc a b { color: color-mix(in srgb, var(--muted) 60%, transparent); font-size: 9px; letter-spacing: .04em; }
#specToc a:hover { color: var(--ink); background: var(--surface-soft); }
#specToc a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, transparent); border-left-color: var(--brand); font-weight: 750; }
.spec-nav-footer { margin-top: auto; padding: 16px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.spec-nav-footer span, .spec-nav-footer strong { display: block; }.spec-nav-footer span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }.spec-nav-footer strong { margin-top: 3px; font-size: 11px; }

.spec-content { min-width: 0; }
.spec-article { padding: clamp(30px, 5vw, 64px); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.spec-article > h1 { max-width: 720px; margin: 0; font-size: clamp(42px, 6vw, 66px); line-height: 1; letter-spacing: -.058em; }
.spec-article > h1::before { content: "PRODUCT SPEC"; margin-bottom: 18px; display: block; color: var(--brand); font-size: 10px; line-height: 1; letter-spacing: .16em; }
.spec-article > blockquote:first-of-type { margin: 32px 0 56px; padding: 25px 27px; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 10%, var(--surface)), var(--surface-soft)); border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line)); border-left: 5px solid var(--brand); border-radius: 0 16px 16px 0; }
.spec-article > blockquote:first-of-type p { margin: 8px 0; }
.spec-article h2, .spec-article h3 { position: relative; color: var(--ink); }
.spec-article h2 { margin: 72px 0 25px; padding-top: 20px; border-top: 1px solid var(--line); font-size: clamp(28px, 4vw, 38px); line-height: 1.15; letter-spacing: -.04em; }
.spec-article h3 { margin: 44px 0 16px; font-size: 23px; line-height: 1.25; letter-spacing: -.025em; }
.spec-article h4 { margin: 32px 0 12px; font-size: 18px; }
.spec-article h2 .heading-anchor, .spec-article h3 .heading-anchor { position: absolute; right: calc(100% + 10px); color: var(--line); text-decoration: none; opacity: 0; transition: opacity .15s; }
.spec-article h2:hover .heading-anchor, .spec-article h3:hover .heading-anchor { opacity: 1; }
.spec-article p { margin: 0 0 17px; color: var(--muted); }
.spec-article strong { color: var(--ink); }
.spec-article em { color: color-mix(in srgb, var(--ink) 80%, var(--brand)); }
.spec-article hr { height: 1px; margin: 56px 0; background: var(--line); border: 0; }
.spec-article ul, .spec-article ol { margin: 16px 0 25px; padding-left: 25px; color: var(--muted); }
.spec-article li { margin: 8px 0; padding-left: 5px; }
.spec-article li::marker { color: var(--brand); font-weight: 800; }
.spec-article blockquote:not(:first-of-type) { margin: 24px 0; padding: 20px 22px; color: var(--muted); background: var(--surface-soft); border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; }
.spec-article blockquote p:last-child { margin-bottom: 0; }
.spec-article code { padding: 2px 6px; color: color-mix(in srgb, var(--brand) 78%, var(--ink)); background: color-mix(in srgb, var(--brand) 8%, var(--surface-soft)); border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line)); border-radius: 5px; font-family: "SFMono-Regular", Consolas, monospace; font-size: .84em; }
.spec-article .local-reference { padding: 2px 6px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 5px; font-family: "SFMono-Regular", Consolas, monospace; font-size: .84em; text-decoration: none; cursor: default; }
.spec-article pre { margin: 24px 0 30px; padding: 22px; color: #dce5ff; background: var(--code); border: 1px solid color-mix(in srgb, #7591ff 18%, transparent); border-radius: 14px; overflow: auto; box-shadow: inset 0 1px rgba(255,255,255,.05); }
.spec-article pre code { padding: 0; color: inherit; background: transparent; border: 0; font-size: 12px; line-height: 1.5; }
.table-scroll { width: 100%; margin: 22px 0 32px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.spec-article table { width: 100%; min-width: 620px; border-collapse: collapse; background: var(--surface); font-size: 12px; line-height: 1.45; }
.spec-article th, .spec-article td { padding: 13px 15px; text-align: left; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.spec-article th:last-child, .spec-article td:last-child { border-right: 0; }
.spec-article tr:last-child td { border-bottom: 0; }
.spec-article th { color: var(--ink); background: var(--surface-soft); font-size: 10px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.spec-article td { color: var(--muted); }
.spec-article td[align="center"], .spec-article th[align="center"] { text-align: center; }
.original-summary, .original-summary-heading { display: none; }
.section-tag { margin-right: 9px; padding: 4px 7px; display: inline-flex; transform: translateY(-3px); color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); border-radius: 6px; font-size: 9px; font-weight: 900; letter-spacing: .05em; vertical-align: middle; }
.back-to-top { position: fixed; right: 24px; bottom: 24px; z-index: 20; width: 48px; height: 48px; display: grid; place-items: center; color: #fff; background: var(--brand); border-radius: 14px; box-shadow: 0 12px 28px color-mix(in srgb, var(--brand) 30%, transparent); text-decoration: none; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

@media (max-width: 980px) {
  html { scroll-padding-top: 138px; }
  .spec-header { height: 72px; grid-template-columns: 110px 1fr auto; gap: 15px; }
  .spec-logo { width: 98px; height: 48px; }.spec-header-title { padding-left: 15px; }.spec-header-title span { display: none; }
  .spec-layout { padding-top: 18px; grid-template-columns: 1fr; gap: 18px; }
  .spec-nav { position: sticky; top: 85px; z-index: 30; height: auto; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 9px 25px rgba(15,23,42,.07); backdrop-filter: blur(14px); }
  .spec-nav-head > span, .spec-nav-footer { display: none; }
  #tocToggle { width: 100%; height: 42px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; color: var(--ink); background: var(--surface-soft); border: 0; border-radius: 9px; font-size: 12px; font-weight: 800; cursor: pointer; }
  #tocToggle b { transition: transform .2s; }.spec-nav.open #tocToggle b { transform: rotate(180deg); }
  #specToc { display: none; max-height: 55vh; margin-top: 8px; }.spec-nav.open #specToc { display: block; }
  #specToc a { border-left: 0; border-bottom: 1px solid var(--line); }
  .spec-article h2 .heading-anchor, .spec-article h3 .heading-anchor { display: none; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .spec-header { padding: 0 14px; grid-template-columns: 86px 1fr auto; }
  .spec-logo { width: 78px; height: 43px; padding: 4px 7px; }.spec-header-title { padding-left: 10px; }.spec-header-title strong { font-size: 12px; }
  .back-link { width: 44px; padding: 0; font-size: 0; }.back-link::before { content: "←"; font-size: 17px; }.theme-toggle { width: 40px; }
  .spec-header-actions { gap: 5px; }
  .spec-layout { padding: 12px 10px 70px; }
  .spec-nav { top: 80px; }
  .spec-article { padding: 34px 20px; border-radius: 18px; }
  .spec-article > h1 { font-size: 40px; }
  .spec-article > blockquote:first-of-type { margin-bottom: 42px; padding: 19px; }
  .spec-article h2 { margin-top: 56px; font-size: 29px; }.spec-article h3 { font-size: 21px; }
  .spec-article pre { margin-left: -8px; margin-right: -8px; padding: 16px; }
  .table-scroll { width: calc(100% + 16px); margin-left: -8px; }
  .back-to-top { right: 14px; bottom: 14px; }
}

@media print {
  .spec-header, .spec-nav, .reading-progress, .back-to-top { display: none !important; }
  body { background: #fff; }.spec-layout { display: block; padding: 0; }.spec-article { padding: 0; border: 0; box-shadow: none; }
  .spec-article h2, .spec-article h3 { break-after: avoid; }.table-scroll, pre, blockquote { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
