:root {
  --bg: #05070f;
  --fg: #e8edf2;
  --muted: #8b97a5;
  --accent: #d68ee0;
  --accent-contrast: #1c0a20;
  --card: #14181d;
  --line: #232a32;
  --well: #0f1216;
  --calm: #7ee0a8;
  --warn: #e0b87e;
  --alert: #e0937e;
  --read: 46rem;
  --wide: 80rem;
  --bar-start: 0px;
  --bar-end: 0px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar > .bar-inner { margin-left: var(--bar-start); margin-right: var(--bar-end); }
:root[data-window="mac-app"] { --bar-start: 4rem; }
@media (display-mode: window-controls-overlay) {
  :root { --bar-start: max(0px, calc(env(titlebar-area-x, 0px) - 1rem)); --bar-end: max(0px, calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) - 1rem)); }
  .bar { min-height: env(titlebar-area-height, 0px); -webkit-app-region: drag; app-region: drag; }
  .bar a, .bar button, .bar select, .bar input, .bar label { -webkit-app-region: no-drag; app-region: no-drag; }
}
.bar-inner { display: flex; align-items: center; gap: 1rem; }
.spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.3rem 0.4rem; margin-left: -0.4rem; border: 0; border-radius: 0.5rem; background: none; color: var(--fg); font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; }
.brand:hover { background: var(--card); }
.brand::after { content: ""; width: 0.35rem; height: 0.35rem; margin: -0.2rem 0 0 0.1rem; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.mark { width: 0.9rem; height: 0.9rem; border-radius: 0.3rem; background: var(--accent); flex: none; }
.me { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.me:hover { color: var(--fg); }
.me svg { width: 1.1rem; height: 1.1rem; }
.menu { position: fixed; inset: auto; top: 3.6rem; bottom: auto; width: max-content; height: auto; max-height: calc(100vh - 4.5rem); overflow-y: auto; margin: 0; min-width: 14rem; padding: 0.35rem; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 0.75rem; box-shadow: 0 12px 30px rgb(0 0 0 / 0.5); }
.menu:popover-open { display: grid; align-content: start; gap: 2px; }
.menu-start { left: calc(0.6rem + var(--bar-start)); }
.menu-end { right: calc(0.6rem + var(--bar-end)); }
.menu > a, .menu > button { display: flex; align-items: center; gap: 0.65rem; width: 100%; padding: 0.5rem 0.7rem; border: 0; border-radius: 0.5rem; background: none; color: var(--fg); font: inherit; font-size: 0.92rem; text-align: left; text-decoration: none; cursor: pointer; }
.menu > a:hover, .menu > button:hover { background: var(--line); }
.menu > [aria-current] { font-weight: 600; }
.menu > a > i { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); }
.menu hr { width: 100%; margin: 0.25rem 0; border: 0; border-top: 1px solid var(--line); }
.menu .to-sluice > i { background: #7ec4e0; }
.menu .to-scan > i { background: #b8a0e8; }
.menu .to-iris > i { background: #d0dc7e; }
.menu .to-streamline > i { background: #e0877e; }
.menu .to-exchange > i { background: #7ee0a8; }
.menu .to-cadence > i { background: #e0b07e; }
.menu .to-account > i { background: #e89ab8; }
.shell { flex: 1 0 auto; width: 100%; max-width: calc(var(--shell) + 14.5rem); margin: 0 auto; padding: 0 1.25rem; display: grid; grid-template-columns: 12.5rem minmax(0, 1fr) 12.5rem; gap: 2rem; }
.nav { position: sticky; top: 3.5rem; align-self: start; padding: 1.5rem 0; display: grid; gap: 0.15rem; }
.nav a, .nav button { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; border: 0; border-radius: 0.55rem; background: none; color: var(--muted); font: inherit; font-size: 0.93rem; text-align: left; text-decoration: none; cursor: pointer; }
.nav a:hover, .nav button:hover { color: var(--fg); background: var(--card); }
.nav [aria-current="page"], .nav [aria-pressed="true"] { color: var(--fg); background: var(--card); box-shadow: inset 2px 0 0 var(--accent); }
.nav .count { font-size: 0.75rem; color: var(--accent-contrast); background: var(--accent); border-radius: 999px; padding: 0 0.45rem; font-weight: 700; }
.nav hr { border: 0; border-top: 1px solid var(--line); margin: 0.75rem 0.5rem; }
.tabbar { display: none; }
@media (max-width: 1100px) {
  .shell { max-width: var(--shell); grid-template-columns: minmax(0, 1fr); gap: 0; }
  .nav { display: none; }
  body:has(.tabbar:not([hidden])) { padding-bottom: 4.5rem; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line); padding: 0.35rem env(safe-area-inset-right) calc(0.35rem + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 0.1rem; padding: 0.3rem 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.7rem; text-decoration: none; position: relative; cursor: pointer; }
  .tabbar b { font-size: 1.05rem; font-weight: 400; }
  .tabbar [aria-current="page"], .tabbar [aria-pressed="true"] { color: var(--accent); }
  .tabbar .count { position: absolute; top: 0; left: 55%; font-size: 0.65rem; background: var(--accent); color: var(--accent-contrast); border-radius: 999px; padding: 0 0.35rem; font-weight: 700; }
}
img[data-turn="90"] { rotate: 90deg; }
img[data-turn="180"] { rotate: 180deg; }
img[data-turn="270"] { rotate: 270deg; }
.freshtoast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; max-width: calc(100vw - 2rem); padding: 0.55rem 1.1rem; background: var(--card); color: var(--fg); border: 1px solid var(--accent); border-radius: 999px; box-shadow: 0 12px 30px rgb(0 0 0 / 0.45); font-size: 0.9rem; text-align: center; }
@media (max-width: 1100px) { .freshtoast { bottom: calc(5.2rem + env(safe-area-inset-bottom, 0px)); } }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0.9rem 0 0.4rem; }
h3:first-child { margin-top: 0; }
p { margin: 0.5rem 0; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.86rem; }
.top { padding: 0.55rem 1rem; min-height: 3rem; }
.wordmark { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--fg); font-weight: 700; text-decoration: none; }
.where { color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pilot { color: var(--muted); font-size: 0.86rem; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; justify-content: center; padding: 0.4rem 0.85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--fg); font: inherit; font-size: 0.86rem; text-decoration: none; cursor: pointer; }
.pill:hover { border-color: var(--accent); }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.pill:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--line); }
.primary { padding: 0.55rem 1.2rem; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-contrast); font: inherit; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: 0.5; cursor: wait; }
.field { display: grid; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); margin: 0.7rem 0; }
.field input:not([type="range"]) { padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 0.55rem; background: var(--well); color: var(--fg); font: inherit; font-size: 0.95rem; }
.field input[type="range"] { accent-color: var(--accent); width: 100%; }
.status { min-height: 1.3rem; font-size: 0.88rem; color: var(--warn); }
.status[data-state="error"] { color: var(--alert); }

.lobby { flex: 1; width: 100%; max-width: var(--read); margin: 0 auto; padding: 2rem 1.25rem 3rem; display: grid; gap: 1.25rem; align-content: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 0.9rem; padding: 1.4rem; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 0.8rem; }
.choice form { background: var(--well); border: 1px solid var(--line); border-radius: 0.7rem; padding: 1rem; }
.ranks { display: grid; grid-template-columns: max-content 1fr max-content; gap: 0.35rem 1rem; margin: 0.8rem 0; }
.ranks dt { color: var(--muted); }
.ranks dd { margin: 0; }
.ranks .xp { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

.bridge { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.bridge canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.tag { position: absolute; left: 0; top: 0; padding: 0.05rem 0.4rem; border-radius: 0.35rem; background: rgb(5 7 15 / 0.6); color: var(--muted); font-size: 0.72rem; white-space: nowrap; will-change: transform; }
.tag-station { color: #c8d3e0; }
.tag-ship { color: #7ec4e0; }
.tag-calling { color: var(--alert); font-weight: 700; }
.tag-chosen { color: var(--fg); outline: 1px solid var(--line); }
.panel { position: absolute; background: rgb(20 24 29 / 0.88); border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.8rem 0.9rem; backdrop-filter: blur(6px); max-height: calc(100% - 1.5rem); overflow-y: auto; }
.panel-ship { top: 0.75rem; left: 0.75rem; width: 15.5rem; }
.panel-contacts { top: 0.75rem; right: 0.75rem; width: 17rem; max-height: 46%; }
.panel-controls { right: 0.75rem; bottom: 0.75rem; width: 17rem; max-height: calc(54% - 2.25rem); display: grid; gap: 0.6rem; }
.panel-log { left: 0.75rem; bottom: 0.75rem; width: min(30rem, calc(100% - 20rem)); max-height: 26%; }
.gauges { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 0.7rem; margin: 0.6rem 0 0; font-size: 0.86rem; }
.gauges dt { color: var(--muted); }
.gauges dd { margin: 0; display: flex; align-items: center; gap: 0.5rem; font-variant-numeric: tabular-nums; }
.gauges meter { flex: 1; min-width: 0; height: 0.6rem; }
.stations, .contacts, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.stations button, .contacts button { display: flex; justify-content: space-between; gap: 0.6rem; width: 100%; padding: 0.35rem 0.55rem; border: 1px solid transparent; border-radius: 0.45rem; background: var(--well); color: var(--fg); font: inherit; font-size: 0.84rem; text-align: left; cursor: pointer; }
.stations button:hover, .contacts button:hover { border-color: var(--line); }
.stations button[aria-current="true"] { box-shadow: inset 2px 0 0 var(--accent); }
.stations button:disabled { cursor: default; color: var(--muted); }
.stations small, .contacts small { color: var(--muted); white-space: nowrap; }
.contacts button[aria-pressed="true"] { border-color: var(--accent); }
.contacts .calling { color: var(--alert); font-weight: 600; }
#invite { margin-top: 0.7rem; width: 100%; }
.row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
fieldset { margin: 0; padding: 0.55rem 0.7rem 0.7rem; border: 1px solid var(--line); border-radius: 0.6rem; min-width: 0; display: grid; gap: 0.4rem; }
fieldset:disabled { opacity: 0.5; }
legend { padding: 0 0.35rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
fieldset .field { margin: 0; }
fieldset p { margin: 0; }
.compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; }
.compass .here { text-align: center; align-self: center; font-size: 0.72rem; }
.compass .pill { padding: 0.25rem 0; font-size: 0.76rem; }
.power { display: grid; grid-template-columns: 1fr max-content max-content max-content; gap: 0.25rem 0.4rem; align-items: center; font-size: 0.84rem; }
.power .pill { padding: 0.1rem 0.55rem; }
.power output { min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 0.5rem; accent-color: var(--accent); }
.log { font-size: 0.84rem; }
.log li { padding: 0.15rem 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); margin-right: 0.5rem; font-variant-numeric: tabular-nums; }
.log .distress, .log .heat, .log .disabled { color: var(--alert); }
.log .delivered, .log .charted_first { color: var(--calm); }
.toast { position: absolute; left: 50%; top: 0.75rem; transform: translateX(-50%); margin: 0; padding: 0.45rem 1rem; border: 1px solid var(--accent); border-radius: 999px; background: var(--card); font-size: 0.88rem; max-width: calc(100% - 37rem); text-align: center; }

@media (max-width: 900px) {
  .choice { grid-template-columns: 1fr; }
  .bridge { overflow-y: auto; display: grid; gap: 0.6rem; padding: 0.6rem; align-content: start; }
  .bridge canvas { position: relative; inset: auto; height: 56vh; border: 1px solid var(--line); border-radius: 0.8rem; }
  .labels { height: 56vh; inset: 0.6rem 0.6rem auto; }
  .panel { position: static; width: auto; max-height: none; }
  .panel-log { width: auto; }
  .toast { position: fixed; top: 3.6rem; max-width: calc(100% - 2rem); }
  .where { display: none; }
}
