:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #141816;
  --ink-2: #545c57;
  --ink-3: #89918c;
  --line: #e3e6e2;
  --line-2: #d2d7d2;
  --teal: #0f766e;
  --teal-2: #14b8a6;
  --teal-soft: #e6f4f1;
  --teal-ink: #ffffff;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(20, 24, 22, .05), 0 1px 3px rgba(20, 24, 22, .04);
  --shadow-2: 0 14px 34px -14px rgba(15, 118, 110, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1211;
    --surface: #171b1a;
    --ink: #eef2f0;
    --ink-2: #aab3ae;
    --ink-3: #7a8480;
    --line: #242a28;
    --line-2: #323a37;
    --teal: #2dd4bf;
    --teal-2: #5eead4;
    --teal-soft: #11302c;
    --teal-ink: #062421;
    --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* bottom padding keeps Friday clear of the host badge */
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 96px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(150deg, var(--teal-2), var(--teal)); color: #fff; box-shadow: var(--shadow-2);
}
.mark svg { width: 22px; height: 22px; stroke-width: 2.1; }
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.15; }
.sub { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.sub .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.sub.live .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.sub.err .dot { background: var(--danger); }
.me { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.me .who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.me strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--ink); }

/* ---------- name card ---------- */
.name-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line)); border-radius: 18px;
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.name-card h2 { margin: 0 0 2px; font-size: 16px; letter-spacing: -.01em; }
.name-card p { margin: 0; color: var(--ink-2); font-size: 13.5px; max-width: 460px; }
.name-row { display: flex; gap: 8px; flex: 1; min-width: 260px; max-width: 420px; }
.name-row input {
  flex: 1; min-width: 0; height: 42px; border: 1px solid var(--line-2); border-radius: 11px; padding: 0 14px; background: var(--bg); outline: none;
}
.name-row input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent); background: var(--surface); }
.btn {
  height: 42px; padding: 0 18px; border-radius: 11px; border: 0; background: var(--teal); color: var(--teal-ink);
  font-weight: 650; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }

/* ---------- week bar ---------- */
.weekbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.nav {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); box-shadow: var(--shadow);
}
.nav:hover { color: var(--ink); border-color: var(--ink-3); }
.week-label { display: flex; flex-direction: column; min-width: 130px; padding: 0 4px; }
.week-label .rel { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.week-label strong { font-size: 18px; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.today {
  margin-left: auto; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.today:hover { color: var(--ink); }

/* ---------- days grid ---------- */
.days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 340px; overflow: hidden;
}
.day-head { padding: 14px 16px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
.day-name { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.day-date { font-size: 15px; font-weight: 650; margin-top: 1px; }
.count { text-align: right; line-height: 1; }
.count b { display: block; font-size: 30px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.count span { font-size: 11.5px; color: var(--ink-3); }
.meter { height: 3px; background: var(--line); }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-2), var(--teal)); transition: width .35s ease; }
.people { list-style: none; margin: 0; padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.person { display: flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: 9px; font-size: 14px; min-width: 0; }
.person .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person.mine { background: var(--teal-soft); font-weight: 600; }
.person.mine .you { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; }
.av {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 10.5px; font-weight: 700; color: #fff;
}
.nobody { color: var(--ink-3); font-size: 13.5px; padding: 8px 6px; }

.tick {
  margin: 8px 10px 10px; height: 44px; border-radius: 12px; border: 1.5px dashed var(--line-2); background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 14px; color: var(--ink-2);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.tick:hover { border-color: var(--teal); color: var(--teal); }
.tick:active { transform: scale(.98); }
.tick .box {
  width: 20px; height: 20px; border-radius: 6px; border: 1.8px solid currentColor; display: grid; place-items: center;
}
.tick .box svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.tick[aria-pressed="true"] { background: var(--teal); border: 1.5px solid var(--teal); color: var(--teal-ink); }
.tick[aria-pressed="true"] .box { background: var(--teal-ink); border-color: var(--teal-ink); color: var(--teal); }
.tick[aria-pressed="true"] .box svg { opacity: 1; }
.tick[disabled] { opacity: .5; cursor: not-allowed; }

.summary { margin: 18px 2px 0; color: var(--ink-3); font-size: 13.5px; }

.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 11px; font-size: 13.5px; box-shadow: var(--shadow-2); }
.toast a { color: inherit; font-weight: 700; }

/* ---------- tablets: 5 columns get tight ---------- */
@media (max-width: 980px) {
  .days { grid-template-columns: 1fr; gap: 10px; }
  .day { min-height: 0; display: grid; grid-template-columns: 150px 1fr auto; align-items: center; }
  .day-head { border-bottom: 0; border-right: 1px solid var(--line); height: 100%; align-items: center; }
  .meter { display: none; }
  .people { flex-direction: row; flex-wrap: wrap; padding: 10px 12px; gap: 6px; }
  .person { padding: 3px 10px 3px 3px; background: var(--bg); border-radius: 999px; font-size: 13.5px; }
  .person.mine .you { display: none; }
  .tick { margin: 10px 12px; padding: 0 14px; }
}
/* ---------- phones ---------- */
@media (max-width: 620px) {
  .wrap { padding: 18px 16px 96px; }
  .top { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  h1 { font-size: 20px; }
  .name-card { padding: 16px; }
  .name-row { min-width: 0; max-width: none; width: 100%; }
  .week-label { min-width: 0; flex: 1; text-align: center; }
  .week-label strong { font-size: 16px; }
  .weekbar .today { margin: 0 auto; order: 5; }
  .day { grid-template-columns: 1fr auto; grid-template-areas: "head tick" "people people"; }
  .day-head { grid-area: head; border-right: 0; padding: 12px 14px 4px; justify-content: flex-start; gap: 12px; align-items: baseline; }
  .count { display: flex; align-items: baseline; gap: 4px; text-align: left; }
  .count b { font-size: 18px; display: inline; }
  .tick { grid-area: tick; margin: 10px 10px 4px; height: 38px; font-size: 13px; padding: 0 12px; }
  .tick .lbl-long { display: none; }
  .people { grid-area: people; padding: 6px 12px 12px; }
  .day-name { font-size: 11px; }
  .day-head > div:first-child { display: flex; gap: 6px; align-items: baseline; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
