:root {
  --bg: #f3efe8;
  --card: #ffffff;
  --ink: #18181b;
  --muted: #6b6b75;
  --line: #e4ded4;
  --btn: #f0ebe3;
  --brand: #d9480f;
  --ok: #1f9d55;
  --warn: #f59f00;
  --warn-bg: #fff3cf;
  --warn-ink: #9a5b00;
  --over: #dc2626;
  --over-2: #f04444;
  --ring: rgba(0, 0, 0, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 3px 10px rgba(0, 0, 0, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --card: #1d1d21;
    --ink: #f4f4f5;
    --muted: #a1a1aa;
    --line: #303036;
    --btn: #2a2a30;
    --warn-bg: #3a2c06;
    --warn-ink: #ffc94d;
    --ring: rgba(255, 255, 255, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:active { transform: scale(.97); }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- topo ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.brand svg { width: 34px; height: 34px; }
.count {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 15px;
  color: var(--muted);
}
.count b { color: var(--ink); }

.banner {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #ffe9a8;
  color: #5a4300;
  font-weight: 700;
  text-align: left;
}
.banner[hidden] { display: none; }

/* ---------- crianças ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.tile {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 150px;
  padding-bottom: 16px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}
.tile.new { animation: pop .45s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: .3; } }

.band {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 8px;
  background: var(--c);
  box-shadow: inset 0 -1px 0 var(--ring);
}
.tag {
  max-width: 100%;
  padding: 3px 11px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .94);
  color: #18181b;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.light .tag { background: #18181b; color: #fff; }

.cap {
  margin-top: 12px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.time {
  font-size: 44px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.05;
}
.time.long { font-size: 34px; }
.sub { margin-top: 2px; font-size: 13.5px; color: var(--muted); }

.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--line); }
.bar i { display: block; height: 100%; background: var(--ok); transition: width .3s linear; }

/* último minuto */
.tile[data-kind="warn"] { background: var(--warn-bg); box-shadow: inset 0 0 0 3px var(--warn); }
.tile[data-kind="warn"] .cap,
.tile[data-kind="warn"] .time { color: var(--warn-ink); }
.tile[data-kind="warn"] .bar i { background: var(--warn); }

/* acabou */
.tile[data-kind="over"] { background: var(--over); color: #fff; }
.tile[data-kind="over"]:not([data-ack]) { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { background: var(--over-2); transform: scale(1.03); } }
.tile[data-kind="over"] .band { box-shadow: inset 0 -3px 0 #fff; }
.tile[data-kind="over"] .cap {
  padding: 3px 12px;
  border-radius: 99px;
  background: #fff;
  color: var(--over);
  font-size: 15px;
  letter-spacing: .04em;
}
.tile[data-kind="over"] .time { font-size: 34px; margin-top: 4px; }
.tile[data-kind="over"] .sub { color: #fff; font-weight: 700; }
.tile[data-kind="over"] .bar { display: none; }

.empty { margin: 48px 16px; text-align: center; color: var(--muted); }
.empty[hidden] { display: none; }
.empty svg { width: 140px; color: var(--line); }
.empty p { margin: 10px 0 0; font-size: 17px; line-height: 1.5; }
.empty b { color: var(--ink); }

/* ---------- botão de baixo ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 16px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}
.add-btn {
  display: block;
  width: 100%;
  max-width: 528px;
  height: 66px;
  margin: 0 auto;
  border-radius: 20px;
  background: var(--brand);
  color: #fff;
  font-size: 23px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(217, 72, 15, .35), inset 0 -4px 0 rgba(0, 0, 0, .18);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 528px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: rise .2s ease-out;
}
.toast[hidden] { display: none; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.toast span { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast button {
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-weight: 800;
}
.toast button[hidden] { display: none; }

/* ---------- janelas ---------- */
dialog.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 24px; } }
.sheet-in { padding: 6px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 2px; }
.sheet-head h2 { margin: 0; font-size: 23px; }
.x {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  background: var(--btn);
  font-size: 18px;
}

.step { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; font-size: 17px; font-weight: 800; }
.step span {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 14px;
}
.step small { font-size: 14px; font-weight: 600; color: var(--muted); }

.times { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.time-btn {
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--btn);
  line-height: 1;
}
.time-btn b { font-size: 21px; font-weight: 800; }
.time-btn small { margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--muted); }
.time-btn[aria-pressed="true"] { background: var(--brand); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.time-btn[aria-pressed="true"] small { color: rgba(255, 255, 255, .9); }

.colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; }
.color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}
.color-btn i {
  display: block;
  width: 100%;
  aspect-ratio: 1 / .78;
  border-radius: 16px;
  background: var(--c);
  box-shadow: inset 0 0 0 1.5px var(--ring);
}

.kid-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.kid-title i {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--c);
  box-shadow: inset 0 0 0 1.5px var(--ring);
}
.kid-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kid-status { margin: 10px 0 14px; font-size: 18px; color: var(--muted); }
.kid-status b { color: var(--ink); font-variant-numeric: tabular-nums; }
.kid-status.over b { color: var(--over); }

.big {
  display: block;
  width: 100%;
  height: 66px;
  margin-top: 10px;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 800;
}
.big.done { background: var(--ok); color: #fff; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15); }
.big.more { background: var(--btn); }
