/* R22 IOMMU star map. List ("flight plan") by default; a map on wide screens. */
.star-page h1 em { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400; color: var(--accent); }
.star-page .model-note { margin-block: 18px 8px; }
.star-map { margin-block: 28px 48px; }
.star-paths { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.star-paths[hidden] { display: none; }
.star-paths::before {
  content: "READING PATH";
  margin-right: 6px;
  font: 11px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.star-path {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.star-path[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--button-ink); }

/* Glyphs: guided story = dot + ring, lab = four-point star, reference = hollow dot. */
.star-glyph { position: relative; display: grid; place-items: center; width: 44px; height: 44px; color: var(--ink); }
.star-glyph::before, .star-glyph::after { content: ""; position: absolute; border-radius: 50%; }
.star[data-kind="story"] .star-glyph::before { width: 9px; height: 9px; background: currentColor; }
.star[data-kind="story"] .star-glyph::after { width: 18px; height: 18px; border: 1px solid currentColor; }
.star[data-kind="lab"] .star-glyph::before {
  width: 19px; height: 19px; border-radius: 0; background: currentColor;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
.star[data-kind="ref"] .star-glyph { color: var(--muted); }
.star[data-kind="ref"] .star-glyph::before { width: 10px; height: 10px; border: 1.5px solid currentColor; background: var(--bg); }
.star-traj .star-glyph { transform: scale(1.22); }
.star[data-current] .star-glyph { color: var(--accent); }
.star-link { color: inherit; text-decoration: none; }
.star-link:focus-visible { outline: none; }
.star-link:focus-visible .star-glyph { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 50%; }
.star-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--button-ink);
  font: 700 10px/18px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: center; pointer-events: none;
}
/* On the route: ring, number and bold text, never a dimmed neighbour. */
.star[data-on] .star-glyph { box-shadow: 0 0 0 2px var(--accent) inset; border-radius: 50%; }
.star[data-on] .star-label { font-weight: 700; }
.star-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 0.8125rem; color: var(--muted); }
.star-legend span::before { content: ""; display: inline-block; margin-right: 8px; vertical-align: -1px; background: currentColor; }
.star-legend .legend-story::before { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px currentColor; }
.star-legend .legend-lab::before { width: 13px; height: 13px; clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); }
.star-legend .legend-ref::before { width: 9px; height: 9px; border-radius: 50%; background: transparent; border: 1.5px solid currentColor; }

/* ---- Flight-plan list (no JavaScript, and narrow screens) ---- */
.star-list { position: relative; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.star-list::before { content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px; width: 1px; background: var(--line); }
.star { position: relative; padding: 8px 0 10px; }
.star:not(.star-traj) { margin-left: 30px; }
.star:not(.star-traj)::before { content: ""; position: absolute; left: -9px; top: 30px; width: 14px; height: 1px; background: var(--line); }
.star .star-link { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.star .star-glyph { flex: none; background: var(--bg); border-radius: 50%; }
.star-label { font: var(--label-size)/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.star-detail { margin: 2px 0 0 56px; display: flex; flex-direction: column; gap: 4px; }
.star-detail strong { font-size: 1.05rem; line-height: 1.3; }
.star-detail span { color: var(--muted); font-size: 0.9375rem; line-height: 1.55; }
.star-detail small { font-size: 0.75rem; color: var(--muted); }
.star .star-num { position: absolute; left: 30px; top: 6px; }
.star:not(.star-traj) .star-num { left: 30px; }
.star-sky, .star-card { display: none; }

/* ---- Map (wide screens with JavaScript) ---- */
@media (min-width: 960px) {
  .star-map-live .star-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
  .star-map-live .star-stage {
    position: relative;
    aspect-ratio: 900 / 620;
    border: 1px solid var(--line);
    border-radius: 22px;
    background-color: color-mix(in srgb, var(--bg) 82%, #000);
    background-image: linear-gradient(#ffffff08 1px, transparent 1px), linear-gradient(90deg, #ffffff08 1px, transparent 1px);
    background-size: calc(100% / 15) calc(100% / 10.33);
    overflow: hidden;
  }
  html[data-canvas="light"] .star-map-live .star-stage {
    background-color: var(--surface);
    background-image: linear-gradient(#18203a0a 1px, transparent 1px), linear-gradient(90deg, #18203a0a 1px, transparent 1px);
  }
  .star-map-live .star-sky { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
  .star-sky .sky-dots circle { fill: var(--ink); opacity: 0.5; }
  .star-sky .sky-drops { stroke: var(--line); stroke-dasharray: 1 5; fill: none; }
  .star-sky .sky-axis { stroke: var(--line); fill: none; }
  .star-sky .sky-step { fill: var(--muted); font: 10px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.16em; }
  .star-sky .sky-branches { stroke: color-mix(in srgb, var(--muted) 45%, transparent); fill: none; }
  .star-sky .sky-refs { stroke: color-mix(in srgb, var(--muted) 45%, transparent); stroke-dasharray: 3 5; fill: none; }
  .star-sky .sky-traj-glow { stroke: var(--ink); stroke-width: 6; opacity: 0.06; fill: none; stroke-linejoin: round; }
  .star-sky .sky-traj { stroke: var(--ink); stroke-width: 1.6; opacity: 0.75; fill: none; stroke-linejoin: round; }
  .star-sky .sky-route { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 6 6; fill: none; stroke-linejoin: round; }
  .star-sky .sky-packet .core { fill: var(--accent); }
  .star-sky .sky-packet .halo { fill: var(--accent); opacity: 0.18; }

  .star-map-live .star-list { position: absolute; inset: 0; display: block; }
  .star-map-live .star-list::before { content: none; }
  .star-map-live .star {
    position: absolute; left: calc((var(--x) + var(--dx, 0)) / 900 * 100%); top: calc((var(--y) + var(--dy, 0)) / 620 * 100%);
    width: 0; height: 0; padding: 0; margin: 0;
  }
  .star-map-live .star::before { content: none; }
  .star-map-live .star-link { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; display: block; min-height: 0; }
  .star-map-live .star-glyph { background: transparent; }
  .star-map-live .star[data-current] .star-glyph { box-shadow: 0 0 0 1.5px var(--accent) inset; }
  .star-map-live .star-label {
    position: absolute; white-space: nowrap;
    font: 400 13px/18px var(--body-font, inherit); letter-spacing: 0; text-transform: none;
    color: color-mix(in srgb, var(--ink) 78%, var(--muted));
  }
  .star-map-live .star-traj .star-label { font-size: 14px; font-weight: 600; color: var(--ink); }
  .star-map-live .star[data-current] .star-label { color: var(--accent); }
  .star-map-live .star[data-side="r"] .star-label { left: 40px; top: 13px; }
  .star-map-live .star[data-side="l"] .star-label { right: 40px; top: 13px; }
  .star-map-live .star[data-side="t"] .star-label { left: 22px; top: -30px; transform: translateX(-50%); }
  .star-map-live .star[data-side="b"] .star-label { left: 22px; top: 42px; transform: translateX(-50%); }
  .star-map-live .star-detail {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .star-map-live .star .star-num { left: 8px; top: -30px; }

  .star-map-live .star-card {
    display: flex; flex-direction: column;
    padding: 26px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  }
  .star-map-live .star-card[hidden] { display: none; }
  .star-card .eyebrow { color: var(--accent); margin: 0; }
  .star-card h3 { margin: 12px 0 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.03em; }
  .star-card-desc { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
  .star-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
  .star-chips span { font-size: 0.75rem; font-weight: 600; padding: 5px 10px; border-radius: 12px; background: var(--soft); color: var(--ink); }
  .star-card .star-open { margin-top: 18px; align-self: flex-start; }
  .star-next {
    margin-top: 16px; padding: 12px 0 0; min-height: 44px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink);
    font: inherit; text-align: left; cursor: pointer;
  }
  .star-next .eyebrow { color: var(--muted); font-size: var(--label-size); }
}
@media (min-width: 1200px) {
  .star-map-live .star-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (forced-colors: active) {
  .star-sky .sky-packet { display: none; }
  .star-glyph { forced-color-adjust: none; color: CanvasText; }
  .star[data-current] .star-glyph { color: Highlight; }
}
@media print {
  .star-paths, .star-sky, .star-card { display: none !important; }
}

/* ---- R24: pan, zoom, speckles, bold reading paths and your own constellation ---- */
.star-speckles, .star-tools, .star-hint, .star-builder { display: none; }
.star-world { position: static; }
@media (min-width: 960px) {
  .star-map-live .star-stage { cursor: grab; touch-action: none; outline: none; }
  .star-map-live .star-stage:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
  .star-map-live .star-stage.panning { cursor: grabbing; }
  .star-map-live .star-world { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
  .star-map-live .star-world.glide { transition: transform .35s cubic-bezier(.2,.8,.2,1); }
  /* Stars and labels keep their size while the sky scales around them. */
  .star-map-live .star { transform: scale(calc(1 / var(--k, 1))); transform-origin: 0 0; }
  .star-map-live .star-speckles { display: block; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
  .star-speckles circle { fill: var(--ink); opacity: .28; }
  .star-speckles .depth-2 circle { opacity: .42; }
  .star-speckles .depth-3 circle { opacity: .6; }
  html[data-motion=on] .star-speckles .twinkle { animation: star-twinkle 3s ease-in-out infinite alternate; }
  @keyframes star-twinkle { from { opacity: .08; } to { opacity: .85; } }
  .star-map-live .star-tools { display: flex; position: absolute; z-index: 3; top: 12px; right: 12px; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); }
  .star-tools button { min-width: 36px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
  .star-tools button:disabled { opacity: .4; cursor: default; }
  .star-tools output { min-width: 44px; text-align: center; font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
  .star-tools .star-build[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--button-ink); }
  .star-map-live .star-hint { display: block; margin: 10px 0 0; font-size: .8125rem; color: var(--muted); }
  .star-map-live .star-builder:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; position: absolute; z-index: 3; left: 12px; right: 12px; bottom: 12px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--surface) 94%, transparent); cursor: default; }
  .star-builder p { margin: 0; flex: 1 1 280px; font-size: .875rem; }
  .star-builder div { display: flex; flex-wrap: wrap; gap: 8px; }
  .star-builder .button { min-height: 40px; padding: 0 16px; margin: 0; }
  .star-builder button:not(.button) { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem; cursor: pointer; }
  .star-builder button:disabled { opacity: .45; cursor: default; }
  .building .star-link { cursor: crosshair; }
  /* One bold route in the Remix accent; the structure behind it steps back. */
  .star-sky .sky-route { stroke: var(--accent); stroke-width: 3; stroke-dasharray: none; stroke-linecap: round; fill: none; opacity: 1; }
  .star-sky .sky-route-glow { stroke: var(--accent); stroke-width: 12; opacity: .16; fill: none; stroke-linecap: round; }
  .path-on .star-sky :is(.sky-branches, .sky-traj, .sky-traj-glow, .sky-refs, .sky-drops) { opacity: .12; transition: opacity .3s; }
  .path-on .star-sky .sky-packet { display: none; }
  .path-on .star[data-on] .star-glyph { color: var(--accent); }
  .path-on .star[data-on] .star-label { color: var(--ink); font-weight: 600; }
}
.star-chips .level { background: transparent; border: 1px solid var(--line); }
@media (forced-colors: active) { .star-sky .sky-route { stroke: Highlight; } }

/* R25: constellation gallery. */
.constellations { margin-block: 8px 56px; }
.constellations h2 { margin: 0 0 8px; }
.constellations-deck { color: var(--muted); max-width: 62ch; margin: 0 0 24px; }
.constellation-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.constellation {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: border-color 0.2s ease;
}
.constellation[data-active] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.constellation-art {
  aspect-ratio: 1;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--second) 16%, var(--bg)), var(--bg) 75%);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.constellation-art svg { width: 100%; height: auto; display: block; }
.constellation-figure .cf-speck { fill: var(--muted); opacity: 0.35; }
.constellation-figure .cf-route { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; }
.constellation-figure .cf-star { fill: var(--ink); }
.constellation-figure .cf-seen { fill: var(--accent); }
.constellation-figure .cf-current { fill: var(--accent); }
.constellation-figure .cf-ring { fill: none; stroke: var(--accent); opacity: 0.6; }
.constellation-ghost svg path { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 6; }
.constellation-ghost svg circle { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.constellation-body { min-width: 0; }
.constellation-body .eyebrow { margin: 0; color: var(--accent); }
.constellation-body h3 { margin: 6px 0 8px; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.03em; }
.constellation-body > p:not(.eyebrow) { color: var(--muted); font-size: 0.9375rem; line-height: 1.6; margin: 0 0 10px; }
.constellation-body .constellation-stats { font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.06em; color: var(--ink); }
.constellation-stops { list-style: none; counter-reset: stop; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 4px; font-size: 0.8125rem; line-height: 1.5; }
.constellation-stops li { counter-increment: stop; display: inline-flex; align-items: baseline; gap: 4px; }
.constellation-stops li::before { content: counter(stop); font: 600 10px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--accent); }
.constellation-stops li:not(:last-child)::after { content: "→"; color: var(--muted); margin-left: 4px; }
.constellation-stops a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.constellation-stops a:hover { text-decoration-color: var(--accent); }
.constellation-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0 !important; }
.constellation-actions .button { margin: 0; min-height: 40px; padding: 8px 16px; }
.constellation-actions button:not(.button) { min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font-size: 0.875rem; }
.constellation-actions button:not(.button):hover { border-color: var(--accent); }
.constellation-name input {
  width: 100%;
  margin: 6px 0 8px;
  padding: 4px 0;
  border: 0;
  border-bottom: 1px dashed var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.constellation-name input:focus { outline: none; border-bottom-color: var(--accent); }
.constellation-note { font-size: 0.8125rem; word-break: break-all; margin: 8px 0 0 !important; }
.constellation-note:empty { display: none; }
@media (max-width: 520px) {
  .constellation { grid-template-columns: 1fr; }
  .constellation-art { width: 128px; }
}
/* Opened guides read as lit on the map. */
.star-map-live .star[data-visited] .star-glyph { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 70%, transparent)); }
.constellation-stops li, .constellation-stops a { margin: 0; min-height: 0; padding: 0; }
.constellation-stops a { display: inline-block; min-height: 24px; line-height: 24px; }

/* R30: living stars — a grab cursor, and a lifted glyph while dragging. */
@media (hover: hover) and (pointer: fine) { .star-map-live:not(.building) .star-link { cursor: grab; } .star-map-live .star[data-dragging] .star-link { cursor: grabbing; } }
.star-map-live .star[data-dragging] .star-glyph { color: var(--accent); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 70%, transparent)); }
/* R40: the chapter map, the guide in reading order. */
.chapter-map { margin-block: 24px 40px; }
.chapter-parts { list-style: none; padding: 0; display: grid; gap: 4px 32px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.chapter-parts h3 { font-size: 1rem; margin: 16px 0 6px; }
.chapter-list { margin: 0; padding-left: 1.6rem; }
.chapter-list li { margin: 2px 0; }
.chapter-list span { color: var(--muted); font-size: .85rem; }
/* R41: hyperspace streaks, whistle rank and part ticks, a status line. */
.star-stage.warp .star-speckles circle { visibility: hidden; }
.star-speckles .streak { stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; opacity: .55; }
.star-rank { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font-size: .8125rem; color: var(--muted); }
.star-part::before { content: "✓ "; content: "✓ " / ""; color: var(--accent); }
.star-rank:empty { display: none; }  /* .star-note stays rendered: it is a live region */
.star-note { margin: 6px 0 0; min-height: 0; font-size: .8125rem; color: var(--muted); }

/* Selected-route card: above the map, and first thing on a phone. */
.route-card { margin: 0 0 20px; padding: 20px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 18px; background: var(--surface); display: grid; gap: 4px 32px; }
.route-card[hidden] { display: none; }
.route-card .eyebrow { margin: 0; color: var(--accent); }
.route-card h3 { margin: 4px 0 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.03em; }
.route-card p { margin: 6px 0 0; }
.route-line { color: var(--muted); max-width: 62ch; line-height: 1.6; }
.route-first { font-weight: 600; }
.route-stops { list-style: decimal; margin: 12px 0 0; padding-left: 1.6rem; }
.route-stops li { margin: 0; }
.route-stops a { display: inline-block; min-height: 28px; padding: 2px 8px; border-left: 3px solid transparent; }
.route-stops a[aria-current] { border-left-color: var(--accent); font-weight: 700; }
.route-stops a[aria-current]::after { content: " ◂"; }
.route-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.route-actions .button { margin: 0; }
.route-chapters { text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 960px) {
  .route-card:not([hidden]) { grid-template-columns: minmax(0, 1fr) minmax(240px, 1fr); }
  .route-card > :nth-child(-n+4), .route-card > .route-actions { grid-column: 1; }
  .route-card > .route-stops { grid-column: 2; grid-row: 1 / span 5; margin-top: 0; }
}
/* Phones: route chooser and card come right after the title; the longer deck follows the list. */
@media (max-width: 959px) {
  .star-page { display: flex; flex-direction: column; }
  .star-page .back-link { align-self: flex-start; }
  .star-page .star-map { order: 1; margin-block: 16px 24px; }
  .star-page .note-deck { order: 2; }
  .star-page > .constellations, .star-page > .chapter-map, .star-page > .caption { order: 3; }
}
