:root {
  color-scheme: light;
  --bg: #eef6f7;
  --card: #ffffff;
  --card-2: #f4fafb;
  --line: #dbe9ec;
  --text: #13262b;
  --muted: #5d7479;
  --brand: #0b8fa3;
  --brand-2: #10b5c9;
  --brand-ink: #ffffff;
  --brand-soft: #d7f1f5;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5200;
  --bad-bg: #fde4e4;
  --bad-ink: #a12525;
  --good-ink: #006c10;
  --shadow: 0 1px 2px rgb(16 50 58 / 6%), 0 6px 20px rgb(16 50 58 / 7%);
  --radius: 20px;
  /* People in the charts: the categorical slots, in order of joining. */
  --c0: #257de0; --c1: #f47230; --c2: #00b894; --c3: #f2a600;
  --c4: #ee7fac; --c5: #008a17; --c6: #6a4ce2; --c7: #ec4647;
  --seq: #257de0;
  --grid: #e3eef0;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1517;
    --card: #142124;
    --card-2: #1a2a2e;
    --line: #22363a;
    --text: #e6f1f3;
    --muted: #92a9ae;
    --brand: #22b8cc;
    --brand-2: #4fd3e3;
    --brand-ink: #05272d;
    --brand-soft: #123a41;
    --warn-bg: #3a2e0c;
    --warn-ink: #fbc94e;
    --bad-bg: #3d1717;
    --bad-ink: #ff9a9a;
    --good-ink: #4cd964;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --c0: #338ced; --c1: #e76624; --c2: #00a888; --c3: #d28e05;
    --c4: #e24d8b; --c5: #0aac23; --c6: #9887ef; --c7: #eb6263;
    --seq: #338ced;
    --grid: #22363a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 600; margin: 22px 4px 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad-ink); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ splash & login */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.splash img { width: 88px; height: 88px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; gap: 10px; }
.login-logo { width: 112px; height: 112px; border-radius: 30px; box-shadow: var(--shadow); }
.login h1 { font-size: 34px; margin-top: 10px; }
.login p { max-width: 300px; margin: 0 0 18px; }

/* ------------------------------------------------------------------ layout */
#app { max-width: 640px; margin: 0 auto; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 6px;
}
.dog { display: flex; align-items: center; gap: 12px; }
.dog h1 { font-size: 24px; font-weight: 700; }
.dog p { margin: 0; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff;
  display: grid; place-items: center; font-size: 28px; overflow: hidden;
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--brand-soft);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.live { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); opacity: .5; }
.live.on { background: #12b886; opacity: 1; box-shadow: 0 0 0 4px rgb(18 184 134 / 18%); }
main { padding: 0 14px; }
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 0; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabs a .ico { font-size: 21px; filter: grayscale(1) opacity(.65); transition: filter .15s; }
.tabs a.active { color: var(--brand); background: var(--brand-soft); }
.tabs a.active .ico { filter: none; }
.tabs .dot { position: absolute; top: 5px; inset-inline-end: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: #dc3c3d; box-shadow: 0 0 0 2px var(--card); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.status { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden;
}
.stat .lbl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
.stat .lbl .e { font-size: 18px; }
.stat .big { font-size: 26px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.warn { background: var(--warn-bg); }
.stat.warn .big, .stat.warn .lbl { color: var(--warn-ink); }
.stat .flag { position: absolute; top: 12px; inset-inline-end: 12px; font-size: 16px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.act {
  border: 0; border-radius: 22px; padding: 18px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 17px; font-weight: 600; color: var(--text);
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .15s;
}
.act .e { font-size: 34px; line-height: 1; }
.act:active { transform: scale(.96); }
.act.walk { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 12px; font-size: 20px; padding: 20px;
  background: linear-gradient(135deg, #14b4c8, #0a7d90); color: #fff; }
.act.walk .e { font-size: 32px; }
.minor { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.minor .act { flex-direction: row; justify-content: center; padding: 12px; font-size: 15px; gap: 8px; }
.minor .act .e { font-size: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.today-sum { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 4px 10px; }
.today-sum span { background: var(--card); border-radius: 999px; padding: 4px 10px; font-size: 14px; box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ lists */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--card-2); }
.item .e { font-size: 24px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--card-2); flex: none; }
.item .t { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.item .note { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { display: inline-flex; align-items: center; gap: 5px; }
.who i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.day-h { margin: 18px 6px 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty .e { font-size: 38px; display: block; margin-bottom: 6px; }

.banner { display: flex; align-items: center; gap: 12px; border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; background: var(--warn-bg); color: var(--warn-ink); }
.banner.bad { background: var(--bad-bg); color: var(--bad-ink); }
.banner .e { font-size: 24px; }
.banner b { display: block; }

/* ------------------------------------------------------------------ buttons & forms */
.btn {
  border: 0; border-radius: 14px; padding: 10px 16px; cursor: pointer; font-weight: 600; font-size: 15px;
  background: var(--card-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad-bg); color: var(--bad-ink); }
.btn.big { padding: 14px 22px; font-size: 17px; border-radius: 16px; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.login .btn.primary { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

label.f { display: block; margin-top: 14px; }
label.f > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=time], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--card-2); border-radius: 14px; padding: 11px 12px; font-size: 16px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 70px; }
.seg { display: inline-flex; background: var(--card-2); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 11px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.switch { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: inset-inline-start .15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { inset-inline-start: 21px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick {
  border: 2px solid var(--line); background: var(--card); border-radius: 18px; padding: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 16px;
}
.pick .e { font-size: 26px; }
.pick.on { border-color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------------ sheet, toast, tooltip */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(5 20 24 / 45%); animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto;
  background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet .grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.sheet .foot { display: flex; gap: 10px; margin-top: 20px; }
.sheet .foot .btn { flex: 1; }

.toast {
  position: fixed; inset-inline: 14px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 45;
  max-width: 600px; margin: 0 auto; background: #13262b; color: #fff; border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgb(0 0 0 / 25%); animation: up .2s;
}
.toast .grow { font-weight: 500; }
.toast button { background: none; border: 0; color: #7fe3f0; font-weight: 700; cursor: pointer; padding: 4px 6px; }
@media (prefers-color-scheme: dark) { .toast { background: #e6f1f3; color: #0b1517; } .toast button { color: #0b7d8f; } }

.tip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--text); color: var(--bg);
  padding: 7px 10px; border-radius: 10px; font-size: 13px; line-height: 1.35; box-shadow: var(--shadow); max-width: 220px;
}

/* ------------------------------------------------------------------ stats */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.tile .v { font-size: 26px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.tile .k { font-size: 13px; color: var(--muted); }
.chart-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 12px 10px; margin-top: 12px; }
.chart-card h3 { font-size: 16px; font-weight: 600; margin: 0 4px 2px; }
.chart-card .sub { font-size: 13px; color: var(--muted); margin: 0 4px 10px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 4px 2px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars-h .bar-row { display: grid; grid-template-columns: 82px 1fr 34px; align-items: center; gap: 8px; margin: 8px 4px; font-size: 14px; }
.bars-h .track { height: 14px; border-radius: 4px; background: var(--card-2); overflow: hidden; }
.bars-h .fill { height: 100%; border-radius: 4px; }
.bars-h .num { font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }
.bars-h .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.badge { font-size: 12px; background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-row .avatar { width: 72px; height: 72px; font-size: 38px; }
.section-note { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
