:root {
  --bg: #f5f7fc;
  --surface: #ffffff;
  --ink: #23262f;
  --muted: #646a78;
  --line: #d9deec;
  --primary: #3f4fb5;
  --on-primary: #ffffff;
  --bar: #00959c;
  --track: #e8ebf3;
  --good: #2e7d4f;
  --danger: #b3261e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --surface: #1f2229;
    --ink: #eceef3;
    --muted: #a3a9b6;
    --line: #363b46;
    --primary: #aab4f5;
    --on-primary: #161a33;
    --bar: #129fa6;
    --track: #2e323c;
    --good: #6fcf97;
    --danger: #f2a29c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, "Noto Sans Devanagari", "Segoe UI", sans-serif;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.acting {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: .625rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

header.top {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: center;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
header.top .title { font-weight: 700; }
header.top .spacer { flex: 1; }

nav.tabs { display: flex; flex-wrap: wrap; gap: .25rem; padding: .5rem 1rem 0; }
nav.tabs button { border: 0; background: none; color: var(--muted); padding: .5rem .75rem; border-bottom: 2px solid transparent; border-radius: 0; }
nav.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { max-width: 1040px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
main.narrow { max-width: 420px; padding-top: 3rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.stack { display: grid; gap: .75rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.row > label { flex: 1 1 160px; }

label { display: grid; gap: .25rem; font-size: .875rem; color: var(--muted); }
input, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .5rem .625rem;
  width: 100%;
}
input[type="checkbox"] { width: auto; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: .4rem .75rem; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; padding: .55rem 1rem; }
button.link { border: 0; background: none; color: var(--primary); padding: 0; text-align: left; font-weight: 600; }
button.danger { color: var(--danger); }

.error { color: var(--danger); font-weight: 600; }
.good { color: var(--good); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { text-align: left; padding: .5rem .625rem; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 160px; }
th { color: var(--muted); font-weight: 600; font-size: .8125rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code.join { font: 600 1rem ui-monospace, Consolas, monospace; letter-spacing: .05em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; }
.tile .value { font-size: 1.625rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .label { color: var(--muted); font-size: .875rem; }

.meter { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(80px, 2fr) auto; gap: .5rem .75rem; align-items: center; }
.track { height: 10px; background: var(--track); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-items: end; height: 150px; border-bottom: 1px solid var(--line); }
.week .col { display: flex; flex-direction: column; justify-content: end; align-items: center; height: 100%; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.week .bar { width: min(28px, 70%); background: var(--bar); border-radius: 4px 4px 0 0; }
.week-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; color: var(--muted); font-size: .8125rem; padding-top: .25rem; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
.checks label { display: flex; gap: .25rem; align-items: center; color: var(--ink); }
