:root {
  color-scheme: dark;
  --bg: #05060a;
  --surface: #0d0f17;
  --border: #1d2130;
  --fg: #e6e8f0;
  --muted: #8a90a6;
  --accent: #6ab0ff;
  --gold: #ffd36a;
  --danger: #ff6e5a;
  --aid: #7cf0b0;
  --project: #d9a6ff;
  --order: #4fd1c5;
  --dusk: #ff6ad5;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  box-sizing: border-box;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  /* No bottom inset here: the panel pads itself so its background reaches the screen edge. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

#map {
  position: relative;
  flex: 55 1 0;
  /* What shows if the canvas is ever blank for a frame: the map's own black, never white. */
  background: var(--bg);
  min-width: 0;
  min-height: 0;
}

#map canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* The map handles its own drag and pinch gestures. */
  touch-action: none;
  cursor: grab;
}

.map-controls {
  position: absolute;
  /* Bottom right, so the view switch gets the whole top edge. */
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.map-button {
  padding: 6px 12px;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

#panel {
  flex: 45 1 0;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
  /* Only the safe area at the bottom: the collapsed sheet's height (`sheet.ts`) counts on it. */
  padding: 12px 16px env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/*
 * Phones: the panel is a bottom sheet that the grip resizes (`ui/sheet.ts`). Collapsed, it shows
 * only its header, so the map gets nearly the whole screen. A phone held sideways is too short for
 * a sheet and gets the sidebar instead: this query is the exact opposite of the sidebar's below.
 */
@media (max-width: 899.98px) and (orientation: portrait), (max-width: 899.98px) and (min-height: 500.02px) {
  #map {
    flex: 1 1 0;
  }
  #panel {
    flex: 0 0 45%;
    transition: flex-basis 0.25s ease;
  }
  #panel.sheet-full {
    flex-basis: 85%;
  }
  #panel.sheet-peek {
    /* The header, the border above it and the safe area under it. */
    flex-basis: calc(var(--sheet-header, 110px) + 1px + env(safe-area-inset-bottom));
    overflow: hidden;
  }
  #panel.sheet-peek:not(.sheet-dragging) > .panel-header ~ * {
    display: none;
  }
  #panel.sheet-dragging {
    transition: none;
    overflow: hidden;
  }
}

.sidebar-resizer {
  display: none;
}

.sheet-grip {
  /* The grip resizes the sheet, so it mustn't scroll the panel. */
  touch-action: none;
  cursor: ns-resize;
}

.sheet-handle {
  display: block;
  width: 100%;
  /* A thin bar on a taller tap target. */
  height: 20px;
  margin: -8px 0 4px;
  padding: 0;
  background: none;
  border: none;
  cursor: inherit;
}

.sheet-handle::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--border);
}

/* Matches `SIDEBAR` in `ui/sheet.ts`. */
@media (min-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .sheet-grip {
    touch-action: auto;
    cursor: auto;
  }
  .sheet-handle {
    display: none;
  }
  /*
   * A phone held sideways has the notch and rounded corners at the sides. Padding `#app` there
   * would leave empty strips, so the map runs under the left one with its controls clear of it,
   * and the panel takes the right one as extra width it pads. The app's web view trims the side
   * without a notch to almost nothing (`ios/App/App/SceneDelegate.swift`).
   */
  #app {
    flex-direction: row;
    padding-left: 0;
    padding-right: 0;
  }
  #map {
    flex: 1 1 0;
  }
  #map .view-switch {
    left: calc(12px + env(safe-area-inset-left));
    max-width: calc(100% - 24px - env(safe-area-inset-left));
  }
  /* Sideways, the map reaches the bottom edge and its home indicator. */
  #map .map-controls {
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  #map .list-view {
    padding-left: env(safe-area-inset-left);
  }
  #panel {
    /* The limits match `ui/sidebar.ts`, which sets the width without the safe area. */
    flex: 0 0 calc(clamp(320px, var(--sidebar-width, 360px), 60%) + env(safe-area-inset-right));
    padding-right: calc(16px + env(safe-area-inset-right));
    border-top: none;
    border-left: 1px solid var(--border);
  }
  /* The header reaches the panel's edges over its padding, safe area included. */
  #panel .panel-header {
    margin-right: calc(-16px - env(safe-area-inset-right));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  /* A wide grab area centered on the panel's border, taking no room from either side. */
  .sidebar-resizer {
    display: block;
    position: relative;
    z-index: 1;
    flex: 0 0 9px;
    margin: 0 -4px;
    touch-action: none;
    cursor: ew-resize;
    outline: none;
  }
  .sidebar-resizer::after {
    content: '';
    position: absolute;
    inset: 0 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  /* A finger needs more than 9 pixels: a wider grab area, still drawn as a thin line. */
  @media (pointer: coarse) {
    .sidebar-resizer::before {
      content: '';
      position: absolute;
      inset: 0 -10px;
    }
  }
  .sidebar-resizer:hover::after,
  .sidebar-resizer:focus-visible::after,
  .sidebar-resizer.dragging::after {
    opacity: 1;
  }
}

h2 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

p {
  margin: 0 0 4px;
}

.muted {
  color: var(--muted);
}

.warning {
  color: var(--danger);
}

.aid-note {
  color: var(--aid);
}

.project-note {
  color: var(--project);
}

/* What kind of star it is. */
.kind-note {
  color: #b9bfd6;
}

/* Matches the echo marks on the map. */
.echo-note {
  color: #ffb36a;
}

/* Matches the precursor marks on the map. */
.precursor-note {
  color: #6ae0e0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* The stats and the tab bar stay put while the tab below them scrolls. */
.panel-header {
  position: sticky;
  /* Pinned flush with the panel's top edge, over its padding. */
  top: -12px;
  z-index: 1;
  margin: -12px -16px 0;
  padding: 12px 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.dusk {
  margin-top: 10px;
}

.dusk-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.dusk-row .stat-label {
  color: var(--dusk);
}

.dusk-amount {
  color: var(--dusk);
  font-variant-numeric: tabular-nums;
}

.dusk-speeds {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.dusk-speed {
  min-width: 44px;
  min-height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.dusk-speed[aria-pressed='true'] {
  border-color: var(--dusk);
  color: var(--dusk);
}

.dusk-note {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  /* Natural width, not stretched: a tab added at the end must not squeeze the others sideways. */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* At least 44pt tall, for touch. */
  min-height: 44px;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.tab[aria-selected='true'] {
  border-bottom-color: var(--accent);
  color: var(--fg);
}

.tab-badge {
  min-width: 1.4em;
  padding: 1px 5px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--border);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.tab-badge.urgent,
.tab-badge.gold {
  color: var(--bg);
  font-weight: 600;
}

.tab-badge.urgent {
  background: var(--danger);
}

.tab-badge.gold {
  background: var(--gold);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value,
.log-time {
  font-variant-numeric: tabular-nums;
}

.stat-value {
  font-size: 1.15rem;
}

.star-name {
  font-size: 1.05rem;
  color: var(--gold);
}

button {
  font: inherit;
  color: inherit;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
}

.action[hidden] {
  display: none;
}

.action:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}

.action.owned {
  border-color: var(--border);
  color: var(--accent);
}

/* Striking an alien star: a button that should give pause. */
.action.danger:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.action-detail {
  font-size: 0.8rem;
  color: var(--muted);
}

/* A row that folds more under a tap: the specializations, a colony's long tech list. */
details > summary {
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::after {
  content: ' ▸';
  color: var(--muted);
}

details[open] > summary::after {
  content: ' ▾';
}

summary.action {
  /* Buttons are border-box already; a summary isn't, and would spill past the panel. */
  box-sizing: border-box;
  flex-direction: row;
  border-style: dashed;
}

.star-more > p {
  margin-top: 4px;
}

/* What Earth knows of the star, under its buttons. */
.star-info {
  margin-top: 12px;
}

.log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-time {
  margin-right: 8px;
  color: var(--accent);
}

.log .cleared {
  opacity: 0.55;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
}

/* A heading partway through a section, as far from what's above it as sections are apart. */
.subsection-head {
  margin-top: 20px;
}

.text-button {
  /* A 44pt tall tap target, pulled back with negative margins so the layout doesn't change. */
  padding: 14px 0 14px 16px;
  margin: -14px 0 -14px -16px;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
}

.text-button[hidden] {
  display: none;
}

.log + .text-button {
  align-self: flex-start;
  /* 6px below the list, less the tap-target padding. */
  margin-top: -8px;
}

.reset {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  /* Room under the last button, above the safe area. */
  padding-bottom: 24px;
}

.language {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.reset[hidden] {
  display: none;
}

.contact + .contact {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(138, 144, 166, 0.2);
}

.hint {
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(106, 176, 255, 0.08);
}

.hint[hidden] {
  display: none;
}

.hint-title {
  font-weight: 600;
  color: var(--accent);
}

.hint-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.hint-buttons .action {
  width: auto;
  margin: 0;
  padding-inline: 20px;
}

.legacy[hidden] {
  display: none;
}

.legacy {
  border-left: 3px solid var(--gold);
  padding-left: 12px;
}

.legacy-group {
  margin: 14px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
}

.legacy-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.legacy-row .star-glyph {
  color: var(--gold);
}

.star-node[data-tier='1'] {
  width: calc(100% - 14px);
  margin-left: 14px;
}

.star-node[data-tier='2'] {
  width: calc(100% - 28px);
  margin-left: 28px;
}

.star-node[data-status='lit'] {
  border-color: var(--gold);
}

.star-node[data-status='lit'] .star-glyph {
  color: var(--gold);
}

.star-node[data-status='dark'] {
  border-color: var(--border);
}

.action.primary {
  align-items: center;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.view-switch {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  /* Five views don't fit a phone: the switch scrolls. */
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  overflow-x: auto;
  scrollbar-width: none;
}

.view-switch::-webkit-scrollbar {
  display: none;
}

.view-button {
  flex: none;
  white-space: nowrap;
  padding: 5px 12px;
  font-size: 0.8rem;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.view-button[aria-selected='true'] {
  background: var(--border);
  color: var(--fg);
}

.map-controls {
  z-index: 2;
}

.map-button[hidden] {
  display: none;
}

.list-view {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding-top: 52px;
  background: var(--bg);
}

.list-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 16px;
}

.list-view[hidden] {
  display: none;
}

.list-summary {
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.colony-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5em 6.5em 3.5em;
  column-gap: 8px;
  box-sizing: border-box;
  align-items: baseline;
  width: 100%;
  padding: 8px;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.colony-header {
  position: sticky;
  top: 0;
  padding-top: 0;
  padding-bottom: 4px;
  background: var(--bg);
  cursor: default;
}

.colony-sort {
  padding: 4px 0;
  background: transparent;
  border: none;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.colony-sort.active {
  color: var(--fg);
}

.colony-distance,
.colony-energy,
.colony-development,
.colony-sort.numeric {
  text-align: right;
}

.colony-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold);
}

/* The map's megaproject marks, after the name. */
.colony-glyph {
  width: 1.45em;
  height: 1em;
  margin-left: 6px;
  vertical-align: -0.1em;
  fill: var(--project);
  stroke: var(--project);
}

.colony-glyph-dot {
  fill: var(--gold);
  stroke: none;
}

.colony-projects {
  color: var(--project);
}

.colony-detail {
  grid-column: 1 / -1;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
}

.colony-row.selected {
  background: rgba(106, 176, 255, 0.1);
}

.colony-row.crisis .colony-detail {
  color: var(--danger);
}

.colony-row.collapsed .colony-name,
.colony-row.collapsed .colony-development {
  color: var(--muted);
}

.transit-row {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr) auto;
  column-gap: 8px;
  align-items: baseline;
  box-sizing: border-box;
  width: 100%;
  padding: 8px;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.transit-row.selected {
  background: rgba(106, 176, 255, 0.1);
}

.transit-tag {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.transit-row[data-kind='ship'] .transit-tag {
  color: var(--fg);
}

.transit-row[data-kind='aid'] .transit-tag {
  color: var(--aid);
}

.transit-row[data-kind='strike'] .transit-tag {
  color: var(--danger);
}

.transit-row[data-kind='project'] .transit-tag {
  color: var(--project);
}

.transit-row[data-kind='message'] .transit-tag {
  color: var(--gold);
}

.transit-row[data-kind='broadcast'] .transit-tag,
.transit-row[data-kind='ark'] .transit-tag,
.transit-row[data-kind='deep'] .transit-tag {
  color: var(--accent);
}

/* The journey under each row, in the tag's color: out, a megaproject's build, the news home. */
.transit-row {
  --kind: var(--muted);
}

.transit-row[data-kind='ship'] {
  --kind: var(--fg);
}

.transit-row[data-kind='aid'] {
  --kind: var(--aid);
}

.transit-row[data-kind='strike'] {
  --kind: var(--danger);
}

.transit-row[data-kind='project'] {
  --kind: var(--project);
}

.transit-row[data-kind='message'] {
  --kind: var(--gold);
}

.transit-row[data-kind='broadcast'],
.transit-row[data-kind='ark'],
.transit-row[data-kind='deep'] {
  --kind: var(--accent);
}

.transit-row[data-kind='order'] {
  --kind: var(--order);
}

.transit-bar {
  position: relative;
  grid-column: 1 / -1;
  height: 5px;
  margin-top: 6px;
}

/* Clips the phases to rounded ends; the marks for now and the deadline stick out past it. */
.transit-track {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px;
  background: var(--border);
}

.transit-phase,
.transit-ahead {
  position: absolute;
  top: 0;
  bottom: 0;
}

.transit-phase.out {
  background: var(--kind);
}

.transit-phase.build {
  background: var(--kind);
  opacity: 0.5;
}

.transit-phase.back {
  background: var(--accent);
  opacity: 0.45;
}

/* What's still ahead, dimmed. */
.transit-ahead {
  background: rgba(5, 6, 10, 0.6);
}

.transit-now,
.transit-deadline {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--fg);
}

.transit-deadline {
  background: var(--danger);
}

.transit-title {
  overflow-wrap: anywhere;
}

.transit-when {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.transit-detail {
  grid-column: 2 / -1;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
}

.log .linked {
  cursor: pointer;
}

.log .selected {
  margin: 0 -6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(106, 176, 255, 0.1);
}

.log .late-note {
  display: none;
}

/* News that happened before news already in the list: the archive's jumbled parts. */
.log .late .late-note {
  display: block;
  margin-top: 1px;
  font-size: 0.75rem;
  color: var(--gold);
}

.log .late .late-note::before {
  content: '↺ ';
}

/* Standing orders: a framed dial in their own colour, so they never pass for a research button. */
.orders {
  padding: 10px 12px 8px;
  background: rgba(79, 209, 197, 0.06);
  border-left: 3px solid var(--order);
  border-radius: 0 8px 8px 0;
}

.orders h2 {
  color: var(--order);
}

.order-dial {
  display: flex;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.order-segment {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.order-segment[aria-checked='true'] {
  background: var(--order);
  color: var(--bg);
  font-weight: 600;
}

.order-segment.focused:not([aria-checked='true']) {
  border-color: var(--order);
  color: var(--fg);
}

.order-focus {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin: 8px 0 6px;
}

.order-focus .action-detail {
  flex: 1;
  margin: 0;
}

.order-in-force {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--order);
}

.order-send {
  flex: none;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--order);
  border-radius: 999px;
  color: var(--order);
  cursor: pointer;
}

.order-send:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}

/* The wavefront: how far the order has got (faint) and how much of that Earth has seen (solid). */
.order-wave {
  position: relative;
  height: 4px;
  margin-bottom: 6px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.order-wave-reached,
.order-wave-seen {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 2px;
}

.order-wave-reached {
  background: rgba(79, 209, 197, 0.35);
}

.order-wave-seen {
  background: var(--order);
}

.order-text {
  font-size: 0.8rem;
}

.ledger {
  --source-earth: #4a90e2;
  --source-home: #14a08f;
  --source-near: #b38f12;
  --source-mid: #e0527a;
  --source-far: #8f7cf0;
  --source-trade: #5aa83c;
}

.ledger-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.ledger-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ledger-tile-value {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ledger-tile-detail {
  color: var(--muted);
  font-size: 0.72rem;
}

.ledger-card {
  margin-bottom: 12px;
  padding: 10px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ledger-card h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.ledger-scale {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.ledger-note {
  margin: 0;
  font-size: 0.85rem;
}

.ledger-chart {
  padding: 4px 4px 20px 48px;
}

.ledger-plot {
  position: relative;
  height: 170px;
  touch-action: pan-y;
  cursor: crosshair;
}

.ledger-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ledger-plot svg * {
  vector-effect: non-scaling-stroke;
}

.ledger-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.ledger-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.ledger-tech {
  stroke: var(--muted);
  stroke-width: 1;
}

.ledger-event {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.ledger-event.darkEnergy {
  stroke: var(--danger);
}

.ledger-cross {
  stroke: var(--fg);
  stroke-width: 1;
  opacity: 0.6;
}

.ledger-band {
  stroke: var(--surface);
  stroke-width: 1.5;
}

.ledger-band.source-earth, .ledger-swatch.source-earth { fill: var(--source-earth); background: var(--source-earth); }
.ledger-band.source-home, .ledger-swatch.source-home { fill: var(--source-home); background: var(--source-home); }
.ledger-band.source-near, .ledger-swatch.source-near { fill: var(--source-near); background: var(--source-near); }
.ledger-band.source-mid, .ledger-swatch.source-mid { fill: var(--source-mid); background: var(--source-mid); }
.ledger-band.source-far, .ledger-swatch.source-far { fill: var(--source-far); background: var(--source-far); }
.ledger-band.source-trade, .ledger-swatch.source-trade { fill: var(--source-trade); background: var(--source-trade); }

.ledger-y,
.ledger-x {
  position: absolute;
  color: var(--muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.ledger-y {
  right: calc(100% + 6px);
  transform: translateY(-50%);
}

.ledger-x {
  top: calc(100% + 5px);
  transform: translateX(-50%);
}

.ledger-flag {
  position: absolute;
  padding-left: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
  pointer-events: none;
}

.ledger-flag.flip {
  padding: 0 4px 0 0;
  transform: translateX(-100%);
}

.ledger-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border: 2px solid var(--surface);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ledger-tip {
  position: absolute;
  top: 34px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 180px;
  margin-left: 8px;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  pointer-events: none;
}

.ledger-tip strong {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-tip.flip {
  margin-left: -8px;
  transform: translateX(-100%);
}

.ledger-tip-note {
  color: var(--fg);
}

.ledger-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 8px;
  padding: 0;
  color: var(--muted);
  font-size: 0.75rem;
  list-style: none;
}

.ledger-legend li {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ledger-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.ledger-share {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.ledger-stars {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ledger-star {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.5em 5.5em;
  column-gap: 8px;
  row-gap: 3px;
  align-items: baseline;
  padding: 5px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--fg);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.ledger-star:hover {
  background: var(--border);
}

.ledger-star.selected {
  border-color: var(--accent);
}

.ledger-star-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-star-distance,
.ledger-star-energy {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ledger-star-distance {
  color: var(--muted);
}

.ledger-star-track {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}

.ledger-star-bar {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
}
