/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:          #080d18;
  --bg-alt:      #0c1220;
  --surface:     #111825;
  --surface-2:   #19243a;
  --border:      #1e2e48;
  --border-2:    #2a3d60;

  --accent:      #3ea8e5;
  --accent-dim:  rgba(62,168,229,.10);
  --accent-glow: rgba(62,168,229,.22);
  --accent-2:    #f5a623;
  --accent-2-dim:rgba(245,166,35,.10);

  --text:        #c8d8ee;
  --text-hi:     #e8f0fc;
  --text-lo:     #6b84a8;
  --text-faint:  #354d6e;

  --code-bg:     #090f1c;
  --tip-border:  #f5a623;
  --note-border: #3ea8e5;

  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --sidebar-w: 260px;
  --topbar-h:  52px;
  --r: 6px;
  --ease: 0.16s ease;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.72;
  min-height: 100vh;
}

/* ── Top bar (mobile only) ─────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 110;
}

.topbar-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-hi);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-plane {
  color: var(--accent);
  font-size: 16px;
}

.icon-btn {
  width: 36px; height: 36px;
  background: none;
  border: none;
  color: var(--text-lo);
  cursor: pointer;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--ease), background var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ── Overlay ────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 100;
}
.overlay.show { display: block; }

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 105;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-plane {
  font-size: 26px;
  color: var(--accent);
  display: inline-block;
  transform: rotate(-8deg);
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.logo-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-hi);
}

.logo-sub {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Search */
.search-wrap {
  position: relative;
  padding: 14px 12px 4px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%) translateY(5px);
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 56px 8px 34px;
  border-radius: var(--r);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-input::placeholder { color: var(--text-faint); }

.search-hint {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%) translateY(5px);
  font-family: var(--sans);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  pointer-events: none;
  transition: opacity var(--ease);
}
.search-input:focus + .search-hint { opacity: 0; }
.search-input:not(:placeholder-shown) + .search-hint { opacity: 0; }

.search-results {
  display: none;
  position: absolute;
  top: calc(100% - 4px);
  left: 12px; right: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: 0 12px 28px rgba(0,0,0,.5);
  max-height: 340px;
  overflow-y: auto;
  z-index: 200;
}
.search-results.open { display: block; }

.search-result {
  display: block;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background var(--ease);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.focused { background: var(--accent-dim); }

.sr-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hi);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sr-icon { opacity: .7; font-size: 12px; }
.sr-snippet {
  font-size: 11.5px;
  color: var(--text-lo);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-snippet mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}
.search-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 10px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r);
  color: var(--text-lo);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--ease), background var(--ease);
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 500;
}
.nav-link-icon { font-size: 13px; flex-shrink: 0; opacity: .75; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .06em;
  flex-shrink: 0;
}

/* ── Main ───────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.page-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 52px 44px 96px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 100px 0;
  color: var(--text-lo);
}
.loading-plane {
  font-size: 38px;
  color: var(--accent);
  display: inline-block;
  animation: soar 2.2s ease-in-out infinite;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
@keyframes soar {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50%       { transform: translateY(-14px) rotate(-4deg); }
}
.loading-label {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: .08em;
}

/* ── Content typography ────────────────────────────────── */
.content {
  animation: fadein .2s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Headings */
.content h1 {
  font-size: 2.05rem;
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1.22;
  margin-bottom: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-hi);
  margin-top: 48px;
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 32px;
  margin-bottom: 10px;
  position: relative;
}

.content h4 {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-lo);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 22px;
  margin-bottom: 8px;
  position: relative;
}

.content h5, .content h6 {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-lo);
  margin-top: 18px;
  margin-bottom: 6px;
}

/* Section anchor links */
.heading-anchor {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  text-decoration: none;
  font-size: .8em;
  font-weight: 400;
  opacity: 0;
  transition: opacity var(--ease);
  line-height: 1;
}
.content h1:hover .heading-anchor,
.content h2:hover .heading-anchor,
.content h3:hover .heading-anchor,
.content h4:hover .heading-anchor { opacity: 1; }

/* Paragraph */
.content p { margin-bottom: 16px; }

/* Inline text */
.content strong { font-weight: 600; color: var(--text-hi); }
.content em     { font-style: italic; }

/* Links */
.content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease), color var(--ease);
}
.content a:hover { border-bottom-color: var(--accent); }

/* Lists */
.content ul, .content ol {
  margin: 2px 0 16px 22px;
}
.content li { margin-bottom: 5px; }
.content li > ul, .content li > ol { margin-top: 4px; }

/* Inline code */
.content :not(pre) > code {
  font-family: var(--mono);
  font-size: .83em;
  background: var(--code-bg);
  color: #7dd3fc;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks */
.content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 4px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.content pre::-webkit-scrollbar { height: 4px; }
.content pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.content pre code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: #c9d9f0;
  line-height: 1.65;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* Blockquotes (default) */
.content blockquote {
  border-left: 3px solid var(--border-2);
  padding: 12px 16px;
  margin: 20px 0;
  background: var(--surface);
  border-radius: 0 var(--r) var(--r) 0;
}
.content blockquote p { margin: 0; color: var(--text-lo); font-size: .93em; }
.content blockquote p:not(:last-child) { margin-bottom: 8px; }

/* Tip blockquotes */
.content blockquote.tip {
  border-color: var(--tip-border);
  background: var(--accent-2-dim);
}
.content blockquote.tip p { color: var(--text); }
.content blockquote.tip strong:first-child { color: var(--accent-2); }

/* Note blockquotes */
.content blockquote.note {
  border-color: var(--note-border);
  background: var(--accent-dim);
}
.content blockquote.note p { color: var(--text); }
.content blockquote.note strong:first-child { color: var(--accent); }

/* HR */
.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 6px 0 22px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.content thead th {
  background: var(--surface-2);
  color: var(--text-lo);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.content tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.content tbody tr:last-child td { border-bottom: none; }
.content tbody tr:nth-child(even) td { background: var(--bg-alt); }
.content tbody tr:hover td { background: var(--accent-dim); transition: background .1s; }

/* Screenshot placeholder */
.screenshot-placeholder {
  background: var(--surface);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--r);
  padding: 28px 24px;
  text-align: center;
  margin: 24px 0;
  color: var(--text-faint);
}
.screenshot-plane {
  font-size: 26px;
  display: block;
  margin-bottom: 8px;
  opacity: .4;
}
.screenshot-desc {
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

/* Real screenshots (device captures) */
.shot {
  margin: 24px auto;
  max-width: 264px;
  text-align: center;
}
.shot-frame {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .38);
  background: var(--surface);
  line-height: 0;
}
.shot-frame img { display: block; width: 100%; height: auto; }
.shot figcaption {
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-faint);
  margin-top: 10px;
}
/* A row of screenshots (e.g. the iOS tour) wraps and centers on narrow viewports */
.shot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin: 24px 0;
}
.shot-row .shot { margin: 0; max-width: 220px; }

/* ── Back to top ────────────────────────────────────────── */
.btt {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px; height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-lo);
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--ease), transform var(--ease), color var(--ease), border-color var(--ease);
  z-index: 50;
}
.btt.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.btt:hover {
  color: var(--text-hi);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ── Platform switcher ──────────────────────────────────── */
.platform-switch {
  display: flex;
  gap: 3px;
  padding: 10px 12px 2px;
  flex-shrink: 0;
}

.plat-btn {
  flex: 1;
  padding: 6px 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-lo);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
  white-space: nowrap;
}
.plat-btn:hover { color: var(--text); border-color: var(--border-2); }

.plat-btn[data-plat="ios"].active   { color: #93c5fd; border-color: #3b82f6; background: rgba(59,130,246,.1); }
.plat-btn[data-plat="macos"].active { color: #c4b5fd; border-color: #8b5cf6; background: rgba(139,92,246,.1); }
.plat-btn[data-plat="web"].active   { color: #6ee7b7; border-color: #10b981; background: rgba(16,185,129,.1); }

/* ── Platform content blocks ────────────────────────────── */
.platform-block {
  margin: 16px 0;
  padding: 14px 16px 14px 44px;
  border-radius: var(--r);
  position: relative;
  font-size: .93em;
}
.platform-block::before {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 14px;
  line-height: 1;
}
.platform-block > *:last-child { margin-bottom: 0; }

.platform-block[data-platform="ios"] {
  background: rgba(59,130,246,.07);
  border: 1px solid rgba(59,130,246,.22);
}
.platform-block[data-platform="ios"]::before   { content: "📱"; }

.platform-block[data-platform="macos"] {
  background: rgba(139,92,246,.07);
  border: 1px solid rgba(139,92,246,.22);
}
.platform-block[data-platform="macos"]::before { content: "🖥"; }

.platform-block[data-platform="web"] {
  background: rgba(16,185,129,.07);
  border: 1px solid rgba(16,185,129,.22);
}
.platform-block[data-platform="web"]::before   { content: "🌐"; }

/* Platform badge inside block */
.platform-block .platform-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 2px 7px;
  border-radius: 3px;
}
.platform-block[data-platform="ios"]   .platform-label { background: rgba(59,130,246,.2); color: #93c5fd; }
.platform-block[data-platform="macos"] .platform-label { background: rgba(139,92,246,.2); color: #c4b5fd; }
.platform-block[data-platform="web"]   .platform-label { background: rgba(16,185,129,.2); color: #6ee7b7; }

/* Platform visibility — controlled by body[data-platform] */
body[data-platform="ios"]   .platform-block:not([data-platform="ios"])   { display: none; }
body[data-platform="macos"] .platform-block:not([data-platform="macos"]) { display: none; }
body[data-platform="web"]   .platform-block:not([data-platform="web"])   { display: none; }

/* Inline platform chips in prose */
.plat-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin: 0 2px;
}
.plat-chip.ios   { background: rgba(59,130,246,.2); color: #93c5fd; }
.plat-chip.macos { background: rgba(139,92,246,.2); color: #c4b5fd; }
.plat-chip.web   { background: rgba(16,185,129,.2); color: #6ee7b7; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .topbar { display: flex; }

  .layout { margin-top: var(--topbar-h); }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .24s ease;
    top: 0;
  }
  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

  .page-wrap { padding: 28px 20px 72px; }

  .heading-anchor { display: none; }

  .content h1 { font-size: 1.65rem; }
  .content h2 { font-size: 1.2rem; margin-top: 36px; }
  .content h3 { font-size: 1rem; }

  .btt { right: 16px; bottom: 16px; width: 36px; height: 36px; font-size: 15px; }
}
