:root {
  --bg: #f6f4ef;
  --panel: #fffdf8;
  --fg: #1b1a17;
  --muted: #6b675e;
  --line: #d9d4c8;
  --soft: #ece8de;
  --warn: #b42318;
  --warn-soft: #fbe4e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --panel: #1c1b19;
    --fg: #ece9e2;
    --muted: #9a958a;
    --line: #34322d;
    --soft: #2a2925;
    --warn: #f97066;
    --warn-soft: #3a1d1a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button, select { font: inherit; color: inherit; }
select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }

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

/* ---- header ---- */

.top { padding: 28px 0 14px; }
.band { margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.top h1 { margin: 2px 0 0; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.when { margin: 6px 0 0; color: var(--muted); }

/* ---- running total ---- */

.summary {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 0 12px;
}
.sum-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sum-line strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.of { color: var(--muted); font-variant-numeric: tabular-nums; }
.sum-note { color: var(--muted); font-size: .9rem; }
.bar { margin-top: 8px; height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
#barFill { height: 100%; width: 0; background: var(--fg); border-radius: inherit; transition: width .2s ease; }
.summary.over strong, .summary.over .sum-note { color: var(--warn); }
.summary.over #barFill { background: var(--warn); }

/* ---- the list ---- */

main { padding-top: 12px; padding-bottom: 48px; }

.list { list-style: none; margin: 0; padding: 0; }

.row { display: flex; align-items: center; border-radius: 12px; background: var(--bg); }
.toggle {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 4px 9px 6px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px;
}
.toggle:hover { background: var(--soft); }

.mark {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.in .mark { background: var(--fg); color: var(--bg); }
.out .mark { border: 1.5px dashed var(--muted); color: var(--muted); }

.title { min-width: 0; overflow-wrap: anywhere; }
.in .title { font-weight: 600; }
.out .title, .out .len { color: var(--muted); }
.title small { display: block; font-size: .78rem; font-weight: 400; color: var(--muted); }
.title small:empty { display: none; }
.out .title small { color: var(--warn); }
.len { font-variant-numeric: tabular-nums; color: var(--muted); }
.past .title, .past .len { color: var(--warn); }
.past .mark { background: var(--warn); }

.grip {
  flex: none; width: 40px; height: 44px; border: 0; border-radius: 10px; background: none; padding: 0;
  display: grid; place-items: center; color: var(--muted);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.grip svg { fill: currentColor; }
.grip:hover { color: var(--fg); background: var(--soft); }
.out .grip { opacity: .5; }

.divider, .cutoff {
  display: flex; align-items: center; gap: 10px; margin: 10px 0;
  font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.divider { color: var(--muted); }
.divider::before, .divider::after, .cutoff::before, .cutoff::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.cutoff { color: var(--warn); margin: 4px 0; }
.cutoff::before, .cutoff::after { border-top: 1px dashed var(--warn); }

/* dragging and tapping feedback */
.row.ghost { opacity: .35; }
.row.lifted {
  opacity: 1 !important; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); cursor: grabbing;
}
.row.flash { animation: flash .9s ease-out; }
@keyframes flash { from { background: var(--soft); } to { background: var(--bg); } }

/* ---- actions ---- */

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.actions button {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); cursor: pointer;
  font-size: .9rem; font-weight: 600;
}
.actions button:hover:not(:disabled) { border-color: var(--fg); }
.actions button:disabled { opacity: .4; cursor: default; }
.actions .primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.actions .quiet { border-color: transparent; color: var(--muted); }

.hint { color: var(--muted); font-size: .85rem; margin: 14px 0 0; }
.gap { display: inline-flex; align-items: center; gap: 6px; }

/* ---- toast ---- */

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--fg); color: var(--bg);
  font-size: .9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }
