:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7380;
  --line: #e3e6ea;
  --accent: #e8590c;      /* basketball orange */
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --good: #1f8a4c;
  --good-soft: #e6f5ec;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --radius: 12px;
  --tap: 44px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
.boot { padding: 40vh 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--bad); }
.grow { flex: 1; min-width: 0; }

/* Shell */
.shell { min-height: 100vh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.shell.full { padding-bottom: env(safe-area-inset-bottom); }
.demo-bar { background: #fff8db; color: #7a5d00; font-size: 12px; text-align: center; padding: 4px 16px; padding-top: calc(4px + env(safe-area-inset-top)); }
header.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 8px 8px; padding-top: calc(8px + env(safe-area-inset-top));
}
.demo-bar + main header.top { padding-top: 8px; }
header.top h1 { flex: 1; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  min-width: var(--tap); height: var(--tap); border: 0; background: none; border-radius: 10px;
  font-size: 22px; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn.sm { min-width: 34px; height: 34px; font-size: 16px; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.icon-spacer { width: var(--tap); }
.page { padding: 12px 16px 24px; max-width: 720px; margin: 0 auto; }
.page.narrow { max-width: 480px; }
.page-title { font-size: 24px; margin: 12px 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 4px 8px; font-weight: 600; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; font-size: 11px; color: var(--muted); }
nav.tabs a .ti { font-size: 20px; line-height: 26px; filter: grayscale(1); opacity: .7; }
nav.tabs a.on { color: var(--accent); font-weight: 600; }
nav.tabs a.on .ti { filter: none; opacity: 1; }

/* Cards & lists */
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card h2 { font-size: 17px; margin-bottom: 8px; }
.card.empty { text-align: center; padding: 24px 16px; }
.card.list { padding: 0; overflow: hidden; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 12px 14px; min-height: var(--tap); border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; color: var(--ink); cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row:active { background: var(--bg); }
.list-add { width: 100%; padding: 12px 14px; border: 0; border-top: 1px dashed var(--line); background: none; color: var(--accent); text-align: left; cursor: pointer; }
.skipped { opacity: .45; }
.skipped .rr-name { text-decoration: line-through; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.gap { gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.center-row { justify-content: center; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* Buttons */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: #f2c4c4; }
.btn.big { min-height: 54px; font-size: 18px; padding: 0 24px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.ok { background: var(--good); border-color: var(--good); }
.link-btn { background: none; border: 0; color: var(--accent); padding: 8px 0; cursor: pointer; font-weight: 600; }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 10px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }

/* Chips / segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 600; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.add { color: var(--accent); border-style: dashed; }
.seg { display: flex; background: #e7e9ec; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg a { flex: 1; text-align: center; padding: 7px 0; border-radius: 8px; color: var(--ink); font-weight: 600; font-size: 14px; }
.seg a.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

/* Forms */
.field { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, textarea, .search {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-weight: 400; font-size: 16px;
}
.search { margin: 0 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); }

/* Stepper */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--bg); font-size: 18px; cursor: pointer; }
.stepper .val { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }

/* Schedule */
.sec { padding: 0; overflow: hidden; }
.sec-head { display: flex; justify-content: space-between; padding: 8px 14px; background: var(--accent-soft); color: #9a3b07; font-weight: 700; font-size: 14px; }
.sec-row { display: flex; justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--line); }
.sec-head + .sec-row { border-top: 0; }
.divider-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; margin: 4px 0 12px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; }
.card.list .divider-row { margin: 0; border-radius: 0; }
.divider-row.edit .link-btn { color: #fff; padding: 0; }
.divider-row .icon-btn.sm { color: #cfd3d8; }
.end-row { text-align: center; color: var(--muted); font-weight: 600; padding: 4px 0 12px; }
.goal-dot { color: var(--accent); font-size: 10px; vertical-align: middle; }
.goal-tag { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.tag.now { color: #fff; background: var(--accent); }

/* Plan editor */
.plan-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); }
.sec-head + .plan-row { border-top: 0; }
.pr-name { flex: 1; min-width: 0; }
.pr-tools { display: flex; flex: none; }

/* Practice runner */
/* Header + timer + controls stay pinned while the drill list scrolls underneath. */
.run-top { position: sticky; top: 0; z-index: 6; background: var(--bg); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.run-top header.top { position: static; }
.run.live .page { padding-bottom: 70vh; } /* room so even the last drill can scroll to the top */
.timer-card { background: var(--card); padding: 8px 16px 10px; text-align: center; transition: background .3s; }
.t-head { display: flex; align-items: baseline; justify-content: center; gap: 8px; flex-wrap: wrap; }
.t-cat { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.t-name { font-size: 20px; font-weight: 800; }
.t-clock { font-size: 60px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.t-clock.over { color: var(--bad); }
.t-sub { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.timer-card .t-drift { margin: 6px 0 8px; }
.timer-card .t-controls .btn { min-height: 46px; }
.timer-card .score-btn { margin-top: 8px; min-height: 40px; }
.run-row { scroll-margin-top: 300px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; background: var(--accent); transition: width .25s linear; }
.run.over .bar div { background: var(--bad); }
.t-drift { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin: 10px 0; flex-wrap: wrap; }
.t-drift .late { color: var(--bad); font-weight: 700; }
.t-drift .early { color: var(--good); font-weight: 700; }
.t-controls { display: grid; grid-template-columns: 1fr 1fr 1fr 2fr; gap: 8px; }
.t-controls .btn { padding: 0 6px; min-height: 52px; font-size: 16px; }
.score-btn { background: var(--good-soft); border-color: #bfe3cc; color: var(--good); }
.run.flash .timer-card { animation: flash .5s 3; }
@keyframes flash { 50% { background: #ffd8c2; } }
.run-row { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.run-row.cur { background: var(--accent-soft); }
.run-row.done { opacity: .6; }
.rr-main { flex: 1; min-width: 150px; }
.rr-name { font-weight: 600; }
.rr-meta { font-size: 13px; }
.rr-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* Attendance & scores */
.jersey { display: inline-block; min-width: 28px; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.att-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-row { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sr-top { display: flex; align-items: baseline; gap: 6px; }
.sr-entry { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.chips-inline { display: flex; gap: 4px; flex-wrap: wrap; min-height: 28px; align-items: center; }
.att-chip { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 3px 8px; font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer; }
.att-chip.pr { background: var(--good-soft); border-color: #bfe3cc; color: var(--good); font-weight: 700; }
.sr-input { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.sr-input .sq { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 20px; cursor: pointer; }
.sr-input input { width: 64px; height: 40px; text-align: center; border: 1px solid var(--line); border-radius: 10px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sr-input input.beats { border-color: var(--good); color: var(--good); }
.sr-input .btn { min-height: 40px; }

/* Stats */
.hist { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.spark { width: 100%; height: 40px; margin-top: 6px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.rank { display: inline-block; width: 22px; color: var(--muted); font-weight: 700; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); }
table.matrix { border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.matrix tbody th { text-align: left; position: sticky; left: 0; background: var(--card); }
.matrix thead th { vertical-align: bottom; height: 110px; }
.matrix thead th span { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 600; }
.matrix td.hot { background: var(--good-soft); color: var(--good); font-weight: 700; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { overflow-y: auto; padding: 12px 16px 20px; -webkit-overflow-scrolling: touch; }
.pick-group { margin-bottom: 12px; }
.pick-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 8px 4px; }
.pick-row { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); text-align: left; cursor: pointer; }
.pick-row:first-of-type { border-radius: 10px 10px 0 0; }
.pick-row:last-child { border-radius: 0 0 10px 10px; border-bottom: 0; }
.pick-row:active { background: var(--accent-soft); }

/* Sign-in */
.signin { max-width: 380px; margin: 0 auto; padding: 22vh 24px 0; text-align: center; }
.signin .logo { font-size: 56px; }
.signin h1 { font-size: 28px; margin: 8px 0; }
.signin .btn { margin-top: 24px; width: 100%; }

@media (min-width: 720px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 16px; }
}

/* Mini timer: pinned above the tab bar on every screen while a practice runs. */
.mini-timer {
  position: fixed; left: 0; right: 0; z-index: 11;
  bottom: calc(54px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  transition: background .3s;
}
.shell.full .mini-timer { bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
.mini-timer .bar { height: 4px; border-radius: 0; }
.mini-timer.over .bar div { background: var(--bad); }
.mini-timer.flash { animation: flash .5s 3; }
.mt-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 12px; max-width: 720px; margin: 0 auto; }
.mt-info { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); }
.mt-clock { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mt-clock.over { color: var(--bad); }
.mt-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-row .btn.sm { padding: 0 9px; min-height: 40px; }
.mt-score { display: block; text-align: center; font-size: 13px; font-weight: 600; color: var(--good); background: var(--good-soft); padding: 5px; }
.shell.has-mini { padding-bottom: calc(54px + 110px + env(safe-area-inset-bottom)); }
.shell.full.has-mini { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.hdr-right { display: inline-flex; align-items: center; gap: 2px; }
.opts .btn.wide { margin-top: 14px; justify-content: flex-start; }
.opts p { margin: 4px 2px 0; }
.modal-body { position: relative; }
.pick-search { position: sticky; top: -12px; z-index: 2; background: var(--bg); padding: 12px 0 0; margin-top: -12px; }
.pick-cat.focus { color: var(--accent); }
.pick-right { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.in-plan { font-size: 11px; font-weight: 700; color: var(--good); background: var(--good-soft); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.pick-row.used { background: #f7fbf8; }
.att-sum { margin: 0 2px 4px; color: var(--muted); }
.att-row.absent .grow { color: var(--muted); }
.abs-tag { display: inline-block; font-size: 12px; font-weight: 600; color: #8a5a00; background: #fff4d6; border-radius: 6px; padding: 1px 6px; margin-top: 2px; }
.abs-count { font-size: 13px; font-weight: 700; color: #8a5a00; white-space: nowrap; }

/* ---------- Larger screens: iPad and laptop ---------- */
.nav-brand, .wide-only { display: none; }
.sec-block { break-inside: avoid; }
.sec-flow > * { break-inside: avoid; -webkit-column-break-inside: avoid; }

/* iPad portrait and up: roomier content column */
@media (min-width: 700px) {
  .page { max-width: 820px; }
}

/* iPad landscape, laptops: sidebar navigation instead of bottom tabs */
@media (min-width: 900px) {
  .shell { padding-bottom: 0; padding-left: 220px; }
  .shell.full { padding-left: 0; }
  .shell.has-mini { padding-bottom: 96px; }
  .shell.full.has-mini { padding-bottom: 96px; }
  .demo-bar { position: sticky; top: 0; z-index: 7; }
  nav.tabs {
    top: 0; bottom: 0; right: auto; width: 220px; flex-direction: column; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line); padding: 16px 10px;
    background: #fafbfc;
  }
  .nav-brand { display: block; font-weight: 800; font-size: 17px; padding: 8px 12px 18px; }
  .nav-brand small { display: block; font-weight: 600; font-size: 12px; color: var(--muted); margin-top: 2px; }
  nav.tabs a { flex: none; flex-direction: row; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 15px; }
  nav.tabs a .ti { font-size: 18px; line-height: 22px; width: 22px; text-align: center; }
  nav.tabs a.on { background: var(--accent-soft); }
  nav.tabs a:hover { background: #f0f1f3; }
  .mini-timer { left: 220px; bottom: 0; }
  .shell.full .mini-timer { left: 0; }
  .mt-row { max-width: 900px; }
  .mt-clock { font-size: 28px; }
  .page.wide { max-width: 1240px; }
  .page.narrow { max-width: 520px; }

  /* Today: actions + upcoming on the left, schedule on the right */
  .today-grid { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; grid-template-areas: "a b" "c b"; column-gap: 24px; align-items: start; }
  .today-grid > .t-a { grid-area: a; }
  .today-grid > .t-b { grid-area: b; }
  .today-grid > .t-c { grid-area: c; }
  .wide-only { display: block; }
  .t-b > .section-title:first-child { margin-top: 4px; }

  /* Run practice: timer column on the left stays put, drill list scrolls on the right */
  .run.live { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; align-items: start; }
  .run.live .run-top { height: 100vh; overflow-y: auto; box-shadow: none; border-right: 1px solid var(--line); background: var(--card); }
  .run.live .timer-card { padding: 24px 20px; }
  .run.live .t-head { flex-direction: column; align-items: center; gap: 2px; }
  .run.live .t-name { font-size: 26px; }
  .run.live .t-clock { font-size: 104px; margin: 12px 0 4px; }
  .run.live .t-controls { grid-template-columns: 1fr 1fr 1fr; }
  .run.live .t-controls .btn.primary { grid-column: 1 / -1; min-height: 60px; font-size: 20px; }
  .run.live .page { max-width: 820px; width: 100%; }
}

/* Wide laptops: plan sections and drill library in two columns */
@media (min-width: 1150px) {
  .sec-flow { column-count: 2; column-gap: 16px; }
  .sec-flow > .card { display: inline-block; width: 100%; }
}
@media (min-width: 1500px) {
  .page.wide .sec-flow { column-count: 3; }
  .today-grid .sec-flow { column-count: 1; }
}
.invite-banner { background: var(--good-soft); border-bottom: 1px solid #bfe3cc; padding: 8px 16px; font-size: 14px; }
.invite-banner .row + .row { margin-top: 6px; }
.invite-row { flex-wrap: wrap; }
.row.gap0 { gap: 4px; }
.invite-msg { color: var(--good); font-weight: 600; }
