/* Padelchecker: mobile-first, app-like. Light and dark follow the phone. */
:root {
  --bg: #f1f4f2;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --text: #14201a;
  --muted: #64716b;
  --line: #e2e8e4;
  --accent: #0d7f57;
  --accent-ink: #ffffff;
  --accent-soft: #dff2e8;
  --ball: #d6ee3f;
  --warn: #8a5a00;
  --warn-soft: #fff1cf;
  --bad: #b3261e;
  --bad-soft: #fde4e1;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 4px 16px rgba(16, 32, 24, .06);
  --radius: 18px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b100e;
    --surface: #151c19;
    --surface-2: #1c2521;
    --text: #e7eeea;
    --muted: #93a29b;
    --line: #25302b;
    --accent: #3cc98f;
    --accent-ink: #062014;
    --accent-soft: #163628;
    --warn: #f3cf7a;
    --warn-soft: #3a2e10;
    --bad: #ffaba4;
    --bad-soft: #43201d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* --- app bar ------------------------------------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.appbar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.appbar h1 { font-size: 1.75rem; line-height: 1.1; letter-spacing: -.02em; margin: 0; margin-right: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; background: var(--surface); box-shadow: var(--shadow);
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pill.warn .dot { background: #e0a100; box-shadow: 0 0 0 3px var(--warn-soft); }
.pill.bad { color: var(--bad); }
.pill.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

main {
  max-width: 640px; margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px);
}
main.bare { padding-bottom: 40px; }

/* --- tab bar ------------------------------------------------------------------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar nav { max-width: 640px; margin: 0 auto; display: flex; height: var(--tabbar); }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent); }

/* --- floating action button ---------------------------------------------------- */
.fab {
  position: fixed; z-index: 15; right: max(16px, calc(50vw - 304px));
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px);
  display: inline-flex; align-items: center; gap: 8px; height: 56px; padding: 0 22px 0 18px;
  border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 700; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  cursor: pointer;
}
.fab:active { transform: scale(.97); }

/* --- cards & lists --------------------------------------------------------------- */
.section-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 26px 4px 8px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; }
.list > .item + .item { border-top: 1px solid var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .sub { color: var(--muted); font-size: .85rem; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }

.watch.is-paused { opacity: .62; }
.watch-top { display: flex; align-items: flex-start; gap: 12px; }
.watch-time { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.watch-meta { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.watch-meta strong { color: var(--text); font-weight: 650; }
.days { display: flex; gap: 5px; }
.days span {
  width: 29px; height: 29px; border-radius: 50%; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--surface-2);
}
.days span.on { background: var(--accent-soft); color: var(--accent); }
.date-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; }
.upcoming { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
  background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--muted); }
.chip.paused { background: var(--warn-soft); color: var(--warn); }
.chip button { all: unset; cursor: pointer; text-decoration: underline; font-weight: 700; }
.watch-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.watch-foot .icon-btn { margin-right: -8px; }
.tag { margin-left: 6px; vertical-align: 1px; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }

.empty { text-align: center; padding: 48px 24px 24px; }
.empty img { width: 76px; height: 76px; border-radius: 22px; box-shadow: var(--shadow); margin-bottom: 14px; }
.empty h2 { margin: 0 0 6px; font-size: 1.2rem; }

/* --- controls --------------------------------------------------------------------- */
button, .btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 14px; padding: 12px 16px; min-height: 48px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:active, .btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px; min-height: 40px; border-radius: 12px; }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.icon-btn { background: transparent; color: var(--muted); padding: 8px; min-height: 40px; width: 40px; border-radius: 12px; }
.icon-btn:hover { background: var(--surface-2); }

label.field { display: block; font-weight: 650; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select {
  font: inherit; color: inherit; width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px; outline: none;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { border-color: var(--accent); background: var(--surface); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* segmented control from radio buttons */
.segmented { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 9px 6px; border-radius: 10px; font-weight: 650;
  font-size: .9rem; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* day picker from checkboxes */
.daypick { display: flex; justify-content: space-between; gap: 6px; }
.daypick label { flex: 1; }
.daypick input { position: absolute; opacity: 0; pointer-events: none; }
.daypick span { display: grid; place-items: center; aspect-ratio: 1; max-width: 46px; margin: 0 auto; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-weight: 750; font-size: .9rem; cursor: pointer;
  transition: background .15s, color .15s; }
.daypick input:checked + span { background: var(--accent); color: var(--accent-ink); }
.daypick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.presets { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.presets button { min-height: 34px; padding: 6px 12px; border-radius: 99px; font-size: .82rem;
  background: var(--surface-2); color: var(--text); font-weight: 600; }

/* switch from a checkbox */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- bottom sheet ------------------------------------------------------------------- */
dialog.sheet {
  width: 100%; max-width: 640px; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--surface); color: var(--text);
  max-height: 92vh; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
}
dialog.sheet[open] { animation: up .25s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgba(5, 12, 8, .45); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-body:focus { outline: none; }
.sheet-body { padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; max-height: 92vh; }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }

/* --- banners & toast ------------------------------------------------------------------ */
.banner { border-radius: 14px; padding: 12px 14px; margin: 12px 0; font-size: .92rem; font-weight: 550; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--accent-soft); color: var(--accent); }
.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 86px);
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: .9rem; font-weight: 600; box-shadow: var(--shadow);
  animation: toast 4.5s ease forwards; pointer-events: none;
}
main.bare ~ .toast, .toast.low { bottom: calc(env(safe-area-inset-bottom) + 20px); }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 6%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); } }

/* --- misc ------------------------------------------------------------------------------- */
.qr { background: #fff; border-radius: 14px; padding: 8px; display: inline-block; line-height: 0; }
.qr svg { width: 168px; height: 168px; }
code.topic { display: block; word-break: break-all; font-size: .88rem; background: var(--surface-2);
  padding: 10px 12px; border-radius: 12px; margin: 6px 0 12px; }
.stack > * + * { margin-top: 10px; }
.center { text-align: center; }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px 60px; }
.login .logo { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: var(--shadow); }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 1.7rem; letter-spacing: -.02em; }
details.more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-weight: 650; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "›"; font-size: 1.4rem; color: var(--muted); transition: transform .2s; }
details.more[open] > summary::after { transform: rotate(90deg); }
table.plain { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.plain td { padding: 8px 4px; border-top: 1px solid var(--line); }
table.plain tr:first-child td { border-top: 0; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
