:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --text: #1f1a17;
  --muted: #6b625b;
  --line: #e8dfd6;
  --brand: #c2410c;
  --brand-ink: #ffffff;
  --brand-soft: #fdebdd;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171311;
    --surface: #221c19;
    --text: #f3ece6;
    --muted: #a99d93;
    --line: #3a302b;
    --brand: #f97316;
    --brand-ink: #1a0f08;
    --brand-soft: #3b2415;
    --ok: #4ade80;
    --ok-soft: #173222;
    --warn: #facc15;
    --warn-soft: #3a3113;
    --err: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
main, .bar { max-width: 520px; margin: 0 auto; }
main { padding: 12px 16px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.top h1 { font-size: 1.15rem; }
.top-actions { display: flex; gap: 8px; }
.chip-btn {
  min-width: 44px; height: 36px; border-radius: 18px; border: 1px solid color-mix(in srgb, var(--brand-ink) 40%, transparent);
  background: transparent; color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer;
}

.bar { padding: 8px 16px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.bar-soft { background: var(--brand-soft); color: var(--text); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 14px; margin-top: 12px;
}
label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
input {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input:disabled { opacity: .75; }

button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- compact one-screen sadhana form ---- */
.card.compact { gap: 0; padding: 2px 14px 10px; }
.frow { display: grid; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.frow:first-child { border-top: 0; }
.frow-top, .frow-inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flabel { flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; line-height: 1.25; }
.tstep { display: flex; align-items: center; gap: 6px; flex: none; }
.tstep button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--brand-soft); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.tstep output, .tstep input {
  min-width: 96px; text-align: center; font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tstep input { width: 72px; min-width: 72px; min-height: 44px; padding: 6px 4px; }
.chips { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; }
.chips[data-chips=rounds] { grid-auto-columns: minmax(0, 52px); }
.chip {
  position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 2px;
  min-width: 0; overflow: hidden; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 19px; background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-variant-numeric: tabular-nums; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.chip-other input {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0;
  opacity: 0; cursor: pointer;
}
.card.locked .chips, .card.locked .tstep button { opacity: .45; }
.card.compact .note { padding-top: 8px; border-top: 1px solid var(--line); }
.submit-bar {
  position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 2;
  padding: 10px 0 2px; background: linear-gradient(transparent, var(--surface) 35%);
}
.submit-bar .primary { width: 100%; }
@media (max-width: 370px) {
  main { padding: 10px 12px; }
  .card.compact { padding: 2px 10px 10px; }
  .flabel { font-size: .88rem; }
  .tstep { gap: 4px; }
  .tstep button { width: 38px; height: 38px; font-size: 1.2rem; }
  .tstep output { min-width: 78px; font-size: 1.02rem; }
  .tstep input { width: 56px; min-width: 56px; font-size: 1.05rem; }
  .chip { font-size: .8rem; min-height: 34px; }
}
.hello-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 10px; }
.hello-row .hello { margin: 0; }
.streak {
  flex: none; padding: 4px 10px; border-radius: 99px; background: var(--warn-soft); color: var(--warn);
  font-size: .85rem; font-weight: 700; white-space: nowrap;
}

button.primary {
  min-height: 48px; border: 0; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer;
}
button.primary:disabled { opacity: .6; }
button.ghost {
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
button.danger { color: var(--err); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--brand-soft); border-radius: 12px; }
.seg-btn { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn.active { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.hello { margin: 4px 0 10px; color: var(--muted); }
/* fixed height on .day: Chrome sized these buttons to ~126px for 60px of content */
.days { display: flex; gap: 8px; align-items: flex-start; }
.day {
  flex: 1 1 0; min-width: 0; display: block; padding: 6px 2px; height: 76px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.day-in { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.day b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.day small { color: var(--muted); font-size: .8rem; }
.day i { display: block; font-style: normal; font-size: .85rem; height: 1.2em; }
.day.filled i { color: var(--ok); }
.day.pending i { color: var(--warn); }
.day.active { border: 2px solid var(--brand); background: var(--brand-soft); }

.note { margin: 0; font-size: .88rem; color: var(--muted); }
.err { margin: 0; color: var(--err); font-size: .9rem; min-height: 0; }
.err:empty { display: none; }
.hint, .muted { margin: 0; color: var(--muted); font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.summary { font-weight: 600; margin: 12px 0 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.row-between input { width: auto; flex: 1; }

.hcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 10px; display: grid; gap: 8px;
}
#admin-day-list .hcard, .hcard.click { cursor: pointer; }
.hcard.missing { border-style: dashed; }
.badge { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }
.grid5 { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0; font-size: .92rem; }
.grid5 dt { color: var(--muted); }
.grid5 dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

table.stats { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .92rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.stats th, table.stats td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.stats tr > :first-child { text-align: left; color: var(--muted); }
table.stats th { background: var(--brand-soft); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  display: grid; justify-items: center; gap: 2px; padding: 8px 0; min-height: 60px;
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer;
}
.tabs button .ico { font-size: 1.2rem; }
.tabs button.active { color: var(--brand); font-weight: 700; }

dialog {
  width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 16px;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { display: grid; gap: 12px; }

#toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translate(-50%, -10px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog form + form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
