:root {
  color-scheme: dark;
  --navy: #071827; --ocean: #102c43; --slate: #18384f;
  --cyan: #00d9ff; --gold: #ffc857; --green: #22c55e; --orange: #ff8a3d; --red: #ef4444;
  --text: #f5faff; --text-2: #a9bfce;
  --line: rgb(169 191 206 / 18%); --line-strong: rgb(169 191 206 / 34%);
  --panel: rgb(16 44 67 / 90%); --panel-solid: #123049; --hover: rgb(245 250 255 / 8%);
  --radius: 12px; --radius-sm: 8px; --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  --font: Inter, "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-family: var(--font); font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--text); background: var(--navy); font: 14px/1.4 var(--font); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 8px 14px; background: linear-gradient(180deg, #0b2437, var(--navy)); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; flex: none; border-radius: 9px; color: var(--navy); background: linear-gradient(135deg, var(--cyan), #5eead4); }
.brand-text { display: grid; line-height: 1.1; min-width: 0; }
.eyebrow { color: var(--text-2); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.brand-title { overflow: hidden; font-size: 18px; font-weight: 750; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.tabs-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
#board-tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; }
#board-tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; max-width: 190px; min-height: 34px; overflow: hidden; padding: 0 13px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; transition: background .15s, color .15s; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab[aria-selected="true"] { color: var(--navy); background: var(--cyan); }
.top-status { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 999px; background: rgb(7 24 39 / 55%); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.badge.offline { border-color: var(--orange); color: var(--orange); }
.badge.offline .dot { background: var(--orange); border-radius: 2px; }
.badge.saving .dot { background: var(--gold); border-radius: 2px; transform: rotate(45deg); }
.chip { display: inline-flex; align-items: baseline; gap: 6px; min-height: 28px; padding: 0 11px; align-items: center; border-radius: 999px; background: rgb(255 255 255 / 6%); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.chip b { color: var(--text); font-weight: 700; }

.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: none; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-2); transition: background .15s, color .15s, border-color .15s; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--navy); background: var(--cyan); }
.icon-btn:disabled { opacity: .38; cursor: default; }
.btn { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: rgb(255 255 255 / 5%); font-size: 13px; font-weight: 600; transition: background .15s; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { color: var(--navy); background: var(--cyan); border-color: transparent; }
.btn.primary:hover { background: #4ae6ff; }
.btn.danger { color: #ffb4b4; border-color: rgb(239 68 68 / 55%); }

.stage { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(1100px 520px at 15% -10%, #174766 0%, transparent 62%), linear-gradient(180deg, #0c3350 0%, #09263c 50%, #071827 100%); }
.water { position: absolute; inset: -80px 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgb(0 217 255 / 4.5%) 0 1px, transparent 1px 38px), repeating-linear-gradient(0deg, rgb(255 255 255 / 3%) 0 1px, transparent 1px 57px); animation: drift 38s linear infinite; }
@keyframes drift { to { transform: translate3d(0, 114px, 0); } }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; outline-offset: -3px; }
canvas.select { cursor: default; }
canvas.over { cursor: grab; }
canvas.chip { cursor: pointer; }
canvas.grabbing { cursor: grabbing; }

.floating { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
@media (min-width: 821px) { .floating { backdrop-filter: blur(12px); } }
.rail { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 3px; padding: 6px; z-index: 3; }
.rail .sep { height: 1px; margin: 4px 6px; background: var(--line); }
.options { position: absolute; left: 74px; top: 12px; max-width: calc(100% - 74px - 372px); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 6px 12px; z-index: 3; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.opt[hidden] { display: none; }
.label { color: var(--text-2); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.swatches { display: flex; align-items: center; gap: 6px; }
.swatch { width: 28px; height: 28px; padding: 0; border: 2px solid transparent; border-radius: 50%; box-shadow: 0 0 0 1px rgb(255 255 255 / 30%); }
.swatch[aria-pressed="true"] { border-color: var(--navy); box-shadow: 0 0 0 2px var(--cyan); }
#custom-color { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; }
#custom-color::-webkit-color-swatch-wrapper { padding: 2px; }
#custom-color::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 50%; }
input[type="range"] { accent-color: var(--cyan); width: 110px; }
select { min-height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--navy); }
.hint { color: var(--text-2); font-size: 11px; }

.panels { position: absolute; right: 12px; top: 12px; bottom: 64px; width: min(348px, 30vw); display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain; pointer-events: none; scrollbar-width: thin; z-index: 3; }
.panels > * { pointer-events: auto; flex: none; }
.card-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 0; background: transparent; text-align: left; }
.card-head .title { flex: 1; color: var(--text-2); font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.card-head .meta { color: var(--text-2); font-size: 12px; }
.card-head .chev { transition: transform .2s; }
.card-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.card-body { padding: 0 12px 12px; }
.card-body[hidden] { display: none; }
.muted { margin: 0; color: var(--text-2); font-size: 12px; }

.compass { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 12px; }
.compass svg { width: 92px; height: 92px; }
.wind-value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1; }
.wind-sub { margin-top: 4px; color: var(--text-2); font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.sel-title { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 16px; font-weight: 750; }
.sel-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; box-shadow: 0 0 0 2px rgb(255 255 255 / 55%); }

.fleet-head, .fleet-row { display: grid; grid-template-columns: 26px 1fr 46px 56px 48px; align-items: center; gap: 6px; }
.fleet-head { padding: 0 8px 4px; color: var(--text-2); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.fleet-head span:nth-child(n+3) { text-align: right; }
.fleet { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.fleet-row { position: relative; min-height: 40px; padding: 0 8px; border: 1px solid transparent; border-left: 3px solid var(--line-strong); border-radius: 8px; background: rgb(255 255 255 / 4%); font-size: 13px; }
.fleet-row:hover { background: var(--hover); }
.fleet-row[data-selected="true"] { border-color: var(--cyan); background: rgb(0 217 255 / 12%); }
.fleet-row.p1 { border-left-color: var(--gold); } .fleet-row.p2 { border-left-color: #c9d6df; } .fleet-row.p3 { border-left-color: #cd7f32; }
.fleet-row .pos { font-weight: 800; font-size: 15px; }
.fleet-row.p1 .pos { color: var(--gold); } .fleet-row.p2 .pos { color: #dbe5ec; } .fleet-row.p3 .pos { color: #e6a15c; }
.row-hit { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; border-radius: 7px; background: transparent; }
.row-hit:focus-visible { outline-offset: -2px; }
.name-btn { position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 32px; padding: 0 6px; margin-left: -6px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-weight: 650; }
.name-btn:hover { background: var(--hover); }
.name-btn i { width: 11px; height: 11px; flex: none; border-radius: 50%; box-shadow: 0 0 0 2px rgb(255 255 255 / 45%); }
.name-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-btn .icon { width: 14px; height: 14px; margin-left: auto; opacity: .5; }
.name-btn:hover .icon, .name-btn:focus-visible .icon { opacity: 1; color: var(--cyan); }
.sel-title-btn { display: flex; align-items: center; gap: 9px; max-width: 100%; margin: 0 0 10px; padding: 2px 6px; margin-left: -6px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 16px; font-weight: 750; }
.sel-title-btn:hover { background: var(--hover); }
.sel-title-btn span:not(.sel-dot) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-title-btn .sel-dot, .sel-title-btn .icon { flex: none; }
.sel-title-btn .icon { width: 15px; height: 15px; opacity: .55; }
.sel-title-btn:hover .icon { opacity: 1; color: var(--cyan); }
.fleet-row .r { text-align: right; color: var(--text-2); font-size: 12px; }
.fleet-note { margin: 8px 0 0; color: var(--text-2); font-size: 11px; }

.activity { display: grid; gap: 5px; max-height: 150px; margin: 0; padding: 0; overflow-y: auto; list-style: none; font-size: 12px; }
.activity li { display: flex; gap: 9px; color: var(--text); }
.activity li span { min-width: 0; overflow-wrap: anywhere; }
.activity time { color: var(--text-2); }

.view-controls { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 3px; padding: 5px; z-index: 3; }
.view-controls .sep { width: 1px; margin: 4px 4px; background: var(--line); }
.caption { position: absolute; left: 74px; bottom: 14px; z-index: 2; color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; pointer-events: none; text-shadow: 0 1px 2px rgb(0 0 0 / 60%); }
.zoom-readout { min-width: 44px; display: grid; place-items: center; color: var(--text-2); font-size: 12px; font-weight: 700; }

.toasts { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: grid; gap: 6px; z-index: 6; pointer-events: none; }
.toast { padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-solid); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; animation: rise .2s ease-out both; }
.toast.error { border-color: var(--red); } .toast.ok { border-color: var(--green); } .toast.warn { border-color: var(--orange); }
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sheet-toggle { display: none; }

dialog { width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line-strong); border-radius: 14px; color: var(--text); background: var(--panel-solid); box-shadow: 0 24px 70px rgb(0 0 0 / 55%); }
dialog::backdrop { background: rgb(3 10 18 / 62%); }
dialog h2 { margin: 0 0 14px; font-size: 18px; font-weight: 750; }
.field { display: grid; gap: 6px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.field input, .field textarea { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--navy); color: var(--text); }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.dialog-error { min-height: 18px; margin: 8px 0 0; color: #ff9f9f; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (max-width: 1100px) { .chip.counts { display: none; } .options { max-width: calc(100% - 74px - 12px); top: auto; bottom: 66px; left: 74px; } }
@media (max-width: 820px), (max-height: 520px) {
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; }
  .brand-title { font-size: 16px; max-width: 18ch; }
  .tabs-wrap { order: 3; flex-basis: 100%; }
  .chip { display: none; }
  .rail { left: 8px; right: 8px; top: auto; bottom: 8px; transform: none; flex-direction: row; overflow-x: auto; padding: 5px; scrollbar-width: none; }
  .rail .sep { width: 1px; height: auto; margin: 6px 4px; flex: none; }
  .icon-btn { width: 42px; height: 42px; }
  .swatches { flex-wrap: wrap; }
  .swatch { width: 32px; height: 32px; }
  #custom-color { width: 36px; height: 36px; }
  .options { left: 8px; right: 8px; max-width: none; bottom: 64px; top: auto; }
  .hint, .caption { display: none; }
  .view-controls { top: 10px; right: 10px; bottom: auto; flex-direction: column; }
  .view-controls .sep { width: auto; height: 1px; margin: 4px; }
  .sheet-toggle { display: inline-flex; position: absolute; left: 10px; top: 10px; z-index: 5; min-height: 40px; padding: 0 14px; }
  .panels { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 64%; padding: 12px 10px calc(12px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: var(--panel-solid); border-top: 1px solid var(--line-strong); box-shadow: 0 -12px 40px rgb(0 0 0 / 45%); pointer-events: auto; transform: translateY(105%); transition: transform .25s ease; z-index: 6; }
  .panels.open { transform: none; }
  .toasts { top: 58px; }
}
@media (orientation: landscape) and (max-height: 520px), (orientation: landscape) and (max-width: 820px) { .panels { left: auto; width: min(380px, 50vw); max-height: calc(100% - 8px); border-radius: 14px 0 0 14px; } .view-controls { flex-direction: row; right: 60px; } .view-controls .sep { width: 1px; height: auto; margin: 4px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } .water { animation: none; } }
