:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --line: #2a3441;
  --text: #e6edf3;
  --dim: #8b98a8;
  --accent: #2f81f7;
  --green: #2ea043;
  --amber: #d29922;
  --red: #da3633;
  --purple: #8957e5;
  --radius: 12px;
  /* iOS home-screen (standalone) paints under the status bar and the Dynamic
     Island. Expose the insets as variables so layout can offset by them and so
     a test can simulate a 59px island on a machine that reports 0. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
/* Home-screen mode gets a floor as well as the inset: if a device under-reports
   env(safe-area-inset-top), the tab bar must still clear a status bar/island. */
@media (display-mode: standalone) {
  :root {
    --safe-top: max(env(safe-area-inset-top, 0px), 47px);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
  max-width: 760px;
  margin: 0 auto;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
p.sub { color: var(--dim); font-size: 14px; margin: 0 0 16px; }
a { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

/* QR needs a light quiet zone — a dark-mode QR often fails to scan. */
.qrbox { background: #fff; padding: 12px; border-radius: 12px; display: block; width: max-content; margin: 4px auto 0; line-height: 0; }
.qrbox img { width: 186px; height: 186px; display: block; }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); padding: 14px 16px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; width: 100%; transition: filter .12s;
}
button:active { filter: brightness(1.3); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.green { background: var(--green); border-color: var(--green); color: #fff; }
button.red { background: var(--red); border-color: var(--red); color: #fff; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

input, select {
  font: inherit; width: 100%; padding: 13px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); min-height: 48px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--dim); margin: 0 0 6px; font-weight: 600; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.pill.present { background: rgba(46,160,67,.18); color: #56d364; }
.pill.late { background: rgba(210,153,34,.18); color: #e3b341; }
.pill.absent { background: rgba(218,54,51,.16); color: #f85149; }
.pill.excused { background: rgba(137,87,229,.18); color: #a371f7; }

.err { color: #f85149; font-size: 14px; min-height: 20px; margin-top: 8px; }

/* ---- big code display ---- */
.code-display {
  font: 700 76px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 10px; text-align: center; padding: 18px 0 4px; color: #fff;
  text-indent: 10px;
}
.timer { text-align: center; font-size: 15px; color: var(--dim); margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.timer.warn { color: #e3b341; }
.timer.dead { color: #f85149; }
.bar { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; margin: 10px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--green); transition: width .25s linear; }
.bar.warn > i { background: var(--amber); }

/* ---- report grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.tile {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 9px;
  padding: 9px 8px; font-size: 14px; font-weight: 600; text-align: left;
  cursor: pointer; min-height: 58px; display: flex; flex-direction: column; justify-content: center;
  align-items: stretch; line-height: 1.2; width: 100%; overflow: hidden;
}
/* min-width:0 is load-bearing: without it the flex item refuses to shrink below
   its text width and the name hard-clips instead of wrapping or ellipsing. */
.tile .nm {
  display: block; min-width: 0; width: 100%; text-align: left;
  overflow-wrap: anywhere;
}
.tile .mt { font-size: 11px; font-weight: 700; opacity: .85; margin-top: 2px; letter-spacing: .02em; }
.tile.present { background: rgba(46,160,67,.22); border-color: var(--green); }
.tile.late { background: rgba(210,153,34,.22); border-color: var(--amber); }
.tile.absent { background: rgba(218,54,51,.14); border-color: rgba(218,54,51,.5); }
.tile.excused { background: rgba(137,87,229,.2); border-color: var(--purple); }
.tile .out { font-size: 10px; color: #e3b341; font-weight: 700; }
/* Faces: a small avatar inline with every name, plus a photo wall for learning
   names before practice. Photos are coach-session-only fetches. */
.av {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: block;
  background: var(--panel-2); border: 1px solid var(--line); flex: 0 0 auto;
}
.av.sm { width: 26px; height: 26px; }
/* In a 112px tile an inline avatar steals the width the name needs, and
   "Lindqvist" wraps with the comma stranded on line two. Stack it instead. */
.av.tileav { width: 32px; height: 32px; margin: 0 0 6px; }
.avo { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: var(--panel); border: 1px dashed var(--line); display: flex;
  align-items: center; justify-content: center; font-size: 11px; color: var(--dim); }
.tile .top { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.feed .who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.facegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.facegrid figure { margin: 0; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; }
.facegrid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.facegrid figcaption { padding: 6px 7px; font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }

.counter { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.counter b { font-size: 38px; line-height: 1; font-variant-numeric: tabular-nums; }
.counter span { color: var(--dim); font-size: 15px; }

.feed { max-height: 190px; overflow-y: auto; font-size: 14px; }
.feed div { padding: 5px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.feed div:last-child { border-bottom: 0; }
.feed .t { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---- sheet ---- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: flex-end; z-index: 50; }
.sheet-wrap.on { display: flex; }
.sheet { background: var(--panel); width: 100%; max-width: 760px; margin: 0 auto; border-radius: 16px 16px 0 0; padding: 18px; padding-bottom: calc(18px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.sheet h3 { margin: 0 0 14px; font-size: 17px; }
.sheet .row { margin-bottom: 9px; }

.hint { font-size: 13px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.center { text-align: center; }
.tiny { font-size: 12px; color: var(--dim); }
