:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --acc: #2563eb;
  --acc-press: #1d4ed8;
  --danger: #dc2626;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #151b2b;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --acc: #3b82f6;
    --acc-press: #2563eb;
    --danger: #f87171;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
body {
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 4px 0;
}
header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
#dateLabel {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}
.ieri {
  margin: 0;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
#counters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  align-items: center;
}
.card .label {
  grid-column: 1;
  grid-row: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.card .num {
  grid-column: 1;
  grid-row: 2;
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.card .btns {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.btn-plus, .btn-minus {
  border: none;
  border-radius: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.btn-plus {
  width: 72px;
  height: 72px;
  font-size: 36px;
  background: var(--acc);
}
.btn-plus:active { background: var(--acc-press); transform: scale(0.96); }
.btn-minus {
  width: 48px;
  height: 36px;
  font-size: 22px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-minus:active { background: var(--border); }
footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  padding-top: 6px;
}
.azzera {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--danger);
  font-size: 17px;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
}
.azzera:active { opacity: 0.85; }
.hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  #toast { background: rgba(241, 245, 249, 0.95); color: #0f172a; }
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 20px;
  padding: 22px 18px 16px;
  box-shadow: var(--shadow);
}
.modal-card p {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-actions button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
}
.modal-actions .danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}
