:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  /* Background for active/selected controls. In dark mode this goes *lighter*
     than --bg so it stands out; in light mode it goes darker. The name is a
     misnomer in dark mode but kept for symmetry with the light theme. */
  --bg-sink: #1d1d1d;
  --text: #f5f5f5;
  --border: #262626;
  --border-strong: #3f3f3f;
  --muted: #a3a3a3;
  --fill: #f5f5f5;

  /* Status traffic-light accents. Tuned for the dark background. */
  --color-ok: #4ade80;
  --color-warn: #facc15;
  --color-bad: #f87171;

  /* Spacing scales with the root font-size (rem). Numbers below are
     keyed to a 14px base so the visual rhythm matches the original
     px design at viewport ~378px. */
  --gap-xs: 0.286rem;
  --gap-sm: 0.571rem;
  --gap-md: 0.857rem;
  --gap-lg: 1.143rem;
  --gap-xl: 1.714rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --status-bar-height: 3.714rem;
  --tab-bar-height: 4.571rem;

  --frame-bg: #1a1a1a;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #fafafa;
  --bg-sink: #eeeeee;
  --text: #0a0a0a;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --muted: #737373;
  --fill: #0a0a0a;
  --frame-bg: #f5f5f5;

  /* Darker accents for legibility on a white background. */
  --color-ok: #16a34a;
  --color-warn: #ca8a04;
  --color-bad: #dc2626;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

html {
  /* Fluid base size: 13px floor on tiny phones (~320 wide), grows ~1px per 100vw,
     ceiling at 18px around tablet portrait (~700 wide). Anchored so a 390px
     phone lands near 15px and an iPad portrait lands at the 18px ceiling. */
  font-size: clamp(13px, 1vw + 11px, 18px);
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html {
  /* Painted with the same color as the app's status bar so that when Android
     Chrome's URL bar collapses on scroll, the strip of html that briefly
     becomes visible above `body` (see below) blends seamlessly — looking like
     an extension of the status bar instead of a foreign band. */
  background: var(--bg);
}

body {
  /* The trick that finally makes the tab bar stay put on mobile:
     anchor body to the BOTTOM of the visual viewport, not the top, and lock
     its height to `100svh` (small viewport height = viewport-with-chrome).

     Why bottom and not top: on Android Chrome (and iOS Safari) the URL bar
     can collapse mid-scroll. When it does, the visual viewport's TOP edge
     slides upward to fill the freed space, while its BOTTOM edge doesn't
     move. Anchoring `top: 0` glues body to the moving edge, so the whole
     app slides up and the tab bar pulls off the bottom of the screen.
     Anchoring `bottom: 0` glues body to the stable edge — the tab bar stays
     where it is, and the chrome animation just opens/closes a strip of
     html-colored space above the status bar.

     `100vh` is left as a fallback for browsers without svh support. */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100svh;
  background: var(--frame-bg);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: 100%;
  height: 100%;
  max-width: 1024px;
  display: grid;
  grid-template-rows: var(--status-bar-height) 1fr var(--tab-bar-height);
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ============ Status bar ============ */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap-md);
  border-bottom: 1px solid var(--border);
  font-size: 0.929rem;
  background: var(--bg);
}

.status-bar__left,
.status-bar__right {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.status-bar svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-xs);
  padding: 4px var(--gap-sm);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-size: 0.857rem;
  /* Sized to comfortably fit worst-case content ("9.9K/9.9K") so credits and
     capacity pills share a uniform width regardless of current values. */
  min-width: 7rem;
  box-sizing: border-box;
}

.status-pill > span[data-bind] {
  margin-left: auto;
  text-align: right;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.icon-btn:active {
  background: var(--bg-elev);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ============ Settings dropdown ============ */
.settings-wrap {
  position: relative;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  min-width: 200px;
  padding: 4px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .settings-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.settings-menu__item {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 8px 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.929rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.settings-menu__item:hover {
  background: var(--bg-elev);
}

.settings-menu__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.settings-menu__label {
  flex: 1;
}

.settings-menu__value {
  font-size: 0.714rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#settings-toggle[aria-expanded="true"] {
  background: var(--bg-elev);
}

/* ============ Content ============ */
.content {
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--gap-lg);
  -webkit-overflow-scrolling: touch;
  /* Vertical scrolling stays native; horizontal motion is reserved for the
     tab-swipe handler in main.js (so Android Chrome's back-swipe doesn't
     race our gesture). */
  touch-action: pan-y;
  /* Stop overscroll (rubber-band at the top/bottom of the scrollable area)
     from propagating up to the document. Some mobile browsers use that
     propagation as the signal to collapse the URL bar — `none` here means
     the gesture stays contained in this element and the chrome stays put. */
  overscroll-behavior: none;
}

/* Cap the *content area* at ~720px on tablet-and-up so single-column lists
   (missions, repair rows, recipes) don't get stretched across iPad widths.
   The status bar and tab bar still span the full app width as the app's chrome. */
@media (min-width: 720px) {
  .content {
    padding-left: max(var(--gap-lg), calc((100% - 720px) / 2));
    padding-right: max(var(--gap-lg), calc((100% - 720px) / 2));
  }
}

.tab-panel.hidden {
  display: none;
}

.tab-title {
  font-size: 1.571rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--gap-lg);
}

.placeholder {
  color: var(--muted);
  font-size: 0.929rem;
  padding: var(--gap-xl);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* ============ Tab bar ============ */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.tab-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.714rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 8px 0 6px;
  position: relative;
  transition: color 0.12s ease;
  font-family: inherit;
}

.tab-btn:last-child {
  border-right: none;
}

.tab-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}

.tab-btn.active {
  color: var(--text);
  background: var(--bg-sink);
  font-weight: 600;
}

.tab-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--fill);
}

.tab-btn--has-badge::after {
  content: "";
  position: absolute;
  top: 8px;
  left: calc(50% + 8px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-bad);
  box-shadow: 0 0 0 2px var(--bg);
}

.tab-btn:active {
  background: var(--bg-elev);
}

/* ============ Planet header ============ */
.planet-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) 0 var(--gap-xl);
  text-align: center;
}

.planet-sprite {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  margin-bottom: var(--gap-xs);
}

.planet-sprite svg {
  width: 44px;
  height: 44px;
  stroke-width: 1.25;
  color: var(--muted);
}

.planet-header__name {
  font-size: 1.571rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.planet-header__sub {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============ Scan button ============ */
.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 0.929rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: var(--gap-md);
  position: relative;
  overflow: hidden;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.scan-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.scan-btn:disabled {
  cursor: not-allowed;
  color: var(--muted);
}

.scan-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.scan-btn__cooldown {
  font-size: 0.786rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

.scan-btn__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--text);
  width: 0;
  transition: width 0.4s linear;
  pointer-events: none;
}

/* ============ Scanning animation ============ */
.scanning .planet-sprite {
  animation: scan-pulse 1.2s ease-in-out;
}

.scanning .scan-btn svg {
  animation: scan-spin 1.2s linear;
}

.scanning .node-card--unsurveyed {
  animation: scan-flicker 0.6s ease-in-out infinite alternate;
}

@keyframes scan-pulse {
  0%   { transform: scale(1);    border-color: var(--border); }
  30%  { transform: scale(1.06); border-color: var(--text); }
  60%  { transform: scale(1.02); border-color: var(--text); }
  100% { transform: scale(1);    border-color: var(--border); }
}

@keyframes scan-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes scan-flicker {
  from { opacity: 0.6; border-color: var(--border); }
  to   { opacity: 1;   border-color: var(--border-strong); }
}

/* ============ Section header ============ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: var(--gap-md) 0 var(--gap-md);
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.857rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-meta {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============ Node list / cards ============ */
.node-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  padding-bottom: var(--gap-lg);
}

.node-card {
  background: var(--bg);
  font-family: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  position: relative;
  overflow: hidden;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.node-card:active {
  transform: scale(0.985);
  border-color: var(--border-strong);
}

.node-card--locked {
  border-style: dashed;
  cursor: default;
  opacity: 0.55;
}

.node-card--locked:active {
  transform: none;
}

.node-card--auto {
  cursor: default;
  background: var(--bg-elev);
}

.node-card--auto:active {
  transform: none;
  border-color: var(--border);
}

.node-card--unsurveyed {
  cursor: default;
  background: var(--bg-elev);
  border-style: dotted;
}

.node-card--unsurveyed:active {
  transform: none;
  border-color: var(--border);
}

.node-card--unsurveyed .node-card__name {
  font-style: italic;
  color: var(--muted);
}

.node-card--unsurveyed .node-card__icon svg {
  color: var(--muted);
}

.node-card__autotag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.node-card__autotag svg {
  width: 10px;
  height: 10px;
  stroke-width: 2;
}

.node-card__icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.node-card__icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

.node-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.node-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
}

.node-card__name {
  font-size: 1rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.node-card__counter {
  font-size: 0.857rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.node-card__tier {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.node-card__hint {
  font-size: 0.857rem;
  color: var(--muted);
}

/* ============ Progress bar ============ */
.progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--fill);
  transition: width 0.18s ease;
}

/* ============ Floater (+1 popup) ============ */
.floater {
  position: absolute;
  right: var(--gap-md);
  top: 50%;
  font-size: 0.857rem;
  font-weight: 600;
  pointer-events: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  animation: floater-rise 900ms ease-out forwards;
}

.floater--warn {
  font-style: italic;
  opacity: 0.9;
}

@keyframes floater-rise {
  0%   { opacity: 0; transform: translateY(-50%); }
  15%  { opacity: 1; transform: translateY(-90%); }
  100% { opacity: 0; transform: translateY(-200%); }
}

/* ============ Flash feedback ============ */
.flash-reject {
  animation: flash-reject 0.32s ease;
}

@keyframes flash-reject {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  80% { transform: translateX(-2px); }
}

/* ============ Sub-tabs ============ */
.subtab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--gap-md);
  padding: 2px;
  gap: 2px;
  background: var(--bg);
}

.subtab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px;
  font-size: 0.929rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}

.subtab-btn.active {
  background: var(--bg-sink);
  color: var(--text);
}

/* ============ Capacity bar ============ */
.capacity-bar {
  margin-bottom: var(--gap-lg);
}

.capacity-bar__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--gap-sm);
}

.capacity-bar__label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.786rem;
}

.capacity-bar__value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.929rem;
}

/* ============ Inventory grid ============ */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.inv-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--gap-md) var(--gap-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
}

.inv-cell__qty {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.857rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}

.inv-cell__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inv-cell__icon svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
  color: var(--text);
}

.inv-cell__name {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Craft rows ============ */
.craft-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.craft-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.craft-row--locked {
  border-style: dashed;
  opacity: 0.55;
}

.craft-row__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.craft-row__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.craft-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.craft-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
}

.craft-row__name {
  font-size: 1rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.craft-row__locktag {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.craft-row__formula {
  font-size: 0.857rem;
  color: var(--muted);
}

.craft-row__formula .ok {
  color: var(--color-ok);
}

.craft-row__formula .lacking {
  color: var(--color-bad);
}

.craft-row__formula .sep {
  margin: 0 4px;
  opacity: 0.5;
}

.craft-row__hint {
  font-size: 0.857rem;
  color: var(--muted);
}

/* ============ Buttons ============ */
.btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.857rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-elev);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--border);
}

.btn--small {
  padding: 4px 10px;
  font-size: 0.786rem;
}

.btn--block {
  width: 100%;
}

/* ============ Sub-tab variants ============ */
.subtab-bar--three {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ============ Inbox toggle (Unread / Archived) ============ */
.inbox-toggle {
  display: flex;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.inbox-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.786rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.inbox-toggle__btn:hover {
  color: var(--text);
}

.inbox-toggle__btn.active {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-sink);
}

.inbox-toggle__count {
  font-size: 0.714rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  background: var(--bg);
}

.inbox-toggle__btn.active .inbox-toggle__count {
  border-color: var(--border-strong);
}

/* ============ Messages (Inbox) ============ */
.msg {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  margin-bottom: var(--gap-sm);
  background: var(--bg);
}

.msg--unread {
  border-color: var(--border-strong);
  cursor: pointer;
}

.msg--unread:active {
  background: var(--bg-elev);
}

.msg__header {
  display: flex;
  justify-content: space-between;
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.msg__subject {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
}

.msg--unread .msg__subject::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-bad);
  display: inline-block;
}

.msg__body {
  font-size: 0.929rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ============ Missions ============ */
.mission {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  margin-bottom: var(--gap-sm);
  background: var(--bg);
}

.mission--done {
  opacity: 0.5;
}

.mission--ready {
  border-color: var(--border-strong);
}

.mission__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--gap-sm);
  padding-top: var(--gap-sm);
  border-top: 1px dashed var(--border);
}

.mission__reward {
  font-size: 0.786rem;
  color: var(--text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mission__claimed {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mission__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap-sm);
}

.mission__name {
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.mission__footer-right {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.mission__type {
  font-size: 0.643rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.mission__type--main {
  color: var(--text);
  border-color: var(--border-strong);
}

.mission__progress {
  font-size: 0.786rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mission__objs {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mission__objs li {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 0.929rem;
  color: var(--muted);
}

.mission__objs li.done {
  color: var(--text);
}

.mission__objs li svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

/* ============ Research ============ */
.rp-balance {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--gap-md) var(--gap-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--gap-md);
  background: var(--bg-elev);
}

.rp-balance__label {
  font-size: 0.786rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rp-balance__value {
  font-size: 2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.research-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.research-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.research-row--locked {
  border-style: dashed;
  opacity: 0.55;
}

.research-row--owned {
  background: var(--bg-elev);
}

.research-row__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.research-row__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.research-row__body {
  flex: 1;
  min-width: 0;
}

.research-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: 4px;
}

.research-row__name {
  font-size: 1rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.research-row__owned {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.research-row__locktag {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.research-row__hint {
  font-size: 0.857rem;
  color: var(--muted);
}

/* ============ Ship ============ */
.ship-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) 0 var(--gap-lg);
  text-align: center;
}

.ship-sprite {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  margin-bottom: var(--gap-xs);
}

.ship-sprite svg {
  width: 44px;
  height: 44px;
  stroke-width: 1.25;
  color: var(--muted);
}

.ship-header__name {
  font-size: 1.571rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ship-header__sub {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============ Ship system status grid ============ */
.ship-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.ship-status__cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ship-status__cell--interactive {
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.ship-status__cell--interactive:hover {
  border-color: var(--border-strong);
}

.ship-status__cell--interactive:active {
  background: var(--bg-elev);
}

.ship-status__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.643rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ship-status__label svg {
  width: 11px;
  height: 11px;
  stroke-width: 2;
  flex-shrink: 0;
}

.ship-status__value {
  font-size: 0.929rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  /* Indent past the label's icon + gap so the number lines up under the
     label text, not under the icon. Matches the 11px icon + 5px gap above. */
  margin-left: calc(11px + 5px);
}

.ship-status__value--ok {
  color: var(--color-ok);
}

.ship-status__value--warn {
  color: var(--color-warn);
}

.ship-status__value--critical {
  color: var(--color-bad);
}

.ship-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) var(--gap-md);
  text-align: center;
}

.ship-stat__label {
  font-size: 0.714rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.ship-stat__value {
  font-size: 1.429rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.upgrade-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.upgrade-row--locked {
  border-style: dashed;
  opacity: 0.55;
}

.upgrade-row--owned {
  background: var(--bg-elev);
}

.upgrade-row__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.upgrade-row__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.upgrade-row__body {
  flex: 1;
  min-width: 0;
}

.upgrade-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: 4px;
}

.upgrade-row__name {
  font-size: 1rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.upgrade-row__owned {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.upgrade-row__locktag {
  font-size: 0.714rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.upgrade-row__hint {
  font-size: 0.857rem;
  color: var(--muted);
  line-height: 1.4;
}

.upgrade-row__cost {
  display: inline-block;
  margin-top: 2px;
}

.upgrade-row__cost .ok {
  color: var(--color-ok);
}

.upgrade-row__cost .lacking {
  color: var(--color-bad);
}

.upgrade-row__cost .sep {
  margin: 0 4px;
  opacity: 0.5;
}

/* ============ Power grid ============ */
.power-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) var(--gap-md);
  margin-bottom: var(--gap-md);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.power-summary--brownout {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}

.power-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
}

.power-summary__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.714rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.power-summary__label svg {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

.power-summary__status {
  font-size: 0.714rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 999px;
}

.power-summary__status--ok {
  color: var(--muted);
}

.power-summary__status--brownout {
  color: var(--text);
  border-color: var(--border-strong);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

.power-summary__metric {
  font-size: 0.857rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.power-summary__metric strong {
  color: var(--text);
  font-weight: 600;
}

.machine-row--generator {
  background: var(--bg);
  border-color: var(--border-strong);
}

/* ============ Base ============ */
.base-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.machine-list,
.slot-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.machine-row,
.slot-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.machine-row {
  background: var(--bg-elev);
}

.slot-row--disabled {
  opacity: 0.6;
  border-style: dashed;
}

.machine-row__icon,
.slot-row__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.machine-row__icon svg,
.slot-row__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.machine-row__body,
.slot-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.machine-row__header,
.slot-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
}

.machine-row__name,
.slot-row__name {
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.machine-row__tier {
  font-size: 0.643rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
}

.machine-row__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.machine-row__status {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.machine-row__status--full {
  color: var(--text);
}

.machine-row--tier2 {
  background: var(--bg);
  border-color: var(--border-strong);
}

.machine-upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}

.machine-upgrade__cost {
  font-size: 0.786rem;
  color: var(--muted);
}

.machine-upgrade__cost .ok {
  color: var(--color-ok);
}

.machine-upgrade__cost .lacking {
  color: var(--color-bad);
}

.machine-upgrade__cost .sep {
  margin: 0 4px;
  opacity: 0.5;
}

.slot-row__hint {
  font-size: 0.857rem;
  color: var(--muted);
}

/* Ghost button (icon-only) */
.btn--ghost {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn--ghost svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--gap-lg);
  animation: modal-fade 0.15s ease;
}

[data-theme="light"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.3);
}

@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--gap-xl) var(--gap-lg) var(--gap-lg);
  width: 100%;
  max-width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  position: relative;
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal__close:hover {
  color: var(--text);
  background: var(--bg-elev);
}

.modal__close svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.modal__icon {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  margin-bottom: var(--gap-xs);
}

.modal__icon svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
}

.modal__name {
  font-size: 1.286rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal__meta {
  font-size: 0.786rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--gap-md);
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-sm);
  width: 100%;
  margin-bottom: var(--gap-sm);
}

/* Confirm variant — title + body + actions */
.modal--confirm {
  padding: var(--gap-lg) var(--gap-lg) var(--gap-md);
  align-items: stretch;
  text-align: left;
}

.modal--confirm .modal__actions {
  margin-top: var(--gap-sm);
  margin-bottom: 0;
}

.modal__title {
  font-size: 1.143rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.modal__body {
  font-size: 0.929rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal__actions .btn {
  width: 100%;
  padding: 10px;
  font-size: 0.929rem;
}

.modal__cancel,
.btn--ghost-text {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.857rem;
  letter-spacing: 0.04em;
  padding: 6px;
}

.btn--ghost-text:hover {
  color: var(--text);
}

/* ============ Selection mode ============ */
.inv-cell--selected {
  border-color: var(--text);
  background: var(--bg-elev);
  outline: 1px solid var(--text);
  outline-offset: -2px;
}

.selection-mode .inv-cell {
  position: relative;
}

.selection-mode .inv-cell::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg);
}

.selection-mode .inv-cell--selected::before {
  background: var(--text);
  border-color: var(--text);
}

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-bar-height) + 12px);
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  z-index: 150;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  width: max-content;
  max-width: min(480px, calc(100% - 24px));
  animation: modal-pop 0.18s ease-out;
}

/* ============ Tablet breakpoint (portrait) ============ */
@media (min-width: 600px) {
  /* More inventory columns when there's room. Capped at 4 — the content area
     is itself capped at ~720px on larger screens, so 4 cells of ~150px feels
     better than 5 cells of ~120px. */
  .inv-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.selection-bar__count {
  font-size: 0.857rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.selection-bar__actions {
  display: flex;
  gap: var(--gap-sm);
}

/* ============ Main menu ============ */
.main-menu {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-xl);
}

.main-menu__inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 56px;
  width: 100%;
  max-width: min(340px, 78%);
}

.main-menu__header {
  text-align: center;
}

.main-menu__title {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.main-menu__subtitle {
  font-size: 0.786rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.main-menu__actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.menu-btn {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  column-gap: var(--gap-sm);
  padding: 12px 16px 12px 32%;
  font-size: 0.929rem;
  letter-spacing: 0.05em;
  text-align: left;
}

.menu-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.menu-btn > span {
  justify-self: start;
}

.main-menu__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--gap-md) var(--gap-lg);
  padding-bottom: max(var(--gap-md), env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.714rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

.main-menu__version {
  text-transform: none;
}

/* ============ Intro overlay ============ */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-xl);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1rem;
  line-height: 1.6;
  letter-spacing: 0.01em;
  cursor: pointer;
  /* No entrance animation — overlay must appear instantly to avoid flashing
     the game world for the duration of a fade-in. The fade-out on exit
     intentionally remains. */
}

.intro-overlay--fading {
  animation: intro-fade-out 0.3s ease forwards;
}

@keyframes intro-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.intro-overlay__inner {
  width: 100%;
  max-width: min(520px, 92vw);
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  min-height: 0;
}

.intro-overlay__lines {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

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

.intro-overlay__line--current {
  color: var(--text);
  min-height: 1.6em;
}

.intro-cursor {
  display: inline-block;
  margin-left: 2px;
  animation: intro-blink 0.9s steps(2, end) infinite;
}

@keyframes intro-blink {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.intro-overlay__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-sm);
  padding-top: var(--gap-md);
  min-height: 32px;
}

.intro-overlay__hint {
  font-size: 0.714rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro-overlay__continue {
  margin-left: auto;
  letter-spacing: 0.08em;
}

/* ============ Repair sub-tab ============ */
.repair-lede {
  font-size: 0.929rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: var(--gap-md);
}

.launch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  margin-top: var(--gap-md);
  padding: 12px;
  font-size: 0.929rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.launch-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

/* ============ Toast notifications ============ */
.toast-container {
  position: absolute;
  top: calc(var(--status-bar-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: calc(100% - 24px);
  max-width: min(480px, 92%);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: 10px var(--gap-md);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

[data-theme="light"] .toast {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.toast--in {
  opacity: 1;
  transform: translateY(0);
}

.toast--out {
  opacity: 0;
  transform: translateY(-10px);
}

.toast__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}

.toast__icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.toast__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toast__title {
  font-size: 0.714rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toast__msg {
  font-size: 0.929rem;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ============ Hazard chips (Planet header) ============ */
.hazard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.hazard-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hazard-chip__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.643rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hazard-chip__label svg {
  width: 11px;
  height: 11px;
  stroke-width: 2;
  flex-shrink: 0;
}

.hazard-chip__value {
  font-size: 0.929rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.hazard-chip__value--warn {
  color: var(--text);
}

.hazard-chip__value--critical {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.hazard-chip__sub {
  font-size: 0.643rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hazard-chip__sub--warn {
  color: var(--color-warn);
}

.hazard-chip__sub--critical {
  color: var(--color-bad);
}

/* ============ Mystery node ============ */
.node-card--mystery {
  border-style: dotted;
  opacity: 0.65;
}

.node-card--mystery .node-card__name {
  font-style: italic;
}

.node-card--mystery .node-card__tier {
  letter-spacing: 0.12em;
}

/* ============ Utilities ============ */
.hidden {
  display: none !important;
}
