/* TackTracker web theme — ports the iOS dark/cyan design tokens
   (android/lib/core/theme/app_colors.dart). cyan = your own data; gray = others. */
:root {
  --bg: #000000;
  --accent: #00C8DC;
  --text: #FFFFFF;
  --text-2: rgba(255,255,255,0.50);
  --text-3: rgba(255,255,255,0.35);
  --row: rgba(255,255,255,0.05);
  --field: rgba(255,255,255,0.08);
  --gray: #8E8E93;
  --warning: #FF9500;
  --danger: #FF3B30;
  --success: #34C759;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout
   The phone apps are a single column; on desktop that leaves ~65% of the screen
   empty. Rather than restyle components (they must stay identical to iOS/
   Android), we only change ARRANGEMENT: a wider shell plus auto-fit grids that
   collapse back to one column under ~700px — so on a phone-width browser the
   layout is literally the app layout, and on desktop it uses the width. */
.shell { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
/* At phone width the desktop gutter eats real estate the apps don't spend. */
@media (max-width: 560px) {
  .shell { padding: 14px 12px 40px; }
  .nav { padding: 8px 10px; gap: 2px; }
  .nav .brand span { display: none; }
  .page-title { font-size: 24px; }
}
/* Forms and auth stay narrow — a full-width text input looks broken, and the
   create-race wizard is a phone-shaped flow. */
.shell.narrow { max-width: 720px; }

/* Responsive column sets. Cards inside keep their exact phone styling.
   NB: named `.cols`, NOT `.grid` — `table.grid` is the existing results-table
   class, and a `display:grid` rule would silently destroy its column layout.
   `align-items: start` keeps cards at their natural height — without it grid
   stretches every card in a row to the tallest one, leaving dead space. */
.cols { display: grid; gap: 12px; align-items: start; }
/* `min(Npx, 100%)`, not a bare `Npx`: a plain minmax floor wider than the
   viewport forces the track to overflow instead of collapsing to one column. */
/* `auto-fill`, not `auto-fit`: these hold lists of cards, and auto-fit collapses
   the empty tracks so a lone card stretches the full page width. auto-fill keeps
   the empty columns, so one race card stays card-sized. */
.cols-2 { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
/* Analytics detail: charts/tables side by side on wide screens. */
.cols-analytics { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
/* A card that must not be split across columns (wide tables, maps). */
.span-all { grid-column: 1 / -1; }

/* Large screen title — mirrors Android's LargeTitle / iOS .navigationTitle
   (.large): 28px bold white, tight above the first section header. */
.page-title { font-size: 28px; font-weight: 700; margin: 4px 4px 2px; letter-spacing: -0.2px; }

.section-head {
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-2); font-weight: 600; margin: 18px 4px 8px;
}
/* Section header with a trailing action (mirrors the apps' header rows). The
   header's uppercasing must not leak into the action — those are normal-case
   buttons in the apps. */
.section-head.with-action { display: flex; align-items: baseline; gap: 12px; }
.section-head.with-action .spacer { flex: 1; }
.section-head a { text-transform: none; letter-spacing: 0; font-weight: 500; }
/* Race Organization heading — a level *below* .section-head, so "Your Races"
   still reads as the section and the club is the grouping inside it. */
.club-head { display: flex; align-items: center; gap: 10px; margin: 14px 4px 8px;
  font-size: 13px; font-weight: 600; color: var(--accent); }
.club-head::after { content: ""; flex: 1; height: 1px; background: rgba(0,200,220,0.18); }

.muted { color: var(--text-2); }
.muted-2 { color: var(--text-3); }
.accent { color: var(--accent); }
.gray { color: var(--gray); }

/* Top nav (mirrors the iOS tab bar) */
.nav {
  position: sticky; top: 0; z-index: 10; background: #0a0a0a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 4px; padding: 10px 14px;
}
.nav .brand { font-weight: 700; margin-right: auto; letter-spacing: .3px; display: flex;
  align-items: center; gap: 8px; flex: 0 0 auto; }
.nav-tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .tab { white-space: nowrap; }
.nav .brand:hover { text-decoration: none; }
.nav .brand img { height: 28px; width: 28px; border-radius: 6px; object-fit: cover; }
.nav .brand .dot { color: var(--accent); }
.nav a.tab { color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.nav a.tab.active, .nav a.tab:hover { color: var(--text); background: var(--row); text-decoration: none; }
.nav .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #2e2e2e;
  display: grid; place-items: center; color: var(--text); font-size: 13px; border: 1px solid #444;
}

/* Hamburger + slide-in drawer — mirrors the apps' menu button + drawer.
   CSS-only via the #drawer-toggle checkbox (no JS). */
.hamburger {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 0 8px;
}
.hamburger span { display: block; height: 2px; border-radius: 2px; background: var(--text-2); }
.hamburger:hover span { background: var(--text); }

.drawer-scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: min(320px, 86vw);
  background: #0d0d0d; border-right: 1px solid rgba(255,255,255,0.10);
  transform: translateX(-100%); transition: transform .2s ease;
  overflow-y: auto; padding: 8px 10px 24px;
}
.drawer-toggle:checked ~ .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer-toggle:checked ~ .drawer { transform: translateX(0); }

.drawer-head { display: flex; align-items: center; padding: 10px 8px 6px; }
.drawer-title { font-weight: 700; letter-spacing: .3px; }
.drawer-close { margin-left: auto; cursor: pointer; font-size: 26px; line-height: 1;
  color: var(--text-2); padding: 0 8px; }
.drawer-close:hover { color: var(--text); }
.drawer-group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3, #777); padding: 16px 10px 6px; }
.drawer-item {
  display: block; width: 100%; text-align: left; color: var(--text); padding: 10px 10px;
  border-radius: 8px; font-size: 15px; background: none; border: 0; cursor: pointer;
}
.drawer-item:hover, .drawer-item.active { background: var(--row); text-decoration: none; }
.drawer-item.active { color: var(--accent); }
.drawer-signout { color: var(--danger, #ff5a5a); }

/* Cards / list rows */
.card { background: var(--row); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card.linkish:hover { background: rgba(255,255,255,0.08); cursor: pointer; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.row-line { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,0.08); color: var(--text-2);
}
.chip.cyan { color: var(--accent); background: rgba(0,200,220,0.12); }
.chip.ok { color: var(--success); background: rgba(52,199,89,0.14); }
.mine { color: var(--accent) !important; }

/* Key/value detail row — mirrors the apps' `_row(label, value)` in the Info tab:
   dim label left, white value right, hairline separators. */
.kv { display: flex; align-items: baseline; gap: 16px; padding: 9px 0;
      border-top: 1px solid rgba(255,255,255,0.06); font-size: 14px; }
.kv:first-of-type { border-top: none; }
.kv > span:first-child { color: var(--text-2); flex: 0 0 auto; min-width: 128px; }
.kv > span:last-child { margin-left: auto; text-align: right; }
/* Join code / RC PIN — monospace and letter-spaced so they're easy to read out. */
.code-chip { font-family: ui-monospace, Menlo, monospace; font-weight: 700;
  letter-spacing: 3px; color: var(--accent); }

/* Fleet-summary stat row (Boats / Finished / DNF), matching the apps' card. */
.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; text-align: center; }
.stat-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-l { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* Forms */
.field {
  width: 100%; background: var(--field); color: var(--text); border: none; outline: none;
  border-radius: 10px; padding: 12px 14px; font-size: 15px; margin: 6px 0;
}
.field::placeholder { color: var(--text-3); }
label.lbl { display: block; color: var(--text-2); font-size: 13px; margin: 10px 2px 0; }

/* Browsers render date/time pickers and <option> popups from the OS light theme
   unless told otherwise — `color-scheme` is what makes the native calendar and
   the select dropdown come back dark, matching the apps. */
select.field, input[type="date"].field, input[type="time"].field { color-scheme: dark; }
/* Kill the OS select chrome and draw our own chevron, so it reads as the apps'
   Picker rather than a platform dropdown. */
select.field {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2300C8DC' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
textarea.field { resize: vertical; min-height: 76px; font-family: inherit; }

/* iOS Toggle. `.switch` is the visible control; the checkbox itself stays a real
   form control so it still posts, it's just restyled rather than replaced. */
.switch {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; margin: 0; cursor: pointer;
  width: 51px; height: 31px; border-radius: 16px; background: rgba(255,255,255,0.16);
  position: relative; transition: background .18s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform .18s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.06); }
.toggle-row:first-of-type { border-top: none; }
.toggle-row .t-label { flex: 1; font-size: 15px; }
.toggle-row .t-sub { display: block; color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* Checklist row — the apps show a plain label with a trailing cyan checkmark
   when selected (no box at all), e.g. the Allowed Classes picker. The real
   checkbox is hidden but still present, so the form still posts its value. */
.check-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; cursor: pointer;
  font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.check-row .tick { margin-left: auto; color: var(--accent); font-weight: 700; visibility: hidden; }
.check-row input:checked ~ .tick { visibility: visible; }
.check-row:hover { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #000; font-weight: 700; border: none; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; cursor: pointer; width: 100%;
}
.btn:hover { filter: brightness(1.05); }
.btn.outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost { background: var(--row); color: var(--text); font-weight: 500; }
.btn.danger { background: rgba(255,59,48,0.12); color: var(--danger); border: 1px solid rgba(255,59,48,0.4); }
.btn.auto { width: auto; padding: 9px 14px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }

/* Place-search type-ahead — the apps' MKLocalSearchCompleter list: bold title,
   grey subtitle, overlaid on whatever is below rather than pushing it down. */
.search-wrap { position: relative; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 500;
  background: #121212; border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.search-row { padding: 9px 12px; cursor: pointer; border-top: 1px solid rgba(255,255,255,0.06); }
.search-row:first-child { border-top: none; }
.search-row:hover { background: rgba(255,255,255,0.07); }
.search-row .s-title { font-size: 14px; font-weight: 600; }
.search-row .s-sub { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* Tables (standings, results) */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { color: var(--text-2); font-weight: 600; font-size: 12px; text-align: center; padding: 6px 8px; }
table.grid th.left, table.grid td.left { text-align: left; }
table.grid td { padding: 7px 8px; text-align: center; border-top: 1px solid rgba(255,255,255,0.06); }
.scroll-x { overflow-x: auto; }

/* Flash */
.flash { border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.flash.success { background: rgba(52,199,89,0.12); color: var(--success); }
.flash.danger  { background: rgba(255,59,48,0.12); color: var(--danger); }
.flash.warning { background: rgba(255,149,0,0.12); color: var(--warning); }

/* Auth screens — the sign-in card sits over the same sailing photo the Home hero
   uses, so the first screen looks like the app rather than a bare black form.
   The image is a fixed background layer with a dark scrim: text contrast has to
   hold regardless of what part of the photo lands behind the card. */
.auth-wrap {
  position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: #000 center/cover no-repeat fixed;
}
/* Light enough that the photo still reads — the card carries its own contrast. */
.auth-wrap::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.15) 0%, rgba(0,0,0,.6) 75%);
}
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: rgba(10,10,10,0.72); backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 18px; padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
/* On the photo the field's 8%-white fill nearly vanishes — darken it here only. */
.auth-card .field { background: rgba(255,255,255,0.10); }
.auth-logo { text-align: center; font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.auth-logo .dot { color: var(--accent); }
.auth-logo-img { display: block; height: 88px; width: 88px; border-radius: 20px; object-fit: cover; margin: 0 auto 12px; box-shadow: 0 8px 30px rgba(0,200,220,.15); }
.auth-sub { text-align: center; color: var(--text-2); margin-bottom: 22px; }

/* Home hero (uses the iOS homepage image) */
.hero {
  position: relative; border-radius: 14px; overflow: hidden; margin: 4px 0 4px;
  min-height: 168px; display: flex; align-items: flex-end; padding: 16px;
  background-size: cover; background-position: center 35%;
}
.hero::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.8), rgba(0,0,0,.15)); }
.hero .hero-inner { position: relative; z-index: 1; }
.hero h1 { margin: 0; font-size: 22px; }
.hero .sub { color: var(--text-2); font-size: 13px; }
.center-links { text-align: center; margin-top: 16px; font-size: 14px; }

/* Segmented tabs — the apps' `Picker(.segmented)`. Two flavours share one look:
   `<button class="tab-btn">` for client-side tab panels (analytics detail), and
   `<a class="tab-btn">` for server-rendered segments (Pin Library, Race Setup). */
.tabs { display: flex; gap: 4px; background: var(--row); border-radius: 10px; padding: 4px;
  margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs.inline { max-width: 460px; }
/* `1 0 auto`, not `1`: the segments share width when they fit, but keep their
   label width and scroll the strip when they don't (7 tabs at phone width). */
.tab-btn { flex: 1 0 auto; text-align: center; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); cursor: pointer; font-size: 14px; border: none; background: transparent;
  white-space: nowrap; }
a.tab-btn { display: block; }
a.tab-btn:hover { text-decoration: none; color: var(--text); }
.tab-btn.active { background: rgba(255,255,255,0.10); color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.bar-track { flex: 1; height: 18px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gray); border-radius: 4px; }
.bar-fill.mine { background: var(--accent); }

/* Empty state — the apps' shared `emptyState(icon:title:subtitle:)`:
   50px glyph at accent@0.4, 20px bold title, 12px dim subtitle, all centered. */
.empty { text-align: center; color: var(--text-2); padding: 48px 16px; }
.empty .glyph { font-size: 50px; line-height: 1; color: var(--accent); opacity: .4; }
.empty .big { font-size: 20px; font-weight: 700; color: var(--text); margin: 16px 0 0; }
.empty .sub { font-size: 12px; color: #666; margin: 16px auto 0; max-width: 420px; line-height: 1.5; }
/* Inline icon + text: keeps the SVG optically centred on the text baseline. */
.ico { display: inline-flex; align-items: center; gap: 4px; }
.ico svg { flex: 0 0 auto; }
/* Uppercase the typed value but leave the placeholder in sentence case. */
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }

/* Draft badge — yellow pill on black text, as on the apps' race rows. */
.badge { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.badge.draft { background: #FFD60A; color: #000; }
.badge.warn { background: rgba(255,149,0,0.15); color: var(--warning); }
.map { height: 280px; border-radius: var(--radius); overflow: hidden; margin: 8px 0; }

/* Replay fullscreen */
.replay-card.fullscreen { position: fixed; inset: 0; z-index: 9999; margin: 0; border-radius: 0;
  display: flex; flex-direction: column; background: #000; }
.replay-card.fullscreen .map { height: auto !important; flex: 1 1 auto; margin: 0; border-radius: 0; }
.chart-wrap { height: 260px; }
