/* Burn Ledger Companion — mobile first, widens to a two-column desktop layout. */

:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0d1420;
  --panel-2: #111a28;
  --line: #1c2838;
  --line-soft: #141d2a;
  --fg: #dbe6f2;
  --dim: #8ba3bd;
  --faint: #5a6e85;
  --accent: #ffb347;
  --accent-ink: #241703;
  --teal: #4fd6c0;
  --red: #ea6a5e;
  --green: #63c98b;
  --font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute is only `display:none` in the UA stylesheet, so any id/class rule
   that sets `display` silently defeats it. `.shell` sets `display:flex` below, which once
   left the whole app chrome visible behind the login gate. Do not remove this. */
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2 { margin: 0; font-weight: 600; }

/* ───────────── shell ───────────── */
.shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.ident { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.pilot { font-family: var(--font); color: var(--teal); letter-spacing: .1em; font-size: 13px; }
.credits { font-size: 12px; color: var(--dim); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.tickclock { font-family: var(--font); font-size: 11px; color: var(--faint); }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  border-radius: var(--r); width: 38px; height: 38px; font-size: 17px; line-height: 1;
}
.icon-btn:active { color: var(--accent); }
.icon-btn.spin { animation: spin .7s linear infinite; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; padding: 12px 4px; background: none; border: 0;
  border-bottom: 2px solid transparent; color: var(--faint);
  font-size: 13px; letter-spacing: .04em; -webkit-user-select: none; user-select: none;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

.content { flex: 1; padding: 12px; }
.screen { max-width: 1200px; margin: 0 auto; }

.pane { min-width: 0; }
.pane-title {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--faint); margin: 16px 0 8px;
}
.pane-title:first-child { margin-top: 0; }

/* ───────────── rows & lists ───────────── */
.list { border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.list:empty::after {
  content: "Nothing here."; display: block; padding: 14px; color: var(--faint); font-size: 13px;
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 13px; border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row.tappable { cursor: pointer; }
.row.tappable:hover { background: var(--panel-2); }
.row.selected { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.row-main { min-width: 0; }
.row-name { display: block; font-size: 14px; }
.row-sub { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
.row-side { text-align: right; white-space: nowrap; }
.row-value { display: block; font-family: var(--font); font-size: 13px; color: var(--teal); }
.row-note { display: block; font-size: 11px; color: var(--faint); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.hint { color: var(--faint); font-size: 12px; margin: 8px 0; }
.hint.disclaimer { margin-top: 16px; line-height: 1.5; }

/* standing colours */
.st-hostile { color: var(--red); }
.st-core, .st-ally { color: var(--teal); }
.st-marked { color: var(--accent); }
.st-neutral { color: var(--dim); }

/* ───────────── gauges ───────────── */
.gauge { padding: 11px 13px; border-bottom: 1px solid var(--line-soft); }
.gauge:last-child { border-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.gauge-label { letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.gauge-value { font-family: var(--font); color: var(--fg); }
.gauge-track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--teal); border-radius: 3px; }
.gauge-fill.warn { background: var(--accent); }
.gauge-fill.bad { background: var(--red); }

/* ───────────── hull rail ───────────── */
.hull-rail { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; }
.hull-chip {
  flex: 0 0 auto; text-align: left; padding: 9px 13px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
}
.hull-chip-name { display: block; font-size: 13px; color: var(--fg); }
.hull-chip-sub { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }
/* The active hull is shown by colour, not a punctuation mark. */
.hull-chip.active {
  background: rgba(255,179,71,.14); border-color: var(--accent);
}
.hull-chip.active .hull-chip-name { color: var(--accent); font-weight: 600; }
.hull-chip.active .hull-chip-sub { color: var(--accent); opacity: .8; }
.hull-chip.inspected { outline: 2px solid var(--teal); outline-offset: -2px; }

.command-row { margin-top: 10px; }
.command-row .primary { margin-top: 8px; }

/* ───────────── chips ───────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 7px 12px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip.danger.on { background: var(--red); border-color: var(--red); color: #1b0605; }

/* Comms go out from the hull you have command of, and land on the recipient's nearest
   hull. Both facts change the light delay, so the sender is not decoration. */
.from-line {
  margin: 0 0 12px; padding: 9px 12px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--teal); border-radius: var(--r); color: var(--dim);
}
.from-line strong { color: var(--fg); font-weight: 600; }
.from-line .from-warn { color: var(--accent); }

.compose-target { margin-bottom: 4px; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ───────────── messages ───────────── */
.msg { padding: 11px 13px; border-bottom: 1px solid var(--line-soft); }
.msg:last-child { border-bottom: 0; }
.msg-head { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; margin-bottom: 5px; }
.msg-from { color: var(--teal); font-family: var(--font); letter-spacing: .06em; }
.msg-chan { color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.msg-body { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.msg.mine { background: rgba(79,214,192,.05); }
.msg.mine .msg-from { color: var(--dim); }

/* ───────────── cards ───────────── */
.cards { display: grid; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.route-ore { font-size: 15px; font-weight: 600; }
.route-profit { font-family: var(--font); color: var(--green); font-size: 15px; white-space: nowrap; }
.route-path { margin: 0 0 4px; font-size: 13px; color: var(--dim); }
.route-meta { margin: 0 0 4px; font-size: 12px; color: var(--dim); font-family: var(--font); }
.route-legs { margin: 0 0 6px; }
.route-run2 { margin: 0; font-size: 12px; color: var(--dim); }
.route-run2.bad { color: var(--red); }
.warn-text { color: var(--accent) !important; }
.route-warnings { margin-top: 8px; }
.warn { font-size: 12px; color: var(--accent); margin: 4px 0 0; }
.market-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.market-controls { display: flex; gap: 6px; flex-wrap: wrap; }

/* The two halves of Buy & sell answer different questions — "shift what I am holding" and
   "start a new trade". On a phone they stack and the headings carry it; on a desktop they
   sat as one undifferentiated wall of cards. */
.section { margin-top: 22px; }
.section:first-child { margin-top: 0; }
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.section-head h3 {
  margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--teal);
}
.section-head .section-note { font-size: 12px; color: var(--faint); }

@media (min-width: 760px) {
  .section {
    margin-top: 28px; padding: 18px 20px 20px;
    background: rgba(255,255,255,.014);
    border: 1px solid var(--line-soft); border-radius: 14px;
  }
  .section-head h3 { font-size: 13px; }
}

/* ───────────── desktop ───────────── */
@media (min-width: 760px) {
  body { font-size: 15px; }
  .content { padding: 20px 24px 40px; }
  .tabs { justify-content: flex-start; padding: 0 24px; }
  .tabs button { flex: 0 0 auto; padding: 13px 22px; font-size: 14px; }
  .topbar { padding: 12px 24px; }
  .split { display: grid; grid-template-columns: minmax(320px, 460px) 1fr; gap: 24px; align-items: start; }
  .plot-wrap { position: sticky; top: 78px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .hull-rail { flex-wrap: wrap; overflow: visible; }
}

@media (min-width: 1200px) {
  .split { grid-template-columns: minmax(360px, 520px) 1fr; }
}

/* ── Notifications screen ── */
.icon-btn.on { color: var(--accent); border-color: var(--accent); }
/* The bell is the one emoji in the UI. Desaturated so it sits in the palette beside the
   monochrome ⟳ instead of shouting in full colour. */
#bell { filter: grayscale(1); font-size: 15px; }
#bell.on { filter: none; }

/* This is the first screen to stack .pane blocks vertically. `.pane-title:first-child`
   zeroes its own top margin — correct WITHIN a pane, but it leaves stacked panes flush
   against each other, so the device list's border ran straight into the next heading. */
#screen-settings .pane + .pane { margin-top: 22px; }

.push-headline { font-family: var(--font); font-size: 14px; color: var(--fg); margin: 0 0 6px; }
/* Which device the switches below belong to. Loud on purpose when it is NOT the device
   in your hand — silencing a phone you left at home and not working out why for a week
   is the failure mode this screen has to design against. */
.push-editing {
  font-family: var(--font); font-size: 12px; letter-spacing: .04em;
  color: var(--faint); margin: 12px 0 4px;
}
.push-editing.remote {
  color: var(--accent-ink); background: var(--accent);
  padding: 7px 10px; border-radius: var(--r); margin-bottom: 8px;
}
.hint.silenced { color: var(--accent); }
.hint.err { color: var(--red); }

.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.toggle:last-child { border-bottom: 0; }
.toggle-text { display: flex; flex-direction: column; min-width: 0; }
.toggle-label { font-size: 13px; color: var(--fg); }
.toggle-detail { font-size: 11px; color: var(--faint); margin-top: 2px; }
/* A 44px target: the iOS minimum, and this is a phone-first screen. */
.toggle input { width: 22px; height: 22px; margin: 11px; flex: none; accent-color: var(--accent); }

.primary.launch { display: inline-block; text-align: center; text-decoration: none; margin-top: 4px; }
/* Turning notifications off is destructive, so it must not look like the same button as
   turning them on. `.danger` existed only for chips, so this rendered in accent orange. */
.primary.danger { background: var(--red); color: #1b0605; }

/* ── Events feed ── */
.row.event { display: flex; align-items: baseline; gap: 12px; padding: 10px 12px 10px 14px; }
/* The accent bar carries the category, matching the push categories in server/push.py so
   an event looks the same wherever a player meets it. */
.row.event { box-shadow: inset 3px 0 0 var(--faint); }
.row.event[data-category="combat"]     { box-shadow: inset 3px 0 0 var(--red); }
.row.event[data-category="claims"]     { box-shadow: inset 3px 0 0 var(--accent); }
.row.event[data-category="mining"]     { box-shadow: inset 3px 0 0 var(--green); }
.row.event[data-category="navigation"] { box-shadow: inset 3px 0 0 var(--teal); }
.row.event[data-category="comms"]      { box-shadow: inset 3px 0 0 #7aa2f7; }
.event-text { flex: 1; font-size: 13px; line-height: 1.45; color: var(--fg); min-width: 0; }
.event-age { font-family: var(--font); font-size: 11px; color: var(--faint); white-space: nowrap; }

/* ── Comms layout ──
   Phone: DOM order — compose, then the messages you came to read, then contacts.
   The contacts roster used to sit inside the compose column, which on a phone stacked it
   ABOVE the inbox and pushed every message off the bottom of the screen.
   Desktop: two columns, with contacts tucked under the compose form so the message column
   still gets the full height. */
.comms-layout { display: flex; flex-direction: column; gap: 22px; }

.comms-contacts > .contacts-summary {
  cursor: pointer; list-style: none; margin: 0 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.comms-contacts > .contacts-summary::-webkit-details-marker { display: none; }
.comms-contacts > .contacts-summary::before {
  content: "›"; display: inline-block; transition: transform .15s ease;
  font-size: 15px; line-height: 1; color: var(--faint);
}
.comms-contacts[open] > .contacts-summary::before { transform: rotate(90deg); }

.chip .chip-count { opacity: .65; margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip.on .chip-count { opacity: .8; }

@media (min-width: 760px) {
  .comms-layout {
    display: grid;
    grid-template-columns: minmax(320px, 460px) 1fr;
    grid-template-areas: "compose messages" "contacts messages";
    gap: 24px; align-items: start;
  }
  .comms-compose { grid-area: compose; }
  .comms-messages { grid-area: messages; }
  .comms-contacts { grid-area: contacts; }
}

/* ── Reply ── */
.msg-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.msg-actions:empty { display: none; }
.msg-actions .chip { padding: 5px 10px; font-size: 11px; }

/* The inbox is filtered by channel, so a private reply to a broadcast switches channel and
   the message being answered scrolls out of the list. This keeps the target on screen. */
.reply-context {
  display: flex; align-items: baseline; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r); padding: 8px 10px; margin: 10px 0 0;
  font-size: 12px; color: var(--dim);
}
#reply-context-text { flex: 1; min-width: 0; }
.reply-clear {
  background: none; border: 0; color: var(--faint);
  font-size: 11px; text-decoration: underline; padding: 0; flex: none;
}
