:root {
  --bg: #f4f7fa;
  --panel: rgba(255, 255, 255, 0.96);
  --ink: #0d1b26;
  --muted: #5a6b78;
  --line: #d6dfe6;
  --accent: #0a6fb8;
  --brand: #0b2236;
  --gold: #f2c14e;
  --shadow: 0 6px 24px rgba(8, 26, 40, 0.18);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071521;
    --panel: rgba(12, 29, 43, 0.96);
    --ink: #e6eef4;
    --muted: #93a7b6;
    --line: #23394b;
    --accent: #5cb4f2;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }

.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 10px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; pointer-events: none; z-index: 3; }
.topbar > * { pointer-events: auto; }
.brand { border: 0; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  display: flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; font-weight: 650;
  letter-spacing: .02em; padding: 7px 12px 7px 8px; border-radius: 999px; box-shadow: var(--shadow); }
.brand.tapped img { animation: brand-tap .3s ease-out; }
@keyframes brand-tap { 40% { transform: rotate(45deg) scale(.88); } }
@media (prefers-reduced-motion: reduce) { .brand.tapped img { animation: none; } }
.reloading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 10px;
  background: var(--brand); color: #fff; font-weight: 600; }
.reloading[hidden] { display: none; }
.reloading img { animation: brand-spin 1.2s linear infinite; }
@keyframes brand-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reloading img { animation: none; } }
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 9px 14px; font: inherit; box-shadow: var(--shadow); outline: none; }
.search input:focus { border-color: var(--accent); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.search-results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-results li[aria-selected="true"], .search-results li:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.search-results small { display: block; color: var(--muted); }
.icon-btn { margin-left: auto; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--panel);
  box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.icon-btn[aria-expanded="true"] { background: var(--accent); }
.icon-btn[aria-expanded="true"] svg { fill: #fff; }
/* Ships: a labelled pill next to the layers button */
.ships-btn { width: auto; padding: 0 14px 0 11px; border-radius: 999px; gap: 6px; display: flex; align-items: center; font-weight: 600; }
.ships-btn + .icon-btn, .icon-btn + .icon-btn { margin-left: 0; }
.ships-btn[aria-expanded="true"] { color: #fff; }

.panel { position: fixed; z-index: 4; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px 14px; overflow: auto; backdrop-filter: blur(8px); }
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel h2 { font-size: 16px; margin: 0; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.close { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.layers { top: calc(env(safe-area-inset-top) + 64px); right: 12px; width: 320px; max-height: calc(100% - 120px); }
.info { left: 12px; bottom: 40px; width: 340px; max-height: calc(100% - 130px); }

.opt { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 6px 0; cursor: pointer; }
.opt input { margin: 3px 0 0; accent-color: var(--accent); }
.opt small { grid-column: 2; color: var(--muted); }
.opt .zoomhint { grid-column: 2; color: #b4690e; font-size: 12px; }
.opt input[type="range"] { grid-column: 2; width: 100%; margin: 4px 0 0; }
.fine { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

.rows { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-variant-numeric: tabular-nums; }
.pos { font-variant-numeric: tabular-nums; font-weight: 600; margin: 0 0 4px; }
.src { color: var(--muted); font-size: 12px; margin-top: 4px; }
.loading { color: var(--muted); }
.err { color: #c0392b; }
.tide-graph { width: 100%; height: 70px; display: block; margin-top: 6px; }
.tide-graph .curve { fill: none; stroke: var(--accent); stroke-width: 2; }
.tide-graph .fill { fill: color-mix(in srgb, var(--accent) 15%, transparent); }
.tide-graph .now { stroke: var(--gold); stroke-width: 2; }
.tide-graph text { fill: var(--muted); font-size: 10px; }
.arrow { display: inline-block; }

.readout { position: fixed; z-index: 2; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 8px); display: flex; gap: 10px;
  background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow); color: var(--muted); }
.build { opacity: .6; }

.click-marker { width: 22px; height: 22px; border: 3px solid var(--gold); border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(11, 34, 54, .7); }

/* AIS */
.ais-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--panel); color: var(--ink); font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; box-shadow: var(--shadow); white-space: nowrap; }
.ais-tip[hidden] { display: none; }
.ais-status { font-size: 12px; color: var(--muted); margin: 2px 0 6px 26px; min-height: 1em; }
.ais-status[data-tone="err"] { color: #c0392b; }
.ais-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin: 0 0 8px 26px; }
.ais-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.ais-setup { font-size: 13px; margin: 0 0 4px 26px; color: var(--muted); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.info-btn, .set-btn { border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.set-btn.primary { background: var(--accent); color: #fff; }
.set-btn.danger { background: none; color: #c0392b; padding: 6px 0; font-weight: 500; }
.set-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Settings */
.set-section + .set-section { border-top: 1px solid var(--line); margin-top: 14px; }
.set-steps { padding-left: 18px; margin: 6px 0 10px; }
.set-steps li { margin: 2px 0; }
.set-state { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--muted) 12%, transparent); margin: 8px 0; }
.set-state[data-tone="ok"] { background: color-mix(in srgb, #1f9d55 14%, transparent); }
.set-state[data-tone="warn"] { background: color-mix(in srgb, #d98a1c 16%, transparent); }
.set-form { display: grid; gap: 8px; margin: 8px 0; }
.set-form label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.set-form input, .set-form textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; resize: vertical; min-width: 0; }
.set-form input:focus, .set-form textarea:focus { outline: none; border-color: var(--accent); }
.set-secret { display: flex; gap: 8px; align-items: center; }
.set-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.set-msg { font-size: 13px; color: var(--muted); min-height: 1em; margin: 4px 0; }
.set-msg[data-tone="ok"] { color: #1f9d55; }
.set-msg[data-tone="err"] { color: #c0392b; }
.set-token { margin: 6px 0 10px; font-size: 13px; }
.set-token summary { cursor: pointer; color: var(--accent); }
.set-code { display: block; font-size: 11px; padding: 6px 8px; border-radius: 6px; background: color-mix(in srgb, var(--muted) 12%, transparent);
  overflow-wrap: anywhere; user-select: all; }
.set-bookmarklet { display: inline-block; margin: 6px 0 2px; padding: 5px 12px; border-radius: 999px; background: var(--brand); color: #fff;
  font-weight: 650; text-decoration: none; cursor: grab; }
.set-tabs { margin: 4px 0; }
.set-tabs .link-btn[aria-pressed="false"] { color: var(--muted); text-decoration: none; font-weight: 500; }
.set-more summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
kbd { font: 11px ui-monospace, monospace; padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; }
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.info-btn.primary { background: var(--accent); color: #fff; }

.maplibregl-ctrl-bottom-left { bottom: 0; }
.maplibregl-ctrl-top-left { top: calc(env(safe-area-inset-top) + 58px); }
.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 640px) {
  .brand span { display: none; }
  .ships-btn { width: 42px; padding: 0; justify-content: center; }
  .ships-btn span { display: none; }
  .layers, .info { left: 8px; right: 8px; width: auto; }
  .layers.settings { max-height: 82%; }
  .layers { top: auto; bottom: 8px; max-height: 65%; }
  .info { bottom: 8px; max-height: 55%; }
  .readout { top: calc(env(safe-area-inset-top) + 62px); bottom: auto; }
}

/* View from the bridge (pov.js) */
body.bridge-view #map { background: linear-gradient(#7fb3dc 0%, #bcd9ee 45%, #e3eff7 60%); }
body.bridge-view .layers, body.bridge-view .info, body.bridge-view .readout,
body.bridge-view .maplibregl-ctrl-top-left, body.bridge-view .search { display: none; }
.bridge-bar { position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 999px;
  background: rgba(11, 34, 54, 0.92); color: #fff; box-shadow: var(--shadow); max-width: calc(100% - 16px); }
.bridge-bar[hidden] { display: none; }
.bridge-who { display: grid; line-height: 1.2; min-width: 0; }
.bridge-who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bridge-who span { font-size: 12px; opacity: .8; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bridge-looks { display: flex; gap: 2px; background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 2px; }
.bridge-looks button, .bridge-exit { border: 0; border-radius: 999px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer;
  background: none; color: #fff; }
.bridge-looks button[aria-pressed="true"] { background: #fff; color: var(--brand); font-weight: 600; }
.bridge-exit { background: var(--gold); color: var(--brand); font-weight: 700; padding: 6px 14px; }
@media (max-width: 560px) {
  .bridge-bar { flex-wrap: wrap; justify-content: center; border-radius: 18px; gap: 8px; }
  .bridge-who { width: 100%; text-align: center; }
}

/* Ship search, next to "Ships" (shown while AIS works) */
.ship-search { flex: 0 1 210px; min-width: 120px; }
.ship-search[hidden] { display: none; }
.ship-search input { padding-left: 34px; background-repeat: no-repeat; background-position: 11px 50%; background-size: 17px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235a6b78'%3E%3Cpath d='M11 2h2v3h4l1 6 3 1-3 7H6l-3-7 3-1 1-6h4V2Zm-2.3 5-.6 3.4L12 9l3.9 1.4L15.3 7H8.7Z'/%3E%3C/svg%3E"); }
.ship-search .search-results { left: auto; min-width: 300px; }
.search-results .hit-note { color: var(--muted); font-size: 13px; cursor: default; }
.search-results .hit-note:hover { background: none; }
@media (max-width: 640px) {
  /* A second row under the top bar, so both search fields are wide enough to type in. */
  .topbar { flex-wrap: wrap; }
  .ship-search { order: 10; flex: 1 1 100%; max-width: none; }
  .ship-search .search-results { left: 0; min-width: 0; }
  body.ais-working .maplibregl-ctrl-top-left { top: calc(env(safe-area-inset-top) + 108px); }
}

/* ---------- The bridge console while the user has the helm (helm.js) ---------- */
.bridge-helm { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  background: #1f9d55; color: #fff; }
body.helm-on .bridge-helm { display: none; }
body.helm-on .bridge-bar { bottom: auto; top: calc(env(safe-area-inset-top) + 62px); }
body.helm-on .readout, body.helm-on .maplibregl-ctrl-bottom-left, body.helm-on .maplibregl-ctrl-bottom-right { display: none; }
.maplibregl-canvas-container.looking { cursor: grabbing; }
body.bridge-view .maplibregl-canvas-container { cursor: grab; }

.helm { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; max-height: 46vh; overflow: auto;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: linear-gradient(#1d262e, #0c1116); color: #d5e1ea; border-top: 2px solid #46525e;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .45); font-size: 12px; }
.helm[hidden] { display: none; }
.helm .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.helm-alarm { margin: 0 0 6px; padding: 5px 14px; border-radius: 8px; text-align: center;
  background: #c0392b; color: #fff; font-weight: 800; letter-spacing: .05em; animation: alarm 1s steps(2) infinite; }
.helm-alarm[hidden] { display: none; }
@keyframes alarm { 50% { background: #7a1f17; } }

/* Read-outs: one strip of back-lit displays */
.helm-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.ds { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 6px;
  background: #04100a; border: 1px solid #23372b; box-shadow: inset 0 0 8px rgba(0, 0, 0, .8); }
.ds i { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #6f8f7b; }
.ds b { font: 700 16px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #8ff0a4;
  text-shadow: 0 0 6px rgba(80, 255, 140, .4); font-variant-numeric: tabular-nums; }
.ds em { font-style: normal; font-size: 11px; color: #7fa58b; }
.ds.shallow { border-color: #b8860b; }
.ds.shallow b { color: #ffcf5a; }

/* Controls: one row */
.helm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 8px; }
.telegraph { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 0; padding: 5px 7px 6px; border-radius: 10px;
  background: linear-gradient(135deg, #b8943f, #6e5320); box-shadow: inset 0 0 0 2px #d9b863; }
.tg-cap { font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #2b1f08; }
.tg-cap.ahead { text-align: right; }
.tg-buttons { grid-column: 1 / -1; display: flex; gap: 2px; }
.telegraph button { border: 0; border-radius: 5px; padding: 4px 6px; font: 700 11px system-ui, sans-serif; cursor: pointer;
  text-transform: uppercase; background: #f2ead6; color: #3a2c10; min-width: 38px; }
.telegraph button.stop { background: #e7dcc0; min-width: 44px; }
.telegraph button[aria-checked="true"].ahead { background: #1f9d55; color: #fff; box-shadow: 0 0 8px rgba(31, 157, 85, .8); }
.telegraph button[aria-checked="true"].astern { background: #c0392b; color: #fff; box-shadow: 0 0 8px rgba(192, 57, 43, .8); }
.telegraph button[aria-checked="true"].stop { background: #f2b630; color: #2b1f08; box-shadow: 0 0 8px rgba(242, 182, 48, .8); }
.tg-answer { grid-column: 1 / -1; position: relative; height: 5px; background: #1b1408; border-radius: 3px; overflow: hidden; }
.tg-answer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: #d9b863; }
.tg-answer i { position: absolute; top: 0; bottom: 0; }
.tg-answer i.ahead { background: #36d06a; }
.tg-answer i.astern { background: #ff5a4f; }

/* The steering stick: a lever across a port-to-starboard track */
.steer { display: grid; gap: 4px; flex: 1 1 240px; max-width: 340px; }
.steer-cap { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #9fb3c2; }
.steer-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.steer-row small { font-weight: 800; }
.steer-row .port { color: #ff6b5a; }
.steer-row .stbd { color: #36d06a; }
.stick { position: relative; height: 30px; border-radius: 15px; cursor: ew-resize; touch-action: none;
  background: linear-gradient(90deg, rgba(192, 57, 43, .45), #11181e 45%, #11181e 55%, rgba(31, 157, 85, .45));
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .8), 0 0 0 1px #46525e; }
.stick:focus-visible { outline: 2px solid #f2b630; outline-offset: 2px; }
.stick-scale { position: absolute; inset: 6px 14px; background:
  linear-gradient(90deg, transparent calc(50% - 1px), #9fb3c2 calc(50% - 1px), #9fb3c2 calc(50% + 1px), transparent calc(50% + 1px)),
  repeating-linear-gradient(90deg, rgba(159, 179, 194, .35) 0 1px, transparent 1px 14.2857%); }
.stick-actual { position: absolute; top: 3px; bottom: 3px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #ffcf5a;
  box-shadow: 0 0 6px rgba(255, 207, 90, .8); left: 50%; }
.stick-knob { position: absolute; top: -4px; width: 20px; height: 38px; margin-left: -10px; border-radius: 8px; left: 50%;
  background: linear-gradient(90deg, #6d7a86, #d7e1e8 45%, #8995a0); box-shadow: 0 3px 6px rgba(0, 0, 0, .6), inset 0 0 0 1px #2b343c; }
.steer-buttons { display: flex; gap: 4px; }
.steer-buttons button, .helm-buttons button { border: 1px solid #46525e; border-radius: 7px; background: #1a232b; color: #d5e1ea;
  padding: 3px 8px; font: inherit; font-size: 11px; cursor: pointer; }
.steer-buttons button:hover, .helm-buttons button:hover { background: #24313c; }

.thrusters { display: grid; gap: 4px; }
.thr { display: grid; grid-template-columns: 40px 130px 34px; gap: 6px; align-items: center; }
.thr span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #9fb3c2; }
.thr input { width: 100%; accent-color: #f2b630; margin: 0; }
.thr b { font: 11px ui-monospace, monospace; color: #8ff0a4; }
.thr.none { opacity: .4; }
.helm-buttons { display: grid; gap: 4px; margin-left: auto; }
.helm-buttons .helm-release { border-color: #8a3b33; }
@media (max-width: 760px) {
  .helm { padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
  .ds { padding: 2px 7px; }
  .ds b { font-size: 14px; }
  .telegraph { flex: 1 1 100%; }
  .tg-buttons button { flex: 1; min-width: 0; padding: 4px 2px; font-size: 10px; }
  .steer { max-width: none; }
  .thr { grid-template-columns: 36px 1fr 30px; }
  .thrusters { flex: 1 1 160px; }
  .helm-buttons { grid-auto-flow: column; margin-left: 0; }
}

/* With the helm console open, the map ends where the console begins (helm.js sets --helm-room). */
body.helm-on #map { bottom: var(--helm-room, 0px); }

/* ---------- Ships tracker (tracker.js) ---------- */
.tracker { width: 340px; }
.tk-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.tk-stats div { background: color-mix(in srgb, var(--muted) 10%, transparent); border-radius: 8px; padding: 6px 8px; }
.tk-stats dt { font-size: 11px; color: var(--muted); }
.tk-stats dd { margin: 0; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.tk-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tk-row select, .tk-speed select, .tk-from input { font: inherit; font-size: 14px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); }
.tk-from { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin: 6px 0 10px; }
.tk-from input:disabled { opacity: .5; }
.tk-speed { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.tk-clock { display: grid; margin: 4px 0; }
.tk-clock b { font-size: 16px; font-variant-numeric: tabular-nums; }
.tk-clock span { font-size: 12px; color: var(--muted); }
.tk-slider { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.tk-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.tk-traces { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; }
.tk-traces li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.tk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-color { width: 34px; height: 22px; border-radius: 6px; border: 1px solid var(--line); color: transparent; cursor: pointer; padding: 0; }
.tk-color option { color: #000; }
.tk-show { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; }
.tk-card { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.tk-card-label { font-weight: 600; }
.tk-card { flex-wrap: wrap; }
.tk-traces li { grid-template-columns: auto 1fr auto auto auto; }
.tk-files { margin-top: 8px; }

/* ---------- webcams (webcamlayer.js, webcamview.js) ---------- */

.webcam-eye {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; background: #ff9800; color: #1d2b36;
  display: grid; place-items: center; padding: 0; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.webcam-eye svg { width: 20px; height: 20px; fill: currentColor; }
.webcam-eye:hover { background: #ffb020; }
.webcam-site { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.webcam-site button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.webcam-site button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.webcam-shot { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer; background: #000; aspect-ratio: 4 / 3; }
.webcam-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.webcam-shot-eye {
  position: absolute; right: 8px; bottom: 8px; width: 38px; height: 38px; border-radius: 50%; background: #ff9800; color: #1d2b36;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.webcam-shot-eye svg { width: 22px; height: 22px; fill: currentColor; }
a.info-btn { text-decoration: none; display: inline-flex; align-items: center; }

.webcam-view { position: fixed; inset: 0; z-index: 6; background: #05090d; color: #e9f1f7; display: flex; flex-direction: column; }
.webcam-view[hidden] { display: none; }
.wv-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.wv-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.wv-overlay { position: absolute; inset: 0; pointer-events: none; }
.wv-overlay button { pointer-events: auto; }
.wv-msg, .wv-status {
  position: absolute; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 999px;
  background: rgba(5, 15, 24, 0.75); font-size: 13px; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.wv-msg { top: 45%; white-space: normal; text-align: center; border-radius: 12px; }
.wv-status { bottom: 10px; }
.wv-status.warn { background: rgba(160, 80, 0, 0.9); }
.wv-box { position: absolute; border: 2px solid #ffb020; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.wv-lead { position: absolute; width: 0; border-left: 1.5px solid rgba(255, 176, 32, 0.9); }
.wv-tag {
  position: absolute; transform: translateX(-50%); display: grid; gap: 1px; text-align: left; cursor: pointer;
  padding: 4px 8px; border: 1px solid rgba(255, 176, 32, 0.9); border-radius: 8px; background: rgba(5, 15, 24, 0.82); color: #fff;
  font: 600 13px/1.2 system-ui, sans-serif; white-space: nowrap; max-width: 260px;
}
.wv-tag small { font-weight: 400; font-size: 11.5px; color: #cfe0ec; overflow: hidden; text-overflow: ellipsis; }
.wv-tag:hover { background: rgba(30, 50, 70, 0.95); }
.wv-edge {
  position: absolute; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); cursor: pointer;
  background: rgba(5, 15, 24, 0.7); color: #e9f1f7; font: 500 12px system-ui, sans-serif; white-space: nowrap;
}
.wv-horizon { position: absolute; height: 0; border-top: 1.5px dashed rgba(120, 220, 255, 0.75); }
.wv-target { position: absolute; transform: translateX(-50%); padding: 2px 6px; font: 600 12px system-ui, sans-serif; color: #9fe3ff; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.wv-bar { flex: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #0d1b26; display: grid; gap: 8px; max-height: 45vh; overflow-y: auto; }
.wv-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wv-title b { display: block; font-size: 17px; }
.wv-title small { display: block; color: #a9bccb; font-size: 13px; }
.wv-eye { width: 34px; height: 34px; border-radius: 50%; background: #ff9800; color: #1d2b36; display: grid; place-items: center; flex: none; }
.wv-eye svg { width: 20px; height: 20px; fill: currentColor; }
.wv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wv-btn {
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.08); color: #e9f1f7; border-radius: 999px;
  padding: 7px 14px; font: 600 14px system-ui, sans-serif; cursor: pointer;
}
.wv-btn[aria-pressed="true"] { background: #ff9800; color: #1d2b36; border-color: #ff9800; }
.wv-close { margin-left: auto; width: 36px; padding: 0; font-size: 20px; line-height: 1; }
.wv-adjust { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 16px; }
.wv-adjust[hidden] { display: none; }
.wv-adjust label { display: grid; gap: 2px; font-size: 13px; color: #cfe0ec; }
.wv-adjust label span { display: flex; justify-content: space-between; }
.wv-adjust input[type="range"] { width: 100%; accent-color: #ff9800; }
.wv-hint, .wv-adjust .wv-actions { grid-column: 1 / -1; margin: 0; font-size: 12.5px; color: #a9bccb; }
.wv-note { margin: 0; font-size: 12px; color: #8ea3b3; }
@media (min-width: 900px) {
  .wv-bar { grid-template-columns: 1fr auto; align-items: center; }
  .wv-adjust, .wv-note { grid-column: 1 / -1; }
}

/* placing a ship of one's own (app.js) */
.place-bar {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 64px);
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 8px 8px 8px 16px;
  border-radius: 999px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-size: 14px;
}
.place-bar[hidden] { display: none; }
.place-bar[data-tone="err"] { background: #fff1e6; color: #8a3a00; }
.place-bar button { border: 0; border-radius: 999px; padding: 6px 14px; font: 600 14px system-ui, sans-serif; background: color-mix(in srgb, var(--ink) 10%, transparent); color: inherit; cursor: pointer; }
