/* ============================================================================
   M3UTool guide + customer help. Light and quiet like the m3utool.com landing (Levi, 2026-09-29: "make the
   guide light themed like our landing page"; recoloured blue 2026-10-31 for the M3UTool rebrand): white ground,
   one typeface (Inter), one accent, thin lines, screenshots in plain frames. The accent variables keep their old
   names (--violet, --violet-lt, --grad): guide-brand.js sets them to a reseller's own colour on the customer help.
   Dark theme: the toggle (top right) sets data-theme="dark" on <html> and theme.js restores it on the next page.
   Accent-coloured TEXT uses --accent-ink, which the dark theme lightens, so a reseller's dark brand colour stays
   readable on a dark ground.
   ========================================================================== */

/* Inter 4.1 from our own address (0.2.689; it came from rsms.me). The version is in the file name, so the
   year-long cache is safe. Same cut-down files as web/src/fonts. SIL Open Font License (LICENSE-Inter.txt). */
@font-face { font-family: InterVariable; font-style: normal; font-weight: 100 900; font-display: swap; src: url('InterVariable-latin-4.1.woff2') format('woff2'); }
@font-face { font-family: InterVariable; font-style: italic; font-weight: 100 900; font-display: swap; src: url('InterVariable-Italic-latin-4.1.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap; src: url('InterVariable-latin-4.1.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: italic; font-weight: 100 900; font-display: swap; src: url('InterVariable-Italic-latin-4.1.woff2') format('woff2'); }

:root {
  --bg: #ffffff;
  --bg-soft: #f6f6f3;
  --bg-softer: #fafaf8;
  --ink: #16161a;
  --ink-dim: #4a4a55;
  --ink-faint: #6b6b76;
  --line: #e4e4e8;
  --line2: #ececef;

  --violet: #2563EB;
  --violet-deep: #1D4ED8;
  --violet-lt: #2563EB;
  --grad: linear-gradient(90deg, #2563EB, #2563EB);
  --grad-btn: linear-gradient(90deg, #2563EB, #2563EB);
  --grad-line: linear-gradient(90deg, transparent, #2563EB 45%, transparent);

  --body: 'InterVariable', 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --sidebar-w: 288px;
  --content-w: 760px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 1px 2px rgba(16, 16, 26, 0.04), 0 16px 40px -24px rgba(16, 16, 26, 0.18);
  --accent-ink: var(--violet);
  --link-line: rgba(37, 99, 235, 0.35);
  --glass: rgba(255, 255, 255, 0.92);
  --tip-bg: #f1f8f9;
  --warn-bg: #fff8ed;
  --shot-dim: none;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0f13;
  --bg-soft: #1a1a21;
  --bg-softer: #141419;
  --ink: #ececf1;
  --ink-dim: #b6b6c2;
  --ink-faint: #8c8c99;
  --line: #2b2b35;
  --line2: #24242c;

  --violet: #3B82F6;
  --violet-deep: #2563EB;
  --violet-lt: #60A5FA;
  --grad: linear-gradient(90deg, #3B82F6, #3B82F6);
  --grad-btn: linear-gradient(90deg, #3B82F6, #3B82F6);
  --grad-line: linear-gradient(90deg, transparent, #3B82F6 45%, transparent);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -24px rgba(0, 0, 0, 0.6);
  --accent-ink: color-mix(in srgb, var(--violet) 55%, #ffffff);
  --link-line: color-mix(in srgb, var(--violet) 55%, transparent);
  --glass: rgba(20, 20, 25, 0.92);
  --tip-bg: rgba(14, 116, 144, 0.14);
  --warn-bg: rgba(217, 119, 6, 0.13);
  --shot-dim: brightness(0.94);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-feature-settings: 'cv11', 'ss01';
  font-size: 16.5px; line-height: 1.65; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: rgba(37, 99, 235, 0.14); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }

/* ── sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 14px; padding: 20px 16px 24px;
  background: var(--bg-softer); border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
}
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 4px 6px; margin-bottom: 2px; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; }
.brand span { font-weight: 650; font-size: 17px; letter-spacing: -0.02em; line-height: 1.1; display: flex; flex-direction: column; color: var(--ink); }
.brand small { font-weight: 500; font-size: 12px; letter-spacing: 0; color: var(--ink-faint); margin-top: 1px; }

.search-wrap { position: relative; }
#search {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search::placeholder { color: var(--ink-faint); }
#search:focus { border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
#results {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50;
  max-height: 60vh; overflow-y: auto; padding: 6px; border-radius: 11px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow);
}
#results.show { display: block; }
#results a { display: block; padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--ink-dim); }
#results a:hover { background: var(--bg-soft); color: var(--ink); }
.r-sec { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin-bottom: 1px; }
.r-none { padding: 10px 11px; font-size: 13.5px; color: var(--ink-faint); }

#nav { display: flex; flex-direction: column; gap: 1px; padding-bottom: 20px; }
.nav-section { display: flex; flex-direction: column; }
.nav-sec-title {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer;
  padding: 8px 8px; border: none; background: none; color: var(--ink); font: inherit;
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.005em;
  border-radius: 8px; transition: background .15s;
}
.nav-sec-title::before {
  content: '\203A'; display: inline-block; width: 10px; font-size: 15px; color: var(--ink-faint);
  transform: rotate(90deg); transition: transform .2s var(--ease);
}
.nav-section.collapsed .nav-sec-title::before { transform: rotate(0deg); }
.nav-sec-title:hover { background: var(--bg-soft); }
.nav-section ul { list-style: none; margin: 1px 0 8px 13px; padding: 0 0 0 5px; display: flex; flex-direction: column; gap: 1px;
  border-left: 1px solid var(--line); }
.nav-section.collapsed ul { display: none; }
.nav-section a {
  display: block; padding: 6px 10px; margin-left: -6px; border-left: 2px solid transparent; border-radius: 0 7px 7px 0;
  font-size: 14px; color: var(--ink-dim); transition: color .15s, background .15s;
}
.nav-section a:hover { color: var(--ink); background: var(--bg-soft); }
.nav-section a.active { color: var(--ink); font-weight: 600; border-left-color: var(--violet); background: var(--bg-soft); }

/* ── customer help: "get the app" box (branded via guide-brand.js) ───────── */
.get-app { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.get-app-btn { display: block; text-align: center; padding: 11px 14px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 14.5px; background: var(--violet); transition: background .15s; }
.get-app-btn:hover { background: var(--violet-deep); }
.get-app-link { text-align: center; font-size: 13px; color: var(--ink-dim); }
.get-app-link:hover { color: var(--ink); }

/* ── mobile nav toggle ──────────────────────────────────────────────────── */
#navtoggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60; width: 42px; height: 42px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--glass);
  color: var(--ink); font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
}

/* ── light / dark toggle (top right, every width) ───────────────────────── */
#themetoggle {
  position: fixed; top: 12px; right: 12px; z-index: 60; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; padding: 0;
  border-radius: 10px; border: 1px solid var(--line); background: var(--glass);
  color: var(--ink-dim); cursor: pointer; transition: color .15s, border-color .15s;
}
#themetoggle:hover { color: var(--ink); border-color: var(--ink-faint); }
#themetoggle svg { width: 18px; height: 18px; }
#themetoggle .i-sun, :root[data-theme="dark"] #themetoggle .i-moon { display: none; }
:root[data-theme="dark"] #themetoggle .i-sun { display: block; }

/* ── main / content ─────────────────────────────────────────────────────── */
main { margin-left: var(--sidebar-w); padding: 44px clamp(20px, 5vw, 64px) 96px; }
.crumbs { max-width: var(--content-w); margin: 0 auto 8px; font-size: 13.5px; font-weight: 600; color: var(--accent-ink); }
#article { max-width: var(--content-w); margin: 0 auto; }
.credit { max-width: var(--content-w); margin: 48px auto 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-dim); }
.credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

#article h1 { font-weight: 700; font-size: clamp(30px, 4.4vw, 40px); line-height: 1.1; letter-spacing: -0.03em; margin: 4px 0 18px; }
#article h2 { font-weight: 650; font-size: 23px; letter-spacing: -0.02em; line-height: 1.25; margin: 44px 0 12px; scroll-margin-top: 24px; }
#article h3 { font-weight: 650; font-size: 18px; letter-spacing: -0.015em; margin: 30px 0 8px; scroll-margin-top: 24px; }
#article h4 { font-weight: 650; font-size: 15.5px; margin: 22px 0 6px; color: var(--ink-dim); }
#article p { margin: 0 0 16px; color: var(--ink); }
#article a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--link-line); transition: text-decoration-color .15s; }
#article a:hover { text-decoration-color: var(--accent-ink); }
#article strong { color: var(--ink); font-weight: 650; }
#article ul, #article ol { margin: 0 0 18px; padding-left: 22px; }
#article li { margin: 7px 0; }
#article li::marker { color: var(--ink-faint); }
#article ol li::marker { color: var(--ink-faint); font-weight: 600; font-variant-numeric: tabular-nums; }
#article code {
  font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace; font-size: 0.86em;
  padding: 2px 6px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--line2); color: var(--ink);
}
/* Fenced code blocks: a long command scrolls inside its block instead of widening the page. */
#article pre.code { margin: 18px 0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; background: var(--bg-soft); border: 1px solid var(--line); }
#article pre.code code { display: block; padding: 0; background: none; border: none; border-radius: 0; font-size: 13.5px; line-height: 1.65; white-space: pre; tab-size: 2; }

#article hr { border: none; height: 1px; background: var(--line); margin: 34px 0; }
#article kbd {
  font-family: var(--body); font-size: 12.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: 0 1px 0 var(--line); color: var(--ink);
}

/* ── callouts (note / tip / warning) ────────────────────────────────────── */
.callout {
  margin: 20px 0; padding: 13px 16px 13px 18px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line2); border-left: 3px solid var(--violet);
  color: var(--ink-dim); font-size: 15.5px; line-height: 1.6;
}
.callout strong { color: var(--ink); }
.callout.tip { border-left-color: #0e7490; background: var(--tip-bg); }
.callout.warning { border-left-color: #d97706; background: var(--warn-bg); }

/* ── screenshots ────────────────────────────────────────────────────────── */
.shot { margin: 18px 0 24px; }
.shot img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft); box-shadow: var(--shadow); filter: var(--shot-dim); }
.shot figcaption { margin-top: 8px; font-size: 13px; color: var(--ink-faint); }
.shot-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  aspect-ratio: 16 / 9; border-radius: 10px; border: 1px dashed var(--line); background: var(--bg-soft);
}
.shot-cam { font-size: 26px; opacity: 0.6; }
.shot-cap { font-size: 13.5px; color: var(--ink-faint); }

/* ── tables ─────────────────────────────────────────────────────────────── */
.table-wrap { margin: 20px 0; overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
#article table { width: 100%; border-collapse: collapse; font-size: 15px; }
#article th, #article td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line2); vertical-align: top; }
#article th { font-weight: 600; font-size: 13px; color: var(--ink-faint); background: var(--bg-softer); }
#article tbody tr:last-child td { border-bottom: none; }

/* ── prev / next ────────────────────────────────────────────────────────── */
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 52px; padding-top: 24px; border-top: 1px solid var(--line); }
.pn {
  display: flex; flex-direction: column; gap: 2px; padding: 13px 16px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 15px; transition: border-color .15s, background .15s;
}
.pn span { font-size: 12.5px; font-weight: 500; color: var(--ink-faint); }
.pn.next { text-align: right; }
.pn:hover { border-color: var(--ink-faint); background: var(--bg-softer); }
.prevnext > span:empty, .pn:not([href]) { visibility: hidden; }

/* ── footer ─────────────────────────────────────────────────────────────── */
.docfoot { max-width: var(--content-w); margin: 40px auto 0; padding-top: 20px; border-top: 1px solid var(--line2); font-size: 13.5px; color: var(--ink-faint); }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 940px) {
  #navtoggle { display: flex; align-items: center; justify-content: center; }
  #sidebar { transform: translateX(-100%); transition: transform .3s var(--ease); }
  #sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.18); }
  main { margin-left: 0; padding: 68px 18px 80px; }
  .prevnext { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
