@import url('fonts.css');

/* ==========================================================================
   SkyTrackPro Pilot Manual: cockpit design system
   Palette and motifs follow api.skytrackpro.ch, bridged to the app tokens in
   lib/theme/sky_tokens.dart. Dark is the default face, light is a toggle.
   ========================================================================== */

:root {
  --bg: #0a0e1a;
  --bg-2: #0e1426;
  --panel: rgba(255, 255, 255, 0.028);
  --panel-2: rgba(255, 255, 255, 0.05);
  --ink: #e8edf7;
  --ink-dim: #b7c2d6;
  --muted: #7a8aa8;
  --line: rgba(122, 138, 168, 0.16);
  --line-strong: rgba(122, 138, 168, 0.32);
  --accent: #4fc3f7;
  --accent-ink: #0a0e1a;
  --accent-soft: rgba(79, 195, 247, 0.1);
  --accent-warm: #ffb74d;
  --accent-warm-soft: rgba(255, 183, 77, 0.1);
  --glow: rgba(79, 195, 247, 0.5);

  --ok: #26c281;
  --ok-soft: rgba(38, 194, 129, 0.11);
  --caution: #ff9100;
  --caution-soft: rgba(255, 145, 0, 0.11);
  --danger: #ff5d52;
  --danger-soft: rgba(255, 93, 82, 0.11);

  --display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-chip: 8px;
  --r-tile: 10px;
  --r-card: 14px;
  --r-pill: 100px;

  --sidebar-w: 300px;
  --rail-w: 208px;
  --measure: 74ch;
  --topbar-h: 58px;

  --shadow-float: 0 10px 34px -14px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --panel: rgba(11, 22, 44, 0.025);
  --panel-2: rgba(11, 22, 44, 0.05);
  --ink: #101623;
  --ink-dim: #33405a;
  --muted: #5b6880;
  --line: rgba(16, 22, 35, 0.13);
  --line-strong: rgba(16, 22, 35, 0.26);
  --accent: #0d6fa8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 111, 168, 0.09);
  --accent-warm: #a35a00;
  --accent-warm-soft: rgba(163, 90, 0, 0.09);
  --glow: rgba(13, 111, 168, 0.28);

  --ok: #0f8f5b;
  --ok-soft: rgba(15, 143, 91, 0.1);
  --caution: #a35a00;
  --caution-soft: rgba(163, 90, 0, 0.1);
  --danger: #c02b21;
  --danger-soft: rgba(192, 43, 33, 0.1);

  --shadow-float: 0 10px 30px -16px rgba(16, 22, 35, 0.5);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 20px);
  -webkit-text-size-adjust: 100%;
  /* The off canvas sidebar sits at a negative offset on small screens, which
     would otherwise let the page scroll sideways. `clip` removes that without
     creating a scroll container, so the sticky topbar keeps working. */
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16.5px;
  line-height: 1.65;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Atmosphere: radial glow plus radar grid, both fixed behind the content
   -------------------------------------------------------------------------- */

.atmosphere,
.grid-lines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.atmosphere {
  background:
    radial-gradient(ellipse 80% 46% at 50% -8%, var(--accent-soft), transparent 62%),
    radial-gradient(ellipse 56% 38% at 88% 108%, var(--accent-warm-soft), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.grid-lines {
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 74% 68% at 62% 32%, #000 24%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 74% 68% at 62% 32%, #000 24%, transparent 78%);
  opacity: 0.55;
}

/* Flight path streaks, hero only */
.streaks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.streak {
  position: absolute;
  height: 1px;
  width: 180px;
  background: linear-gradient(90deg, transparent, var(--glow), transparent);
  opacity: 0;
  animation: fly 9s linear infinite;
}

.streak:nth-child(1) { top: 24%; animation-delay: 0s; }
.streak:nth-child(2) { top: 52%; width: 240px; animation-delay: 3s; }
.streak:nth-child(3) { top: 74%; width: 140px; animation-delay: 5.5s; }

@keyframes fly {
  0% { transform: translateX(-240px) translateY(0); opacity: 0; }
  10% { opacity: 0.85; }
  90% { opacity: 0.85; }
  100% { transform: translateX(calc(100% + 240px)) translateY(-36px); opacity: 0; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--glow); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .streak,
  .dot,
  .rise { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
}

/* Sidebar ------------------------------------------------------------------ */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.16), transparent 40%);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 22px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-chip);
  border: 1px solid var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-mark svg { width: 20px; height: 20px; }

.brand-text { min-width: 0; }

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.4;
}

.search-trigger {
  margin: 14px 16px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: var(--r-tile);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.search-trigger:hover {
  border-color: var(--line-strong);
  color: var(--ink-dim);
  background: var(--panel-2);
}

.search-trigger svg { width: 15px; height: 15px; flex: none; }
.search-trigger .grow { flex: 1; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}

.toc {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 12px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.toc::-webkit-scrollbar { width: 9px; }
.toc::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 9px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.toc-part {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 18px 10px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toc-part::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.toc a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: var(--r-chip);
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
  border-left: 2px solid transparent;
  transition: background 0.14s ease, color 0.14s ease;
}

.toc a:hover { background: var(--panel-2); color: var(--ink); }

.toc a.is-current {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc .num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  flex: none;
  min-width: 1.6em;
}

.toc a.is-current .num { color: var(--accent); }

/* Topbar ------------------------------------------------------------------- */

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.crumbs .sep { opacity: 0.45; }
.crumbs .here {
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-chip);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-dim);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--panel-2); }
.icon-btn svg { width: 17px; height: 17px; }

.menu-btn { display: none; }

.lang-select {
  font: inherit;
  font-size: 12.5px;
  font-family: var(--mono);
  padding: 6px 26px 6px 10px;
  border-radius: var(--r-chip);
  border: 1px solid var(--line);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8aa8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 7px center / 12px;
  color: var(--ink-dim);
  cursor: pointer;
  appearance: none;
}

.lang-select:hover { border-color: var(--line-strong); color: var(--ink); }

/* --------------------------------------------------------------------------
   Content column
   -------------------------------------------------------------------------- */

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: 40px;
  padding: 40px 44px 96px;
  max-width: 1420px;
}

.content { min-width: 0; max-width: var(--measure); }

/* Chapter head ------------------------------------------------------------- */

.kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.chapter-head { margin-bottom: 34px; }

.chapter-head h1 {
  font-size: clamp(2rem, 4.2vw, 2.85rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.022em;
  margin: 0 0 14px;
}

.chapter-num {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--muted);
  font-size: 0.5em;
  vertical-align: 0.42em;
  margin-right: 0.7em;
  letter-spacing: 0;
}

.summary {
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-dim);
  margin: 0 0 20px;
}

.head-badges { display: flex; flex-wrap: wrap; gap: 8px; }

/* Badges ------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 5px 11px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); background: var(--accent-soft); }
.badge--accent .dot { animation: pulse 2.4s ease-out infinite; box-shadow: 0 0 0 0 var(--glow); }
.badge--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 34%, transparent); background: var(--ok-soft); }
.badge--caution { color: var(--caution); border-color: color-mix(in srgb, var(--caution) 34%, transparent); background: var(--caution-soft); }
.badge--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, transparent); background: var(--danger-soft); }
.badge--warm { color: var(--accent-warm); border-color: color-mix(in srgb, var(--accent-warm) 34%, transparent); background: var(--accent-warm-soft); }

/* Sections ----------------------------------------------------------------- */

.section { margin: 0 0 44px; scroll-margin-top: calc(var(--topbar-h) + 24px); }

.section > h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.014em;
  line-height: 1.24;
  margin: 0 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section > h2 .anchor,
.sub h3 .anchor {
  font-family: var(--mono);
  font-size: 0.62em;
  color: var(--line-strong);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.14s ease, color 0.14s ease;
}

.section:hover > h2 .anchor,
.sub:hover h3 .anchor { opacity: 1; }
.anchor:hover { color: var(--accent) !important; }

.sub { margin: 30px 0 0; scroll-margin-top: calc(var(--topbar-h) + 24px); }

.sub h3 {
  font-size: 1.11rem;
  font-weight: 600;
  letter-spacing: -0.008em;
  margin: 0 0 10px;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.content p { margin: 0 0 15px; }
.content p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

strong { font-weight: 600; color: var(--ink); }

.content ul {
  margin: 0 0 15px;
  padding-left: 0;
  list-style: none;
}

.content ul li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 7px;
}

.content ul li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0.66em;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.75;
  transform: rotate(45deg);
}

/* UI label: a control name exactly as it reads in the app. Quotes can be
   whole sentences from the ARB files, so they must wrap like prose. */
.ui {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1.5px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.val {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--accent-warm);
}

/* Where breadcrumb --------------------------------------------------------- */

.where {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 15px;
  padding: 9px 13px;
  border-radius: var(--r-tile);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
}

.where .where-label {
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
  margin-right: 3px;
}

.where .node { color: var(--ink); }
.where .node:last-child { color: var(--accent); }
.where .arrow { color: var(--line-strong); }

/* Steps -------------------------------------------------------------------- */

.steps {
  counter-reset: step;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 14px 40px;
  margin: 0;
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.steps > li::after {
  content: '';
  position: absolute;
  left: 13px;
  top: 32px;
  bottom: 4px;
  width: 1px;
  background: var(--line);
}

.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }

/* Callouts ----------------------------------------------------------------- */

.callout {
  display: flex;
  gap: 13px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--panel);
}

.callout .ico {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--accent);
}

.callout .ico svg { width: 20px; height: 20px; }
.callout .body { min-width: 0; }
.callout .body > :last-child { margin-bottom: 0; }

.callout .title {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 5px;
}

.callout--tip { border-left-color: var(--accent-warm); background: var(--accent-warm-soft); }
.callout--tip .ico, .callout--tip .title { color: var(--accent-warm); }
.callout--caution { border-left-color: var(--caution); background: var(--caution-soft); }
.callout--caution .ico, .callout--caution .title { color: var(--caution); }
.callout--danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout--danger .ico, .callout--danger .title { color: var(--danger); }
.callout--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.callout--ok .ico, .callout--ok .title { color: var(--ok); }

/* Tables ------------------------------------------------------------------- */

.table-wrap {
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow-x: auto;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--panel);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.5;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel-2); }
td .ui, th .ui { white-space: normal; }

/* Settings reference table ------------------------------------------------- */

.settings-list {
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--panel);
}

.setting {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
  gap: 0 20px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.setting:last-child { border-bottom: none; }
.setting:hover { background: var(--panel-2); }

.setting-key { min-width: 0; }

.setting-name {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.35;
  margin-bottom: 5px;
}

.setting-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-2);
}

.chip--default { color: var(--accent-warm); border-color: color-mix(in srgb, var(--accent-warm) 30%, transparent); }

.setting-body { min-width: 0; font-size: 14.5px; line-height: 1.55; }
.setting-body .when {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13.5px;
}
.setting-body .when::before {
  content: attr(data-when-label);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

/* Figures ------------------------------------------------------------------ */

.figure { margin: 0 0 24px; }

.figure-frame {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  padding: 12px;
  cursor: zoom-in;
  transition: border-color 0.16s ease;
}

.figure-frame:hover { border-color: color-mix(in srgb, var(--accent) 42%, transparent); }

.figure-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-tile);
  background: #000;
}

.figure--phone .figure-frame { max-width: 300px; }
.figure--phone .figure-frame img { border-radius: 18px; }
.figure--wide .figure-frame { max-width: 100%; }

.figure figcaption {
  display: flex;
  gap: 9px;
  margin-top: 9px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.figure figcaption .fig-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  flex: none;
  padding-top: 1px;
}

.figure-missing {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 200px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-tile);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: center;
  padding: 24px;
  background: repeating-linear-gradient(45deg, transparent, transparent 9px, var(--panel-2) 9px, var(--panel-2) 18px);
}

.figure-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 0 24px;
}

.figure-row .figure { flex: 1 1 220px; margin: 0; }

/* Ready made layout gallery ------------------------------------------------ */

.layout-gallery {
  display: grid;
  gap: 16px;
  margin: 0 0 24px;
}

.layout-card {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 132px;
  gap: 18px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  transition: border-color 0.16s ease;
}

.layout-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.layout-preview .figure-frame,
.layout-qr .figure-frame {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
}

.layout-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-tile);
  border: 1px solid var(--line);
  background: #000;
}

.layout-preview .figure-missing,
.layout-qr .figure-missing {
  min-height: 132px;
  font-size: 10px;
  padding: 12px;
  word-break: break-all;
}

.layout-meta { min-width: 0; }

.layout-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
  margin-bottom: 3px;
}

.layout-orientation {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.layout-summary {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin: 8px 0 0;
}

.layout-qr { text-align: center; }

.layout-qr img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-chip);
  background: #fff;
  padding: 6px;
  border: 1px solid var(--line);
}

.layout-qr-hint {
  display: block;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 720px) {
  .layout-card { grid-template-columns: 116px minmax(0, 1fr); }
  .layout-qr { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; text-align: left; }
  .layout-qr .figure-frame, .layout-qr .figure-missing { width: 116px; flex: none; }
  .layout-qr-hint { margin-top: 0; }
}

/* Video -------------------------------------------------------------------- */

.video-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 0 0 18px;
  padding: 12px 15px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.video-card:hover { border-color: color-mix(in srgb, var(--accent) 44%, transparent); background: var(--panel-2); }

.video-card .play {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  color: var(--accent);
}

.video-card .play svg { width: 14px; height: 14px; margin-left: 2px; }
.video-card .meta { min-width: 0; }
.video-card .vt { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.video-card .vs { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* Key list (definition style) --------------------------------------------- */

.keylist { margin: 0 0 20px; }

.keylist .row {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(0, 1fr);
  gap: 4px 20px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.keylist .row:last-child { border-bottom: none; }
.keylist .k { font-weight: 600; font-size: 14.5px; }
.keylist .v { color: var(--ink-dim); font-size: 14.5px; }

/* Code --------------------------------------------------------------------- */

code {
  font-family: var(--mono);
  font-size: 0.87em;
  padding: 1.5px 5px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

pre {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

pre code { background: none; border: none; padding: 0; font-size: inherit; }

/* Right rail --------------------------------------------------------------- */

.rail {
  position: sticky;
  top: calc(var(--topbar-h) + 32px);
  max-height: calc(100vh - var(--topbar-h) - 64px);
  overflow-y: auto;
  font-size: 13px;
  scrollbar-width: thin;
}

.rail-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.rail a {
  display: block;
  padding: 4px 10px;
  color: var(--muted);
  text-decoration: none;
  border-left: 1px solid var(--line);
  line-height: 1.4;
  transition: color 0.14s ease, border-color 0.14s ease;
}

.rail a:hover { color: var(--ink); }
.rail a.is-active { color: var(--accent); border-left-color: var(--accent); }
.rail a.lvl-3 { padding-left: 22px; font-size: 12.5px; }

/* Pager -------------------------------------------------------------------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.pager a {
  display: block;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.pager a:hover { border-color: color-mix(in srgb, var(--accent) 44%, transparent); background: var(--panel-2); }
.pager .dir { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.pager .ttl { font-weight: 600; font-size: 15px; line-height: 1.3; }
.pager .next { text-align: right; }
.pager .slot-empty { visibility: hidden; }

.page-foot {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.page-foot a { color: var(--muted); text-decoration: none; }
.page-foot a:hover { color: var(--accent); }
.page-foot .sep { opacity: 0.4; }

/* --------------------------------------------------------------------------
   Home page
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  padding: 84px 44px 60px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.hero-inner { position: relative; z-index: 1; max-width: 780px; }

.hero h1 {
  font-size: clamp(2.4rem, 6.4vw, 4.1rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.028em;
  margin: 18px 0 0;
  animation: rise 0.7s ease both 0.1s;
}

.hero h1 .thin {
  display: block;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.3em;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-top: 14px;
}

.hero .lead {
  max-width: 62ch;
  color: var(--ink-dim);
  font-size: clamp(1rem, 2.2vw, 1.16rem);
  line-height: 1.62;
  margin: 22px 0 0;
  animation: rise 0.7s ease both 0.22s;
}

.hero .badge { animation: rise 0.7s ease both 0s; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
  animation: rise 0.7s ease both 0.34s;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-tile);
  padding: 12px 20px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 8px 26px -10px var(--glow);
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -10px var(--glow); filter: brightness(1.08); }
.btn svg { width: 17px; height: 17px; transition: transform 0.18s ease; }
.btn:hover svg { transform: translateX(3px); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn--ghost:hover { border-color: var(--accent); color: var(--accent); box-shadow: none; }

.home-body { padding: 44px 44px 96px; max-width: 1240px; }

.part-block { margin-bottom: 42px; }

.part-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.part-head h2 {
  font-size: 1.02rem;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.part-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 14px;
}

.chapter-card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.chapter-card:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, transparent);
  background: var(--panel-2);
  transform: translateY(-2px);
}

.chapter-card .cc-num {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 7px;
}

.chapter-card .cc-title { font-weight: 600; font-size: 15.5px; line-height: 1.3; margin-bottom: 6px; }
.chapter-card .cc-sum { font-size: 13.5px; line-height: 1.5; color: var(--muted); }

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  padding: 10vh 20px 20px;
  justify-content: center;
  align-items: flex-start;
  background: rgba(4, 7, 14, 0.68);
  backdrop-filter: blur(5px);
}

.search-modal.is-open { display: flex; }

.search-panel {
  width: min(720px, 100%);
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--bg-2);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  animation: rise 0.2s ease both;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.search-head svg { width: 18px; height: 18px; color: var(--muted); flex: none; }

#search-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
}

#search-input::placeholder { color: var(--muted); }

.search-results {
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.search-empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.sr-group {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px 5px;
}

.sr-item {
  display: block;
  padding: 9px 11px;
  border-radius: var(--r-chip);
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}

.sr-item:hover, .sr-item.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

.sr-title { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.sr-snip { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.sr-item mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

.search-foot {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.search-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* Lightbox ----------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(4, 7, 14, 0.9);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
}

.lightbox.is-open { display: grid; }

.lightbox img {
  max-width: 100%;
  max-height: 84vh;
  border-radius: var(--r-card);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
}

.lightbox .lb-caption {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 62ch;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1240px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    width: min(320px, 86vw);
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    background: var(--bg-2);
    box-shadow: var(--shadow-float);
  }

  .sidebar.is-open { transform: none; }
  .menu-btn { display: grid; }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(4, 7, 14, 0.6);
    display: none;
  }

  .scrim.is-open { display: block; }

  .page { padding: 26px 20px 72px; }
  .hero { padding: 54px 20px 42px; }
  .home-body { padding: 30px 20px 72px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .crumbs { flex: 0 1 auto; overflow: hidden; }
  .setting { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .keylist .row { grid-template-columns: minmax(0, 1fr); }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { text-align: left; }
  .pager .slot-empty { display: none; }
}

@media (max-width: 620px) {
  /* Only the current page keeps its label in the breadcrumb. */
  .crumbs .sep:first-of-type,
  .crumbs > a { display: none; }
  .lang-select { max-width: 128px; }
  .chapter-head h1 { font-size: 1.9rem; }
  .figure--phone .figure-frame { max-width: 100%; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff;
    --bg-2: #fff;
    --ink: #000;
    --ink-dim: #222;
    --muted: #555;
    --line: #ccc;
    --line-strong: #999;
    --accent: #0b5f92;
    --panel: #fff;
    --panel-2: #f6f6f6;
  }

  .atmosphere, .grid-lines, .streaks,
  .sidebar, .topbar, .rail, .pager,
  .search-modal, .lightbox, .scrim { display: none !important; }

  .app { display: block; }
  .page { display: block; padding: 0; max-width: none; }
  .content { max-width: none; }
  body { font-size: 11pt; background: #fff; }

  .section { break-inside: auto; }
  .section > h2, .sub h3 { break-after: avoid; }
  .figure, .callout, .setting, .video-card { break-inside: avoid; }
  .figure-frame { cursor: default; }
  a { color: #000; text-decoration: none; }
  .anchor { display: none; }
  .chapter-head { break-after: avoid; }
}
