/* Tally: a ledger, not a dashboard. Hairline rules instead of cards, a serif for the numbers that
   matter, mono for dates and counts, and one signature: the square. The heatmap cell, the check
   button, the brand mark and the week strip are all the same rounded square at different sizes. */
:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #e7ebe6;
  --ink: #111714;
  --ink-2: #4a544e;
  --ink-3: #7f8983;
  --line: rgba(17, 23, 20, 0.09);
  --line-strong: rgba(17, 23, 20, 0.2);
  --cell0: #e1e6e0;
  --rest-cell: #ecf0eb;
  --accent: #3f7d0e;
  --on-fill: #ffffff;
  --danger: #c2382a;
  --scrim: rgba(17, 23, 20, 0.38);
  --shadow: 0 24px 60px -24px rgba(17, 23, 20, 0.4);
  --h0: #4f8a10;
  --h1: #0e8a6a;
  --h2: #1d79c0;
  --h3: #5a4bd6;
  --h4: #b0399a;
  --h5: #d0452f;
  --h6: #b17400;
  --h7: #56625c;
  color-scheme: light;

  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body:
    "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --c: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f0e;
    --surface: #151a18;
    --surface-2: #1c2220;
    --ink: #e8ede9;
    --ink-2: #a3ada7;
    --ink-3: #69736d;
    --line: rgba(232, 237, 233, 0.08);
    --line-strong: rgba(232, 237, 233, 0.18);
    --cell0: #1b2220;
    --rest-cell: #141917;
    --accent: #c4f24a;
    --on-fill: #0c0f0e;
    --danger: #ff7a66;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
    --h0: #c4f24a;
    --h1: #4fe0b6;
    --h2: #5cc6ff;
    --h3: #a093ff;
    --h4: #f282da;
    --h5: #ff7e69;
    --h6: #ffc24d;
    --h7: #cbd3ce;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f0e;
  --surface: #151a18;
  --surface-2: #1c2220;
  --ink: #e8ede9;
  --ink-2: #a3ada7;
  --ink-3: #69736d;
  --line: rgba(232, 237, 233, 0.08);
  --line-strong: rgba(232, 237, 233, 0.18);
  --cell0: #1b2220;
  --rest-cell: #141917;
  --accent: #c4f24a;
  --on-fill: #0c0f0e;
  --danger: #ff7a66;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  --h0: #c4f24a;
  --h1: #4fe0b6;
  --h2: #5cc6ff;
  --h3: #a093ff;
  --h4: #f282da;
  --h5: #ff7e69;
  --h6: #ffc24d;
  --h7: #cbd3ce;
  color-scheme: dark;
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem / 1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] {
  display: none !important;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
svg {
  display: block;
}
h1,
h2,
h3,
p {
  margin: 0;
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) max(20px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom, 0px) + 48px) max(20px, env(safe-area-inset-left));
}
.view {
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: view-in 0.35s var(--ease);
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}
.topbar-detail {
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 400 2.25rem / 1 var(--font-display);
  letter-spacing: -0.01em;
}
.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 9px);
  gap: 3px;
}
.brand-mark i {
  width: 9px;
  height: 9px;
  border-radius: 2.5px;
  background: var(--accent);
}
.brand-mark i:nth-child(1) {
  opacity: 0.35;
}
.brand-mark i:nth-child(2) {
  opacity: 1;
}
.brand-mark i:nth-child(3) {
  opacity: 0.7;
}
.brand-mark i:nth-child(4) {
  opacity: 0.18;
}
.dateline {
  margin-top: 6px;
  font: 400 0.75rem / 1.2 var(--font-mono);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.topbar-actions {
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  transition:
    background 0.15s,
    transform 0.15s var(--ease);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-2);
  }
}
.icon-btn-solid {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
@media (hover: hover) {
  .icon-btn-solid:hover {
    background: var(--ink-2);
  }
}

/* ---------- segmented ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--surface-2);
}
.seg button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.9rem;
  transition:
    background 0.15s,
    color 0.15s;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px var(--line-strong);
}
.seg-sm button {
  min-height: 38px;
  min-width: 40px;
  padding: 0 10px;
  font: 500 0.72rem / 1 var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---------- ledger + heatmap ---------- */
.ledger {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
}
.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.map {
  position: relative;
  margin-right: -4px;
}
.map-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 4px 4px 4px 0;
  scroll-behavior: auto;
}
.map-scroll::-webkit-scrollbar {
  display: none;
}
.map-grid {
  --gap: 3px;
  display: grid;
  gap: var(--gap);
  grid-template-columns: auto repeat(var(--weeks), minmax(var(--cell-min, 9px), 1fr));
  grid-template-rows: auto repeat(7, auto);
  min-width: 0;
  border-radius: 6px;
}
.map-grid[data-weeks="13"] {
  --gap: 5px;
}
.map-grid[data-weeks="26"] {
  --gap: 3px;
}
.map-grid:focus-visible {
  outline-offset: 4px;
}
.map-month {
  width: 0;
  overflow: visible;
  font: 400 0.66rem / 1 var(--font-mono);
  color: var(--ink-3);
  white-space: nowrap;
  padding-bottom: 4px;
  align-self: end;
}
.map-days {
  grid-area: 2 / 1 / 9 / 2;
  display: grid;
  grid-template-rows: subgrid;
  position: sticky;
  left: 0;
  z-index: 2;
  padding-right: 4px;
  background: var(--bg);
  transition: box-shadow 0.2s;
}
.map.scrolls:not(.at-start) .map-days {
  box-shadow: 10px 0 10px -10px var(--line-strong);
}
.map-day {
  font: 400 0.62rem / 1 var(--font-mono);
  color: var(--ink-3);
  align-self: center;
}
.cell {
  display: block;
  aspect-ratio: 1;
  border-radius: 22%;
  background: var(--cell0);
  transition:
    background-color 0.25s,
    transform 0.2s var(--ease);
}
.lv1 {
  background: color-mix(in oklab, var(--c) 30%, var(--cell0));
}
.lv2 {
  background: color-mix(in oklab, var(--c) 52%, var(--cell0));
}
.lv3 {
  background: color-mix(in oklab, var(--c) 76%, var(--cell0));
}
.lv4 {
  background: var(--c);
}
.cell.off {
  background: var(--rest-cell);
  box-shadow: inset 0 0 0 1px var(--line);
}
.cell.pre {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}
.cell.today {
  box-shadow:
    0 0 0 1.5px var(--bg),
    0 0 0 2.5px var(--ink-3);
}
.cell.sel {
  box-shadow:
    0 0 0 1.5px var(--bg),
    0 0 0 3px var(--ink);
  position: relative;
  z-index: 1;
}
.cell.pop {
  animation: pop 0.45s var(--ease);
}
@keyframes pop {
  40% {
    transform: scale(1.5);
  }
}
.map-grid .cell {
  cursor: pointer;
}

.map-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 22px;
}
.readout {
  font: 400 0.8rem / 1.4 var(--font-mono);
  color: var(--ink-2);
}
.readout b {
  color: var(--ink);
  font-weight: 500;
}
.legend {
  display: flex;
  align-items: center;
  gap: 3px;
  font: 400 0.66rem / 1 var(--font-mono);
  color: var(--ink-3);
}
.legend .cell {
  width: 10px;
}
.legend span:first-child {
  margin-right: 4px;
}
.legend span:last-child {
  margin-left: 4px;
}

.figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 4px 0 0;
  border-top: 1px solid var(--line);
}
.figures > div {
  padding: 14px 0 0;
}
.figures > div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.figures dt {
  font: 400 0.68rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.figures dd {
  margin: 6px 0 0;
  font: 400 2.1rem / 1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.figures dd small {
  font: 400 0.75rem / 1 var(--font-body);
  color: var(--ink-3);
  margin-left: 3px;
}

/* ---------- today ---------- */
.today {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-title {
  font: 400 1.9rem / 1 var(--font-display);
}
.progress {
  font: 400 0.8rem / 1 var(--font-mono);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.progress-bar {
  height: 3px;
  border-radius: 3px;
  background: var(--cell0);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.5s var(--ease);
}

.habits {
  list-style: none;
  margin: 0;
  padding: 0;
}
.habit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.habit:first-child {
  border-top: 0;
}
.habit-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  border: 0;
  padding: 4px 0;
  background: none;
  text-align: left;
  border-radius: 8px;
}
.habit-dot {
  grid-row: 1;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}
.habit-name {
  font-weight: 600;
  font-size: 1.04rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-meta {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font: 400 0.72rem / 1 var(--font-mono);
  color: var(--ink-3);
}
.habit-meta b {
  color: var(--ink);
  font-weight: 500;
}
.strip {
  display: inline-flex;
  gap: 2px;
  flex: none;
}
.strip .cell {
  width: 8px;
  border-radius: 2px;
}
.strip .cell.today {
  box-shadow: none;
  outline: 1px solid var(--ink-3);
  outline-offset: 1px;
}
.habit.is-done .habit-name {
  color: var(--ink-2);
}

.check {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    border-color 0.2s,
    transform 0.15s var(--ease);
}
.check::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c);
  border-radius: inherit;
  transform: scale(var(--fill, 0));
  transform-origin: center;
  opacity: var(--fill-o, 0);
  transition:
    transform 0.35s var(--ease),
    opacity 0.2s;
}
.check[data-lv="1"] {
  --fill: 1;
  --fill-o: 0.28;
}
.check[data-lv="2"] {
  --fill: 1;
  --fill-o: 0.5;
}
.check[data-lv="3"] {
  --fill: 1;
  --fill-o: 0.75;
}
.check[data-lv="4"] {
  --fill: 1;
  --fill-o: 1;
  border-color: var(--c);
  color: var(--on-fill);
}
.check:active {
  transform: scale(0.92);
}
.check svg {
  position: relative;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.check .tick {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.3s 0.08s var(--ease);
}
.check[data-lv="4"] .tick {
  stroke-dashoffset: 0;
}
.check .ring-empty {
  stroke: var(--line-strong);
}
.check-count {
  position: relative;
  font: 500 0.82rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.check-count small {
  display: block;
  margin-top: 2px;
  font-size: 0.6rem;
  opacity: 0.7;
  text-align: center;
}
.check.pop::before {
  animation: ink 0.5s var(--ease);
}
@keyframes ink {
  0% {
    transform: scale(0.2);
    border-radius: 50%;
  }
  60% {
    border-radius: 30%;
  }
}
@media (hover: hover) {
  .check:hover {
    border-color: var(--c);
  }
}

.add-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-top: 4px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-weight: 500;
  border-radius: 8px;
}
.add-row span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
}
.add-row svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
@media (hover: hover) {
  .add-row:hover {
    color: var(--ink);
  }
}

.rest summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
  font: 400 0.75rem / 1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.rest summary::-webkit-details-marker {
  display: none;
}
.rest summary svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: transform 0.2s;
}
.rest[open] summary svg {
  transform: rotate(180deg);
}
.rest .habit {
  opacity: 0.78;
}
.hint {
  font-size: 0.8rem;
  color: var(--ink-3);
  padding-top: 6px;
}

/* ---------- empty ---------- */
.empty {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line-strong);
}
.empty-title {
  font: 400 2.4rem / 1.05 var(--font-display);
  letter-spacing: -0.01em;
}
.empty-title em {
  color: var(--ink-3);
}
.empty p {
  color: var(--ink-2);
  max-width: 32ch;
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  font-size: 0.9rem;
}
.chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}
@media (hover: hover) {
  .chip:hover {
    background: var(--surface-2);
  }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition:
    transform 0.15s var(--ease),
    background 0.15s;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}
@media (hover: hover) {
  .btn-ghost:hover {
    background: var(--surface-2);
  }
}
.btn-danger {
  background: transparent;
  border-color: color-mix(in oklab, var(--danger) 45%, transparent);
  color: var(--danger);
}
.btn-danger.armed {
  background: var(--danger);
  color: var(--on-fill);
}
.btn-block {
  width: 100%;
}
.link {
  border: 0;
  background: none;
  padding: 10px 0;
  min-height: 44px;
  color: var(--ink-2);
  font-size: 0.85rem;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

/* ---------- detail ---------- */
.detail-title {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.swatch {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 12px;
  border-radius: 4px;
  background: var(--c);
}
.habit-title {
  font: 400 2.6rem / 1.02 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.habit-sub {
  margin-top: 8px;
  font: 400 0.75rem / 1.4 var(--font-mono);
  color: var(--ink-3);
}
.streak {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.streak-num {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font: 400 6.5rem / 0.9 var(--font-display);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.streak-num span {
  font: 400 0.8rem / 1.3 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--ink-3);
  max-width: 9ch;
}
.streak-num i {
  font-style: italic;
  color: var(--c);
}
.figures-tight dd {
  font-size: 1.8rem;
}

.day-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}
.day-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}
.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
}
.stepper button:disabled {
  opacity: 0.3;
  cursor: default;
}
.stepper svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.stepper output {
  min-width: 3ch;
  text-align: center;
  font: 500 0.9rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.btn-mark {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: none;
  font-weight: 600;
  font-size: 0.88rem;
}
.btn-mark[aria-pressed="true"] {
  background: var(--c);
  border-color: var(--c);
  color: var(--on-fill);
}

.weekdays {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
}
.bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
}
.bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.bar-track {
  position: relative;
  width: 100%;
  height: 96px;
  border-radius: 6px;
  background: var(--cell0);
  overflow: hidden;
}
.bar-track span {
  position: absolute;
  inset: auto 0 0;
  height: calc(var(--v, 0) * 100%);
  background: var(--c);
  border-radius: 6px 6px 0 0;
  transition: height 0.5s var(--ease);
}
.bar-track.none {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}
.bar b {
  font: 500 0.7rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.bar small {
  font: 400 0.66rem / 1 var(--font-mono);
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ---------- sheets ---------- */
.sheet {
  width: 100%;
  max-width: 32rem;
  max-height: min(92dvh, 760px);
  margin: auto auto 0;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet[open] {
  animation: sheet-in 0.32s var(--ease);
}
.sheet::backdrop {
  background: var(--scrim);
}
@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}
@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-radius: 22px;
  }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 10px auto 4px;
  border-radius: 4px;
  background: var(--line-strong);
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 12px;
  background: var(--bg);
}
.sheet-head h2 {
  font: 400 1.9rem / 1 var(--font-display);
}
.sheet form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sheet > .field + .field {
  margin-top: 22px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.field > label,
.field legend,
.field .label {
  padding: 0;
  font: 500 0.7rem / 1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.field legend {
  margin-bottom: 10px;
}
input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.05rem;
}
#f-name {
  font: 400 1.5rem / 1 var(--font-display);
}
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0;
  border-color: transparent;
}
.field-error {
  font-size: 0.82rem;
  color: var(--danger);
}
.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.swatches label {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
}
.swatches input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.swatches span {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--c);
  transition: transform 0.15s var(--ease);
  pointer-events: none;
}
.swatches input:checked + span {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--c);
  transform: scale(0.9);
}
.swatches input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 5px;
}
.count-fields {
  display: flex;
  gap: 10px;
}
.mini-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 7rem;
  font-size: 0.8rem;
  color: var(--ink-3);
}
.mini-field.grow {
  flex: 1;
  width: auto;
}
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.days button {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font: 500 0.78rem / 1 var(--font-mono);
  color: var(--ink-2);
}
.days button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.quick-days {
  display: flex;
  gap: 18px;
  margin-top: -4px;
}
.sheet-actions .btn {
  width: 100%;
}
.sheet-danger {
  display: flex;
  gap: 10px;
}
.sheet-danger .btn {
  flex: 1;
}

.note {
  font-size: 0.88rem;
  color: var(--ink-2);
}
.row-btns {
  display: flex;
  gap: 10px;
}
.row-btns .btn {
  flex: 1;
  padding: 0 12px;
}
.file-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-btn:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.archived {
  list-style: none;
  margin: 0;
  padding: 0;
}
.archived li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}
.archived li span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archived li span::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}
.archived .btn {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.85rem;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px;
  min-height: 48px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s var(--ease);
}
.toast button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in oklab, var(--bg) 16%, transparent);
  color: var(--bg);
  font-weight: 600;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

@media (min-width: 720px) {
  .app {
    max-width: 46rem;
  }
  .view {
    gap: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Account sheet: maps Tally's tokens onto the shared account sheet (css/account.css). */
:root {
  --acct-bg: var(--bg);
  --acct-field: var(--surface);
  --acct-raised: var(--surface-2);
  --acct-raised-on: var(--surface);
  --acct-ink: var(--ink);
  --acct-muted: var(--ink-2);
  --acct-faint: var(--ink-3);
  --acct-line: var(--line);
  --acct-line-strong: var(--line-strong);
  --acct-accent: var(--accent);
  --acct-danger: var(--danger);
  --acct-primary: var(--ink);
  --acct-on-primary: var(--bg);
  --acct-scrim: var(--scrim);
  --acct-shadow: var(--shadow);
  --acct-font-body: var(--font-body);
  --acct-font-display: var(--font-display);
  --acct-font-label: var(--font-mono);
  --acct-display-size: 2.75rem;
  --acct-display-weight: 400;
  --acct-display-tracking: -0.01em;
  --acct-accent-style: italic;
  --acct-label-size: 0.7rem;
  --acct-label-weight: 500;
  --acct-label-tracking: 0.1em;
  --acct-sheet-width: 32rem;
  --acct-sheet-radius: 22px 22px 0 0;
  --acct-radius: 12px;
  --acct-btn-radius: 12px;
  --acct-seg-radius: 12px;
  --acct-btn-h: 50px;
}
