/* ---------- Font (self-hosted Inter, OFL: see /fonts/OFL.txt) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/inter-400.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/inter-500.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/inter-600.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/inter-700.woff2) format("woff2"); }

/* ---------- Tokens ---------- */
:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text2: #8E8E93;
  --sep: rgba(60, 60, 67, 0.12);
  --fill: #E5E5EA;
  --pill: #F2F2F7;
  --accent: #007AFF;
  --accent-ink: #FFFFFF;
  --green: #34C759;
  --amber: #FF9500;
  --red: #FF3B30;
  --bar: rgba(255, 255, 255, 0.72);
  --drawer: #FFFFFF;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --r: 16px;
  --gutter: 20px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1C1C1E; --text: #FFFFFF; --text2: #8E8E93;
    --sep: rgba(84, 84, 88, 0.6); --fill: #2C2C2E; --pill: #2C2C2E;
    --accent: #0A84FF; --green: #30D158; --amber: #FF9F0A; --red: #FF453A;
    --bar: rgba(22, 22, 24, 0.72); --drawer: #1C1C1E; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1C1C1E; --text: #FFFFFF; --text2: #8E8E93;
  --sep: rgba(84, 84, 88, 0.6); --fill: #2C2C2E; --pill: #2C2C2E;
  --accent: #0A84FF; --green: #30D158; --amber: #FF9F0A; --red: #FF453A;
  --bar: rgba(22, 22, 24, 0.72); --drawer: #1C1C1E; --shadow: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 17px/1.35 "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.2px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body.locked { overflow: hidden; }
main {
  max-width: 600px; margin: 0 auto;
  padding: 8px max(var(--gutter), env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.4px; margin: 4px 0 24px; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin: 32px 0 12px; }
h3 { font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text2); margin: 0 0 8px 16px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
b { font-weight: 600; }
.muted, small { color: var(--text2); font-size: 15px; }
.tiny { font-size: 13px; color: var(--text2); }
hr { border: 0; border-top: 0.5px solid var(--sep); margin: 8px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-size: 17px; margin: -8px 0 0 -4px; padding: 0 4px; }
.foot { margin: 40px 8px 8px; text-align: center; font-size: 13px; line-height: 1.4; color: var(--text2); opacity: 0.8; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(52px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right));
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid transparent; transition: border-color 200ms;
}
.topbar.scrolled { border-bottom-color: var(--sep); }
.tb-title {
  text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateY(4px); transition: opacity 200ms, transform 200ms;
}
.topbar.titled .tb-title { opacity: 1; transform: none; }
.menu-btn, .tb-back {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--accent); border-radius: 12px; cursor: pointer; padding: 0;
}
.tb-back { font-size: 34px; font-weight: 300; line-height: 1; padding-bottom: 4px; }
.menu-btn:active, .tb-back:active { background: var(--fill); }

/* ---------- Drawer ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 280ms var(--ease);
}
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  width: 80%; max-width: 320px; background: var(--drawer);
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(24px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
  transform: translateX(-100%); transition: transform 280ms var(--ease);
  outline: none;
}
html.drawer-open .scrim { opacity: 1; }
.drawer[hidden], .scrim[hidden] { display: none; }
html.drawer-open .drawer { transform: none; }
.drawer.dragging, .scrim.dragging { transition: none; }
.dhead { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px 20px; }
.dhead .av { margin-bottom: 10px; }
.dhead b { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.dhead small { font-size: 15px; }
.dnav { display: flex; flex-direction: column; gap: 2px; }
.dfoot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 16px; }
.dfoot hr { margin: 0 12px 8px; }
.drow {
  display: flex; align-items: center; gap: 14px; height: 48px; padding: 0 12px; border-radius: 12px;
  color: var(--text); font-size: 17px;
}
.drow .ic { color: var(--text2); flex: none; }
.drow:active { background: var(--pill); }
.drow.on { background: var(--pill); color: var(--accent); font-weight: 500; }
.drow.on .ic { color: var(--accent); }

/* ---------- Cards & grouped lists ---------- */
.group { margin: 0 0 28px; }
.list, .hero, .card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 11px 16px; position: relative; color: var(--text); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
a.row { transition: background 120ms; }
a.row:active { background: var(--fill); }
.row .grow { flex: 1; min-width: 0; }
.row .grow > * { display: block; overflow: hidden; text-overflow: ellipsis; }
.row .grow small { margin-top: 1px; }
.chev { color: var(--text2); opacity: 0.6; font-size: 22px; line-height: 1; }
.gfoot { font-size: 13px; color: var(--text2); margin: 8px 16px 0; line-height: 1.4; }
.empty { padding: 16px; color: var(--text2); font-size: 15px; margin: 0; }
.hero { padding: 20px; margin-bottom: 28px; }
.hero .who { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.hero .who b { font-size: 20px; display: block; letter-spacing: -0.3px; }
.stack > * + * { margin-top: 12px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--text2); margin: 0 0 4px; }
.field { padding: 12px 16px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: transparent; border: 0; padding: 2px 0; min-height: 28px; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text2); opacity: 0.7; }
textarea { resize: vertical; min-height: 72px; line-height: 1.4; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--text); font-size: 17px; margin: 0; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; flex: none; }
.err { color: var(--red); font-size: 15px; margin: 0 4px 12px; }
.flash { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 16px; margin: 0 0 20px; font-size: 15px; display: flex; gap: 10px; align-items: center; }
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--card); color: var(--accent); font: inherit; font-size: 17px; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow); text-align: center;
  transition: transform 120ms var(--ease), opacity 120ms; -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.98); opacity: 0.8; }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: none; }
.btn.block { display: flex; width: 100%; min-height: 50px; border-radius: 14px; }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 36px; min-width: 36px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- Avatar, badges, pills ---------- */
.av { border-radius: 50%; object-fit: cover; background: var(--fill); color: var(--text2); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none; letter-spacing: 0; }
.badge { display: inline-block; font-size: 13px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--fill); color: var(--text2); margin-top: 4px; }
.status { font-size: 15px; font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: color-mix(in srgb, var(--green) 15%, transparent); }
.pill.warn { background: color-mix(in srgb, var(--amber) 16%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--red) 14%, transparent); }
.ok { color: var(--green); } .warn { color: var(--amber); } .bad { color: var(--red); }

/* ---------- Home ---------- */
.dateline { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text2); margin: 8px 0 2px; }
.next { padding: 20px; }
.next .when { font-size: 28px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.15; margin: 16px 0 10px; }
.next .who { display: flex; gap: 12px; align-items: center; color: var(--text); }
.next .who b { display: block; font-size: 17px; }
.next .actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.emptystate { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 20px 16px; gap: 2px; }
.emptystate .ic { color: var(--text2); opacity: 0.7; margin-bottom: 8px; }
.emptystate b { font-size: 17px; }
.emptystate a { font-size: 17px; min-height: 44px; display: inline-flex; align-items: center; }
.week { display: flex; align-items: center; gap: 16px; padding: 16px; }
.week .num { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; display: block; }
.ring { flex: none; display: block; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.tile small { display: block; font-size: 13px; font-weight: 500; }
.tile b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.feltline { font-size: 13px; color: var(--text2); margin: 10px 16px 0; }
.quiet { color: var(--text2); font-size: 15px; margin: 0 16px; }
.group.cta { margin-top: 8px; }

/* ---------- Members ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { padding: 20px 12px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; color: var(--text); transition: transform 120ms var(--ease); }
.card:active { transform: scale(0.98); }
.card .name { font-weight: 600; margin-top: 8px; }
.card small { font-size: 13px; }

/* Segmented control */
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; gap: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg a, .segopt {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--text); font-size: 15px; font-weight: 500; white-space: nowrap; margin: 0; cursor: pointer; position: relative;
}
.seg a.on, .segopt.on, .segopt:has(input:checked) { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
:root[data-theme="dark"] .seg a.on, :root[data-theme="dark"] .segopt.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg a.on, :root:not([data-theme="light"]) .segopt.on, :root:not([data-theme="light"]) .segopt:has(input:checked) { background: #636366; } }
.segopt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segopt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Calendar ---------- */
.weeknav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.weeknav .btn.sm { min-width: 44px; min-height: 44px; font-size: 20px; }
.days { display: flex; gap: 8px; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) 20px; padding: 2px var(--gutter); scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days a {
  flex: none; width: 48px; height: 64px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text2); background: var(--card); box-shadow: var(--shadow); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.2px;
}
.days a b { font-size: 20px; color: var(--text); text-transform: none; letter-spacing: -0.3px; }
.days a.on { background: var(--accent); color: rgba(255, 255, 255, 0.85); }
.days a.on b { color: #fff; }
.days a.closed { opacity: 0.5; }
.days a.on.closed { opacity: 0.85; }
.slot { min-height: 64px; }
.slot .time { width: 68px; font-weight: 600; flex: none; font-variant-numeric: tabular-nums; }
.avs { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.avs a { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.toggle { position: relative; width: 51px; height: 31px; flex: none; display: block; margin: 0; }
.toggle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--fill); border-radius: 999px; transition: background 200ms; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 250ms var(--ease); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(20px); }

/* ---------- Quiz ---------- */
.quiz fieldset { border: 0; margin: 0 0 28px; padding: 0; min-width: 0; }
.quiz legend { font-weight: 600; margin: 0 0 10px; padding: 0 4px; font-size: 17px; line-height: 1.35; }
.quiz .opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; color: var(--text); margin: 0; font-size: 17px; position: relative; }
.quiz .opt + .opt::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }

/* ---------- Scorecard ---------- */
.sc { width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text2); }
.sc.win { color: var(--text); font-weight: 700; }
.stepcol { width: 124px; text-align: center; flex: none; }
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper .btn.sm { min-width: 36px; min-height: 44px; padding: 0; font-size: 20px; background: var(--fill); box-shadow: none; color: var(--text); }
.stepper input { width: 40px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row.game.off { display: none; }
.felt .segopt { color: var(--text2); }
@media (max-width: 370px) { .stepcol { width: 108px; } .stepper .btn.sm { min-width: 32px; } .stepper input { width: 34px; } }

/* ---------- Log filters ---------- */
.filters { display: flex; gap: 8px; margin: 0 0 20px; flex-wrap: wrap; }
.filters select { flex: 1; min-width: 100px; min-height: 40px; background: var(--card); box-shadow: var(--shadow); border-radius: 10px; padding: 0 10px; font-size: 15px; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  main { animation: rise 260ms var(--ease) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
/* Reduced motion: drawer fades in place instead of sliding. */
@media (prefers-reduced-motion: reduce) {
  .tb-title { transform: none !important; }
  .drawer { transform: none; opacity: 0; transition: opacity 200ms linear; }
  html.drawer-open .drawer { opacity: 1; }
  .btn:active, .card:active { transform: none; }
}
