/* Cosmion Labs — cosmion.dev
   Flat white and pitch-black canvases; the logo purple is an accent for links, focus and one primary action.
   System fonts only (New York, SF Pro, SF Mono), no third-party requests. */

/* ---------- Tokens ---------- */
:root {
  --purple: #5b53ff;          /* logo purple: primary button fill, focus rings */
  --purple-ink: #4a42ee;      /* purple text on white (5.9:1) */
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --text: #111114;
  --muted: #55565f;
  --faint: #6b6c76;           /* 5.2:1 on white, 4.8:1 on --bg-soft */
  --line: rgba(0, 0, 0, .1);
  --card: #ffffff;
  --nav-bg: rgba(255, 255, 255, .86);
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 28px rgba(0, 0, 0, .07);
  --r-control: 10px;          /* buttons, inputs, chips */
  --r-media: 14px;            /* screenshots, images */
  --r-frame: 20px;            /* interactive tools that need a frame */
  --space-group: 2rem;
  --space-section: clamp(4.5rem, 9vw, 8rem);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --max: 1180px;
  color-scheme: light;
}

/* Dark: pitch black. Applies when the system is dark (unless the visitor chose light), or when chosen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --purple-ink: #9a95ff;
    --bg: #000000;
    --bg-soft: #0c0c0e;
    --text: #f5f5f7;
    --muted: #a4a5ae;
    --faint: #7b7c86;
    --line: rgba(255, 255, 255, .14);
    --card: #000000;
    --nav-bg: rgba(18, 18, 22, .82);
    --shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --purple-ink: #9a95ff;
  --bg: #000000;
  --bg-soft: #0c0c0e;
  --text: #f5f5f7;
  --muted: #a4a5ae;
  --faint: #7b7c86;
  --line: rgba(255, 255, 255, .14);
  --card: #000000;
  --nav-bg: rgba(18, 18, 22, .82);
  --shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
#main, #contact, [id] { scroll-margin-top: 96px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--card); padding: 10px 14px; border-radius: var(--r-control); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

/* ---------- Type: serif for display, sans for reading, mono only for data ---------- */
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
.serif, h1, h2 { font-family: var(--serif); letter-spacing: -.02em; }
h2 { font-size: clamp(32px, 4.4vw, 52px); line-height: 1.08; }
h3 { font-family: var(--sans); font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
p { margin: 0 0 1em; text-wrap: pretty; }
.lead { font-size: clamp(18px, 1.9vw, 21px); color: var(--muted); line-height: 1.5; max-width: 62ch; }
.muted { color: var(--muted); }
.label {                         /* metadata only: platforms, kinds, measurements */
  display: inline-block;
  font: 500 12px/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
}
.label.plain { color: var(--faint); }
.center { text-align: center; margin-left: auto; margin-right: auto; }
.credit { font-size: 12.5px; color: var(--faint); line-height: 1.5; }
.num, table, .readout, dd { font-variant-numeric: tabular-nums; }

/* ---------- Floating nav ---------- */
.nav {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--nav-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  max-width: calc(100vw - 24px);
}
.nav .logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.nav .logo img { width: 24px; height: 24px; }
.nav a.link {
  display: inline-flex; align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  padding: 0 13px;
  border-radius: 999px;
  white-space: nowrap;
}
.nav a.link[aria-current="page"] { background: var(--bg-soft); }
.theme-toggle {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text);
  cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
/* Small screens: the app links move into a menu (works without JavaScript: <details>). */
.nav-menu { display: none; position: relative; }
.nav-menu summary { list-style: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; color: var(--text); }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.nav-sheet { position: absolute; right: -48px; top: calc(100% + 10px); min-width: 220px; padding: 6px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; }
.nav-sheet a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r-control); color: var(--text); text-decoration: none; font-weight: 500; }
.nav-sheet a[aria-current="page"] { color: var(--purple-ink); }
.nav-sheet hr { border: 0; border-top: 1px solid var(--line); margin: 6px 8px; }
@media (max-width: 620px) {
  .nav a.link { display: none; }
  .nav-menu { display: block; }
  .nav .nav-title { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px 0 2px; white-space: nowrap; color: var(--text); text-decoration: none; font: 400 19px/1 var(--serif); }
}
@media (min-width: 621px) { .nav .nav-title { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  font: 500 15px/1 var(--sans);
  text-decoration: none;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status { font: 500 12px/1.4 var(--mono); letter-spacing: .04em; color: var(--faint); }

/* ---------- Hero: flat canvas, solid ink, the product in front ---------- */
.hero {
  padding: 128px 0 0;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.hero .tagline { font-family: var(--serif); font-size: clamp(21px, 2.6vw, 30px); line-height: 1.25; color: var(--muted); margin: 0 auto 10px; max-width: 32ch; padding: 0 16px; text-wrap: balance; }
.hero h1 {
  font-size: clamp(48px, 11vw, 168px);
  line-height: .95;
  letter-spacing: -.04em;
  margin: 0;
  padding: 0 16px;
}
.hero .stage { max-width: 1080px; margin: clamp(32px, 5vw, 64px) auto 0; padding: 0 24px; position: relative; }
.hero .stage .phone { position: absolute; width: 19%; right: 2%; bottom: -7%; }
.hero .sub { font-size: 15px; color: var(--muted); margin: 0; padding: 56px 16px 20px; }
.hero .actions { justify-content: center; }
.hero-small { padding-bottom: clamp(56px, 8vw, 88px); text-align: left; }
.hero-small > * { max-width: var(--max); margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; }
.hero-small .tagline { font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); max-width: var(--max); margin: 0 auto 18px; padding: 0 24px; }
.hero-small h1 { font-size: clamp(40px, 6.4vw, 84px); line-height: 1.02; letter-spacing: -.03em; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.hero-small .lead { margin-top: 22px; padding-right: max(24px, calc(min(100%, var(--max)) - 62ch - 24px)); }
@media (max-width: 700px) {
  .hero { padding-top: 96px; }
  .hero .stage { padding: 0 16px; }
  .hero .stage .phone { width: 26%; right: 4%; bottom: -10%; border-width: 3px; border-radius: 16px; }
  .hero .sub { padding: 40px 16px 16px; }
  .hero-small > *, .hero-small .tagline, .hero-small h1 { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Device frames: real screenshots on a neutral mat ---------- */
.mac { border-radius: var(--r-media); overflow: hidden; border: 1px solid var(--line); background: #000; box-shadow: var(--shadow); }
.phone {
  border-radius: 36px; overflow: hidden;
  border: 5px solid #1c1c20;
  background: #000;
  aspect-ratio: 1320 / 2868;
  box-shadow: var(--shadow);
}
.phone img { width: 100%; height: 100%; object-fit: cover; }
.tablet { border-radius: 22px; overflow: hidden; border: 6px solid #1c1c20; background: #000; box-shadow: var(--shadow); }

/* ---------- Sections ---------- */
section { padding: var(--space-section) 0; }
.section-head { max-width: 760px; margin: 0 0 calc(var(--space-group) * 1.5); }
.section-head p { margin-top: 16px; }
.statement { font-family: var(--serif); font-size: clamp(26px, 3.2vw, 40px); line-height: 1.25; letter-spacing: -.01em; max-width: 30ch; margin: 0; text-wrap: pretty; }
.statement .muted { color: var(--faint); }

/* ---------- Steps (numbered list + sticky screenshot) ---------- */
.steps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: start; }
.step { padding: 28px 0 28px 22px; border-left: 1px solid var(--line); transition: opacity .3s ease, border-color .3s ease; }
.step .num { font: 500 12px/1 var(--mono); color: var(--faint); letter-spacing: .06em; }
.step h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 2.6vw, 32px); line-height: 1.2; margin: 10px 0 10px; letter-spacing: -.015em; }
.step p { color: var(--muted); max-width: 46ch; }
.step .step-media { margin-top: 24px; }
.step .step-media .phone { width: 240px; max-width: 70%; }
.steps-stage { display: none; }
.js .steps-list .step { min-height: 62vh; display: flex; flex-direction: column; justify-content: center; opacity: .4; }
.js .steps-list .step.active { opacity: 1; border-left-color: var(--text); }
.js .steps-list .step .step-media { display: none; }
.js .steps-stage {
  display: grid; place-items: center;
  position: sticky; top: 100px;
  height: calc(100vh - 200px); min-height: 480px;
  border-radius: var(--r-frame);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.steps-stage .phone { grid-area: 1 / 1; height: 86%; width: auto; opacity: 0; transform: translateY(10px); transition: opacity .35s ease, transform .35s ease; }
.steps-stage .phone.active { opacity: 1; transform: none; }
@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr; gap: 0; }
  .js .steps-stage { display: none; }
  .js .steps-list .step { min-height: 0; opacity: 1; display: block; }
  .js .steps-list .step .step-media { display: block; }
}

/* ---------- Ruled columns (formerly cards): unboxed text under a hairline ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); column-gap: 40px; row-gap: 40px; }
.card {
  grid-column: span 2;
  border-top: 1px solid var(--line);
  padding: 20px 0 0;
  min-width: 0;   /* long code lines scroll inside instead of widening the column */
}
.card.wide { grid-column: span 3; }
.card.full { grid-column: span 6; }
.card-title, .card > h3:first-child { font: 600 17px/1.3 var(--sans); letter-spacing: -.01em; margin: 0 0 8px; color: var(--text); }
.card p { color: var(--muted); }
.card p.big { color: var(--text); font-size: 19px; line-height: 1.45; }
.card p:last-child { margin-bottom: 0; }
.card .media { margin-top: 24px; padding: 24px 24px 0; background: var(--bg-soft); border-radius: var(--r-media) var(--r-media) 0 0; }
.card .media .tablet { max-width: 360px; margin: 0 auto; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 0; }
.card.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: end; }
.card.split > div:first-child { align-self: center; padding-bottom: 24px; }
.card.split .media { margin: 0; }
@media (max-width: 960px) { .card, .card.wide { grid-column: span 3; } }
@media (max-width: 700px) { .card.split { grid-template-columns: 1fr; gap: 0; } }
@media (max-width: 640px) { .bento { grid-template-columns: 1fr; row-gap: 28px; } .card, .card.wide, .card.full { grid-column: auto; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { padding: 8px 12px; border-radius: var(--r-control); border: 1px solid var(--line); font-size: 14.5px; }
.chip b { font-weight: 600; }
.chip span { color: var(--muted); }

/* ---------- Spec table: the site's signature (hairlines, serif display, mono values) ---------- */
.spec { width: 100%; border-collapse: collapse; margin: 0; }
.spec th, .spec td { text-align: left; vertical-align: baseline; padding: 14px 0; border-top: 1px solid var(--line); }
.spec tr:last-child th, .spec tr:last-child td { border-bottom: 1px solid var(--line); }
.spec th { width: 40%; padding-right: 24px; font: 500 15px/1.4 var(--sans); color: var(--muted); }
.spec td { font: 500 15px/1.45 var(--mono); color: var(--text); }
.spec td span { display: block; margin-top: 2px; font: 14px/1.45 var(--sans); color: var(--muted); }
@media (max-width: 560px) { .spec th { width: 46%; } }

/* ---------- Featured app (home): two columns under a rule, no box ---------- */
.feature {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 48px;
}
.feature h2 { margin: 0 0 14px; }
.feature .phones { display: flex; gap: 18px; justify-content: center; }
.feature .phone { width: 46%; max-width: 220px; }
.feature .phone:nth-child(2) { transform: translateY(34px); }
@media (max-width: 860px) { .feature { grid-template-columns: 1fr; gap: 40px; padding-bottom: 32px; } }

/* ---------- Contact rows ---------- */
.contacts { display: grid; }
.contact { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; padding: 18px 0; border-top: 1px solid var(--line); }
.contact:last-child { border-bottom: 1px solid var(--line); }
.contact h3 { font-size: 17px; }
.contact a { font-weight: 600; }

/* ---------- Closing ---------- */
.closing { padding-bottom: 56px; }
.closing h2 { margin-bottom: 18px; }

/* ---------- Document pages ---------- */
.doc { padding: 128px 0 40px; }
.doc h1 { font-size: clamp(38px, 6vw, 60px); line-height: 1.05; letter-spacing: -.025em; margin-bottom: 14px; }
.doc h2 { font-size: clamp(24px, 3vw, 30px); margin: 48px 0 12px; }
.doc h3 { margin: 30px 0 6px; font-size: 18px; }
.doc p, .doc li { max-width: 68ch; }
.doc ul { padding-left: 22px; }
.doc li { margin-bottom: 8px; }
.doc .muted { font: 500 13px/1.5 var(--mono); letter-spacing: .04em; color: var(--faint); }
.doc .lead { margin-top: 8px; }
.doc .card { margin: 28px 0; padding: 20px 22px; background: var(--bg-soft); border: 0; border-radius: var(--r-media); }
.doc .card p { color: var(--text); margin-bottom: .6em; }
.doc .card p:last-child { margin-bottom: 0; }
.doc .card .muted { letter-spacing: 0; font: 14.5px/1.5 var(--sans); color: var(--muted); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 56px 0 48px; margin-top: 40px; font: 15px/1.6 var(--sans); }
.footer .cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.footer .footer-head { margin: 0 0 10px; font: 600 13px/1.4 var(--sans); color: var(--text); }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer .brand { display: flex; align-items: center; gap: 10px; font: 400 22px/1 var(--serif); color: var(--text); }
.footer .brand img { width: 28px; height: 28px; }
.footer .motto { margin-top: 12px; color: var(--faint); }
.footer .visits { flex-basis: 100%; margin: 0; }
.footer .bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }
.footer .facts { font: 500 12px/1.6 var(--mono); letter-spacing: .02em; }
@media (max-width: 760px) { .footer .cols { grid-template-columns: 1fr 1fr; } .footer .cols > :first-child { grid-column: 1 / -1; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Projects: one ruled row per app ---------- */
.projects { display: grid; }
.project {
  display: grid; grid-template-columns: 96px 1fr; gap: 32px; align-items: start;
  padding: 40px 0; border-top: 1px solid var(--line);
}
.project:last-child { border-bottom: 1px solid var(--line); }
.project h2 { font-size: clamp(30px, 3.4vw, 40px); margin: 8px 0 10px; }
.project p.big { font-size: 19px; line-height: 1.45; color: var(--text); }
.project p { max-width: 64ch; }
.project .actions { margin-top: 20px; }
.app-icon { width: 96px; height: 96px; border-radius: 22.37%; box-shadow: var(--shadow); }
.small { font-size: 14.5px; }
@media (max-width: 640px) {
  .project { grid-template-columns: 1fr; padding: 32px 0; gap: 16px; }
  .app-icon { width: 72px; height: 72px; }
}


/* ---------- Shared bits: code, kbd, tables, status colours ---------- */
:root { --ok: #15803d; --warn: #b45309; --hot: #b91c1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ok: #4ade80; --warn: #fbbf24; --hot: #f87171; } }
:root[data-theme="dark"] { --ok: #4ade80; --warn: #fbbf24; --hot: #f87171; }
code, kbd { font: 500 0.88em/1.4 var(--mono); }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--bg-soft); white-space: nowrap; }
pre.code { margin: 14px 0; padding: 14px 16px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--line); overflow-x: auto; }
pre.code code { font-size: 13px; }
.table-card { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--card); }
.table-card table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table-card th, .table-card td { text-align: left; vertical-align: top; padding: 14px 18px; border-top: 1px solid var(--line); }
.table-card thead th { border-top: 0; font: 500 12px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.table-card tbody th { font-weight: 600; white-space: nowrap; }
.table-card td { color: var(--muted); }
.card.split .media img { display: block; width: 100%; }

/* ---------- Zephyr demo ---------- */
.zdemo { border: 1px solid var(--line); border-radius: var(--r-frame); padding: 22px; background: var(--card); }
.zdemo-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 16px; }
.sim-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  font: 500 11.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--bg-soft); }
.sim-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }
.zstatus { font: 500 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.zdemo.failsafe .zstatus { color: var(--hot); }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.segmented button { flex: 1 0 auto; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: 500 14.5px/1 var(--sans); cursor: pointer; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--purple); color: #fff; box-shadow: 0 2px 10px rgba(91, 83, 255, .3); }
.zdesc { margin: 12px 4px 16px; font-size: 15px; }
.zgrid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; }
.zpanel { border: 1px solid var(--line); border-radius: 20px; padding: 12px; background: var(--bg-soft); }
.curve-svg { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.curve-svg .grid line { stroke: var(--line); stroke-width: 1; }
.curve-svg .grid text, .curve-svg .danger-label { font: 500 11px var(--mono); fill: var(--faint); }
.curve-svg .danger { fill: rgba(185, 28, 28, .08); }
.curve-svg .danger-label { fill: var(--hot); }
.curve-svg .policy { fill: none; stroke: var(--purple); stroke-width: 3; stroke-linecap: round; }
.curve-svg .curve-line { fill: none; stroke: var(--purple); stroke-width: 3; stroke-linejoin: round; display: none; }
.curve-svg .node { display: none; cursor: grab; outline: none; }
.curve-svg.editing .curve-line, .curve-svg.editing .node { display: inline; }
.curve-svg .node .hit { fill: transparent; }
.curve-svg .node .knob { fill: var(--card); stroke: var(--purple); stroke-width: 3; transition: r .15s ease; }
.curve-svg .node:focus-visible .knob, .curve-svg .node.dragging .knob { r: 11; fill: var(--purple); }

.curve-svg .op-line { stroke: var(--faint); stroke-dasharray: 3 4; }
.curve-svg .op-dot { fill: var(--text); stroke: var(--card); stroke-width: 3; }
.zdemo.failsafe .curve-svg .op-dot { fill: var(--hot); }
.zcontrols { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; padding: 10px 6px 4px; }
.zfield { display: grid; gap: 6px; }
.zfield select { min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 15px var(--sans); }
.zfield input[type="range"] { width: 200px; accent-color: var(--purple); }
.manual-only, .curve-only { display: none !important; }
.zdemo[data-mode="manual"] .manual-only { display: grid !important; }
.zdemo[data-mode="curve"] .curve-only { display: inline-flex !important; }
.zside { display: grid; gap: 12px; align-content: start; }
.readout { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; background: var(--card); }
.readout p { margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.readout b { font: 600 34px/1.1 var(--sans); letter-spacing: -.02em; }
.readout small { margin-left: 4px; color: var(--muted); font-size: 15px; }
.readout[data-level="warm"] b { color: var(--warn); }
.readout[data-level="hot"] b { color: var(--hot); }
.zbar { height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin: 8px 0 6px; }
.zbar i { display: block; height: 100%; width: 30%; background: var(--purple); border-radius: inherit; }
.zdemo.failsafe .zbar i { background: var(--hot); }
.history-svg { width: 100%; height: 64px; display: block; margin: 8px 0 6px; }
.history-svg polyline { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.history-svg .h-temp { stroke: var(--warn); }
.history-svg .h-fan { stroke: var(--purple); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-left: 6px; }
.legend .lt { background: var(--warn); margin-left: 0; } .legend .lf { background: var(--purple); }
.zdemo .credit { margin: 16px 4px 0; }
@media (max-width: 860px) {
  .zgrid { grid-template-columns: 1fr; }
  .zside { grid-template-columns: 1fr 1fr; }
  .zside .readout:last-child { grid-column: 1 / -1; }
  .zdemo { padding: 14px; border-radius: 22px; }
  .readout b { font-size: 28px; }
}

/* ---------- Buttons: variants ---------- */
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }

.btn.small { padding: 7px 14px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
button.btn { cursor: pointer; font-family: var(--sans); }

/* ---------- File Converter web tool ---------- */
.converter { border: 1px solid var(--line); border-radius: var(--r-frame); padding: 22px; background: var(--card); }
.dropzone { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 40px 20px; border: 2px dashed var(--line);
  border-radius: 20px; background: var(--bg-soft); cursor: pointer; transition: border-color .2s ease, background-color .2s ease; }
.dropzone.over { border-color: var(--purple); background: rgba(91, 83, 255, .06); }

.dropzone:focus-within { outline: 2px solid var(--purple); outline-offset: 3px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone b { font-size: 18px; }
.dropzone .small { max-width: 520px; }
.dz-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.dz-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--purple-ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copts { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: end; margin: 18px 4px 4px; }
.copts input[type="number"] { width: 150px; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 15px var(--sans); }
.copts input[type="range"] { width: 180px; accent-color: var(--purple); }
.cnote { margin: 8px 4px 0; min-height: 1em; }
.clist { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.citem { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-soft); }
.cthumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--card); }
.ctype { display: grid; place-items: center; font: 600 13px var(--mono); color: var(--purple-ink); border: 1px solid var(--line); }
.cbody { display: grid; gap: 2px; min-width: 0; }
.cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmeta, .cdim { font-size: 13.5px; color: var(--muted); }
.cmac { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.cact { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill-delta { justify-self: start; margin-top: 4px; padding: 3px 10px; border-radius: 999px; font: 600 12.5px/1.4 var(--mono); }
.pill-delta.down { color: var(--ok); background: rgba(21, 128, 61, .12); }
.pill-delta.up { color: var(--warn); background: rgba(180, 83, 9, .12); }
.cbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.cpdf:not(:empty) { margin-top: 12px; display: flex; justify-content: flex-end; }
.cstatus { margin: 14px 4px 0; font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
@media (max-width: 640px) {
  .converter { padding: 14px; border-radius: 22px; }
  .citem { grid-template-columns: 52px minmax(0, 1fr); }
  .cthumb { width: 52px; height: 52px; }
  .cact { grid-column: 1 / -1; justify-content: flex-start; }
}
a.more-app { color: inherit; text-decoration: none; }

a.more-app img { width: 56px; height: 56px; border-radius: 22.37%; margin-bottom: 16px; box-shadow: var(--shadow); }
a.more-app .big { font-family: var(--serif); font-size: 28px; margin: 4px 0 8px; }
@media (max-width: 640px) {
  .segmented { display: grid; grid-template-columns: repeat(6, 1fr); }
  .segmented button { grid-column: span 2; padding: 8px 6px; font-size: 14px; }
  .segmented button:nth-child(4), .segmented button:nth-child(5) { grid-column: span 3; }
  .curve-svg .grid text, .curve-svg .danger-label { font-size: 19px; }
  .curve-svg .node .knob { stroke-width: 4; }
  .sim-badge { font-size: 10.5px; }
}

/* ---------- Infinite Sky: world pages ---------- */
.world { padding: 110px 0 20px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font: 500 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 28px; }
.crumbs a { color: var(--muted); text-decoration: none; }

.world-head { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.world-head h1 { font-size: clamp(44px, 7vw, 84px); line-height: 1; margin: 12px 0 10px; letter-spacing: -.03em; }
.world-rel { margin: 0 0 18px; font-size: 17px; }
.world-rel a { color: var(--muted); }
.world-visual figure { margin: 0; }
.world-visual img { width: 100%; border-radius: 22px; box-shadow: var(--shadow); background: #000; }
.world-visual figcaption { margin-top: 12px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.credit-line { display: block; margin-top: 4px; font-size: 12.5px; color: var(--faint); }
.orb { width: min(320px, 70%); aspect-ratio: 1; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--orb) 35%, #fff) 0%, var(--orb) 45%, color-mix(in srgb, var(--orb) 40%, #000) 100%);
  box-shadow: 0 30px 80px color-mix(in srgb, var(--orb) 35%, transparent), inset -18px -24px 60px rgba(0, 0, 0, .35); }
.world-fact { margin: 48px 0 0; padding: 4px 0 4px 22px; border-left: 2px solid var(--text); max-width: 46em; }
.world-fact p { margin: 0; font-family: var(--serif); font-size: clamp(20px, 2.4vw, 26px); line-height: 1.35; }
.world-section { padding: 56px 0 0; }
.world-section h2 { font-size: clamp(26px, 3vw, 34px); margin-bottom: 18px; }
.world-section .table-card th { width: 34%; }
.chiplist, .links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.links { display: grid; gap: 10px; }
.chip-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; font-size: 15px; }

.chip-link .dot { width: 10px; height: 10px; border-radius: 50%; }
.world-cta { padding: 72px 0 40px; }
.band { border-top: 1px solid var(--line); padding-top: 40px; }
.band .actions { margin-top: 20px; }
@media (max-width: 820px) {
  .world { padding-top: 96px; }
  .world-head { grid-template-columns: 1fr; gap: 28px; }
  .world-section .table-card th { width: auto; white-space: normal; }
}

/* ---------- Infinite Sky: worlds catalogue ---------- */
.world-filter { position: sticky; top: 76px; z-index: 5; display: grid; gap: 12px; padding: 14px; margin-bottom: 28px; border-radius: 22px;
  background: var(--nav-bg); border: 1px solid var(--line); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-height: 44px; border: 0; background: transparent; color: var(--text); font: 16px var(--sans); outline: none; }
.kind-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.kind-chips button { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 500 14px var(--sans); cursor: pointer; }
.kind-chips button[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.world-filter [data-count]:empty { display: none; }
.world-group { padding: 8px 0 36px; scroll-margin-top: 220px; }
.world-group h2 { font-size: clamp(24px, 2.6vw, 30px); margin-bottom: 16px; }
.world-group .count { font: 500 14px var(--mono); color: var(--faint); vertical-align: middle; margin-left: 6px; }
.world-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.world-card { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--r-media); border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; height: 100%; }

.world-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; flex: none; background: #000; }
.world-card b { display: block; font-weight: 600; }
.world-card .small { display: block; }
.mini-orb { width: 44px; height: 44px; margin: 6px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--orb) 35%, #fff) 0%, var(--orb) 50%, color-mix(in srgb, var(--orb) 45%, #000) 100%); }
.credits-table { margin: 18px 0 8px; }
.credits-table tbody th { white-space: normal; }
.credits-table tbody th img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 8px; }
.credits-table td { font-size: 14.5px; }
.doc .crumbs { margin-bottom: 18px; }

/* ---------- Cosmo ---------- */
.cosmo-fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 70;
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px 11px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--nav-bg); color: var(--text); font: 600 15px var(--sans); cursor: pointer;
  box-shadow: var(--shadow); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }

.cosmo-fab svg, .cosmo-avatar svg { width: 20px; height: 20px; fill: none; stroke: var(--purple-ink); stroke-width: 1.8; stroke-linejoin: round; }
@media (max-width: 560px) { .cosmo-fab span { display: none; } .cosmo-fab { padding: 13px; } }
.cosmo { width: min(560px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 40px)); padding: 0; border: 1px solid var(--line);
  border-radius: 28px; background: var(--card); color: var(--text); box-shadow: 0 30px 100px rgba(0, 0, 0, .35); overflow: hidden; }
.cosmo[open] { display: flex; flex-direction: column; }
.cosmo::backdrop { background: rgba(5, 5, 20, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.cosmo-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cosmo-avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(91, 83, 255, .12); }
.cosmo-name { margin: 0; font: 600 17px var(--sans); }
.cosmo-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.cosmo-close { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 14px; }
.cosmo-log { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; min-height: 160px; }
.cosmo-msg { max-width: 88%; padding: 12px 15px; border-radius: 18px; font-size: 15.5px; line-height: 1.5; animation: cosmo-in .18s ease-out; }
.cosmo-msg p { margin: 0 0 8px; } .cosmo-msg p:last-child { margin-bottom: 0; }
.cosmo-msg.me { justify-self: end; background: var(--purple); color: #fff; border-bottom-right-radius: 6px; }
.cosmo-msg.bot { justify-self: start; background: var(--bg-soft); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.cosmo-msg dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 6px 0 0; font-size: 14.5px; }
.cosmo-msg dt { color: var(--muted); } .cosmo-msg dd { margin: 0; font-weight: 600; }
.cosmo-fact { color: var(--muted); font-style: italic; }
.cosmo-src { display: inline-block; margin-top: 8px; padding: 2px 8px; border-radius: 999px; font: 500 11px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--purple-ink); background: rgba(91, 83, 255, .1); }
.cosmo-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14.5px; font-weight: 600; }
.cosmo-related, .cosmo-starters { display: flex; flex-wrap: wrap; gap: 6px; }
.cosmo-related { margin-top: 10px; }
.cosmo-starters { padding: 0 18px 12px; }
.cosmo-starters[hidden] { display: none; }
.cosmo-chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 500 14px var(--sans); cursor: pointer; text-align: left; }

.cosmo-form { display: flex; gap: 8px; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.cosmo-form input { flex: 1; min-height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); font: 16px var(--sans); outline: none; }
.cosmo-form input:focus { border-color: var(--purple); }
.cosmo-form button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--purple); color: #fff; font: 600 20px var(--sans); cursor: pointer; }
@keyframes cosmo-in { from { opacity: 0; transform: translateY(4px); } }
@media (max-width: 560px) {
  .cosmo { width: 100vw; max-width: 100vw; max-height: 88dvh; margin: auto 0 0; border-radius: 26px 26px 0 0; }
}
@media (max-width: 560px) {
  .world-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .world-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .world-card img { width: 44px; height: 44px; }
  .mini-orb { width: 36px; height: 36px; margin: 4px; }
  .world-card b { font-size: 15px; }
  .world-filter { top: 70px; }
}
@media (max-width: 640px) {
  .credits-table table, .credits-table tbody, .credits-table tr, .credits-table th, .credits-table td { display: block; width: auto; }
  .credits-table thead { display: none; }
  .credits-table tr { border-top: 1px solid var(--line); padding: 10px 0; }
  .credits-table tr:first-child { border-top: 0; }
  .credits-table th, .credits-table td { border: 0; padding: 4px 16px; }
}

/* ---------- Infinite Sky: 3D explorer (always dark, like space) ---------- */
.explorer-page .footer { display: none; }
.explorer { position: relative; height: 100dvh; min-height: 480px; overflow: hidden; background: #000; color: #fff; --glass: rgba(18, 18, 26, .72); --gline: rgba(255, 255, 255, .12); }
.explorer-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.explorer-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.xlabel { position: absolute; left: 0; top: 0; padding: calc(var(--off, 4px) + 6px) 0 0; border: 0; background: none; color: rgba(255, 255, 255, .78);
  font: 500 12px/1.2 var(--sans); cursor: pointer; pointer-events: auto; white-space: nowrap; }
.xlabel span { display: block; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .35); }
.xlabel i { position: absolute; left: 50%; top: -3px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: currentColor; opacity: 0; }
.xlabel.tiny i { opacity: .9; }
.xlabel.focus { color: #fff; }

.xlabel.focus span { background: rgba(91, 83, 255, .8); }
.xlabel.k-planet, .xlabel.k-star { font-size: 13px; color: rgba(255, 255, 255, .92); }
/* Spacecraft: a small cyan diamond, always shown (they have no size to draw). */
.xlabel.k-spacecraft { font-size: 12px; color: #9ee8ff; }
.xlabel.k-spacecraft i { opacity: 1; width: 7px; height: 7px; margin-left: -3.5px; top: -4px; border-radius: 1px; background: #7fe3ff; transform: rotate(45deg); box-shadow: 0 0 6px rgba(127, 227, 255, .8); }
.explorer-loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: #a3a4b4; font-size: 15px; text-align: center; padding: 24px; }
.explorer-loading a { color: #9a95ff; }
.spinner { width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: #8f89ff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.explorer-noscript { position: absolute; inset: auto 16px 50% 16px; text-align: center; color: #a3a4b4; }
.explorer .glass, .xpanel, .xbodies, .xbar { background: var(--glass); border: 1px solid var(--gline); -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px); color: #fff; }
.xpanel { position: absolute; right: 16px; top: 84px; width: 340px; max-height: calc(100% - 190px); overflow-y: auto; padding: 20px 22px; border-radius: 22px; }
.xpanel h2 { font-size: 30px; margin: 8px 0 2px; }
.xpanel .label { color: #9a95ff; }
.xpanel .muted { color: #a3a4b4; margin-bottom: 10px; }
.xpanel p { font-size: 15px; line-height: 1.5; }
.xpanel dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 16px; font-size: 13.5px; }
.xpanel dt { color: #a3a4b4; } .xpanel dd { margin: 0; }
.xpanel-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; }
.xbodies { position: absolute; left: 16px; top: 84px; bottom: 96px; width: 320px; display: flex; flex-direction: column; border-radius: 22px; overflow: hidden; }
.xbodies-head { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid var(--gline); }
.xbodies-head .xpanel-close { position: static; flex: none; }
.xbodies .search { flex: 1; background: rgba(255, 255, 255, .08); border-color: var(--gline); }
.xbodies .search input { color: #fff; min-height: 38px; }
.xbodies-list { overflow-y: auto; padding: 6px 12px 14px; }
.xbodies-list h3 { margin: 14px 4px 6px; font: 500 11.5px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #8b8d9c; }
.xbodies-list ul { list-style: none; margin: 0; padding: 0; }
.xbodies-list button { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: #fff; font: 15px var(--sans); text-align: left; cursor: pointer; }
.xbodies-list button:focus-visible { background: rgba(255, 255, 255, .08); }

.xbodies-list button span { color: #8b8d9c; font-size: 13px; }
.xbar { position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 999px; max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; }
.xbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .08); color: #fff; font: 500 14.5px var(--sans); cursor: pointer; white-space: nowrap; }

.xbtn.icon { width: 40px; padding: 0; justify-content: center; }
.xbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.xbtn .i-play { fill: currentColor; stroke: none; }
.xbtn .i-pause { display: none; }
.explorer.playing .xbtn .i-play { display: none; } .explorer.playing .xbtn .i-pause { display: block; }
.xbtn[aria-pressed="true"] { background: #5b53ff; }
.xsep { width: 1px; height: 22px; background: var(--gline); flex: none; }
.xselect select, .xdate input { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, .08); color: #fff; font: 14.5px var(--sans); color-scheme: dark; }
.explorer-note { position: absolute; left: 16px; bottom: 8px; max-width: 360px; margin: 0; color: rgba(255, 255, 255, .6); font-size: 11px; }
.explorer-note a { color: rgba(255, 255, 255, .7); }
.explorer-page .cosmo-fab { top: 14px; bottom: auto; }
@media (max-width: 1100px) { .explorer-note { display: none; } }
@media (max-width: 760px) {
  .explorer-page .cosmo-fab { top: auto; bottom: calc(var(--xbar-h, 56px) + 28px + env(safe-area-inset-bottom)); }
  .xpanel { left: 12px; right: 12px; top: auto; bottom: calc(var(--xbar-h, 56px) + 24px + env(safe-area-inset-bottom)); width: auto; max-height: 42%; padding: 16px 18px; }
  /* Large sheets over the live 3D view: a solid dark backing instead of a blur recomputed every frame. */
  .xpanel, .xbodies { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(14, 14, 20, .98); }
  .xpanel h2 { font-size: 24px; }
  .xpanel dl { display: none; }
  .xbodies { left: 12px; right: 12px; top: 80px; bottom: calc(80px + env(safe-area-inset-bottom)); width: auto; }
  /* Phones: the controls wrap onto a second row instead of running off the screen; panels sit above the bar's
     measured height (--xbar-h, set by the explorer script). */
  .xbar { left: 12px; right: 12px; transform: none; justify-content: center; flex-wrap: wrap; overflow: visible; border-radius: 24px; }
  .xbtn span { display: none; }
  .xbtn[data-open-bodies] { width: 40px; padding: 0; justify-content: center; }
  .xdate input { width: 140px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media (max-width: 760px) {
  .xpanel { max-height: 34%; }
  .xpanel h2 { font-size: 22px; margin-top: 4px; }
  .xpanel [data-p-summary] { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; margin-bottom: 10px; }
  .xpanel .muted { margin-bottom: 6px; }
  .explorer-page:has(.xpanel:not([hidden])) .cosmo-fab { display: none; }
  .xsep { display: none; }
  .xbar { gap: 4px; }
  .xselect select { padding: 0 8px; max-width: 108px; }
  .xdate input { width: 128px; padding: 0 8px; }
  .xbtn[data-today], .xbtn[data-scale] { padding: 8px 11px; }
}
.xbodies-list section { padding: 0; }

/* ---------- Infinite Sky: Learn ---------- */
.tour-list { display: grid; }
.tour { display: grid; grid-template-columns: 48px 1fr auto; gap: 24px; align-items: start; padding: 28px 0; border-top: 1px solid var(--line); }
.tour:last-child { border-bottom: 1px solid var(--line); }
.tour .num { font: 500 13px/1.8 var(--mono); color: var(--faint); }
.tour h3 { font: 400 26px/1.2 var(--serif); letter-spacing: -.01em; margin-bottom: 4px; }
.tour p { margin-bottom: 10px; }
.tour-stops { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; font-size: 14.5px; color: var(--muted); }
.tour-stops li + li::before { content: "→"; margin: 0 8px; color: var(--faint); }
@media (max-width: 640px) { .tour { grid-template-columns: 1fr; gap: 10px; } .tour .num { display: none; } .tour .btn { justify-self: start; } }
.lessons { display: grid; }
.lesson { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; padding: 32px 0; border-top: 1px solid var(--line); }
.lesson:last-child { border-bottom: 1px solid var(--line); }
.lesson h3 { font: 400 26px/1.2 var(--serif); letter-spacing: -.01em; margin-bottom: 10px; }
.lesson-text p { max-width: 60ch; }
.lesson-highlight { padding-left: 16px; border-left: 2px solid var(--text); color: var(--text); }
.quiz-q { font-weight: 600; margin-bottom: 12px; }
.quiz-q .label { display: block; margin-bottom: 6px; font-weight: 500; }
.quiz-choices { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.quiz-choice { width: 100%; display: flex; gap: 12px; align-items: baseline; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-control); background: transparent; color: var(--text); font: 15.5px/1.4 var(--sans); text-align: left; cursor: pointer; }
.quiz-choice b { font: 600 13px/1.4 var(--mono); color: var(--faint); }
.quiz-choice:disabled { cursor: default; }
.quiz-choice.right { border-color: var(--ok); }
.quiz-choice.right b { color: var(--ok); }
.quiz-choice.wrong { border-color: var(--hot); }
.quiz-choice.wrong b { color: var(--hot); }
.quiz:not(.answered) .quiz-choice:disabled { opacity: .6; }
.quiz-answer summary { cursor: pointer; color: var(--purple-ink); font-size: 15px; }
.quiz-result { margin: 0; font-size: 15px; color: var(--muted); }
.quiz-result:empty { display: none; }
.quiz-again { margin-top: 10px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font: 500 14.5px var(--sans); cursor: pointer; }
@media (max-width: 820px) { .lesson { grid-template-columns: 1fr; gap: 20px; } }

/* Tour panel: the narration scrolls, the Back/Next row always stays in view. */
.xtour:not([hidden]) { display: flex; flex-direction: column; overflow: hidden; }
.xtour-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.xtour-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.xbtn.primary { background: #5b53ff; }
.xbtn:disabled { opacity: .4; cursor: default; }
.xtour .label { color: #9a95ff; margin: 0; }
.xtour h2 { font-size: 26px; margin: 6px 0 8px; padding-right: 36px; }
.xtour .status { color: #a3a4b4; }
.xtour [data-t-link] a { color: #9a95ff; }
@media (max-width: 760px) { .xtour:not([hidden]) { max-height: 44%; } .xtour h2 { font-size: 22px; } }

/* ---------- Night-sky chart ---------- */
.sky { --sky-ink: var(--muted); display: grid; grid-template-columns: minmax(0, 720px) minmax(260px, 1fr); gap: 32px; align-items: start; }
.sky-chart canvas { display: block; max-width: 100%; touch-action: manipulation; }
.sky-how { margin-top: 10px; }
.sky-compass { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.sky-compass p { margin: 0; }
.sky-side { display: grid; gap: 28px; }
.sky-controls { display: grid; gap: 10px; }
.sky-controls .label { margin: 8px 0 0; display: flex; align-items: center; gap: 8px; }
.sky-place { margin: 0; font: 500 22px/1.2 var(--serif); }
.sky-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.sky-field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.sky-field select, .sky-field input { min-height: 44px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line); background: var(--card); color: var(--text); font: 15px var(--sans); }
.sky-field input[type="number"] { width: 120px; }
.sky-coords summary { cursor: pointer; color: var(--purple-ink); font-size: 14.5px; min-height: 32px; display: flex; align-items: center; }
.sky-coords form { margin-top: 8px; }
.sky-toggles { display: grid; gap: 8px; margin-top: 8px; font-size: 15px; }
.sky-toggles label { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.sky-toggles input { width: 18px; height: 18px; accent-color: var(--purple); }
.live-dot { font: 600 11px/1 var(--sans); letter-spacing: .04em; padding: 4px 8px; border-radius: 999px; background: rgba(52, 168, 90, .14); color: #1f7a43; }
.sky-up h2 { font-size: 24px; margin: 0 0 6px; }
.sky-up ul { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.sky-up li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.sky-up .dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.sky-up a { font-weight: 600; }
@media (max-width: 960px) { .sky { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .live-dot { color: #7fe0a3; } }
:root[data-theme="dark"] .live-dot { color: #7fe0a3; }

/* ---------- World pages: planetary system maps and nebula highlights ---------- */
.system-map { margin: 8px 0 28px; display: grid; grid-template-columns: minmax(0, 420px) 1fr; gap: 24px 32px; align-items: center; }
.system-map svg { width: 100%; height: auto; display: block; background: #000; border-radius: var(--r-media); }
.system-map .orbit { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: .5; }
.system-map .orbit.in-hz { stroke: rgba(110, 220, 150, .55); }
.system-map .star-orbit { stroke-dasharray: 2 2; }
.system-map .hz { fill: none; stroke: rgba(70, 200, 120, .16); }
.system-map .ref { fill: none; stroke: rgba(255, 210, 140, .55); stroke-width: .5; stroke-dasharray: 1.5 2; }
.system-map .star { filter: drop-shadow(0 0 4px currentColor); }
.system-map .planet { stroke-width: .8; }
.system-map figcaption { display: grid; gap: 10px; justify-items: start; }
.map-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.map-key .k { display: inline-block; width: 22px; height: 10px; margin-right: 8px; vertical-align: middle; border-radius: 5px; }
.map-key .k.hz { background: rgba(70, 200, 120, .35); }
.map-key .k.ref { height: 0; border-top: 2px dashed rgba(220, 160, 70, .9); border-radius: 0; }
.planet-cards { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.planet-card { display: grid; grid-template-columns: 14px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.planet-card .swatch { width: 14px; height: 14px; border-radius: 50%; margin-top: 6px; }
.planet-card h3 { margin: 0 0 4px; font-size: 19px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.planet-card p { margin: 0 0 6px; }
.badge { font: 600 11.5px/1 var(--sans); letter-spacing: .02em; padding: 5px 8px; border-radius: 999px; background: rgba(52, 168, 90, .14); color: #1f7a43; }
.highlights { margin: 0 0 12px; display: grid; gap: 4px 0; }
.highlights dt { font-weight: 600; margin-top: 10px; }
.highlights dd { margin: 0; color: var(--muted); }
@media (max-width: 720px) { .system-map { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge { color: #7fe0a3; } }
:root[data-theme="dark"] .badge { color: #7fe0a3; }

/* ---------- Explorer: the Milky Way view ---------- */
.xlabel.k-galaxy { font-size: 12.5px; color: rgba(255, 255, 255, .9); }
.xlabel.k-galaxy i { opacity: .95; width: 8px; height: 8px; margin-left: -4px; top: -4px; background: var(--dot, #fff); box-shadow: 0 0 8px var(--dot, #fff); }
.xlabel.here { color: #ffd98a; font-weight: 600; }
/* "You are here": a ring that grows and fades. Only transform and opacity animate, so the compositor does it without
   repainting (an animated box-shadow repaints every frame and kept the CPU busy while the 3D view slept). */
.xlabel.here i { background: #ffd98a; box-shadow: 0 0 0 3px rgba(255, 217, 138, .25), 0 0 12px #ffd98a; }
.xlabel.here i::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid #ffd98a; animation: here-ring 2.4s ease-out infinite; }
@keyframes here-ring { from { transform: scale(.7); opacity: .8; } to { transform: scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .xlabel.here i::after { animation: none; opacity: 0; } }
.xarm { position: absolute; left: 0; top: 0; color: rgba(186, 206, 255, .62); font: italic 500 12px var(--sans); letter-spacing: .02em; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 3px #000; }
.galaxy-view [data-play], .galaxy-view .xselect, .galaxy-view .xdate, .galaxy-view [data-today], .galaxy-view [data-scale], .galaxy-view .xsep { display: none; }
.galaxy-note { display: none; }
.galaxy-view .explorer-note:not(.galaxy-note) { display: none; }
@media (min-width: 1101px) { .galaxy-view .galaxy-note { display: block; } }

/* ---------- Touch screens: every control at least 44 × 44 px ---------- */
@media (pointer: coarse) {
  .xpanel-close, .cosmo-close { width: 44px; height: 44px; }
  .xpanel-close { top: 8px; right: 8px; }
  .xbtn, .xselect select, .xdate input, .xbodies .search input, .segmented button, .xbodies-list button { min-height: 44px; }
  .xbtn.icon, .xbtn[data-open-bodies] { width: 44px; }
  .kind-chips button, .cosmo-chip { min-height: 44px; }
}

/* ---------- Hover: only on devices that can hover (no sticky hover on touch screens) ---------- */
@media (hover: hover) {
  .quiz-choice:not(:disabled):hover { border-color: var(--text); }
  .curve-svg .node:hover .knob { r: 10; }
  .btn.primary:hover { background: var(--purple); color: #fff; filter: brightness(1.08); }
  .dropzone:hover { border-color: var(--purple); background: rgba(91, 83, 255, .06); }
  a.more-app:hover h3, a.more-app:hover .big { color: var(--purple-ink); }
  .crumbs a:hover { color: var(--purple-ink); }
  .chip-link:hover { border-color: var(--purple); color: var(--text); }
  .world-card:hover { border-color: var(--purple); color: var(--text); }
  .cosmo-fab:hover { border-color: var(--purple); }
  .cosmo-chip:hover { border-color: var(--purple); }
  .xlabel:hover { color: #fff; }
  .xbodies-list button:hover { background: rgba(255, 255, 255, .08); }
  .xbtn:hover { background: rgba(255, 255, 255, .16); }
}
