/* Cape to Cape · Chart Room (design A) on a satellite base map */
:root, [data-mode="dark"] {
  --bg: #0B1116; --glass: rgba(14, 22, 29, 0.94); --ink: #DCE6EC; --soft: #B3C1CB; --muted: #8696A3;
  --line: #3A4B59; --rule: #22313D; --inv: #DCE6EC; --inv-fg: #0B1116; --field: #0B1116;
  --accent: #FFB547; --night: #1C2934; --tag-bd: #3A4B59; --sel-bg: #18242E; --bad: #FF7A8A;
  --float: 0 14px 36px rgba(0, 0, 0, 0.5);
  --b0: #3A4654; --b1: #3D74A8; --b2: #2BA597; --b3: #A8D84E; --b4: #FFB547;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans Condensed', system-ui, sans-serif;
  color-scheme: dark;
}
[data-mode="light"] {
  --bg: #E9EEEC; --glass: rgba(244, 245, 240, 0.95); --ink: #12283A; --soft: #33495A; --muted: #4E6372;
  --line: #12283A; --rule: #C7D3D5; --inv: #12283A; --inv-fg: #F4F5F0; --field: #FFFFFF;
  --accent: #B85600; --night: #DCE3E3; --tag-bd: #7E95A3; --sel-bg: #E3EAEA; --bad: #C2410C;
  --float: 0 12px 30px rgba(18, 40, 58, 0.25);
  --b0: #B4BEC4; --b1: #5B8DC0; --b2: #2A9D8F; --b3: #8DC63F; --b4: #F5A623;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; }
input[type=range] { accent-color: var(--accent); }
textarea { font: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; color: var(--muted); }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Header ── */
header {
  min-height: 60px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 1000;
}
.brand { display: flex; align-items: stretch; border: 1px solid var(--line); }
.brand .code { display: flex; align-items: center; padding: 0 8px; background: var(--inv); color: var(--inv-fg); font: 600 13px var(--mono); letter-spacing: 0.06em; }
.brand .txt { display: flex; flex-direction: column; justify-content: center; padding: 4px 10px; }
.brand .txt b { font-size: 15px; letter-spacing: 0.14em; line-height: 1.1; }
.brand .txt span { font: 9px var(--mono); letter-spacing: 0.08em; color: var(--muted); }
.barcode { display: flex; align-items: stretch; padding: 6px 8px; border-left: 1px solid var(--line); }
.barcode i { display: block; background: var(--ink); }
.conds { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font: 12px var(--mono); flex: 1 1 auto; }
@media (min-width: 761px) {
  header { flex-wrap: nowrap; }
  .conds { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
  .brand, .clock { flex: none; }
}
@media (max-width: 1599px) { .barcode { display: none; } }
@media (min-width: 761px) and (max-width: 1100px) { .brand .txt span { display: none; } }
.cond { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#filterBtn { display: none; }
.cond .big { font-size: 15px; font-weight: 600; }
.pill { padding: 1px 5px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: #0B1116; }
.clock { display: flex; align-items: center; gap: 10px; }
.clock .when { font: 11px var(--mono); text-align: right; display: flex; flex-direction: column; }
.live { display: flex; align-items: center; gap: 5px; justify-content: flex-end; color: var(--muted); }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.live.err i { background: var(--bad); }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ── Map stage ── */
#stage { position: relative; flex: 1 1 auto; overflow: hidden; }
#map { position: absolute; inset: 0; background: #0C151D; }
.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(11, 17, 22, 0.6) !important; color: #8696A3 !important; }
.leaflet-control-attribution a { color: #B3C1CB !important; }

.overlay { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 16px 76px; pointer-events: none; z-index: 500; }
.panel { pointer-events: auto; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--float); overflow: hidden; display: flex; flex-direction: column; max-height: 100%; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tab { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--glass); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--float); cursor: pointer; font: 600 12px var(--mono); letter-spacing: 0.06em; }
.tab .chip { padding: 1px 5px; border-radius: 3px; color: #0B1116; }
.smallbtn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer; font: 500 13px var(--mono); flex: none; }

/* ── Where to surf list ── */
#list { flex: 0 1 384px; min-width: 0; }
.list-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.08em; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; cursor: pointer; padding: 4px 10px; font: 500 12px var(--sans); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--inv); color: var(--inv-fg); }
.seg.tiny button { font: 600 10px var(--mono); padding: 3px 7px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { font: 600 12px var(--mono); padding: 6px 10px; border-radius: 6px; cursor: pointer; background: transparent; border: 1px solid var(--line); }
.days button.on { background: var(--inv); color: var(--inv-fg); }
.days .dawn { margin-left: auto; color: var(--accent); border: 1px dashed var(--accent); font-weight: 500; }
.spark { display: flex; align-items: stretch; height: 36px; }
.spark div { flex: 1 1 0; display: flex; align-items: flex-end; cursor: pointer; }
.spark div i { display: block; width: 100%; }
.axis { display: flex; justify-content: space-between; font: 9px var(--mono); color: var(--muted); }
.spark div:hover i { filter: brightness(1.25); }
.days .now { color: var(--ink); border-style: dashed; }
.days .now.on { background: var(--accent); color: #0B1116; border: 1px solid var(--accent); }
.score.low b { opacity: 0.75; }
.score.low span { border-style: dashed; }
.conf { font: 600 9px var(--mono); letter-spacing: 0.08em; color: var(--muted); white-space: nowrap; }
.conf i { font-style: normal; letter-spacing: 1px; }
.miss { font-style: italic; color: var(--muted); }
.chips .sep { width: 1px; background: var(--line); margin: 2px 4px; }

.filters { padding: 12px 16px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.frow { display: flex; align-items: center; gap: 10px; }
.frow > .kicker { width: 70px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { font: 500 12px var(--sans); padding: 3px 8px; border-radius: 5px; cursor: pointer; background: transparent; border: 1px solid var(--line); }
.chips button.on { background: var(--inv); color: var(--inv-fg); border-color: var(--inv); }
select { font: 500 12px var(--sans); padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: var(--ink); }
.check { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 12px; cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }

#rows { list-style: none; margin: 0; padding: 6px 8px 10px; overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
#rows li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: start; padding: 8px; border-radius: 8px; cursor: pointer; border: 1.5px solid transparent; }
#rows li:hover { background: var(--sel-bg); }
#rows li.sel { background: var(--sel-bg); border-color: var(--ink); }
.empty { padding: 20px 12px; color: var(--muted); font: 12px var(--mono); text-align: center; }
.score { display: flex; flex-direction: column; align-items: stretch; }
.score b { font: 600 17px var(--mono); text-align: center; padding: 5px 0 3px; border-radius: 4px 4px 0 0; }
.score span { font: 600 8.5px var(--mono); letter-spacing: 0.1em; text-align: center; padding: 2px 0; border: 1px solid; border-top: 0; border-radius: 0 0 4px 4px; }
.rbody { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rname { display: flex; align-items: baseline; gap: 6px; }
.rname b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rname span { font: 9px var(--mono); color: var(--muted); margin-left: auto; white-space: nowrap; }
.meter { display: flex; gap: 2px; }
.meter i { flex: 1 1 0; height: 3px; background: var(--rule); }
.why { font: 11px var(--mono); color: var(--soft); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--tag-bd); color: var(--soft); }
.tag.inv { background: var(--inv); color: var(--inv-fg); border-color: var(--inv); }
.tag.warn { border-style: dashed; color: var(--muted); }
.surfed { font: 9.5px var(--mono); color: var(--soft); }

/* ── Spot card ── */
#card { flex: 0 1 392px; min-width: 0; margin-left: auto; }
.stripe { height: 8px; flex: none; border-bottom: 1px solid var(--line); }
.cardscroll { overflow-y: auto; display: flex; flex-direction: column; }
.sec { padding: 10px 16px 12px; border-bottom: 1px solid var(--rule); }
.sec:first-child { border-bottom-color: var(--line); display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
h2 { margin: 0; font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: 0.01em; }
.bigscore { display: flex; flex-direction: column; }
.bigscore b { font: 600 34px var(--mono); line-height: 1; padding: 6px 10px 4px; border-radius: 4px 4px 0 0; color: #0B1116; text-align: center; }
.bigscore span { font: 600 9px var(--mono); letter-spacing: 0.14em; text-align: center; padding: 2px 0; border: 1px solid; border-top: 0; border-radius: 0 0 4px 4px; }
.cardtop { display: flex; align-items: center; gap: 14px; }
.cardtop .info { display: flex; flex-direction: column; gap: 3px; font: 11px var(--mono); flex: 1; min-width: 0; }
figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
figcaption { font: 8px var(--mono); letter-spacing: 0.06em; color: var(--muted); }
.checks { display: grid; grid-template-columns: 74px minmax(0, 1fr) minmax(0, 1.2fr) 22px; gap: 0 8px; font-size: 12px; align-items: center; }
.checks > span { padding: 6px 0; border-top: 1px solid var(--rule); }
.checks > .h { border-top: 0; padding: 0 0 6px; }
.checks .l { font-weight: 600; }
.checks .i { font: 11.5px var(--mono); color: var(--soft); }
.checks .n { font: 600 11.5px var(--mono); }
.checks .m { display: flex; justify-content: center; }
.bars { position: relative; height: 72px; display: flex; align-items: stretch; gap: 1px; border-bottom: 1px solid var(--line); }
.bars div { flex: 1 1 0; display: flex; align-items: flex-end; cursor: pointer; }
.bars div i { display: block; width: 100%; }
.bars .thr { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--muted); opacity: 0.5; pointer-events: none; }
.baraxis { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); font: 9px var(--mono); color: var(--soft); }
textarea#notes { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); padding: 8px; font-size: 13px; line-height: 1.4; }
.cardfoot { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 8px; font: 9px var(--mono); letter-spacing: 0.08em; color: var(--muted); }

/* ── Bottom legend bar ── */
#legend { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--float); z-index: 600; font: 10px var(--mono); white-space: nowrap; max-width: calc(100% - 32px); overflow-x: auto; }
#legend .seg button { font: 600 10px var(--mono); letter-spacing: 0.06em; padding: 6px 9px; }
.lg { display: flex; align-items: center; gap: 5px; }
.lg i { width: 14px; height: 8px; border-radius: 2px; }
.lg b { letter-spacing: 0.06em; }
.lgtools { display: flex; gap: 4px; padding-left: 8px; border-left: 1px solid var(--rule); }
.lgtools button { height: 28px; min-width: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font: 600 10px var(--mono); letter-spacing: 0.06em; cursor: pointer; }
.lgtools button.on { background: var(--accent); color: #0B1116; border-color: var(--accent); }

/* ── Map markers ── */
.pin { border-radius: 50%; border: 1.5px solid #0B1116; box-sizing: border-box; transition: transform 0.12s; }
.pin.sel { box-shadow: 0 0 0 2px #0B1116, 0 0 0 4px #DCE6EC, 0 0 16px var(--c); }
.pin.glow { box-shadow: 0 0 10px var(--c); }
.pin.edit { cursor: move; outline: 2px dashed #FFFFFF; outline-offset: 2px; }
.leaflet-tooltip.lbl { background: rgba(12, 21, 29, 0.9); color: #DCE6EC; border: 1px solid #3A4B59; border-radius: 0; box-shadow: none; padding: 2px 3px 2px 6px; font: 500 11px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; display: flex; gap: 6px; align-items: center; }
.leaflet-tooltip.lbl.sel { background: #DCE6EC; color: #0C151D; border-color: #DCE6EC; }
.leaflet-tooltip.lbl::before { display: none; }
.leaflet-tooltip.lbl em { font-style: normal; font-weight: 600; padding: 1px 4px; color: #0C151D; }
.leaflet-tooltip.hov { background: #DCE6EC; color: #0C151D; border: 0; border-radius: 0; font: 11px var(--mono); padding: 5px 8px; box-shadow: none; }
.leaflet-tooltip.hov::before { display: none; }

#toast { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 900; background: var(--glass); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font: 11px var(--mono); box-shadow: var(--float); display: none; max-width: 90%; }

/* ── Spots table ── */
.viewseg button { font: 600 10px var(--mono); letter-spacing: 0.08em; padding: 6px 9px; }
#sheet { position: absolute; inset: 0; z-index: 800; background: var(--bg); display: flex; flex-direction: column; }
.sheet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-bar input[type=search] { font: 13px var(--sans); padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink); min-width: 200px; }
.sheet-actions { margin-left: auto; display: flex; gap: 6px; }
.sheet-actions button { font: 600 10px var(--mono); letter-spacing: 0.06em; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer; }
.sheet-actions button:hover { background: var(--inv); color: var(--inv-fg); }
.sheet-help { padding: 8px 16px; font-size: 10px; color: var(--muted); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.key { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-left: 8px; }
.miss-k { border: 1px dashed var(--accent); }
.edit-k { border-left: 3px solid var(--b2); background: var(--sel-bg); }
.bad-k { border: 1px solid var(--bad); }
.sheet-wrap { flex: 1 1 auto; overflow: auto; }
#sheetTable { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
#sheetTable th { position: sticky; top: 0; z-index: 2; background: var(--bg); text-align: left; font: 600 9px var(--mono); letter-spacing: 0.1em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
#sheetTable th.sorted { color: var(--ink); }
#sheetTable td { border-bottom: 1px solid var(--rule); padding: 2px; vertical-align: middle; }
#sheetTable tr:hover td { background: var(--sel-bg); }
#sheetTable .stick { position: sticky; left: 0; z-index: 1; background: var(--bg); }
#sheetTable th.stick { z-index: 3; }
#sheetTable tr:hover .stick { background: var(--sel-bg); }
#sheetTable input, #sheetTable select { width: 100%; min-width: 0; font: 12px var(--sans); color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 5px 6px; }
#sheetTable input:hover, #sheetTable select:hover { border-color: var(--rule); }
#sheetTable input:focus, #sheetTable select:focus { outline: none; border-color: var(--accent); background: var(--field); }
#sheetTable td.missing input, #sheetTable td.missing select { border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); }
#sheetTable td.edited { box-shadow: inset 3px 0 0 var(--b2); }
#sheetTable td.bad input { border: 1px solid var(--bad); }
#sheetTable .ro { font: 11px var(--mono); color: var(--muted); padding: 0 8px; white-space: nowrap; }
#sheetTable .namecell input { font-weight: 700; font-size: 13px; }
#sheetTable .sc { font: 600 11px var(--mono); padding: 3px 6px; border-radius: 3px; color: #0B1116; display: inline-block; min-width: 32px; text-align: center; }
#sheetTable .rowbtn { border: 1px solid var(--line); background: transparent; border-radius: 5px; cursor: pointer; font: 600 10px var(--mono); padding: 4px 6px; white-space: nowrap; }
#sheetTable .rowbtn:hover { background: var(--inv); color: var(--inv-fg); }

/* ── Sharing: roles, history ── */
.userchip { font: 600 11px var(--mono); letter-spacing: 0.04em; text-decoration: none; color: var(--ink); }
.adminonly { display: none; }
body.admin .adminonly { display: inline-block; }
#sheetTable td.locked input, #sheetTable td.locked select { cursor: default; opacity: 1; }
#sheetTable td.locked input:hover { border-color: transparent; }
#sheetTable select:disabled { appearance: none; -webkit-appearance: none; color: var(--ink); }
#history { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(420px, calc(100% - 24px)); z-index: 5; }
#historyList { list-style: none; margin: 0; padding: 6px 10px; overflow-y: auto; flex: 1 1 auto; }
#historyList li { position: relative; padding: 10px 6px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
#historyList li.undone { opacity: 0.55; }
#historyList .rowbtn, #historyList .hstate { position: absolute; right: 6px; top: 10px; font-size: 10px; }
.hmeta { font-size: 10px; color: var(--muted); padding-right: 70px; }
.hchange { font-size: 11.5px; color: var(--soft); word-break: break-word; }
.hchange .old { text-decoration: line-through; color: var(--muted); }
body.locked #stage { visibility: hidden; }

/* ── Phone ── */
@media (max-width: 760px) {
  header { gap: 6px 14px; padding: 6px 10px; min-height: 0; }
  .barcode, .cond.sun, [data-drop="3"] { display: none; }
  .conds { order: 3; flex-basis: 100%; gap: 4px 14px; font-size: 11px; flex-wrap: nowrap; overflow-x: auto; }
  .clock { margin-left: auto; }
  .overlay { padding: 0; align-items: flex-end; }
  #list, #card { position: absolute; left: 0; right: 0; bottom: 0; flex: none; max-height: 58%; border-radius: 14px 14px 0 0; border-bottom: 0; }
  #card { z-index: 2; }
  .tab { position: absolute; bottom: 12px; left: 12px; }
  #cardTab { left: auto; right: 12px; }
  #legend { bottom: auto; top: 10px; transform: none; left: 10px; max-width: calc(100% - 20px); }
  .filters { gap: 7px; padding: 10px 12px; }
  .list-head { padding: 12px; }
  body.card-open #list { display: none; }
  h1 { font-size: 17px; }
  .filters { display: none; }
  body.filters-open .filters { display: flex; }
  #filterBtn { display: inline-block; width: auto; padding: 0 8px; font-size: 10px; letter-spacing: 0.06em; }
  #filterBtn.on { background: var(--inv); color: var(--inv-fg); }
  #countTxt { display: none; }
  #list { max-height: 62%; }
  .sheet-help { display: none; }
  .sheet-bar input[type=search] { min-width: 0; flex: 1 1 140px; }
  .sheet-actions { margin-left: 0; }
}
