@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #eef0f5;
  --surface: #ffffff;
  --raised: #f1f3f8;
  --line: rgba(20, 24, 38, 0.09);
  --ink: #141826;
  --ink-2: #4c5368;
  --ink-3: #858ca0;
  --accent: #f5a614;
  --accent-ink: #1d1402;
  --accent-text: #a96700;
  --good: #1e9a5a;
  --bad: #d63a48;
  --shadow: 0 1px 2px rgba(20, 24, 38, 0.05), 0 8px 24px -12px rgba(20, 24, 38, 0.12);
  --display: 'Bricolage', ui-rounded, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f16;
    --surface: #151924;
    --raised: #1e2331;
    --line: rgba(255, 255, 255, 0.08);
    --ink: #eef0f6;
    --ink-2: #a9afc2;
    --ink-3: #6f768c;
    --accent: #ffb224;
    --accent-text: #ffb224;
    --good: #46c987;
    --bad: #ff6b76;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--body);
  overscroll-behavior-y: none;
}

body:has(#sheet-host > *) {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--tabbar-h) + var(--safe-b) + 40px);
  min-height: 100dvh;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: view-in 0.18s ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.view > * {
  min-width: 0;
  max-width: 100%;
}

.day-title h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-title,
.day-title h1 {
  font: 700 30px/1.1 var(--display);
  letter-spacing: -0.02em;
  margin: 0;
}

.view-title {
  margin: 6px 0 4px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title,
.group-title {
  font: 600 13px/1 var(--body);
  color: var(--ink-3);
  margin: 0 0 14px;
  letter-spacing: 0.01em;
}

.group-title {
  margin: 10px 4px 8px;
}

.empty,
.empty-inline {
  color: var(--ink-3);
  text-align: center;
  padding: 36px 24px;
  margin: 0;
  text-wrap: balance;
}

.empty-inline {
  padding: 12px 0;
}

.fine {
  color: var(--ink-3);
  font-size: 13px;
  padding: 0 4px;
  text-wrap: pretty;
}

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

.day-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 2px;
}

.day-title {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 2px 4px;
}

.day-title span {
  display: block;
  color: var(--ink-3);
  font-size: 13px;
  min-height: 18px;
}

.date-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
}

.nav-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 24px;
  line-height: 1;
  padding: 0 0 3px;
  color: var(--ink-2);
}

.nav-btn:disabled {
  opacity: 0.35;
}

.nav-btn:active:not(:disabled),
.quick-btn:active,
.row:active,
.list-row:active {
  background: var(--raised);
}

.today-btn {
  flex: none;
  border: 0;
  border-radius: 99px;
  min-height: 36px;
  padding: 0 14px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 13.5px;
}

/* ---------- the day band ---------- */

.card-band {
  padding: 12px 14px 10px;
}

.band {
  display: flex;
  align-items: center;
  gap: 8px;
}

.band-label {
  width: 30px;
  flex: none;
  font: 11px/1 var(--mono);
  color: var(--ink-3);
}

.band-body {
  flex: 1;
  min-width: 0;
}

.band-lane {
  position: relative;
  height: 9px;
}

.band-track {
  height: 38px;
  background: var(--raised);
  border-radius: 9px;
  overflow: hidden;
}

.band-lane > i {
  position: absolute;
}

.band-grid {
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.band-block {
  top: 0;
  bottom: 0;
  border-radius: 3px;
  box-shadow: 0 0 0 0.5px var(--surface);
}

.band-sleep {
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.16) 0 3px, transparent 3px 7px) !important;
  background-blend-mode: normal;
}

.band-running {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.band-tick {
  bottom: 2px;
  width: 3px;
  height: 7px;
  margin-left: -1.5px;
  border-radius: 2px;
}

.band-dot {
  top: 3px;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
}

.band-now {
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--surface);
}

.band-compact .band-track {
  height: 18px;
  border-radius: 5px;
}

.band-compact .band-lane:not(.band-track) {
  height: 6px;
}

.band-compact .band-tick {
  height: 5px;
  bottom: 1px;
}

.band-compact .band-dot {
  top: 1px;
  width: 4px;
  height: 4px;
}

.bands {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.band-tap {
  cursor: pointer;
}

.band-axis {
  font: 10px/1 var(--mono);
  color: var(--ink-3);
  height: 12px;
  margin-top: 2px;
}

.band-axis-gutter {
  margin-left: 38px;
}

.band-axis-inner {
  position: relative;
}

.band-axis span {
  position: absolute;
  transform: translateX(-50%);
}

.band-axis span:first-child {
  transform: none;
}

.band-axis span:last-child {
  transform: translateX(-100%);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: block;
}

.legend-block {
  width: 12px;
  height: 8px;
  border-radius: 2px;
}

.legend-tick {
  width: 3px;
  height: 9px;
  border-radius: 2px;
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* ---------- day stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px 4px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 2px 10px;
  min-width: 0;
}

.stat + .stat {
  border-left: 1px solid var(--line);
}

.stat-label,
.stat-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font: 650 19px/1.1 var(--display);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-warn .stat-value,
.stat-warn .stat-sub {
  color: var(--bad);
}

/* ---------- quick add ---------- */

.quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-btn {
  min-height: 44px;
  border: 1px dashed color-mix(in srgb, var(--ink-3) 55%, transparent);
  background: transparent;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.quick-btn span {
  color: var(--accent-text);
  font-weight: 700;
}

/* ---------- counters ---------- */

.counters {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 8px;
}

.counter {
  position: relative;
  min-width: 0;
}

.counter-add {
  width: 100%;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 12px 11px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  text-align: left;
  transition: transform 0.1s ease;
}

.counter-add:active {
  transform: scale(0.96);
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
}

.counter-emoji {
  font-size: 22px;
  line-height: 1;
}

.counter-total {
  font: 680 26px/1 var(--display);
  letter-spacing: -0.02em;
}

.counter-total em {
  font: 500 13px/1 var(--body);
  color: var(--ink-3);
  letter-spacing: 0;
}

.counter-name,
.counter-sub {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  margin-top: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.counter-sub {
  padding-right: 34px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 1px;
}

.counter-over .counter-total {
  color: var(--bad);
}

.counter-met .counter-total {
  color: var(--good);
}

.counter-undo {
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  padding: 0 0 2px;
}

.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 56px;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--raised);
  font-size: 24px;
}

.qty-value {
  flex: 1;
  text-align: center;
  font: 680 30px/1 var(--display);
}

/* ---------- timer ---------- */

.timer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-left: 4px solid var(--c);
}

.timer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.timer-main small {
  color: var(--ink-3);
  font-size: 12px;
}

.timer-main b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-clock {
  font: 600 22px/1 var(--display);
}

/* ---------- entry rows ---------- */

.rows {
  padding: 4px 0;
}

.rows-flat {
  margin: -8px -16px -12px;
}

.row {
  display: grid;
  grid-template-columns: 44px 4px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-time {
  font: 13px/1.2 var(--mono);
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
}

.row-time small {
  font-size: 10.5px;
  color: var(--ink-3);
}

.row-bar {
  align-self: stretch;
  border-radius: 2px;
  margin: 3px 0;
}

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-main b {
  font-weight: 600;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.row-main small {
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-side {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.row-side.pos {
  color: var(--good);
}

/* ---------- controls ---------- */

.seg {
  display: flex;
  background: color-mix(in srgb, var(--ink-3) 16%, transparent);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  padding: 0 2px;
  white-space: nowrap;
}

.seg-btn.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.seg-quiet {
  background: transparent;
  padding: 0 16px;
  margin: 0 -16px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.seg-quiet::-webkit-scrollbar {
  display: none;
}

.seg-quiet .seg-btn {
  flex: none;
  padding: 0 14px;
}

.seg-types .seg-btn {
  font-size: 13.5px;
}

.seg-quiet .seg-btn {
  min-height: 36px;
  border-radius: 99px;
  font-size: 13.5px;
}

.seg-quiet .seg-btn.on {
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.insights-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.period {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.period b {
  font: 650 18px/1 var(--display);
}

.chips {
  display: flex;
  gap: 7px;
}

.chips[hidden] {
  display: none;
}

.chips-wrap {
  flex-wrap: wrap;
}

.chips-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chip-cat.on {
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  border-color: var(--c);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--c);
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
}

.chip-sug {
  background: transparent;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--ink-3) 60%, transparent);
  color: var(--ink-2);
}

.btn {
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  padding: 0 20px;
  font-weight: 650;
  font-size: 16px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:active {
  filter: brightness(0.93);
}

.btn-ghost {
  background: color-mix(in srgb, var(--ink-3) 16%, transparent);
  color: var(--ink);
}

.btn-danger {
  background: transparent;
  color: var(--bad);
}

.btn-stop {
  min-height: 42px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 99px;
}

.btn-more {
  margin: 8px auto 0;
  display: block;
}

.input {
  width: 100%;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--raised);
  padding: 0 14px;
  font-size: 17px;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.input::placeholder {
  color: var(--ink-3);
}

.input-search {
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-inline {
  min-height: 40px;
  text-align: right;
  border-radius: 10px;
  padding: 0 10px;
}

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.tile-label {
  font-size: 13px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-label i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

.tile-value {
  font: 680 27px/1.05 var(--display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  min-height: 17px;
}

.tile-delta {
  font-weight: 650;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.tile-delta em {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-3);
}

.tile-delta.good {
  color: var(--good);
}

.tile-delta.bad {
  color: var(--bad);
}

.notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.notes li {
  padding-left: 14px;
  border-left: 2px solid var(--accent);
  font-size: 15px;
  line-height: 1.45;
  text-wrap: pretty;
}

.facts {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
}

.facts dt {
  color: var(--ink-2);
}

.facts dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

/* ---------- charts ---------- */

.hbars {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.hbar-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14.5px;
  margin-bottom: 6px;
}

.hbar-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar-value {
  font-weight: 600;
  white-space: nowrap;
}

.hbar-value em {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-3);
  display: inline-block;
  min-width: 2.6em;
  text-align: right;
}

button.hbar {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  width: 100%;
  display: block;
}

.hbar-chev {
  color: var(--ink-3);
  margin-left: 6px;
  font-weight: 400;
}

.col-grouped {
  flex-direction: row !important;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
}

.col-grouped i {
  flex: 1;
  max-width: 12px !important;
  margin: 0 !important;
  border-radius: 3px 3px 0 0;
  box-shadow: none !important;
}

.line-wrap svg {
  display: block;
  width: 100%;
  height: 120px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

.line-axis {
  display: flex;
  justify-content: space-between;
  font: 10px/20px var(--mono);
  color: var(--ink-3);
}

.card-hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-head h2 {
  font: 700 24px/1.1 var(--display);
  letter-spacing: -0.02em;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-head small {
  display: block;
  font: 400 13px/1.3 var(--body);
  color: var(--ink-3);
  letter-spacing: 0;
}

.hbar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--raised);
  overflow: hidden;
}

.hbar-track i {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: 4px;
}

.cols-readout {
  font-size: 13px;
  color: var(--ink-2);
  min-height: 20px;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.cols-readout b {
  color: var(--ink);
}

.cols {
  --stack-h: 124px;
  --label-h: 20px;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.cols-dense {
  gap: 2px;
}

.col {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
}

.col-stack {
  height: var(--stack-h);
  display: flex;
  flex-direction: column-reverse;
  border-bottom: 1px solid var(--line);
}

.col-stack i {
  display: block;
  width: 100%;
  max-width: 28px;
  margin: 0 auto;
  min-height: 2px;
  box-shadow: 0 -1px 0 var(--surface);
}

.col-stack i:last-child {
  border-radius: 4px 4px 0 0;
}

.col-label {
  height: var(--label-h);
  font: 10px/20px var(--mono);
  color: var(--ink-3);
  text-align: center;
  white-space: nowrap;
}

.cols:has(.col-on) .col:not(.col-on) .col-stack i {
  opacity: 0.35;
}

.cols-goal {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px dashed var(--ink-3);
  pointer-events: none;
}

/* ---------- settings lists ---------- */

.list {
  padding: 0;
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 6px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  font-size: 16px;
}

.list-row + .list-row {
  border-top: 1px solid var(--line);
}

.list-row em {
  font-style: normal;
  color: var(--ink-3);
  font-size: 14px;
}

.list-row-add {
  color: var(--accent-text);
  font-weight: 600;
}

.cat-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 10px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  max-width: 48px;
  width: 100%;
  justify-self: center;
}

.swatch.on {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--ink);
}

.cat-name-row {
  display: flex;
  gap: 8px;
}

.input-emoji {
  width: 64px;
  flex: none;
  text-align: center;
  padding: 0;
}

/* ---------- tab bar ---------- */

#tabbar {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: grid;
  grid-template-columns: 1fr 1fr 76px 1fr 1fr;
  align-items: center;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
}

.signed-out #tabbar {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
}

.tab-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.tab.on {
  color: var(--ink);
}

.tab.on .tab-icon {
  color: var(--accent-text);
}

.fab {
  justify-self: center;
  width: 60px;
  height: 60px;
  margin-top: -26px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 5px var(--bg), 0 10px 22px -8px color-mix(in srgb, var(--accent) 70%, #000);
  font: 400 36px/1 var(--display);
  display: grid;
  place-items: center;
  transition: transform 0.12s ease;
}

.fab span {
  margin-top: -4px;
}

.fab:active {
  transform: scale(0.93);
}

/* ---------- sheet ---------- */

.sheet-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  background: rgba(5, 7, 12, 0);
  transition: background 0.25s ease;
}

.sheet-backdrop.open {
  background: rgba(5, 7, 12, 0.5);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: calc(var(--safe-t) + 10px);
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px;
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.2, 0.85, 0.25, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
}

.sheet-backdrop.open .sheet {
  transform: none;
}

.sheet-small {
  bottom: auto;
  max-height: calc(100dvh - var(--safe-t) - 10vh);
  top: calc(var(--safe-t) + 8vh);
  left: 12px;
  right: 12px;
  border-radius: 22px;
  padding-bottom: 16px;
}

.sheet-small .sheet-body {
  padding-bottom: 0;
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 56px;
  margin: 0 -6px;
}

.sheet-head h2 {
  margin: 0;
  font: 650 17px/1 var(--display);
}

.sheet-cancel,
.sheet-save {
  border: 0;
  background: none;
  min-height: 44px;
  padding: 0 6px;
  font-size: 16px;
  color: var(--ink-2);
  justify-self: start;
}

.sheet-save {
  justify-self: end;
  font-weight: 700;
  color: var(--accent-text);
}

.sheet-save:disabled {
  opacity: 0.4;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 -16px;
  padding: 4px 16px 50vh;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.field-label,
.when span {
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-3);
}

.input-title {
  font-size: 19px;
  min-height: 56px;
  font-weight: 550;
}

.input-note {
  padding: 13px 14px;
  min-height: 0;
  resize: none;
  font-size: 16px;
}

.field-amount {
  flex-direction: row;
  align-items: center;
  gap: 0;
  background: var(--raised);
  border-radius: 14px;
  padding-left: 14px;
  border: 1px solid transparent;
}

.field-amount:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.field-amount .input {
  background: transparent;
  border: 0;
  padding-left: 8px;
  font-variant-numeric: tabular-nums;
}

.amount-cur {
  color: var(--ink-3);
  font-weight: 600;
}

.field-amount-big {
  padding: 8px 8px 8px 18px;
}

.field-amount-big .amount-cur {
  font: 600 26px/1 var(--display);
}

.field-amount-big .input {
  font: 680 38px/1 var(--display);
  min-height: 60px;
}

.when-row {
  display: flex;
  gap: 8px;
}

.when {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.when-date {
  flex: 1.35;
}

.when span {
  white-space: nowrap;
  padding-left: 2px;
}

.dur-label {
  color: var(--accent-text);
  font-weight: 650;
}

.input-when {
  padding: 0 8px;
  font-size: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.input-when::-webkit-date-and-time-value {
  text-align: center;
}

.chip-dur {
  min-width: 56px;
  justify-content: center;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

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

#toast-host {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 44px);
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 550;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease-out;
  max-width: 100%;
}

.toast-error {
  background: var(--bad);
  color: #fff;
}

.toast-action {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  padding: 4px 2px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- login ---------- */

.login {
  min-height: 70dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  max-width: 340px;
  margin: 0 auto;
}

.login-mark {
  font: 750 44px/1 var(--display);
  letter-spacing: -0.03em;
}

.login-lead {
  margin: 0 0 14px;
  color: var(--ink-2);
}

.login .input {
  background: var(--surface);
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 8px;
  cursor: pointer;
}

.login-remember input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink-3) 35%, transparent);
  position: relative;
  transition: background 0.18s ease;
}

.login-remember input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}

.login-remember input:checked {
  background: var(--accent);
}

.login-remember input:checked::after {
  transform: translateX(20px);
}

.login-remember span {
  display: flex;
  flex-direction: column;
  font-size: 15px;
}

.login-remember small {
  color: var(--ink-3);
  font-size: 12.5px;
}

.login .btn:disabled {
  opacity: 0.6;
}

.login-error {
  color: var(--bad);
  min-height: 22px;
  margin: 0;
  font-size: 14px;
}

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