@font-face {
  font-family: "Noto Sans";
  src: url("/fonts/notosans.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #efe6d8;
  --surface: #f8f1e6;
  --surface-2: #e6dac7;
  --line: #d8c8b1;
  --line-strong: #c4b096;
  --ink: #3b2c22;
  --ink-2: #806a58;
  --accent: #b5532e;
  --accent-ink: #fbf3e8;
  --accent-soft: #ecd3c0;
  --ok: #5e7349;
  --late: #a3392a;
  --toast: #3b2c22;
  --toast-ink: #f3e9da;
  --scrim: rgba(59, 44, 34, 0.32);
  --radius: 12px;
  --tabbar: 64px;
  --body: "Noto Sans", system-ui, sans-serif;
  --head: "Montserrat", "Noto Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2a211b;
    --surface: #352a22;
    --surface-2: #43352b;
    --line: #4c3d32;
    --line-strong: #65513f;
    --ink: #f0e4d3;
    --ink-2: #b8a28c;
    --accent: #dc7d55;
    --accent-ink: #2a211b;
    --accent-soft: #5a3a2a;
    --ok: #9cb27f;
    --late: #e5826b;
    --toast: #f0e4d3;
    --toast-ink: #2a211b;
    --scrim: rgba(20, 14, 10, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }

h1, h2 {
  font-family: var(--head);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 26px; }
h2 { font-size: 19px; margin: 28px 4px 10px; }
h2:first-child { margin-top: 8px; }
h2.late { color: var(--late); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px);
}

.list { display: grid; gap: 8px; }

.card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  transition: opacity 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.card:active { background: var(--surface-2); }
.card.late { border-color: color-mix(in srgb, var(--late) 55%, var(--line)); }
.card.soon { background: transparent; }
.card.leaving { opacity: 0; transform: translateX(24px); }
.card .body { min-width: 0; }
.card .name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.card .meta .late { color: var(--late); }
.card .side { font-size: 14px; color: var(--ink-2); }
.card .side.late { color: var(--late); }

.pts {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  font: 600 17px/1 var(--head);
  font-variant-numeric: tabular-nums;
}

.check {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.card.leaving .check, .card:active .check { border-color: var(--ok); }
.card.leaving .check { background: var(--ok); color: var(--surface); }

.avatar {
  flex: none;
  border-radius: 999px;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: #f8f1e6;
  font-family: var(--head);
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
  user-select: none;
}

.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--ink-2);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  margin-bottom: 8px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 500;
  white-space: nowrap;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:active { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn.danger { color: var(--late); border-color: transparent; background: transparent; padding: 0 10px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }

.fab {
  position: fixed;
  right: max(16px, calc(50vw - 264px));
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  z-index: 5;
}
.fab:active { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  margin-bottom: 12px;
}

nav.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs .inner { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 560px; }
nav.tabs a {
  height: var(--tabbar);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  position: relative;
}
nav.tabs a.on { color: var(--accent); }
nav.tabs .count {
  position: absolute;
  top: 8px;
  left: calc(50% + 8px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 11px/18px var(--body);
  text-align: center;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border-radius: 10px;
}
.seg button {
  min-height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--ink-2); padding-left: 2px; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); }
input[type="date"].input { appearance: none; -webkit-appearance: none; display: flex; align-items: center; }

.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

.stepper {
  display: inline-grid;
  justify-self: start;
  grid-template-columns: 44px 48px 44px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  height: 48px;
}
.stepper button { height: 100%; border: none; background: transparent; font-size: 20px; color: var(--ink-2); }
.stepper button:active { color: var(--ink); }
.stepper span { text-align: center; font: 600 17px/1 var(--head); font-variant-numeric: tabular-nums; }

.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 15px;
}
.person.on { border-color: var(--accent); background: var(--accent-soft); }
.person.away { opacity: 0.55; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 160ms ease;
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise 180ms ease;
}
.sheet .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-bottom: 8px;
}
.sheet .head h1 { font-size: 21px; }
.sheet .actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 24px; }
.sheet .actions .btn.primary { flex: 1; max-width: 220px; margin-left: auto; }
.icon-btn {
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  border-radius: 999px;
}
.icon-btn:active { background: var(--surface-2); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px);
  z-index: 30;
  max-width: 528px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 6px 6px 16px;
  border-radius: var(--radius);
  background: var(--toast);
  color: var(--toast-ink);
  animation: rise 160ms ease;
}
.toast.bare { bottom: calc(env(safe-area-inset-bottom) + 16px); }
.toast span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  min-height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-soft);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) { .toast button { color: var(--accent); } }

.rank { display: grid; gap: 8px; margin-top: 16px; }
.rank .card { grid-template-columns: 22px 40px 1fr auto; min-height: 68px; }
.rank .pos { color: var(--ink-2); font-size: 14px; text-align: center; }
.rank .total { font: 600 22px/1 var(--head); font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 2px; }

.chart {
  margin-top: 8px;
  padding: 12px 8px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chart svg { display: block; width: 100%; height: 160px; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--ink-2); font-size: 11px; font-family: var(--body); }

.hist .card { grid-template-columns: 1fr auto 44px; min-height: 56px; padding-right: 4px; }
.hist .plus { font-weight: 600; font-variant-numeric: tabular-nums; }

.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.group.group > * + * { border-top: 1px solid var(--line); }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  text-align: left;
  text-decoration: none;
  color: inherit;
}
button.item:active, a.item:active { background: var(--surface-2); }
.item .grow { min-width: 0; }
.item .sub { font-size: 13px; color: var(--ink-2); }
.item.danger { color: var(--late); }
.item .chev { color: var(--ink-2); }

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  transition: background 160ms ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  transition: transform 160ms ease;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(20px); border-color: var(--accent); }

.profile { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0 24px; }
.profile .pick { border: none; background: none; padding: 0; border-radius: 999px; }
.profile .name-input {
  text-align: center;
  font: 600 22px/1.2 var(--head);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  width: 100%;
  max-width: 320px;
}
.profile .name-input:focus { outline: none; border-color: var(--line-strong); background: var(--bg); }

.stack { display: grid; gap: 24px; }

.auth {
  min-height: 100dvh;
  max-width: 400px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 15vh) 24px 32px;
}
.auth h1 { font-size: 30px; margin-bottom: 32px; }
.auth .pick { display: flex; justify-content: center; margin-bottom: 24px; border: none; background: none; width: 100%; }
.error { color: var(--late); font-size: 14px; min-height: 20px; margin: -4px 2px 12px; }

.link {
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  word-break: break-all;
  user-select: all;
}

.dot { width: 3px; height: 3px; border-radius: 9px; background: currentColor; opacity: 0.6; flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
input[type="date"].input::-webkit-calendar-picker-indicator { margin-left: auto; opacity: 0.6; }
