/* ------------------------------------------------------------ Tokens */

:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #fffdfa;
  --surface-2: #f1ede6;
  --ink: #1d1b18;
  --ink-2: #57534c;
  --muted: #827d74;
  --line: #e6e1d8;
  --grid: #ece8e0;
  --axis: #c9c4b9;
  --brand: #b9501d;
  --brand-hover: #a3461a;
  --on-brand: #ffffff;
  --brand-soft: #f9e5d9;
  --good: #0ca30c;
  --good-ink: #0b6b0b;
  --good-soft: #e1f2dd;
  --danger: #b92f2f;
  --danger-soft: #fae2df;
  --focus: #2a78d6;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.05), 0 6px 20px rgb(60 40 20 / 0.05);
  --backdrop: rgb(30 20 10 / 0.35);

  /* Categorical palette (validated order) – tracker colors */
  --c0: #2a78d6;
  --c1: #eb6834;
  --c2: #1baf7a;
  --c3: #eda100;
  --c4: #e87ba4;
  --c5: #008300;
  --c6: #6250d6;
  --c7: #e34948;

  --accent: var(--brand);
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121110;
    --surface: #1c1b19;
    --surface-2: #262522;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #96928a;
    --line: #2f2e2b;
    --grid: #2a2927;
    --axis: #45443f;
    --brand: #e0743f;
    --brand-hover: #ea8655;
    --on-brand: #1a0f08;
    --brand-soft: #3a241a;
    --good: #2fb52f;
    --good-ink: #74d474;
    --good-soft: #1a2d19;
    --danger: #f07a7a;
    --danger-soft: #3b1e1d;
    --focus: #6aa8f0;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --backdrop: rgb(0 0 0 / 0.55);

    --c0: #3987e5;
    --c1: #d95926;
    --c2: #199e70;
    --c3: #c98500;
    --c4: #d55181;
    --c5: #008300;
    --c6: #9085e9;
    --c7: #e66767;
  }
}

/* ------------------------------------------------------------ Base */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; }
a { color: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

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

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.block { display: block; }
.error-text { color: var(--danger); }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------ Layout */

.view {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) 8px 0;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-spacer { width: 44px; }
.topbar-title { min-width: 0; display: flex; justify-content: center; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; min-width: 44px; justify-content: flex-end; }

.page {
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0 4px;
}

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

.card.flush { padding: 0; overflow: hidden; }
.card-heading { font-size: 0.95rem; }

.empty-card { display: flex; flex-direction: column; gap: 6px; text-align: center; padding: 28px 20px; }
.error-card { text-align: center; align-items: center; }

/* ------------------------------------------------------------ Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }

.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); }

.btn.ghost { background: transparent; border-style: dashed; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface); }

.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }

.btn.quiet-btn[aria-pressed='true'] {
  background: var(--good-soft);
  border-color: color-mix(in oklab, var(--good) 45%, var(--surface));
  color: var(--good-ink);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }

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

.fab {
  position: fixed;
  right: max(16px, calc(50vw - 304px));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 6;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 20px;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
  cursor: pointer;
}

.fab .icon { width: 28px; height: 28px; }
.fab:hover { background: var(--brand-hover); }

/* ------------------------------------------------------------ Home */

.pet-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  padding: 0 12px 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}

.pet-switch:hover { background: var(--surface-2); }
.pet-emoji { font-size: 1.5rem; line-height: 1; }
.pet-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tracker-card { display: flex; flex-direction: column; gap: 14px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin: -4px;
  padding: 4px;
  border-radius: 12px;
}

.card-head > .icon { color: var(--muted); margin-left: auto; }
.card-title { display: flex; flex-direction: column; min-width: 0; }

.tracker-emoji {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  font-size: 1.5rem;
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
}

.card-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card-actions .btn { flex: 1 1 0; max-width: 220px; }

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding-top: 18vh;
}

.welcome p { color: var(--ink-2); max-width: 30em; }
.welcome-mark {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 28px;
  font-size: 3rem;
  background: var(--brand-soft);
}

/* Day squares (strip + calendar share the status colors) */

.day-strip {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 3px;
}

.day-strip li { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.day-cell-wd { font-size: 0.65rem; color: var(--muted); line-height: 1; }

.day-cell, .cal-day {
  --cell-bg: var(--surface-2);
  position: relative;
  display: grid;
  place-items: center;
  border: 1.5px solid transparent;
  background: var(--cell-bg);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.day-cell {
  width: 100%;
  aspect-ratio: 1 / 1.25;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.day-cell .icon, .cal-day .icon { width: 14px; height: 14px; stroke-width: 3; color: var(--good-ink); }

.event { --cell-bg: color-mix(in oklab, var(--accent) 24%, var(--surface)); border-color: color-mix(in oklab, var(--accent) 70%, var(--surface)); }
.quiet { --cell-bg: var(--good-soft); }
.unknown { border: 1.5px dashed var(--line); background: transparent; }

/* ------------------------------------------------------------ Tracker view */

.tabs {
  position: sticky;
  top: calc(56px + env(safe-area-inset-top));
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 0 16px 8px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.92rem;
}

.tab .icon { width: 18px; height: 18px; }
.tab[aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav h2 { text-transform: capitalize; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-wd { text-align: center; font-size: 0.75rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }

.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 1px;
}

.cal-day:disabled { opacity: 0.35; cursor: default; }
.cal-num { font-size: 0.8rem; color: var(--ink-2); line-height: 1; }
.cal-day .day-count { font-weight: 750; font-size: 0.95rem; line-height: 1; }
.cal-day.today { box-shadow: 0 0 0 2px var(--brand); }
.cal-grid.quick .cal-day.unknown:not(:disabled) { border-color: var(--good); }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 0.8rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }

.legend-key {
  --cell-bg: var(--surface-2);
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid transparent;
  background: var(--cell-bg);
  vertical-align: -3px;
}

.legend-key .icon { width: 11px; height: 11px; stroke-width: 3; color: var(--good-ink); }
.legend-key.inline { width: 16px; height: 5px; border-radius: 2px; background: var(--good); border: 0; vertical-align: 2px; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented button {
  flex: 1 0 auto;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.tiles.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.tiles.compact .tile { padding: 10px 12px; background: var(--surface-2); box-shadow: none; border: 0; }
.tiles.compact .tile-value { font-size: 1.1rem; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.tile-label { font-size: 0.8rem; color: var(--ink-2); }
.tile-value { font-size: 1.5rem; font-weight: 650; line-height: 1.2; }
.tile-sub { font-size: 0.78rem; color: var(--muted); }

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

/* ------------------------------------------------------------ Charts */

.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .quiet-mark { fill: var(--good); }
.chart .hit { fill: transparent; }
.chart .hover-band { fill: var(--ink); opacity: 0.06; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 650; }

.chart-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.8rem;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
}

.bar-list { display: flex; flex-direction: column; gap: 10px; }

.bar-list li {
  display: grid;
  grid-template-columns: minmax(80px, 34%) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.bar-list li.muted .bar-fill { background: var(--axis); }
.bar-value { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.85rem; text-align: right; }

/* ------------------------------------------------------------ Entries */

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

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.entry-row:hover { background: var(--surface-2); }
.entry-row > .icon { color: var(--muted); margin-left: auto; }
.sheet .entry-row { padding-inline: 4px; }

.entry-when { display: flex; flex-direction: column; min-width: 46px; font-variant-numeric: tabular-nums; }
.entry-date { font-weight: 650; font-size: 0.9rem; }
.entry-time { color: var(--muted); font-size: 0.85rem; }
.entry-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.entry-note { color: var(--ink-2); font-size: 0.9rem; overflow-wrap: anywhere; }

.entry-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.82rem;
  line-height: 1.5;
}

.chip.count { background: color-mix(in oklab, var(--accent) 22%, var(--surface)); font-weight: 700; }

.empty-day { padding: 16px 0; color: var(--muted); text-align: center; }
.empty-day.quiet { color: var(--good-ink); font-weight: 600; }
.empty-day .icon { vertical-align: -4px; }

/* ------------------------------------------------------------ Forms */

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

.field-label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  padding: 0;
}

.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

input[type='text'], input[type='password'], input[type='date'], input[type='time'], input:not([type]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1rem;
}

textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit .unit { color: var(--ink-2); font-weight: 600; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.form-actions .btn.primary { min-width: 140px; }
.form-actions .danger-ghost { margin-right: auto; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { position: relative; }

.chip-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.chip-toggle span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 550;
}

.chip-input:checked + span {
  background: color-mix(in oklab, var(--accent) 22%, var(--surface));
  border-color: var(--accent);
}

.chip-input:checked + span::before { content: '✓'; margin-right: 6px; font-weight: 800; }
.chip-input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 550;
}

.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--axis);
  cursor: pointer;
  transition: background 0.15s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.15s;
}

.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .icon-btn { background: var(--surface-2); }
.stepper-value { min-width: 2.5ch; text-align: center; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.emoji-choice {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: var(--surface-2);
  font-size: 1.35rem;
  cursor: pointer;
}

.emoji-choice[aria-pressed='true'] { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 18%, var(--surface)); }
.emoji-picker .emoji-input { width: 72px; text-align: center; font-size: 1.2rem; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--swatch); cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 5px; }

.kind-options { display: grid; gap: 8px; }

.kind-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  cursor: pointer;
}

.kind-option input { margin-top: 4px; accent-color: var(--brand); }
.kind-option:has(input:checked) { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, var(--surface)); }

.field-card { background: var(--surface); }
.field-card-actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: -4px; }
.field-card-actions .danger-ghost { margin-left: auto; }

.option-list { display: flex; flex-direction: column; gap: 6px; }
.option-list li { display: flex; gap: 4px; align-items: center; }
.option-add { display: flex; gap: 8px; align-items: center; }
.option-add .btn { flex: none; }

/* ------------------------------------------------------------ Lists */

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

.link-list a, .pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.link-list a:hover, .pick-row:hover { background: var(--surface-2); }
.link-list a > .icon:last-child { margin-left: auto; color: var(--muted); }
.link-list li.with-actions { display: flex; align-items: center; }
.link-list li.with-actions a { flex: 1; min-width: 0; }
.row-actions { display: flex; padding-right: 6px; }

.pick-list { margin: 0 -16px; }
.pick-row[aria-current='true'] { font-weight: 700; }
.pick-row > .icon:last-child { margin-left: auto; color: var(--brand); }
.pick-emoji { font-size: 1.5rem; width: 32px; text-align: center; }
.pick-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.template-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  text-decoration: none;
}

.template-card:hover { border-color: var(--accent); }
.template-name { font-weight: 700; }
.template-fields { font-size: 0.78rem; color: var(--ink-2); margin-top: auto; padding-top: 4px; }

/* ------------------------------------------------------------ Sheet & toasts */

dialog.sheet {
  width: min(640px, 100%);
  max-width: 100%;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -8px 40px rgb(0 0 0 / 0.2);
  animation: sheet-in 0.2s ease-out;
}

dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: var(--backdrop); }

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

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 8px 4px 16px;
}

.sheet-head h2 { text-transform: none; }

.sheet-body {
  overflow-y: auto;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm-text { color: var(--ink-2); }

@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: 22px; width: min(560px, 100%); }
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 550;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
  transition: opacity 0.3s, transform 0.3s;
}

.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(8px); }

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

@media (forced-colors: active) {
  .event, .quiet { border: 2px solid CanvasText; }
  .chart .bar, .bar-fill { fill: CanvasText; background: CanvasText; }
}

/* ------------------------------------------------------------ Accounts & sharing */

.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 12vh;
  max-width: 420px;
  margin: 0 auto;
}

.auth h1 { font-size: 1.4rem; text-align: center; }
.auth .welcome-mark { font-size: 2.6rem; }
.auth-card { width: 100%; }

.link-btn {
  border: 0;
  background: none;
  padding: 8px;
  color: var(--brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 750;
  font-size: 0.9rem;
}

.account-row { display: flex; align-items: center; gap: 12px; }

.member-list li, .invite-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.member-list li + li, .invite-list li + li { border-top: 1px solid var(--line); }
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.member-name .muted { font-weight: 400; }
.invite-list { border-top: 1px solid var(--line); }
.invite-list li > .icon { color: var(--muted); }
.invite-list li > span { flex: 1; }

.invite-url { font-family: ui-monospace, monospace; font-size: 0.85rem !important; }

.entry-author { font-size: 0.8rem; color: var(--muted); }
