/* Rowing Server — shared look for every module. Big targets, high contrast:
   these pages get used on a dock in sunlight with cold hands. */
:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --text: #0e1a2b;
  --muted: #5a6a7f;
  --line: #d6dde6;
  --accent: #0a58a8;
  --accent-soft: #dbe9f8;
  --accent-ink: #ffffff;
  --go: #12803a;
  --go-soft: #dcf2e3;
  --stop: #c0262d;
  --stop-soft: #fbe1e2;
  /* Fills behind white text (START, FINISH, Save, armed Delete) and the colour
     of green or red text on white. The same in both themes: 5.0:1 and 5.9:1
     with white. --go and --stop are for coloured text on the page and get
     brighter in dark mode, where white on them would be 2.3:1 and 3.0:1. */
  --go-fill: #12803a;
  --stop-fill: #c0262d;
  --warn: #a35f00;
  --warn-soft: #fdefd6;
  --port: #c0262d;
  --star: #12803a;
  --both: #5a4bc2;
  --cox: #6b7280;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(14, 26, 43, .06), 0 6px 18px rgba(14, 26, 43, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111d;
    --surface: #111b2b;
    --surface-2: #172337;
    --text: #e7eef8;
    --muted: #96a5ba;
    --line: #24334a;
    --accent: #4d9cff;
    --accent-soft: #15304f;
    --accent-ink: #04101f;
    --go: #34c26a;
    --go-soft: #0f3420;
    --stop: #ff5c63;
    --stop-soft: #3d1517;
    --warn: #ffb547;
    --warn-soft: #3a2a0f;
    --port: #ff6b70;
    --star: #3ed27a;
    --both: #9d92ff;
    --cox: #9aa3b2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a111d; --surface: #111b2b; --surface-2: #172337; --text: #e7eef8; --muted: #96a5ba;
  --line: #24334a; --accent: #4d9cff; --accent-soft: #15304f; --accent-ink: #04101f;
  --go: #34c26a; --go-soft: #0f3420; --stop: #ff5c63; --stop-soft: #3d1517; --warn: #ffb547;
  --warn-soft: #3a2a0f; --port: #ff6b70; --star: #3ed27a; --both: #9d92ff; --cox: #9aa3b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; letter-spacing: .01em; }
h3 { font-size: .95rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { flex: 1 1 auto; }

/* buttons + inputs */
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .9rem;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-go { background: var(--go-fill); border-color: var(--go-fill); color: #fff; }
.btn-danger { color: var(--stop); }
.btn-danger.armed { background: var(--stop-fill); border-color: var(--stop-fill); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: .3rem .6rem; font-size: .88rem; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  min-height: 44px;
  min-width: 0;
}
textarea { min-height: 90px; width: 100%; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
label.field > input, label.field > select { color: var(--text); font-weight: 400; }

/* tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
  border-radius: 999px; padding: .12rem .55rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.go { background: var(--go-soft); color: var(--go); border-color: transparent; }
.badge.stop { background: var(--stop-soft); color: var(--stop); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* toast */
#rs-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%);
  background: var(--text); color: var(--bg);
  padding: .65rem .8rem .65rem 1rem; border-radius: 12px;
  display: flex; gap: .8rem; align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transition: transform .2s ease; z-index: 50; max-width: calc(100vw - 32px);
  width: max-content;   /* else left: 50% caps it at half the screen and a phone shows one word a line */
}
#rs-toast.show { transform: translate(-50%, 0); }
#rs-toast.bad { background: var(--stop-fill); color: #fff; }
#rs-toast button { min-height: 34px; padding: .25rem .7rem; background: transparent; color: inherit; border-color: currentColor; }

/* Notched phones: keep content clear of the notch and the home bar. */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Sign-in screen (auth.js) */
#rs-auth {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100;
  background: var(--bg); display: flex;
  padding: 24px 16px; overflow: auto;
}
/* margin: auto centres the card, and a card taller than the screen still
   scrolls from its top (align-items: center would cut the top off) */
.rs-auth-card {
  width: 100%; max-width: 380px; margin: auto; text-align: center; display: flex; flex-direction: column; align-items: stretch;
}
.rs-auth-card > * + * { margin-top: 12px; }
.rs-auth-card img { width: 64px; height: 64px; border-radius: 16px; align-self: center; }
.rs-auth-card h1 { font-size: 1.5rem; }
.rs-auth-card p { color: var(--muted); margin: 0; }
.rs-auth-card p + input { margin-top: 18px; }
.rs-auth-card input[type="password"], .rs-auth-card input[type="text"] { font-size: 1.2rem; text-align: center; min-height: 52px; }
.rs-auth-card button { min-height: 52px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 1.05rem; }
.rs-auth-show { color: var(--muted); font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.rs-auth-show input { width: 18px; height: 18px; min-height: 0; margin-right: 6px; }
.rs-auth-err { color: var(--stop) !important; font-weight: 600; min-height: 1.2em; }
.rs-auth-help { font-size: .85rem; }
.rs-auth-teams { display: flex; flex-direction: column; gap: 8px; }
.rs-auth-teams:empty { display: none; }
.rs-auth-card .rs-auth-team, .rs-auth-card .rs-auth-cancel { background: var(--surface); border-color: var(--line); color: var(--accent); }
/* Sign-in box: one form at a time (username and password, team code, invite,
   choosing a username), each input with its label above it */
.rs-auth-pane { display: flex; flex-direction: column; align-items: stretch; }
.rs-auth-pane > * + * { margin-top: 12px; }
.rs-auth-card > .rs-auth-pane { margin-top: 18px; }
.rs-auth-field { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.rs-auth-field label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.rs-auth-card .rs-auth-field input { font-size: 1.1rem; text-align: left; min-height: 50px; width: 100%; }
.rs-auth-card .rs-auth-hi { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.rs-auth-links { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rs-auth-links:empty { display: none; }
.rs-auth-card .rs-auth-link {
  min-height: 40px; padding: .3rem .5rem; background: transparent; border-color: transparent;
  color: var(--accent); font-size: .95rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.rs-auth-card .rs-auth-link:hover { border-color: transparent; text-decoration-thickness: 2px; }

/* Scull colour (port red, starboard green, scull teal, cox grey) */
:root { --scull: #0e7c86; --scull-soft: #d6f1f3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --scull: #3cc7d3; --scull-soft: #0f3134; } }
:root[data-theme="dark"] { --scull: #3cc7d3; --scull-soft: #0f3134; }
