/* User guide styles. Built into guide.css by tools/build_user_guide.mjs; the tokens below are
   copied from frontend-ng/src/styles.scss :root so the guide looks like the app. */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e3e6ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --header: #1e3a8a;
  --accent: #eef2ff;
  --row-alt: #f9fafb;
  --code-bg: #f1f5f9;
  --tip: #ecfdf5; --tip-edge: #16a34a;
  --note: #eff6ff; --note-edge: #2563eb;
  --important: #fff7ed; --important-edge: #d97706;
  --top-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a; --card: #111827; --border: #263043; --text: #e5e7eb; --muted: #9ca3af;
    --primary: #60a5fa; --primary-dark: #93c5fd; --header: #0b1220; --accent: #1e293b; --row-alt: #151d2e;
    --code-bg: #1e293b; --tip: #052e1c; --note: #0b1d3a; --important: #2f1a05;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f172a; --card: #111827; --border: #263043; --text: #e5e7eb; --muted: #9ca3af;
  --primary: #60a5fa; --primary-dark: #93c5fd; --header: #0b1220; --accent: #1e293b; --row-alt: #151d2e;
  --code-bg: #1e293b; --tip: #052e1c; --note: #0b1d3a; --important: #2f1a05;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* Top bar */
.g-top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--header); color: #fff;
}
.g-brand { color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
.g-brand:hover { color: #fff; text-decoration: underline; }
.g-menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.g-search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.g-search input {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 15px; background: rgba(255,255,255,.95); color: #111827;
}
.g-results {
  position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  max-height: 70vh; overflow: auto; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); box-shadow: 0 12px 32px rgba(0,0,0,.2);
}
.g-results li a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: inherit; }
.g-results li a:hover, .g-results li a[aria-selected="true"] { background: var(--accent); }
.g-results b { display: block; color: var(--primary); font-weight: 600; }
.g-results small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.g-results mark { background: #fde68a; color: #111827; border-radius: 2px; }
.g-results .g-none { padding: 8px 10px; color: var(--muted); }
.g-ontop { white-space: nowrap; font-size: 14px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.g-ontop[hidden] { display: none; }
.g-lang { height: 36px; border-radius: 8px; border: 0; padding: 0 8px; font: inherit; font-size: 14px; }

/* Layout */
.g-body { display: grid; grid-template-columns: 270px minmax(0, 1fr) 220px; max-width: 1400px; margin: 0 auto; }
.g-nav {
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow: auto;
  padding: 16px 12px 40px; border-right: 1px solid var(--border); font-size: 14.5px;
}
.g-nav ul { list-style: none; margin: 0; padding: 0; }
.g-part > span { display: block; margin: 14px 8px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.g-part:first-child > span { margin-top: 0; }
.g-nav a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--text); text-decoration: none; line-height: 1.35; }
.g-nav a:hover { background: var(--accent); }
.g-nav a[aria-current="page"] { background: var(--accent); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.g-main { padding: 24px 40px 40px; min-width: 0; }
.g-page { max-width: 820px; }
.g-toc { position: sticky; top: var(--top-h); align-self: start; padding: 24px 16px; font-size: 13.5px; max-height: calc(100vh - var(--top-h)); overflow: auto; }
.g-toc strong { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.g-toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.g-toc a { display: block; padding: 3px 10px; color: var(--muted); text-decoration: none; }
.g-toc a:hover, .g-toc a.g-here { color: var(--primary); }
.g-toc a.g-here { box-shadow: -2px 0 0 var(--primary); }

/* Page content */
.g-page h1 { font-size: 30px; line-height: 1.25; margin: 4px 0 14px; color: var(--header); }
.g-page h2 { font-size: 22px; margin: 36px 0 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.g-page h3 { font-size: 18px; margin: 26px 0 8px; }
:root[data-theme="dark"] .g-page h1 { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .g-page h1 { color: var(--text); } }
.g-anchor { margin-left: 8px; color: var(--border); text-decoration: none; font-weight: 400; opacity: 0; }
h2:hover .g-anchor, h3:hover .g-anchor { opacity: 1; }
.g-page p, .g-page li { max-width: 74ch; }
.g-page li { margin: 3px 0; }
.g-page code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; word-break: break-word; }
.g-page pre { background: var(--code-bg); padding: 12px; border-radius: 8px; overflow: auto; }
.g-page pre code { padding: 0; }
.g-table { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.g-table table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.g-table th, .g-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.g-table th { background: var(--accent); font-weight: 600; }
.g-table tr:last-child td { border-bottom: 0; }
.g-table tbody tr:nth-child(even) td { background: var(--row-alt); }
blockquote { margin: 16px 0; padding: 10px 16px; border-left: 4px solid var(--border); background: var(--card); border-radius: 0 8px 8px 0; }
blockquote p { margin: 6px 0; }
.g-callout.g-tip { background: var(--tip); border-color: var(--tip-edge); }
.g-callout.g-note { background: var(--note); border-color: var(--note-edge); }
.g-callout.g-important { background: var(--important); border-color: var(--important-edge); }

/* Screenshots */
.g-shot { margin: 18px 0 22px; }
.g-shot img {
  display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15,23,42,.08); background: #fff;
}
.g-shot a { display: inline-block; cursor: zoom-in; }
.g-shot figcaption { margin-top: 6px; font-size: 14px; color: var(--muted); }
.g-shot-ph {
  padding: 28px 16px; text-align: center; color: var(--muted); border: 2px dashed var(--border);
  border-radius: 8px; background: var(--card);
}
.g-flash { animation: g-flash 1.6s ease-out; }
@keyframes g-flash { from { background: #fef3c7; } to { background: transparent; } }

/* Previous / next, footer */
.g-pager { display: flex; justify-content: space-between; gap: 16px; max-width: 820px; margin-top: 40px; }
.g-pager a {
  flex: 1; max-width: 48%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); text-decoration: none; font-weight: 600;
}
.g-pager a small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.g-pager .g-next { text-align: right; margin-left: auto; }
.g-foot { max-width: 820px; margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.g-foot p { margin: 0 0 6px; }
.g-foot .g-report { font-size: 14px; }
.g-foot .g-report a { color: var(--primary); font-weight: 600; }
@media print { .g-foot .g-report { display: none; } }

/* Narrow windows (the guide window next to the app is often ~600–900 px wide) */
@media (max-width: 1180px) {
  .g-body { grid-template-columns: 250px minmax(0, 1fr); }
  .g-toc { display: none; }
}
@media (max-width: 820px) {
  :root { --top-h: 52px; }
  .g-top { gap: 8px; padding: 0 10px; }
  .g-menu-btn { display: block; }
  .g-brand { display: none; }
  .g-ontop { font-size: 0; gap: 0; }
  .g-ontop::after { content: "📌"; font-size: 16px; margin-left: 2px; }
  .g-body { display: block; }
  .g-nav {
    position: fixed; z-index: 15; top: var(--top-h); left: 0; bottom: 0; width: min(300px, 85vw);
    background: var(--card); transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s;
    height: auto;
  }
  body.g-nav-open .g-nav { transform: none; visibility: visible; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  .g-main { padding: 18px 16px 32px; }
  .g-page h1 { font-size: 25px; }
  .g-pager { flex-direction: column; }
  .g-pager a { max-width: none; }
}

@media print {
  .g-top, .g-nav, .g-toc, .g-pager { display: none !important; }
  .g-body { display: block; }
  .g-main { padding: 0; }
  body { background: #fff; color: #000; }
  .g-shot { break-inside: avoid; }
}
