/* PixAstro · Desktop User Manual (no dependencies)
   Matches pixastro.org charcoal/amber palette and astronomical night mode. */
:root {
  --bg: #19191a;
  --surface: #212122;
  --raised: #272728;
  --canvas: #0e0e0f;
  --border: #2e2e30;
  --line: #3c3c40;
  --text: #ededee;
  --bright: #ffffff;
  --muted: #9b9ba0;
  --accent: #d9902f;
  --accent-hi: #f0ab49;
  --accent-soft: rgba(217, 144, 47, 0.14);
  --on-accent: #181108;
  --ok: #68b87a;
  --note-bg: rgba(96, 165, 250, 0.10);
  --note-bd: #60a5fa;
  --warn-bg: rgba(217, 144, 47, 0.12);
  --warn-bd: #f0ab49;
  --bar-bg: rgba(25, 25, 26, 0.88);
  --overlay-bg: rgba(9, 9, 11, 0.86);
  --r: 6px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html.night {
  --bg: #0c0405;
  --surface: #140708;
  --raised: #1c0a0b;
  --canvas: #070203;
  --border: #2b1011;
  --line: #3f181a;
  --text: #d68a8a;
  --bright: #f2b4b4;
  --muted: #8a4b4b;
  --accent: #b83333;
  --accent-hi: #e05252;
  --accent-soft: rgba(184, 51, 51, 0.22);
  --on-accent: #1a0606;
  --ok: #c46868;
  --note-bg: rgba(184, 51, 51, 0.14);
  --note-bd: #b83333;
  --warn-bg: rgba(224, 82, 82, 0.16);
  --warn-bd: #e05252;
  --bar-bg: rgba(12, 4, 5, 0.92);
  --overlay-bg: rgba(12, 4, 5, 0.90);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  color-scheme: dark;
  background: var(--bg);
  overflow-x: clip;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 0.2s, color 0.2s;
}
img { display: block; max-width: 100%; }
a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--bright);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------- Top bar ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.bar .wrap {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 600 15.5px/1 var(--display);
  color: var(--bright);
  letter-spacing: -0.015em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; opacity: 0.92; }
.brand img { width: 28px; height: 28px; }
.bar-sub {
  color: var(--muted);
  font: 400 13px/1 var(--mono);
  border-left: 1px solid var(--line);
  padding-left: 10px;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--bright);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--raised); border-color: var(--muted); text-decoration: none; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.flat { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.flat:hover { color: var(--bright); border-color: var(--line); background: var(--surface); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.mono { font-family: var(--mono); }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  flex-shrink: 0;
}
html.night .dot { background: var(--accent-hi); }
.toc-btn { display: none; }

/* ---------- Manual Hero ---------- */
.manual-hero {
  border-bottom: 1px solid var(--border);
  background: radial-gradient(ellipse at 18% 0%, var(--accent-soft) 0%, transparent 56%);
  padding: 36px 0 30px;
}
.hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: 500 11.5px/1.2 var(--mono);
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}
.manual-hero h1 {
  margin: 0 0 10px 0;
  font-size: clamp(1.85rem, 3.6vw, 2.65rem);
  font-weight: 700;
}
.hero-lead {
  margin: 0;
  color: var(--muted);
  max-width: 660px;
  font-size: 1rem;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- 2-Column Manual Layout ---------- */
.manual-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 38px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 64px;
}

.toc-wrap {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 12px;
}
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 600 11.5px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.toc-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-list a {
  display: block;
  padding: 7px 10px;
  border-radius: 4px;
  border-left: 2px solid transparent;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.toc-list a:hover {
  color: var(--bright);
  background: var(--raised);
  text-decoration: none;
}
.toc-list a.active {
  color: var(--bright);
  background: var(--accent-soft);
  border-left-color: var(--accent-hi);
  font-weight: 500;
}

/* ---------- Article Content ---------- */
.doc {
  min-width: 0;
}
.doc > *:first-child { margin-top: 0; }
.doc h2 {
  font-size: clamp(1.38rem, 2.3vw, 1.72rem);
  margin: 44px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 78px;
}
.doc h2:first-of-type { margin-top: 18px; }
.doc h3 {
  font-size: 1.15rem;
  color: var(--accent-hi);
  margin: 26px 0 10px;
  scroll-margin-top: 78px;
}
.doc h4 {
  font-size: 1.02rem;
  margin: 20px 0 8px;
  scroll-margin-top: 78px;
}
.doc p {
  margin: 0 0 14px;
}
.doc strong { color: var(--bright); font-weight: 600; }
.doc ul, .doc ol {
  margin: 0 0 16px;
  padding-left: 22px;
}
.doc li { margin: 5px 0; }
.doc li > ul, .doc li > ol {
  margin-top: 6px;
  margin-bottom: 6px;
}
.doc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 34px 0;
}
.doc code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--bright);
}
.pre-wrap {
  position: relative;
  margin: 14px 0 18px;
  min-width: 0;
  max-width: 100%;
}
.doc pre {
  margin: 0;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 72px 14px 16px;
  overflow-x: auto;
  font: 13px/1.55 var(--mono);
  color: var(--text);
}
.doc pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: 500 11.5px/1.2 var(--mono);
  cursor: pointer;
}
.copy-btn:hover { color: var(--bright); border-color: var(--muted); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* Callouts */
.callout {
  margin: 18px 0;
  padding: 12px 16px;
  border-radius: 0 var(--r) var(--r) 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--note-bd);
  background: var(--note-bg);
}
.callout-important, .callout-warning {
  border-left-color: var(--warn-bd);
  background: var(--warn-bg);
}
.callout-tip {
  border-left-color: var(--ok);
  background: rgba(104, 184, 122, 0.10);
}
.callout-title {
  font: 600 11.5px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 5px;
  color: var(--note-bd);
}
.callout-important .callout-title,
.callout-warning .callout-title { color: var(--warn-bd); }
.callout-tip .callout-title { color: var(--ok); }
.callout-body { color: var(--text); font-size: 0.96rem; }

/* Tables */
.table-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  margin: 14px 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.doc th {
  background: var(--raised);
  color: var(--bright);
  font-family: var(--display);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.doc td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.doc tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* Screenshots / Figures */
figure.shot {
  margin: 18px 0 24px;
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: zoom-in;
  transition: border-color 0.15s, transform 0.15s;
}
figure.shot:hover {
  border-color: var(--accent);
}
figure.shot img {
  margin: 0 auto;
  width: 100%;
  height: auto;
  border-radius: 3px;
}
html.night figure.shot img {
  opacity: 0.92;
}
figure.shot figcaption {
  margin-top: 9px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Lightbox dialog */
dialog#lightbox {
  max-width: min(94vw, 1320px);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--canvas);
  color: var(--text);
}
dialog#lightbox::backdrop {
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
}
dialog#lightbox header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--bright);
}
.lb-body {
  padding: 12px;
  overflow: auto;
  max-height: calc(92vh - 54px);
}
.lb-body img {
  margin: 0 auto;
  max-height: calc(92vh - 82px);
  width: auto;
}

/* Back to top */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.to-top.show {
  opacity: 1;
  pointer-events: auto;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  color: var(--muted);
  font-size: 13px;
}
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.foot-links a { color: var(--muted); }
.foot-links a:hover { color: var(--bright); }

/* Mobile & Tablet */
@media (max-width: 960px) {
  .bar-sub { display: none; }
  .toc-btn { display: inline-flex; }
  .manual-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .toc-wrap {
    display: none;
    position: fixed;
    top: 64px;
    left: 14px;
    right: 14px;
    max-height: 75vh;
    z-index: 40;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
  }
  .toc-wrap.open { display: block; }
  .toc-close { display: inline-block; }
  .btn-dl-bar { display: none; }
}

@media (max-width: 520px) {
  .wrap { padding: 0 14px; }
  .bar .wrap { gap: 8px; }
  .nav-actions { gap: 6px; }
  .btn.sm { padding: 5px 8px; font-size: 12px; }
  .manual-hero { padding: 26px 0 22px; }
  figure.shot { padding: 6px; }
  .callout { padding: 10px 12px; }
}

@media print {
  .bar, .toc-wrap, .hero-cta, .copy-btn, .to-top, dialog { display: none !important; }
  body { background: #fff; color: #111; }
  .manual-layout { display: block; }
  .manual-hero { background: none; border-bottom: 1px solid #ccc; }
  .doc h2, .doc h3, .doc strong { color: #111; }
  figure.shot, .table-wrap { break-inside: avoid; border-color: #ccc; background: #fff; }
}
