:root {
  --bg: #0a1420;
  --bg2: #0f1e2d;
  --card: #142636;
  --card2: #1a3044;
  --line: #2b4a63;
  --text: #eef6fb;
  --muted: #9db4c7;
  --accent: #38bdf8;
  --accent2: #22d3ee;
  --glow1: #10304a;
  --glow2: #0d3b4a;
  --outline: #22c55e;
  --exc: #22c55e;
  --bom: #84cc16;
  --raz: #eab308;
  --fraco: #f97316;
  --mau: #ef4444;
  --radius: 14px;
  color-scheme: dark;
}

/* ---------- themes (solid colours) ---------- */
html[data-theme="a"] {
  --bg: #160629; --bg2: #1f0a38; --card: #2a0d4d; --card2: #3a1266;
  --line: rgba(34, 227, 255, .42);
  --text: #f6e9ff; --muted: #c3a6e0;
  --accent: #22e3ff; --accent2: #ff2fb9; --accent3: #9d4edd;
  --card-border: rgba(34, 227, 255, .42);
  --card-shadow: 0 0 0 1px rgba(255,47,185,.12) inset, 0 18px 50px rgba(0,0,0,.5);
}
html[data-theme="b"] {
  --bg: #08021a; --bg2: #100628; --card: #1a0b3d; --card2: #24124f;
  --line: rgba(182, 255, 0, .40);
  --text: #eafcff; --muted: #a6b8d8;
  --accent: #00ffc6; --accent2: #ff2e97; --accent3: #b6ff00;
  --card-border: rgba(182, 255, 0, .38);
  --card-shadow: 0 0 0 1px rgba(0,255,198,.10) inset, 0 18px 50px rgba(0,0,0,.55);
}
html[data-theme="c"] {
  --bg: #1c0620; --bg2: #260a2c; --card: #32103f; --card2: #431555;
  --line: rgba(255, 122, 24, .42);
  --text: #fff0f6; --muted: #d3a9c4;
  --accent: #ff7a18; --accent2: #af2896; --accent3: #00d4ff;
  --card-border: rgba(255, 122, 24, .42);
  --card-shadow: 0 0 0 1px rgba(0,212,255,.10) inset, 0 18px 50px rgba(0,0,0,.5);
}
html[data-theme="d"] {
  --bg: #141226; --bg2: #1b1830; --card: #1e1a38; --card2: #272243;
  --line: rgba(180, 190, 240, .24);
  --text: #f4effb; --muted: #b8b0cc;
  --accent: #7fe3d4; --accent2: #e79bb0; --accent3: #9aa6f0;
  --card-border: rgba(180, 190, 240, .26);
  --card-shadow: 0 0 0 1px rgba(127,227,212,.10) inset, 0 18px 55px rgba(0,0,0,.45);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  height: 1.7em;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

a { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--card2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .4px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.search-wrap { display: flex; gap: 8px; align-items: center; flex: 1; max-width: 640px; justify-content: flex-end; }

.search-box { position: relative; flex: 1; min-width: 200px; }

#search {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .15); }

.results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
  max-height: 320px;
  overflow: auto;
  z-index: 60;
}
.results li {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.results li:hover, .results li.active { background: var(--card2); }
.results li span { display: block; font-size: 12px; color: var(--muted); }

select, .icon-btn {
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.icon-btn { cursor: pointer; font-size: 16px; }
.icon-btn:hover { border-color: var(--accent); }

.unit-toggle { display: inline-flex; gap: 6px; }
.unit-btn {
  min-width: 50px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.unit-btn:hover { border-color: var(--accent); color: var(--accent); }
.unit-btn.on { border-color: var(--accent); color: var(--accent); background: rgba(56, 189, 248, .14); }

/* ---------- status / chips ---------- */
.status {
  min-height: 0;
  font-size: 14px;
  color: var(--muted);
  margin: 4px 0 0;
}
.status.error { color: #fca5a5; }
.status.loading::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 8px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0 4px; }
.chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.chip-group b {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-right: 2px;
}
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #04121d; font-weight: 600; }

/* ---------- spot head ---------- */
.spot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 14px;
}
.spot-head h2 { margin: 0; font-size: 26px; }
.spot-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.badge {
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge small { display: block; font-weight: 500; font-size: 11px; opacity: .85; text-align: center; }

.r-exc   { background: #0f3320; color: #6ee7a0; border-color: rgba(34, 197, 94, .55); }
.r-bom   { background: #2c3a12; color: #bef264; border-color: rgba(132, 204, 22, .55); }
.r-raz   { background: #39310d; color: #fde047; border-color: rgba(234, 179, 8, .55); }
.r-fraco { background: #3a2410; color: #fdba74; border-color: rgba(249, 115, 22, .55); }
.r-mau   { background: #3a1517; color: #fca5a5; border-color: rgba(239, 68, 68, .55); }

/* ---------- now ---------- */
.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stat strong { font-size: 27px; line-height: 1.15; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------- days ---------- */
.days {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.day-btn {
  flex: 0 0 auto;
  min-width: 118px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.day-btn:hover { border-color: var(--accent); }
.day-btn.on { border-color: var(--accent); background: rgba(56, 189, 248, .12); }
.day-btn .d1 { font-size: 13px; font-weight: 600; }
.day-btn .d2 { font-size: 12px; color: var(--muted); margin-top: 3px; }
.day-btn .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

/* ---------- detail ---------- */
.detail { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 30px rgba(0, 0, 0, .25);
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(43, 74, 99, .5);
}
.card-head h3 { margin: 0; font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.split-badges { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.split-badges .pill { font-size: 11px; padding: 3px 9px; }
.legend i.sw { display: inline-block; width: 16px; margin-right: 6px; vertical-align: middle; border-radius: 3px; }
.sw.swell { height: 10px; opacity: .30; background: linear-gradient(90deg, #22c55e, #84cc16, #eab308, #f97316, #ef4444); }
.sw.wind { height: 10px; background: linear-gradient(90deg, #22c55e, #84cc16, #eab308, #f97316, #ef4444); box-shadow: 0 0 0 1px rgba(255,255,255,.85) inset, 0 2px 0 rgba(255,255,255,.85) inset; }

.chart svg { width: 100%; height: auto; display: block; }

.table-wrap { overflow: auto; max-height: 460px; }
.table-wrap::-webkit-scrollbar { height: 11px; width: 11px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #2a4a63; }
.table-wrap::-webkit-scrollbar-track { background: rgba(255, 255, 255, .03); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--card2);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
thead th + th, tbody td + td { border-left: 1px solid rgba(43, 74, 99, .45); }
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .025); }
tbody tr:hover { background: rgba(56, 189, 248, .09); }
tbody tr.best { background: rgba(34, 197, 94, .08); }
tbody tr.best td:first-child { font-weight: 700; color: #6ee7a0; }

.arrow {
  display: inline-block;
  margin-right: 6px;
  color: var(--accent);
  font-weight: 700;
}
.muted { color: var(--muted); }

.pill {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.about p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 8px 0 0; }
.about strong { color: var(--text); }

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 40px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 860px) {
  .now-grid { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { max-width: none; width: 100%; }
  .brand { width: 100%; }
  .spot-head h2 { font-size: 22px; }
}
@media (max-width: 520px) {
  .now-grid { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 22px; }
  select { display: none; }
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 16px 0 12px;
}
.tab {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.on { background: var(--accent); border-color: var(--accent); color: #04121d; }

/* ---------- settings ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.form-grid input[type="number"] {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
}
.form-grid .check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  align-self: end;
  padding-bottom: 8px;
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.weight {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}
.weight input[type="range"] { flex: 1; accent-color: var(--accent); }
.weight b { color: var(--text); font-size: 14px; }

.settings-table input[type="number"], .settings-table select {
  width: 78px;
  padding: 6px 7px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
}
.settings-table input:disabled, .settings-table select:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.settings-table .spot-name { font-weight: 600; }
.settings-table .spot-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.spot-days { display: flex; gap: 5px; margin-top: 6px; flex-wrap: nowrap; }
.sd { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9px; color: var(--muted); line-height: 1; }
.sd em { font-style: normal; text-transform: uppercase; letter-spacing: .03em; }
.sd i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.settings-table .center { text-align: center; }
.settings-table th:last-child { position: sticky; right: 0; z-index: 3; background: var(--card2); }
.settings-table td:last-child { position: sticky; right: 0; z-index: 2; background: var(--card); box-shadow: -10px 0 12px -10px rgba(0, 0, 0, .55); }
.settings-table tr.row-dirty td:last-child { background: #12293a; }
.settings-table .facing { font-size: 13px; white-space: nowrap; }
.del-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 6px;
}
.del-btn:hover { color: var(--mau); background: rgba(239, 68, 68, .12); }
.actions-cell { white-space: nowrap; }
.row-save {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 7px;
  margin-right: 4px;
}
.row-save:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.row-save:disabled { opacity: .3; cursor: default; }
tr.row-dirty { background: rgba(56, 189, 248, .06); }

/* ---------- ranking ---------- */
.rank-actions { display: flex; align-items: center; gap: 12px; }
.rank-table td { vertical-align: middle; }
.rank-table .pos {
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
  width: 34px;
}
.rank-table tr.p1 .pos { color: #fbbf24; }
.rank-table tr.p2 .pos { color: #cbd5e1; }
.rank-table tr.p3 .pos { color: #d97706; }
.rank-table tr:hover { cursor: pointer; }
.rank-table .spot-sub { display: block; font-size: 11px; color: var(--muted); }
.rank-table .go {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--accent);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.rank-table .go:hover { border-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

.progress {
  position: relative;
  height: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}
.progress div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .25s;
}
.progress span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #e7f1f7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.breakdown { font-size: 11px; color: var(--muted); margin-left: 6px; }

/* ---------- rank filters ---------- */
.rank-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  margin-top: 4px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.filter-group select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  min-width: 160px;
}

@media (max-width: 720px) {
  .tabs { flex-wrap: wrap; }
  .weight { flex-wrap: wrap; }
}

/* ---------- favorites / stars ---------- */
.star-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 6px;
  transition: .15s;
}
.star-btn:hover { color: #fbbf24; background: rgba(251, 191, 36, .12); }
.star-btn.on { color: #fbbf24; }
.star-btn.big { font-size: 22px; vertical-align: middle; margin-right: 4px; }

.chip-wrap { display: inline-flex; align-items: center; gap: 2px; }
.chip-wrap .star-btn { font-size: 12px; padding: 2px 3px; }
.chip.fav { border-color: rgba(251, 191, 36, .55); }
.chip.fav:hover { border-color: #fbbf24; color: #fbbf24; }
.chip-group b.grp-fav { color: #fbbf24; }
.chip-group b.grp-country { color: var(--accent); }
.chip-group b.grp-custom { color: var(--accent2); }
.chip-wrap .chip-x {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 6px;
  transition: .15s;
}
.chip-wrap .chip-x:hover { color: #f87171; background: rgba(248, 113, 113, .14); }

.fav-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  padding-bottom: 9px;
  cursor: pointer;
}
.rank-table .fav-col { width: 30px; text-align: center; }
.rank-table td.fav-col .star-btn { font-size: 14px; }

/* ---------- settings actions / secret spot ---------- */
.chip.primary { background: var(--accent); border-color: var(--accent); color: #04121d; font-weight: 600; }
.chip.primary:hover { color: #04121d; filter: brightness(1.08); }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chip:disabled:hover { border-color: var(--line); color: var(--text); }

.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.status.ok { color: #6ee7a0; }

.form-grid input[type="text"] {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
}

/* ---------- compass rose ---------- */
.rose-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.rose {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.rose:active { cursor: grabbing; }
.rose-svg { width: 100%; height: 100%; display: block; }
.rose-side { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.rose-side > b { font-size: 13px; color: var(--text); }
.rose-side label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.rose-side input {
  width: 100px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
}

.face-cell { display: flex; align-items: center; gap: 8px; }
.rose-col { vertical-align: middle; }
.mini-rose-row { display: flex; align-items: center; gap: 6px; }
.rose-val { display: flex; align-items: center; gap: 4px; }
.rose-col .face-input, .rose-col .wind-input { width: 52px; font-size: 12px; padding: 4px 6px; }
.rose-col .face-dir { font-size: 11px; }
.rose-mini {
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.rose-mini:active { cursor: grabbing; }
.rose-mini.base-follow { opacity: .5; }
.rose-mini.muted-rose { opacity: .35; }
.muted-rose { opacity: .35; }
.face-val { font-size: 13px; white-space: nowrap; color: var(--text); }
.face-input { width: 62px; }
.face-dir { font-size: 13px; color: var(--muted); min-width: 28px; }

.sw-cell { display: flex; align-items: center; gap: 8px; }
.sw-text { font-size: 12px; white-space: nowrap; color: var(--text); display: flex; align-items: center; gap: 4px; }
.off-iv { font-weight: 600; }
.mini-x {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  cursor: pointer;
}
.mini-x:hover { color: var(--text); border-color: var(--accent); }

/* ---------- login / perfis ---------- */
#app.hidden-app { display: none; }
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h2 { margin: 0; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card input { padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 15px; }
.login-actions { display: flex; gap: 8px; margin-top: 4px; }
.login-actions .chip { flex: 1; }
.login-users { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.user-box { display: flex; align-items: center; gap: 6px; }
.user-name { font-size: 12px; color: var(--muted); }

.wind-input { width: 58px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
  outline: none;
}
.settings-table tr:nth-child(even) td:last-child { background: #182b3b; }
.settings-table tr.row-dirty td:last-child { background: #153447; }

.legend-note { color: #c6ccd4; font-weight: 600; }

.now-date { font-size: 12px; color: var(--muted); text-transform: capitalize; margin: 4px 0 0; }

.sun-note { color: var(--muted); }

.warn { color: #f59e0b; font-size: 12px; font-weight: 600; }

.warn-mixed { color: #ef4444; }

.swell-cell { white-space: normal; }
.swell-line { display: grid; grid-template-columns: 44px 1fr; gap: 6px; align-items: baseline; }
.swell-tag { color: var(--muted); font-size: 11px; letter-spacing: .03em; }

.mode-cell { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.mode-opt { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text); white-space: nowrap; }

.tide-note { color: #c6ccd4; }

.moon-note { color: #cbd5e1; }

#hourlyTable th, #hourlyTable td { text-align: center; white-space: nowrap; }
#hourlyTable td { min-width: 56px; }
#hourlyTable .var-col { position: sticky; left: 0; text-align: left; background: var(--card); z-index: 2; min-width: 92px; }
#hourlyTable thead .var-col { background: var(--card2); z-index: 3; }
#hourlyTable th.best-col { color: #6ee7a0; }
#hourlyTable .pill { font-size: 10px; padding: 2px 6px; }
#hourlyTable .warn { font-size: 10px; }

/* ---------- sessions ---------- */
.session-form { background: var(--card2); border: 1px solid var(--accent); border-radius: 12px; padding: 14px; margin: 8px 0 16px; }
.session-form-head { font-size: 14px; margin-bottom: 10px; }
.session-form .row-actions.right { justify-content: flex-end; }
.chip.green { background: #22c55e; border-color: #22c55e; color: #04121d; font-weight: 600; }
.chip.green:hover { color: #04121d; filter: brightness(1.08); }
#sessionForm input, #sessionForm select { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 14px; }
.sess-cond { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); font-size: 13px; margin: 10px 0; color: var(--text); }
.sess-rating { display: flex; gap: 8px; margin: 10px 0; }
.sess-rating .chip.on { background: var(--accent); border-color: var(--accent); color: #04121d; font-weight: 600; }
.sess-svg { width: 100%; height: auto; display: block; }

/* ---------- sessions legends ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-stars { color: #fbbf24; }
.lg-muted { color: var(--muted); }

#sessLegend { margin: 8px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.moon-note { color: #c9d1d9; }
.moon-icon { display: inline-block; font-size: 2.1em; line-height: 1; vertical-align: -6px; filter: grayscale(1) brightness(1.3) drop-shadow(0 0 5px rgba(200,210,225,.55)); }
#hourlyTable th.night-col { background: var(--bg); color: #93a7bb; }
#hourlyTable td.night-cell { background: var(--bg); }

#hourlyTable thead th { padding-top: 24px; }
#hourlyTable .sun-ev { position: absolute; top: 3px; transform: translateX(-50%); text-align: center; line-height: 1; pointer-events: none; white-space: nowrap; }
#hourlyTable .sun-line { display: block; width: 14px; height: 2px; margin: 0 auto 2px; border-radius: 1px; }
#hourlyTable .sun-ev b { display: block; font-size: 8px; font-weight: 700; letter-spacing: .02em; }
#hourlyTable .sun-ev.rise .sun-line { background: #fbbf24; }
#hourlyTable .sun-ev.rise b { color: #fbbf24; }
#hourlyTable .sun-ev.set .sun-line { background: #fb923c; }
#hourlyTable .sun-ev.set b { color: #fb923c; }

#hourlyTable .sun-ev b { text-transform: none; }

.rose-val.col { flex-direction: column; align-items: flex-start; gap: 3px; }
.rv-line { display: flex; align-items: center; gap: 4px; }
.rose-col .tol-input { width: 46px; font-size: 12px; padding: 4px 6px; }
.tol-cap { font-size: 12px; color: var(--muted); font-weight: 600; }

#secTol { width: 80px; }

/* ---------- social: share / suggestions / feedback ---------- */
.row-share {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 7px;
  margin-right: 4px;
}
.row-share:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.row-share:disabled { opacity: .3; cursor: default; }

.modal-overlay { position: fixed; inset: 0; background: rgba(4,12,20,.72); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal-card { width: min(680px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 14px 16px; overflow: auto; }

.share-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 46vh; overflow: auto; }
.share-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card2); }
.share-note { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin: 10px 0; }
.share-note input { width: 100%; box-sizing: border-box; }

.sugg-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.sugg-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--card2); }
.sugg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sugg-by { font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.sugg-adjust { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 8px 0; }
.sugg-adjust .adj { font-size: 11px; background: rgba(56,189,248,.10); border: 1px solid rgba(56,189,248,.28); color: #cfe9fb; padding: 2px 7px; border-radius: 999px; }
.sugg-note { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 6px; }
.sugg-actions { display: flex; gap: 8px; }

.fb-text-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin: 10px 0; }
#fbText { width: 100%; box-sizing: border-box; resize: vertical; min-height: 90px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 14px; font-family: inherit; }

.msg-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.msg-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--card2); }
.msg-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-top .mini-x { margin-left: auto; }
.msg-text { margin-top: 6px; white-space: pre-wrap; font-size: 13px; }

.row-sugg {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 7px;
  margin-right: 4px;
}
.row-sugg:hover { border-color: #fbbf24; color: #fbbf24; }

/* ---------- painted surfaces (solid) ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--outline);
  box-shadow: var(--card-shadow);
}
.card-head {
  border-bottom-color: var(--card-border);
}
.card-head h3 {
  color: var(--accent);
}
.stat,
.day-btn,
.tab {
  background: var(--card);
  border-color: var(--card-border);
}
.topbar {
  background: var(--card2);
  border-bottom: 1px solid var(--card-border);
}
.topbar .brand h1 {
  color: var(--accent);
}
.tab.on,
.chip.on,
.chip.primary,
.sess-rating .chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0418;
  font-weight: 700;
}
.chip.primary:hover,
.tab.on:hover {
  filter: brightness(1.08);
  color: #0a0418;
}
thead th {
  background: var(--card2);
}
.day-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0418;
  font-weight: 600;
}
.unit-btn.on {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.login-card,
.modal-card {
  background: var(--card);
  border-color: var(--card-border);
}

/* ---------- theme D: nocturne watercolour ---------- */
html[data-theme="d"] body {
  background:
    radial-gradient(58vw 52vw at 6% 4%, rgba(127, 227, 212, .42), transparent 62%),
    radial-gradient(54vw 48vw at 94% 0%, rgba(231, 155, 176, .40), transparent 62%),
    radial-gradient(60vw 54vw at 90% 52%, rgba(150, 160, 240, .34), transparent 62%),
    radial-gradient(56vw 50vw at 2% 54%, rgba(186, 150, 220, .34), transparent 62%),
    radial-gradient(66vw 56vw at 48% 102%, rgba(120, 200, 220, .30), transparent 62%),
    radial-gradient(42vw 38vw at 52% 44%, rgba(255, 210, 180, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
html[data-theme="d"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
}
html[data-theme="d"] .login-overlay { background: transparent; }
html[data-theme="d"] .card,
html[data-theme="d"] .stat,
html[data-theme="d"] .day-btn,
html[data-theme="d"] .tab,
html[data-theme="d"] .login-card,
html[data-theme="d"] .modal-card {
  background:
    radial-gradient(130% 110% at 0% 0%, rgba(127, 227, 212, .17), transparent 55%),
    radial-gradient(130% 110% at 100% 100%, rgba(231, 155, 176, .15), transparent 55%),
    var(--card);
  border-color: var(--card-border);
}
html[data-theme="d"] .topbar {
  background:
    radial-gradient(120% 220% at 50% 0%, rgba(127, 227, 212, .16), transparent 62%),
    var(--card2);
}
html[data-theme="d"] .card-head h3 { color: var(--accent); }
html[data-theme="d"] .modal-overlay { background: rgba(10, 8, 20, .66); }

/* close the outline around tables */
.table-wrap {
  border: 1px solid var(--outline);
  border-radius: 12px;
}

/* ---------- global background image (all pages/themes) ---------- */
html[data-theme] body {
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(8, 6, 18, .30), rgba(8, 6, 18, .46)),
    url("bg.jpg");
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
.login-overlay { background: transparent; }

footer { text-shadow: 0 1px 4px rgba(0,0,0,.75); }

/* green outline on every card / stat / table, all themes */
html[data-theme] .card,
html[data-theme] .stat,
html[data-theme] .table-wrap {
  border: 1px solid var(--outline);
}

/* page tabs: green = current, psychedelic = others */
.tab {
  background: #8b1fb3;
  border-color: #e879f9;
  color: #fdf4ff;
}
.tab:hover {
  background: #a52ad1;
  border-color: #22e3ff;
  color: #ffffff;
}
.tab.on {
  background: #22c55e;
  border-color: #22c55e;
  color: #04120a;
  font-weight: 700;
}

/* day selectors + ranking modes: green = current, psychedelic = others */
.day-btn {
  background: #8b1fb3;
  border-color: #e879f9;
  color: #fdf4ff;
}
.day-btn .d1 { color: #ffffff; }
.day-btn .d2 { color: rgba(255, 255, 255, .82); }
.day-btn:hover { background: #a52ad1; border-color: #22e3ff; }
.day-btn.on {
  background: #22c55e;
  border-color: #22c55e;
  color: #04120a;
}
.day-btn.on .d1 { color: #04120a; }
.day-btn.on .d2 { color: rgba(4, 18, 10, .75); }

#rankMode .unit-btn {
  background: #8b1fb3;
  border-color: #e879f9;
  color: #fdf4ff;
}
#rankMode .unit-btn:hover { background: #a52ad1; border-color: #22e3ff; color: #ffffff; }
#rankMode .unit-btn.on {
  background: #22c55e;
  border-color: #22c55e;
  color: #04120a;
  font-weight: 700;
}

/* softer psychedelic for inactive tabs/days/modes */
.tab { background: #6b2b82; border-color: #a874bd; color: #f3e9f8; }
.tab:hover { background: #7d3398; border-color: #22e3ff; }
.day-btn { background: #6b2b82; border-color: #a874bd; }
#rankMode .unit-btn { background: #6b2b82; border-color: #a874bd; color: #f3e9f8; }
#rankMode .unit-btn:hover { background: #7d3398; border-color: #22e3ff; }

/* favourites: vivid gold everywhere */
.fav-check {
  color: #ffcf3a;
  background: rgba(255, 190, 0, .14);
  border: 1px solid rgba(255, 190, 0, .6);
  border-radius: 8px;
  padding: 5px 9px;
}
.fav-check input { accent-color: #ffcf3a; }
.star-btn.on { color: #ffcf3a; text-shadow: 0 0 7px rgba(255, 190, 0, .65); }
.chip.fav { border-color: #ffcf3a; color: #ffcf3a; background: rgba(255, 190, 0, .10); }
.chip.fav:hover { border-color: #ffcf3a; color: #ffcf3a; }
.chip-group b.grp-fav { color: #ffcf3a; }

/* make "favourites only" clearly visible in all filter bars */
.filter-group .fav-check {
  color: #2a1c00;
  background: #ffcf3a;
  border: 1px solid #ffe680;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 0 12px rgba(255, 200, 0, .35);
}
.filter-group .fav-check input { accent-color: #2a1c00; }

.sw.energy { height: 10px; opacity: .30; background: #a855f7; }

/* clickable chart legend */
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  user-select: none;
  transition: .15s;
}
.legend-item:hover { border-color: var(--accent); }
.legend-item.on { border-color: #22c55e; background: rgba(255, 255, 255, .07); }
.legend-item.on .sw.swell,
.legend-item.on .sw.energy { opacity: 1; }

/* legend swatches: uniform (all toggleable) */
.sw.swell, .sw.wind, .sw.energy { opacity: .5; }
.sw.wind { box-shadow: none; }
.legend-item.on .sw { opacity: 1; }
