:root {
  color-scheme: dark;
  --bg: #0d1015;
  --panel: #161b22;
  --panel-2: #1d2530;
  --line: #2c3440;
  --text: #f4f0e8;
  --muted: #aeb7c2;
  --soft: #7e8794;
  --gold: #f3b743;
  --teal: #48d7c6;
  --red: #ff6b5f;
  --green: #74d37b;
  --blue: #75a7ff;
  --violet: #b98cff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 16, 21, 0.9);
  backdrop-filter: blur(18px);
}

.topbar span,
.section-title span,
.answer-copy .eyebrow,
.quick-card > span,
.loadout-main article span,
.upgrade-path article span,
.ship-cards article span,
.source-list article strong {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1,
.section-title h2,
.answer-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  margin-top: 2px;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar nav a {
  min-height: 36px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar nav a:hover {
  border-color: var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.workflow-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.workflow-tabs a {
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111820;
  color: inherit;
  text-decoration: none;
}

.workflow-tabs a:hover {
  border-color: var(--teal);
}

.workflow-tabs span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.workflow-tabs strong {
  font-size: 1rem;
}

.hero-flow {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.import-panel,
.answer-card,
.quick-card,
.plan-section,
  .editor-section,
  .loadout-section,
  .trade-section,
  .quality-section,
  .database-section details,
.source-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.92);
  box-shadow: var(--shadow);
}

.import-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.drop-zone {
  display: grid;
  min-height: 136px;
  place-items: center;
  gap: 6px;
  padding: 22px;
  border: 1px dashed #556170;
  border-radius: var(--radius);
  background: #111820;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--teal);
  background: #14242a;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  color: var(--text);
  font-size: 1.1rem;
}

.drop-zone span {
  max-width: 30ch;
  font-size: 0.9rem;
  line-height: 1.45;
}

.manual-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manual-controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.manual-controls span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.manual-controls input,
.manual-controls select,
.database-controls input,
.database-controls select,
.trade-controls select,
.editor-fields input,
.editor-fields select,
.hardpoint-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0e131a;
  color: var(--text);
  outline: none;
}

.manual-controls input,
.manual-controls select,
.database-controls input,
.trade-controls select,
.editor-fields input,
.editor-fields select,
.hardpoint-row select {
  padding: 0 12px;
}

.database-controls select {
  padding: 0 34px 0 12px;
}

.manual-controls input:focus,
.manual-controls select:focus,
.database-controls input:focus,
.database-controls select:focus,
.trade-controls select:focus {
  border-color: var(--teal);
}

.save-facts {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #31404f;
  border-radius: var(--radius);
  background: #121923;
}

.save-help,
.save-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f151d;
}

.share-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 13px;
  border: 1px solid #2a3542;
  border-radius: var(--radius);
  background: #101720;
}

.share-panel div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.share-panel strong {
  color: var(--teal);
}

.share-panel span,
.share-panel small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.share-panel button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #17202b;
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.share-panel button:hover {
  border-color: var(--teal);
}

.save-help summary,
.save-editor summary {
  padding: 12px 14px;
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
}

.save-help p,
.save-editor p {
  margin: 0;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.save-help code {
  display: block;
  margin: 0 14px 12px;
  padding: 10px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #080d12;
  color: var(--text);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.share-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(117, 167, 255, 0.08);
}

.share-panel strong,
.share-panel span,
.share-panel small {
  display: block;
}

.share-panel strong {
  color: var(--text);
}

.share-panel span,
.share-panel small {
  color: var(--muted);
  line-height: 1.35;
}

.share-panel small {
  grid-column: 1 / -1;
  color: var(--soft);
}

.share-panel button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101923;
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
}

.save-editor label {
  display: grid;
  gap: 6px;
  padding: 0 14px 12px;
}

.save-editor label span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.save-editor input,
.save-editor select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #0e131a;
  color: var(--text);
}

.save-editor button {
  display: block;
  width: calc(100% - 28px);
  min-height: 40px;
  margin: 0 14px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--gold);
  color: #211607;
  cursor: pointer;
  font-weight: 900;
}

.save-editor button:disabled,
.save-editor input:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.save-edit-status {
  margin: 0 14px 14px;
  padding: 10px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.save-edit-status.ready {
  border-color: rgba(116, 211, 123, 0.45);
  color: var(--green);
}

.save-edit-status.error {
  border-color: rgba(255, 107, 95, 0.5);
  color: var(--red);
}

.save-edit-instructions {
  display: grid;
  gap: 8px;
  margin: 0 14px 14px;
  padding: 12px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #0d131a;
}

.save-edit-instructions strong {
  color: var(--teal);
}

.save-edit-instructions p {
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.save-edit-instructions code {
  display: block;
  padding: 9px;
  border: 1px solid #24303c;
  border-radius: 6px;
  background: #080d12;
  color: var(--text);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.editor-section {
  padding: 20px;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.editor-side,
.editor-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.editor-mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.editor-mode-tabs button {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1720;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.editor-mode-tabs button.active {
  border-color: rgba(72, 215, 198, 0.52);
  background: #0e2026;
  color: var(--text);
}

.editor-mode-tabs span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.editor-mode-tabs strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.84rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-mode-panel[hidden] {
  display: none !important;
}

.editor-mode-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.editor-main > .save-edit-status {
  margin: 0;
}

.editor-mode-panel .save-edit-instructions {
  margin: 0;
}

.ship-goal-strip {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1720;
}

.ship-goal-strip label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.ship-goal-strip span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.drop-zone.compact {
  min-height: 116px;
  padding: 18px;
}

.editor-summary,
.editor-card,
.hardpoint-row,
.empty-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.editor-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.editor-summary.empty {
  border-style: dashed;
}

.editor-summary strong,
.editor-card strong,
.hardpoint-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.editor-summary p,
.editor-card p,
.hardpoint-row p,
.editor-note,
.empty-editor {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.editor-summary dl,
.ship-editor-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.editor-summary dl div,
.ship-editor-readout div {
  min-width: 0;
  padding: 9px;
  border: 1px solid #26313d;
  border-radius: 6px;
  background: #0b1118;
}

.editor-summary dt,
.editor-summary dd,
.ship-editor-readout span,
.ship-editor-readout strong {
  margin: 0;
}

.editor-summary dt,
.ship-editor-readout span,
.editor-card > div > span,
.hardpoint-row span {
  display: block;
  color: var(--soft);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.editor-summary dd,
.ship-editor-readout strong {
  color: var(--text);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.editor-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.editor-card.muted {
  border-style: dashed;
}

.editor-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.editor-fields label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.editor-fields label span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-actions.sticky {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 16, 21, 0.92);
  backdrop-filter: blur(14px);
}

.editor-fields button,
.ship-goal-strip button,
.editor-actions button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--gold);
  color: #211607;
  cursor: pointer;
  font-weight: 900;
}

.editor-actions button:last-child {
  background: #17202b;
  color: var(--teal);
  border-color: var(--line);
}

.editor-fields button:disabled,
.ship-goal-strip button:disabled,
.editor-actions button:disabled,
.hardpoint-row select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ship-editor-card {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.ship-editor-card .editor-note {
  grid-column: 1 / -1;
  padding-top: 4px;
}

.ship-swap-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #2a3542;
  border-radius: var(--radius);
  background: #0c131b;
}

.ship-swap-panel.ready {
  border-color: rgba(116, 211, 123, 0.42);
  background: rgba(116, 211, 123, 0.055);
}

.ship-swap-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.42;
}

.hardpoint-editor-panel {
  display: grid;
  gap: 8px;
}

.hardpoint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.hardpoint-row.locked {
  opacity: 0.72;
}

.empty-editor {
  padding: 12px;
}

.save-facts.empty {
  border-style: dashed;
}

.save-facts strong {
  overflow-wrap: anywhere;
}

.save-facts > span,
.save-facts .fact-grid span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.fact-grid {
  display: grid;
  gap: 8px;
}

.fact-grid span {
  display: grid;
  gap: 2px;
}

.fact-grid b {
  color: var(--text);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.answer-card {
  display: grid;
  grid-template-columns: minmax(240px, 36%) minmax(0, 1fr);
  min-height: 408px;
  overflow: hidden;
}

.answer-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 300px;
  background:
    radial-gradient(circle at center, rgba(72, 215, 198, 0.14), transparent 56%),
    #0c1118;
}

.answer-art img {
  width: min(88%, 360px);
  max-height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 24px 28px rgba(0, 0, 0, 0.55));
  animation: ship-drift 6s ease-in-out infinite;
}

.answer-art span {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--gold);
  color: #201609;
  font-weight: 900;
}

.answer-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  padding: clamp(22px, 4vw, 42px);
}

.answer-copy h2 {
  max-width: 18ch;
  font-size: clamp(1.85rem, 4vw, 3.35rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.answer-copy p {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.55;
}

.answer-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.answer-actions span,
.answer-detail,
  .loadout-main article,
  .rule-strip article,
  .quality-grid article,
  .validation-ledger article,
  .confidence-card,
  .quality-notes article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.answer-actions span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
}

.answer-actions small {
  color: var(--soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.answer-actions b {
  overflow-wrap: anywhere;
}

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

.route-line span {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #2a3542;
  border-radius: var(--radius);
  background: #0f151d;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.route-line b {
  color: var(--gold);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.answer-detail {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.answer-detail strong {
  color: var(--teal);
}

.answer-detail span {
  color: var(--muted);
  line-height: 1.5;
}

.answer-detail.location strong {
  color: var(--green);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.quick-card {
  min-height: 178px;
  padding: 18px;
}

.quick-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.quick-card p,
.loadout-main p,
.loadout-main li,
.rule-strip p,
.upgrade-path p,
.ship-cards p,
.source-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.plan-section,
.editor-section,
.loadout-section,
  .advisor-section,
  .vendor-section,
  .trade-section,
  .database-section,
  .quality-section,
  .source-section {
  margin-top: 22px;
}

.plan-section,
.editor-section,
.loadout-section,
.advisor-section,
.vendor-section,
.trade-section,
.quality-section,
.source-section {
  padding: 20px;
}

.advisor-section,
.editor-section,
.trade-section,
.quality-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.92);
  box-shadow: var(--shadow);
}

.vendor-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.92);
  box-shadow: var(--shadow);
}

.trade-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.trade-controls select {
  width: min(240px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 34px 0 12px;
  background: #0e131a;
  color: var(--text);
}

.trade-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.trade-callout,
.trade-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.trade-callout {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.trade-callout span,
.trade-card-head span,
.advisor-head span,
.advisor-steps > span,
.advisor-route > span,
.advisor-loadout > span,
.advisor-caveats > span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.trade-callout strong {
  display: block;
  margin: 5px 0 7px;
  font-size: 1.2rem;
}

.trade-callout p,
.trade-card p,
.trade-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.trade-hold {
  display: grid;
  min-width: 96px;
  min-height: 76px;
  place-items: center;
  border: 1px solid rgba(72, 215, 198, 0.32);
  border-radius: var(--radius);
  background: #0d171b;
}

.trade-hold b {
  color: var(--teal);
  font-size: 1.9rem;
  line-height: 1;
}

.trade-hold span {
  color: var(--muted);
  font-size: 0.76rem;
}

.trade-card {
  display: grid;
  grid-template-columns: minmax(130px, 34%) minmax(0, 1fr);
  overflow: hidden;
}

.trade-card.risk-low {
  border-left: 4px solid var(--green);
}

.trade-card.risk-medium {
  border-left: 4px solid var(--gold);
}

.trade-card.risk-high {
  border-left: 4px solid var(--red);
}

.trade-map {
  width: 100%;
  height: 100%;
  min-height: 230px;
  object-fit: cover;
  background: #081018;
  opacity: 0.78;
}

.trade-map.empty {
  min-height: 180px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #081018;
  background-size: 24px 24px;
}

.trade-route-copy {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.trade-card-head strong {
  display: block;
  margin-top: 5px;
  font-size: 1.08rem;
}

.trade-leg,
.trade-profit {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trade-profit {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trade-leg span,
.trade-profit span {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #0d131a;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.34;
  overflow-wrap: anywhere;
}

.trade-leg b,
.trade-profit small {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.trade-profit b {
  color: var(--text);
}

.vendor-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mission-panel {
  display: grid;
  gap: 12px;
}

.mission-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.mission-card.spotlight {
  border-color: rgba(225, 183, 99, 0.48);
  background: linear-gradient(135deg, rgba(225, 183, 99, 0.12), rgba(16, 23, 32, 0.96) 48%);
}

.mission-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 132px);
  gap: 16px;
  align-items: center;
}

.mission-card-head img {
  width: 100%;
  max-height: 98px;
  object-fit: contain;
}

.mission-card span,
.mission-grid span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.mission-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.18rem;
}

.mission-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mission-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

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

.mission-strip span {
  min-width: 0;
  padding: 10px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mission-strip b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 0.78rem;
}

.mission-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mission-sources a {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
}

.vendor-panel article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.vendor-panel span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.vendor-panel strong {
  display: block;
  margin: 7px 0;
}

.vendor-panel p,
.vendor-panel li {
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.vendor-panel p {
  margin: 0;
}

.vendor-panel ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 18px;
}

.trade-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.trade-controls select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 34px 0 12px;
  background: #0e131a;
  color: var(--text);
}

.trade-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.trade-callout,
.trade-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.trade-callout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.trade-callout span,
.trade-card-head span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.trade-callout strong,
.trade-card-head strong {
  display: block;
  margin: 6px 0;
}

.trade-callout p,
.trade-card p,
.trade-card small,
.trade-leg span {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.trade-hold {
  display: grid;
  justify-items: center;
  min-width: 76px;
  padding: 10px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #0c1219;
}

.trade-hold b {
  color: var(--teal);
  font-size: 1.4rem;
}

.trade-card {
  display: grid;
  overflow: hidden;
}

.trade-callout {
  grid-column: 1 / -1;
}

.trade-map {
  width: 100%;
  height: 118px;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  filter: saturate(0.9) contrast(1.05);
}

.trade-map.empty {
  background: #0b1016;
}

.trade-route-copy {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.trade-leg,
.trade-profit {
  display: grid;
  gap: 8px;
}

.trade-profit {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trade-profit span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #0c1219;
}

.trade-profit small {
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 800;
}

.trade-profit b,
.trade-leg b {
  display: block;
  color: var(--text);
}

.advisor-shell {
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
  gap: 14px;
}

.advisor-context,
.advisor-chat-panel {
  min-width: 0;
}

.advisor-context {
  display: grid;
  align-content: start;
  gap: 12px;
}

.advisor-context-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.advisor-context-card.ready {
  border-color: rgba(116, 211, 123, 0.34);
  background: #0e1a18;
}

.advisor-context-card.needs-input {
  border-color: rgba(243, 183, 67, 0.38);
  background: #1c1710;
}

.advisor-context-card span,
.advisor-questions span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.advisor-context-card strong {
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.25;
}

.advisor-context-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.advisor-context-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.advisor-context-card dl div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.advisor-context-card dt,
.advisor-context-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.advisor-context-card dt {
  color: var(--soft);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.advisor-context-card dd {
  color: var(--text);
  line-height: 1.35;
}

.advisor-chat-panel {
  display: grid;
  gap: 12px;
}

.advisor-chat-log {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 360px;
  max-height: min(68vh, 660px);
  min-width: 0;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0c1219;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  display: flex;
  min-width: 0;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.assistant {
  justify-content: flex-start;
}

.chat-bubble,
.chat-card {
  min-width: 0;
  max-width: min(100%, 720px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.chat-bubble {
  padding: 12px 14px;
}

.chat-message.user .chat-bubble {
  border-color: rgba(72, 215, 198, 0.34);
  background: #0d1b1d;
}

.chat-bubble strong {
  color: var(--teal);
}

.chat-bubble.loading strong {
  color: var(--gold);
}

.chat-bubble.error {
  border-color: rgba(255, 107, 95, 0.48);
}

.chat-bubble.error strong {
  color: var(--red);
}

.chat-bubble p {
  margin: 0;
  color: var(--muted);
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.chat-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.advisor-input,
.advisor-answer {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.advisor-input {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.advisor-input textarea {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #0e131a;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  outline: none;
}

.advisor-input textarea:focus {
  border-color: var(--teal);
}

.advisor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.advisor-actions button {
  flex: 0 1 180px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #17202b;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.advisor-actions #askAiButton {
  flex: 0 0 auto;
  border-color: transparent;
  background: var(--gold);
  color: #211607;
  font-weight: 900;
}

.advisor-actions .prompt-chip {
  max-width: 190px;
}

.advisor-actions button:hover {
  border-color: var(--teal);
}

.advisor-answer {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 210px;
  padding: 16px;
}

.advisor-answer strong {
  color: var(--teal);
}

.advisor-head {
  display: grid;
  gap: 5px;
}

.advisor-head strong {
  color: var(--teal);
  font-size: 1.25rem;
  line-height: 1.2;
}

.advisor-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(72, 215, 198, 0.28);
  border-radius: var(--radius);
  background: #0d171b;
}

.advisor-summary b {
  min-width: 64px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--teal);
  color: #061413;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 950;
}

.advisor-steps,
.advisor-route,
.advisor-loadout,
.advisor-questions,
.advisor-caveats {
  display: grid;
  gap: 9px;
}

.advisor-steps ol,
.advisor-route ol,
.advisor-loadout ol,
.advisor-caveats ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.advisor-steps li,
.advisor-route li,
.advisor-loadout li,
.advisor-caveats li {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  background: #0d131a;
}

.advisor-steps li b,
.advisor-route li b,
.advisor-loadout li b {
  color: var(--text);
}

.advisor-questions {
  align-items: start;
}

.advisor-questions button {
  min-height: 44px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  padding: 9px 10px;
  background: #0d131a;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
}

.advisor-questions button:hover {
  border-color: var(--teal);
}

.advisor-answer.loading strong {
  color: var(--gold);
}

.advisor-answer.error strong {
  color: var(--red);
}

.advisor-answer p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.evidence-used {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.evidence-used span {
  width: 100%;
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.evidence-used em,
.evidence-used a {
  border: 1px solid #2a3542;
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  text-decoration: none;
}

.evidence-used a:hover {
  border-color: var(--teal);
  color: var(--text);
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2 {
  margin-top: 4px;
  font-size: clamp(1.45rem, 2.8vw, 2.2rem);
}

.upgrade-path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.upgrade-path article {
  display: grid;
  grid-template-rows: auto 132px 1fr;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111820;
}

.upgrade-path article.active {
  border-color: var(--gold);
  background: #1e2118;
}

.step-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
}

.upgrade-path img {
  width: 100%;
  height: 132px;
  object-fit: contain;
  transition: transform 180ms ease;
}

.upgrade-path article:hover img,
.ship-cards article:hover img {
  transform: translateY(-3px) scale(1.03);
}

.upgrade-path strong {
  display: block;
  margin: 5px 0 6px;
  overflow-wrap: anywhere;
}

.loadout-panel {
  display: grid;
  gap: 14px;
}

.loadout-main {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.loadout-main article {
  min-width: 0;
  padding: 14px;
}

.loadout-main ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 18px;
}

.loadout-main p + p {
  margin-top: 10px;
}

.weapon-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.weapon-list a {
  display: grid;
  gap: 6px;
  min-height: 142px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  background: #101720;
  text-decoration: none;
}

.weapon-list a:hover {
  border-color: var(--teal);
  border-left-color: var(--teal);
}

.weapon-list strong,
.weapon-list span,
.weapon-list em,
.weapon-list small {
  overflow-wrap: anywhere;
}

.weapon-list span {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 800;
}

.weapon-list em {
  color: var(--text);
  font-style: normal;
}

.weapon-list small {
  color: var(--muted);
  line-height: 1.35;
}

.rule-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.rule-strip article {
  padding: 12px;
}

.rule-strip strong {
  display: block;
  margin-bottom: 6px;
  color: var(--violet);
}

.database-section details {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
}

.database-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 18px 20px;
  cursor: pointer;
}

.database-section summary span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.database-section summary strong {
  font-size: 1.25rem;
}

.database-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(136px, auto) minmax(150px, 190px) minmax(126px, auto);
  align-items: center;
  gap: 10px;
  padding: 0 20px 16px;
}

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0e131a;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  white-space: nowrap;
}

.filter-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.compare-tray {
  display: grid;
  gap: 10px;
  margin: 0 20px 16px;
  padding: 12px;
  border: 1px solid #2a3542;
  border-radius: var(--radius);
  background: #0f151d;
  color: var(--muted);
}

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compare-head strong {
  font-size: 1rem;
}

.compare-head button,
.compare-btn,
.table-compare {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #17202b;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.compare-head button:hover,
.compare-btn:hover,
.table-compare:hover {
  border-color: var(--teal);
}

.compare-btn {
  justify-self: start;
  margin-top: 9px;
  padding: 6px 10px;
}

.table-compare {
  margin-top: 8px;
  padding: 5px 9px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 132px repeat(var(--compare-ship-cols), minmax(130px, 1fr));
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
}

.compare-grid > * {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 44px;
  padding: 9px 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-wrap: anywhere;
}

.compare-grid > strong {
  gap: 6px;
  color: var(--text);
}

.compare-grid > strong img {
  width: 58px;
  height: 42px;
  object-fit: contain;
}

.compare-grid > span {
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-grid > em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.ship-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 18px;
}

.equipment-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 18px;
}

.equipment-summary article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.equipment-summary strong {
  display: block;
  color: var(--text);
  font-size: 1.3rem;
}

.equipment-summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.ship-cards article {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.ship-cards article.locked {
  opacity: 0.58;
}

.ship-cards img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  align-self: center;
  transition: transform 180ms ease;
}

.ship-cards strong {
  display: block;
  margin: 4px 0 5px;
}

.ship-cards small {
  display: block;
  margin-top: 8px;
  color: var(--soft);
  line-height: 1.35;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #121922;
  color: var(--soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

td:first-child {
  color: var(--text);
  font-weight: 750;
}

.quality-panel {
  display: grid;
  gap: 12px;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.quality-grid article,
.validation-ledger article,
.quality-notes article {
  min-width: 0;
  padding: 14px;
}

.quality-grid span,
.validation-ledger span,
.confidence-card span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.quality-grid strong {
  display: block;
  margin: 7px 0;
  font-size: 1.45rem;
}

.quality-grid p,
.validation-ledger p,
.validation-ledger small,
.confidence-card p,
.confidence-card li,
.quality-notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.validation-ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.validation-ledger article {
  display: grid;
  gap: 8px;
}

.validation-ledger strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
}

.validation-ledger small {
  display: block;
  color: var(--muted-2);
}

.confidence-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  padding: 16px;
  border-left: 4px solid var(--blue);
}

.confidence-card.good {
  border-left-color: var(--green);
}

.confidence-card.warn {
  border-left-color: var(--gold);
}

.confidence-card.manual {
  border-left-color: var(--blue);
}

.confidence-card strong {
  display: block;
  margin: 5px 0 8px;
  font-size: 1.25rem;
}

.confidence-card ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
}

.quality-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quality-notes strong {
  display: block;
  margin-bottom: 7px;
  color: var(--teal);
}

.quality-notes code {
  padding: 1px 4px;
  border: 1px solid #2a3542;
  border-radius: 4px;
  background: #090f15;
  color: var(--text);
  font-size: 0.88em;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.source-list article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.source-list a {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.source-list a:hover {
  text-decoration: underline;
}

@media (max-width: 1060px) {
  .hero-flow,
  .answer-card {
    grid-template-columns: 1fr;
  }

  .answer-card {
    min-height: 0;
  }

  .answer-art {
    min-height: 260px;
  }

  .answer-copy h2 {
    max-width: 18ch;
  }

  .answer-actions,
  .route-line,
  .quick-grid,
  .editor-shell,
  .ship-editor-card,
  .advisor-shell,
  .upgrade-path,
  .loadout-main,
  .weapon-list,
  .mission-grid,
  .mission-strip,
  .rule-strip,
  .vendor-panel,
  .trade-panel,
  .ship-cards,
  .quality-grid,
  .validation-ledger,
  .quality-notes,
  .source-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .database-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-grid {
    grid-template-columns: 116px repeat(var(--compare-ship-cols), minmax(128px, 1fr));
  }
}

@media (max-width: 720px) {
  html {
    scroll-padding-bottom: calc(112px + var(--safe-bottom));
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: calc(14px + var(--safe-top)) 10px 10px;
    border-bottom: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .topbar nav {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    gap: 6px;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(13, 16, 21, 0.94);
    backdrop-filter: blur(18px);
    overflow-x: visible;
  }

  .topbar nav a {
    display: grid;
    min-height: 44px;
    place-items: center;
    padding: 8px 4px;
    border-color: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-size: 0.78rem;
    text-align: center;
  }

  body:has(input:focus) .topbar nav,
  body:has(select:focus) .topbar nav,
  body:has(textarea:focus) .topbar nav {
    transform: translateY(calc(100% + var(--safe-bottom)));
  }

  main {
    width: min(100% - 20px, 1240px);
    padding-top: 12px;
    padding-bottom: calc(112px + var(--safe-bottom));
  }

  .manual-controls,
  .workflow-tabs,
  .editor-summary dl,
  .ship-goal-strip,
  .ship-editor-readout,
  .answer-actions,
  .route-line,
  .quick-grid,
  .editor-shell,
  .editor-fields,
  .ship-editor-card,
  .hardpoint-row,
  .advisor-shell,
  .upgrade-path,
  .loadout-main,
  .weapon-list,
  .mission-card-head,
  .mission-grid,
  .mission-strip,
  .rule-strip,
  .vendor-panel,
  .trade-panel,
  .database-controls,
  .market-controls,
  .ship-cards,
  .equipment-summary,
  .quality-grid,
  .validation-ledger,
  .quality-notes,
  .confidence-card,
  .source-list {
    grid-template-columns: 1fr;
  }

  .market-results article {
    grid-template-columns: 1fr;
  }

  .answer-copy {
    gap: 12px;
    padding: 16px;
  }

  .answer-copy h2 {
    font-size: clamp(1.45rem, 7vw, 2.15rem);
    line-height: 1.05;
  }

  .answer-art {
    min-height: 156px;
  }

  .answer-art img {
    max-height: 124px;
  }

  .answer-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mission-card-head img {
    max-height: 86px;
    justify-self: start;
  }

  .share-panel {
    grid-template-columns: 1fr;
  }

  .editor-actions.sticky {
    bottom: calc(76px + var(--safe-bottom));
  }

  .editor-actions.sticky button,
  .editor-fields button {
    flex: 1 1 180px;
  }

  .trade-callout,
  .trade-card,
  .trade-leg,
  .trade-profit,
  .advisor-summary {
    grid-template-columns: 1fr;
  }

  .trade-map {
    min-height: 180px;
  }

  .advisor-chat-log {
    min-height: 240px;
    max-height: min(32vh, 300px);
    padding: 10px;
  }

  .advisor-context {
    gap: 10px;
  }

  .advisor-context-card {
    gap: 8px;
    padding: 12px;
  }

  .advisor-context-card strong {
    font-size: 0.98rem;
  }

  .advisor-context-card p {
    font-size: 0.88rem;
  }

  .advisor-context-card dl {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .advisor-context-card dl div {
    flex: 0 0 122px;
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px;
    border: 1px solid #2a3542;
    border-radius: 6px;
    background: #0d131a;
  }

  .advisor-input {
    gap: 10px;
    padding: 12px;
  }

  .advisor-input textarea {
    min-height: 112px;
  }

  .advisor-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .advisor-actions button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .advisor-actions .prompt-chip {
    max-width: none;
  }

  .advisor-actions #askAiButton {
    min-width: 86px;
    text-align: center;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .drop-zone {
    min-height: 112px;
    padding: 16px;
  }

  .save-help p,
  .save-help code {
    font-size: 0.8rem;
  }

  .quick-card,
  .plan-section,
  .editor-section,
  .loadout-section,
  .advisor-section,
  .vendor-section,
  .trade-section,
  .quality-section,
  .source-section {
    padding: 16px;
  }

  .database-section summary,
  .database-controls,
  .ship-cards,
  .compare-tray {
    padding-left: 16px;
    padding-right: 16px;
  }

  .compare-tray {
    margin-left: 16px;
    margin-right: 16px;
  }

  .ship-cards article {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .ship-cards img {
    width: 82px;
    height: 82px;
  }
}

@media (max-width: 440px) {
  .topbar nav a {
    font-size: 0.74rem;
  }

  .editor-mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .editor-mode-tabs button {
    min-height: 56px;
    padding: 8px 7px;
  }

  .editor-mode-tabs strong {
    font-size: 0.76rem;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .ship-cards article {
    grid-template-columns: 1fr;
  }

  .ship-cards img {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes ship-drift {
  0%,
  100% {
    transform: translateY(0) rotate(-0.4deg);
  }

  50% {
    transform: translateY(-8px) rotate(0.4deg);
  }
}

/* Feature-shell overhaul: one primary workspace at a time. */
.feature-panel[hidden] {
  display: none !important;
}

.feature-panel.active {
  min-width: 0;
}

.topbar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  width: 236px;
  padding: 24px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  background: rgba(13, 16, 21, 0.95);
  backdrop-filter: blur(18px);
}

.topbar nav {
  display: grid;
  align-content: start;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
}

.topbar nav a {
  display: grid;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #101720;
  white-space: normal;
}

.topbar nav a.active,
.topbar nav a[aria-current="page"] {
  border-color: rgba(72, 215, 198, 0.48);
  background: #0f2025;
  color: var(--text);
}

main {
  width: auto;
  max-width: 1320px;
  margin-right: 28px;
  margin-left: 264px;
}

.progression-workspace {
  display: grid;
  gap: 18px;
}

.editor-toggle {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid rgba(243, 183, 67, 0.34);
  border-radius: 8px;
  background: #17180f;
  color: var(--text);
  font-weight: 800;
}

.editor-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.hardpoint-control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.hardpoint-control small {
  color: var(--soft);
  font-size: 0.76rem;
  line-height: 1.35;
}

.hardpoint-row select {
  width: 100%;
}

.staged-edit-panel {
  display: grid;
  min-width: 0;
}

.staged-edit-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.staged-edit-card.ready {
  border-color: rgba(116, 211, 123, 0.34);
  background: #0e1a18;
}

.staged-edit-card > div > span,
.staged-edit-list article span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.staged-edit-card strong,
.staged-edit-list strong {
  display: block;
  overflow-wrap: anywhere;
}

.staged-edit-card p,
.staged-edit-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.staged-edit-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.staged-edit-list article {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #26313d;
  border-radius: 6px;
  background: #0b1118;
}

.staged-edit-list article.warning {
  border-color: rgba(255, 107, 95, 0.42);
  background: #1b1110;
}

.editor-manifest-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin-top: 10px;
}

.editor-manifest-grid article {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.editor-manifest-grid article.ready {
  border-color: rgba(116, 211, 123, 0.3);
  background: #0e1a18;
}

.editor-manifest-grid article.guarded {
  border-color: rgba(243, 183, 67, 0.26);
  background: #17140f;
}

.editor-manifest-grid span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.editor-manifest-grid ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.4;
}

.editor-manifest-grid li {
  overflow-wrap: anywhere;
}

#downloadEditedSave {
  border-color: transparent;
  background: var(--gold);
  color: #211607;
}

#downloadBackupSave,
#clearAllEditsButton {
  border-color: var(--line);
  background: #17202b;
  color: var(--teal);
}

@media (max-width: 960px) {
  .topbar {
    position: sticky;
    top: 0;
    bottom: auto;
    width: auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: calc(12px + var(--safe-top)) 10px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .topbar nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-top: 0;
  }

  .topbar nav a {
    min-height: 42px;
    place-items: center;
    padding: 8px 4px;
    font-size: 0.78rem;
    text-align: center;
  }

  main {
    width: min(100% - 20px, 1240px);
    margin-right: auto;
    margin-left: auto;
    padding-top: 12px;
    padding-bottom: calc(36px + var(--safe-bottom));
  }
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 128px;
    scroll-padding-bottom: var(--safe-bottom);
  }

  .topbar nav {
    position: static;
    width: 100%;
    padding: 0;
    border-top: 0;
    background: transparent;
    backdrop-filter: none;
  }

  body:has(input:focus) .topbar nav,
  body:has(select:focus) .topbar nav,
  body:has(textarea:focus) .topbar nav {
    transform: none;
  }

  .level-rail-wrap {
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    overflow: visible;
  }

  .level-rail-wrap > span {
    justify-self: stretch;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: 0.72rem;
  }

  .level-rail {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .level-rail button span {
    display: block;
  }

  body:has(input:focus) .level-rail-wrap,
  body:has(select:focus) .level-rail-wrap,
  body:has(textarea:focus) .level-rail-wrap {
    transform: none;
  }

  .hardpoint-row {
    grid-template-columns: 1fr;
  }

  .staged-edit-list {
    grid-template-columns: 1fr;
  }
}
.manual-controls input,
.manual-controls select,
.database-controls input,
.database-controls select,
.trade-controls select,
.editor-fields input,
.editor-fields select,
.ship-goal-strip select,
.editor-toggle,
.hardpoint-row select,
.save-editor input,
.save-editor button,
.editor-fields button,
.editor-actions button,
.share-panel button,
.compare-head button,
.compare-btn,
.table-compare,
.advisor-questions button {
  min-height: 44px;
}

/* UX overhaul: simplify the app into a guided command center. */
.section-copy {
  max-width: 74ch;
  margin: -4px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.command-center {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.start-card,
.reference-section > details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.92);
  box-shadow: var(--shadow);
}

.start-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.start-options {
  display: grid;
  gap: 12px;
}

.primary-upload {
  min-height: 150px;
  border-color: rgba(72, 215, 198, 0.52);
  background:
    linear-gradient(135deg, rgba(72, 215, 198, 0.12), rgba(117, 167, 255, 0.06)),
    #101720;
}

.primary-upload strong {
  font-size: 1.18rem;
}

.manual-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #2a3542;
  border-radius: var(--radius);
  background: #0f151d;
}

.manual-card > strong {
  color: var(--teal);
  font-size: 0.98rem;
}

.band-summary {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid rgba(72, 215, 198, 0.28);
  border-radius: var(--radius);
  background: #0d171b;
}

.band-summary strong {
  color: var(--teal);
  line-height: 1.25;
}

.band-summary span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.level-rail-wrap {
  display: grid;
  gap: 8px;
}

.level-rail-wrap > span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.level-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.level-rail button {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 50px;
  border: 1px solid #2a3542;
  border-radius: 6px;
  padding: 7px 8px;
  background: #0c1219;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.level-rail button:hover,
.level-rail button.active {
  border-color: var(--teal);
  background: #102027;
  color: var(--text);
}

.level-rail button b {
  color: var(--text);
  font-size: 0.9rem;
}

.level-rail button span {
  overflow: hidden;
  color: var(--soft);
  font-size: 0.72rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-rail button.active span {
  color: var(--teal);
}

.decision-card {
  min-height: 430px;
}

.next-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.static-action {
  display: grid;
  color: inherit;
  text-decoration: none;
}

.static-action:hover {
  border-color: var(--teal);
}

.plan-hub {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.92);
  box-shadow: var(--shadow);
}

.plan-grid {
  display: grid;
  gap: 22px;
}

.plan-card {
  margin: 0;
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.plan-card:first-child {
  padding-top: 0;
  border-top: 0;
}

.next-thirty-panel {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.next-thirty-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 16px;
  align-items: stretch;
}

.next-thirty-head > div:first-child,
.next-thirty-status,
.next-thirty-steps li,
.next-thirty-wait {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.next-thirty-head > div:first-child {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.next-thirty-head span,
.next-thirty-steps span,
.next-thirty-wait span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.next-thirty-head h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  line-height: 1.08;
}

.next-thirty-head p,
.next-thirty-steps p,
.next-thirty-wait p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.next-thirty-status {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px;
}

.next-thirty-status small {
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.next-thirty-status strong {
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.next-thirty-status em {
  color: var(--teal);
  font-size: 0.88rem;
  font-style: normal;
  font-weight: 800;
}

.next-thirty-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.next-thirty-steps li {
  display: grid;
  gap: 7px;
  padding: 14px;
}

.next-thirty-steps strong {
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.next-thirty-wait {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-color: rgba(243, 183, 67, 0.25);
  background: #17140f;
}

.section-title.mini {
  align-items: start;
  margin-bottom: 12px;
}

.section-title.mini h3 {
  margin: 2px 0 0;
  font-size: clamp(1.08rem, 2vw, 1.32rem);
  line-height: 1.18;
}

.section-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head-row .trade-controls {
  justify-content: flex-end;
  margin-bottom: 0;
}

.advisor-context-wrap {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.advisor-benefits {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(72, 215, 198, 0.32);
  border-radius: var(--radius);
  background: #0d171b;
}

.advisor-benefits strong {
  color: var(--teal);
}

.advisor-benefits span {
  display: block;
  padding: 9px 10px;
  border: 1px solid #25313b;
  border-radius: 6px;
  background: #0c1219;
  color: var(--muted);
  line-height: 1.35;
}

.reference-section {
  margin-top: 22px;
}

.reference-section > details {
  overflow: hidden;
}

.reference-section > details > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 18px 20px;
  cursor: pointer;
}

.reference-section > details > summary span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reference-section > details > summary strong {
  font-size: 1.1rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.reference-section .database-section,
.reference-section .quality-section,
.reference-section .source-section {
  margin-top: 0;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.reference-section .database-controls,
.reference-section .ship-cards,
.reference-section .equipment-summary {
  padding-right: 0;
  padding-left: 0;
}

.pipeline-section {
  margin-bottom: 22px;
}

.market-finder-section {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.market-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(160px, 220px);
  gap: 10px;
}

.market-filter-chips {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 8px;
}

.market-filter-chips label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0e131a;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.market-filter-chips input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.market-finder-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.market-summary,
.market-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.market-summary article,
.market-results article,
.market-empty {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.market-summary article {
  display: grid;
  gap: 3px;
}

.market-summary strong {
  color: var(--text);
  font-size: 1.18rem;
}

.market-summary span,
.market-results span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.market-filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(72, 215, 198, 0.18);
  border-radius: var(--radius);
  background: #0d171b;
}

.market-filter-summary strong {
  color: var(--teal);
}

.market-filter-summary span,
.market-filter-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.market-results {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.market-results article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.45fr);
  gap: 10px;
}

.market-results article.locked {
  border-color: rgba(255, 183, 67, 0.24);
}

.market-results strong,
.market-empty strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.market-results p,
.market-results small,
.market-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.pipeline-upload {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.pipeline-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.pipeline-card,
.pipeline-readiness article,
.pipeline-gates article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.pipeline-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.pipeline-card.ready {
  border-color: rgba(116, 211, 123, 0.36);
  background: #0e1a18;
}

.pipeline-card.warning,
.pipeline-gates article.warning {
  border-color: rgba(243, 183, 67, 0.36);
  background: #1b1710;
}

.pipeline-card span,
.pipeline-readiness span,
.pipeline-gates span {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pipeline-card strong,
.pipeline-readiness strong,
.pipeline-gates strong {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}

.pipeline-card p,
.pipeline-card li,
.pipeline-card small,
.pipeline-readiness p,
.pipeline-gates p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.pipeline-card code {
  display: block;
  padding: 10px;
  border: 1px solid #24303c;
  border-radius: 6px;
  background: #080d12;
  color: var(--text);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.pipeline-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.pipeline-readiness,
.pipeline-gates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pipeline-readiness article,
.pipeline-gates article {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.pipeline-gates article.ready {
  border-color: rgba(116, 211, 123, 0.32);
  background: #0e1a18;
}

.reference-section .compare-tray {
  margin-right: 0;
  margin-left: 0;
}

.reference-section .table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (max-width: 1060px) {
  .command-center {
    grid-template-columns: 1fr;
  }

  .next-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .decision-card {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  main {
    width: min(100% - 74px, 1240px);
    margin-right: 62px;
    margin-left: 10px;
  }

  .topbar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .command-center,
  .start-options,
  .next-actions,
  .section-head-row {
    grid-template-columns: 1fr;
  }

  .command-center {
    display: flex;
    flex-direction: column;
  }

  .decision-card {
    order: -1;
  }

  .section-head-row {
    display: grid;
  }

  .section-head-row .trade-controls {
    justify-content: stretch;
  }

  .section-head-row .trade-controls select,
  .section-head-row .filter-check {
    width: 100%;
  }

  .start-card,
  .plan-hub {
    padding: 16px;
  }

  .level-rail-wrap {
    position: fixed;
    top: 88px;
    right: 6px;
    bottom: calc(84px + var(--safe-bottom));
    z-index: 25;
    width: 50px;
    gap: 6px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(13, 16, 21, 0.92);
    backdrop-filter: blur(16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .level-rail-wrap > span {
    justify-self: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.62rem;
  }

  .level-rail {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .level-rail button {
    min-height: 42px;
    place-items: center;
    padding: 5px 3px;
    text-align: center;
  }

  .level-rail button b {
    font-size: 0.78rem;
  }

  .level-rail button span {
    display: none;
  }

  body:has(input:focus) .level-rail-wrap,
  body:has(select:focus) .level-rail-wrap,
  body:has(textarea:focus) .level-rail-wrap {
    transform: translateX(calc(100% + 12px));
  }

  .reference-section > details > summary {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .reference-section .database-section,
  .reference-section .quality-section,
  .reference-section .source-section {
    padding: 16px;
  }

  .pipeline-upload,
  .pipeline-readiness,
  .pipeline-gates,
  .market-controls,
  .next-thirty-head,
  .next-thirty-steps,
  .editor-manifest-grid,
  .market-results {
    grid-template-columns: 1fr;
  }

  .market-results article {
    grid-template-columns: 1fr;
  }

  .market-filter-chips label {
    flex: 1 1 140px;
    justify-content: center;
  }

  .market-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Final shell overrides; keep feature navigation top-mounted on phones. */
@media (max-width: 960px) {
  .topbar {
    position: sticky;
    top: 0;
    bottom: auto;
    width: auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: calc(12px + var(--safe-top)) 10px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .topbar nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 7px;
    margin-top: 0;
    padding: 0;
    border-top: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .topbar nav a {
    min-height: 42px;
    place-items: center;
    padding: 8px 4px;
    font-size: 0.78rem;
    text-align: center;
  }

  main {
    width: min(100% - 20px, 1240px);
    margin-right: auto;
    margin-left: auto;
    padding-top: 12px;
    padding-bottom: calc(36px + var(--safe-bottom));
  }
}

@media (max-width: 720px) {
  body:has(input:focus) .topbar nav,
  body:has(select:focus) .topbar nav,
  body:has(textarea:focus) .topbar nav {
    transform: none;
  }

  .level-rail-wrap {
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    overflow: visible;
  }

  .level-rail-wrap > span {
    justify-self: stretch;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: 0.72rem;
  }

  .level-rail {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .level-rail button span {
    display: block;
  }

  body:has(input:focus) .level-rail-wrap,
  body:has(select:focus) .level-rail-wrap,
  body:has(textarea:focus) .level-rail-wrap {
    transform: none;
  }
}
