/* ──────────────────────────────────────────────────────────
   Spine — design tokens
   Warm, calm, ND-friendly. Sage + terracotta. Generous space.
   ────────────────────────────────────────────────────────── */

:root {
  /* Palette — light mode */
  --cream: #faf6ef;
  --paper: #ffffff;
  --paper-2: #f5f0e6;
  --sage: #5b6e5a;
  --sage-soft: #c9d3c3;
  --sage-faint: #e7ede2;
  --sage-deep: #3d4d3c;
  --terracotta: #c97064;
  --terracotta-soft: #f4d4ce;
  --terracotta-faint: #fbeae5;
  --sand: #e8e1d0;
  --sand-line: #d6cdb8;
  --gold: #c9985c;
  --ink: #2a2a2e;
  --ink-soft: #6b6b73;
  --ink-faint: #a0a0a8;

  /* Type scale */
  --t-xs: 12px;
  --t-sm: 14px;
  --t-md: 16px;
  --t-lg: 18px;
  --t-xl: 22px;
  --t-2xl: 28px;
  --t-3xl: 36px;
  --t-4xl: 56px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --tap: 56px;
  --shadow-soft: 0 1px 2px rgba(40, 38, 30, 0.04), 0 4px 12px rgba(40, 38, 30, 0.04);
  --shadow-warm: 0 4px 24px rgba(201, 112, 100, 0.12);
  --transition: 200ms cubic-bezier(0.2, 0.8, 0.3, 1);

  font-size: 17px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cream: #1a1812;
    --paper: #25221c;
    --paper-2: #2c2922;
    --sage: #8aa089;
    --sage-soft: #3d4d3c;
    --sage-faint: #2c352b;
    --sage-deep: #c9d3c3;
    --terracotta: #d99583;
    --terracotta-soft: #4a2a25;
    --terracotta-faint: #2e1f1c;
    --sand: #34302a;
    --sand-line: #44402a;
    --gold: #d4a851;
    --ink: #ece8df;
    --ink-soft: #b0aca0;
    --ink-faint: #76726a;
    --shadow-soft: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
    --shadow-warm: 0 4px 24px rgba(217, 149, 131, 0.1);
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, p, ul, ol, li, figure, blockquote, dl, dd { margin: 0; }
ul[role='list'], ol[role='list'] { list-style: none; padding: 0; }
button { font: inherit; cursor: pointer; }
input, textarea, select, button { font-family: inherit; }
a { color: inherit; }

html, body {
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Text', system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior: none; }

/* App shell */
#app {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
}
main#view {
  flex: 1;
  padding: var(--s-6) var(--s-5);
  padding-bottom: calc(var(--tap) + var(--s-8));
  max-width: 600px; width: 100%; margin: 0 auto;
  animation: fadeIn 280ms ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bottom nav */
nav#nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tap) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--sand);
  z-index: 50;
  box-shadow: 0 -2px 12px rgba(40, 38, 30, 0.04);
}
nav#nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-faint);
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
nav#nav a svg { width: 22px; height: 22px; }
nav#nav a:active { transform: scale(0.94); }
nav#nav a.active { color: var(--sage); }
nav#nav a.active svg { color: var(--sage); }

/* Typography */
h1 {
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: var(--s-2);
}
h2 {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: var(--s-6) 0 var(--s-3);
}
p { color: var(--ink-soft); line-height: 1.55; }
.subtitle {
  color: var(--ink-soft);
  font-size: var(--t-sm);
  margin-bottom: var(--s-6);
}
.muted { color: var(--ink-soft); font-size: var(--t-sm); }
.faint { color: var(--ink-faint); font-size: var(--t-xs); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t-xs);
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: var(--s-1);
}

/* Card */
.card {
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow-soft);
}
.card.warm {
  background: var(--terracotta-faint);
  border-color: var(--terracotta-soft);
}
.card.sage {
  background: var(--sage-faint);
  border-color: var(--sage-soft);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-6);
  background: var(--sage);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: var(--t-md);
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  width: 100%;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 2px rgba(61, 77, 60, 0.12);
}
.btn:hover { background: var(--sage-deep); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--sand-line);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--paper-2); }
.btn-warm { background: var(--terracotta); box-shadow: 0 1px 2px rgba(201, 112, 100, 0.15); }
.btn-warm:hover { background: var(--terracotta); filter: brightness(0.95); }

/* Forms */
input[type="text"], input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-3) var(--s-4);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--sand-line);
  border-radius: var(--radius);
  font-size: var(--t-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-faint);
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6b73' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-4) center;
  padding-right: var(--s-10);
}

label {
  display: block;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--s-2);
}
.field { margin-bottom: var(--s-5); }
.help {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  margin-top: var(--s-2);
}

/* Capacity tile row — warm and tactile */
.capacity-row { display: flex; gap: var(--s-2); }
.capacity-row button {
  flex: 1;
  min-height: 64px;
  background: var(--paper);
  color: var(--ink-soft);
  border: 1.5px solid var(--sand);
  border-radius: var(--radius);
  font-size: var(--t-xl);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.capacity-row button:active { transform: scale(0.96); }
.capacity-row button.selected {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(91, 110, 90, 0.25);
}

/* Day-type toggles */
.day-type-row { display: flex; gap: var(--s-2); }
.day-type-row button {
  flex: 1; min-height: 48px;
  border: 1px solid var(--sand);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: var(--radius);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.day-type-row button.selected {
  background: var(--sage-faint);
  color: var(--sage-deep);
  border-color: var(--sage);
}

/* Priority highlight card */
.priority-card {
  padding: var(--s-5);
  background: var(--sage-faint);
  border: 1px solid var(--sage-soft);
  border-radius: var(--radius-lg);
  margin-bottom: var(--s-4);
}
.priority-card .domain {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sage);
  margin-bottom: var(--s-1);
  font-weight: 600;
}
.priority-card .text {
  font-size: var(--t-lg);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}

/* Outcome selector */
.outcome-row { display: flex; gap: var(--s-3); }
.outcome-row button {
  flex: 1; min-height: var(--tap);
  border: 1px solid var(--sand);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.outcome-row button.selected {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
}

/* Mic button */
.mic-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 18px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--sand-line);
  border-radius: var(--radius-pill);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.mic-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.mic-btn.recording {
  background: var(--terracotta);
  color: white;
  border-color: var(--terracotta);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 112, 100, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(201, 112, 100, 0); }
}

/* Status / messages */
.error {
  color: var(--terracotta);
  background: var(--terracotta-faint);
  border: 1px solid var(--terracotta-soft);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  margin: var(--s-3) 0;
  font-size: var(--t-sm);
}
.success {
  color: var(--sage-deep);
  background: var(--sage-faint);
  border: 1px solid var(--sage-soft);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  margin: var(--s-3) 0;
  font-size: var(--t-sm);
}
.info {
  color: var(--gold);
  background: rgba(201, 152, 92, 0.08);
  border: 1px solid rgba(201, 152, 92, 0.2);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  margin: var(--s-3) 0;
  font-size: var(--t-sm);
}

/* Centered empty / loading screens */
.center-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 70vh;
  gap: var(--s-5);
  text-align: center;
  padding: 0 var(--s-4);
  animation: slideUp 320ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.center-screen .icon-large {
  width: 72px; height: 72px;
  color: var(--sage);
  margin-bottom: var(--s-2);
}
.center-screen .icon-large.warm { color: var(--terracotta); }
.center-screen .icon-large.gold { color: var(--gold); }

/* Spinner */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--sand);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Stats / numbers */
.stat {
  text-align: center;
  padding: var(--s-6);
}
.stat .number {
  font-size: var(--t-4xl);
  font-weight: 600;
  color: var(--sage);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat .number.warm { color: var(--terracotta); }
.stat .number.gold { color: var(--gold); }
.stat .label {
  margin-top: var(--s-3);
  color: var(--ink-soft);
  font-size: var(--t-sm);
}
.stat .sub {
  margin-top: var(--s-1);
  color: var(--ink-faint);
  font-size: var(--t-xs);
}

/* Item list (wins, etc) */
.item-list { margin-top: var(--s-2); }
.item-list .item {
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--sand);
}
.item-list .item:last-child { border-bottom: none; }
.item-list .item .item-text {
  color: var(--ink);
  font-size: var(--t-md);
  line-height: 1.4;
}
.item-list .item .item-meta {
  margin-top: var(--s-1);
  color: var(--ink-faint);
  font-size: var(--t-xs);
}

/* Triage card (Sunday) */
.triage-card {
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  padding: var(--s-8) var(--s-5);
  text-align: center;
  margin: var(--s-5) 0;
  box-shadow: var(--shadow-soft);
  animation: pop 240ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.triage-card .item-text {
  font-size: var(--t-lg);
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}
.triage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.triage-grid button { width: 100%; min-height: 60px; }

/* Pill / chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 14px;
  background: var(--sage-faint);
  color: var(--sage-deep);
  border-radius: var(--radius-pill);
  font-size: var(--t-sm);
  font-weight: 500;
}
.chip.warm { background: var(--terracotta-faint); color: var(--terracotta); }
.chip.gold { background: rgba(201, 152, 92, 0.12); color: var(--gold); }

/* Draggable priority pill (calendar view) */
.priority-drag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 16px;
  background: var(--sage-faint);
  border: 1px solid var(--sage-soft);
  border-radius: var(--radius-pill);
  font-size: var(--t-sm);
  cursor: grab;
  user-select: none;
  color: var(--sage-deep);
  transition: all var(--transition);
}
.priority-drag:active { cursor: grabbing; transform: scale(0.97); }
.priority-drag strong { font-weight: 600; color: var(--sage); }

/* Inline link styling */
.link {
  color: var(--sage);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}
.link:hover { border-bottom-color: var(--sage); }

/* Cal view toolbar */
.cal-toolbar {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 4px;
}
.cal-toolbar button {
  flex: 1;
  height: 40px;
  padding: 0 var(--s-3);
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: var(--t-sm);
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
}
.cal-toolbar button.active {
  background: var(--sage);
  color: white;
}

/* FullCalendar overrides for our palette */
.fc {
  --fc-border-color: var(--sand);
  --fc-page-bg-color: var(--paper);
  --fc-neutral-bg-color: var(--paper-2);
  --fc-today-bg-color: var(--sage-faint);
  --fc-event-bg-color: var(--sage);
  --fc-event-border-color: var(--sage);
  --fc-list-event-hover-bg-color: var(--sage-faint);
  font-family: inherit;
}
.fc .fc-button-primary {
  background: var(--paper);
  border: 1px solid var(--sand);
  color: var(--ink);
  font-weight: 500;
  text-transform: none;
}
.fc .fc-button-primary:not(:disabled):hover {
  background: var(--paper-2);
  border-color: var(--sand-line);
  color: var(--ink);
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--sage);
  border-color: var(--sage);
  color: white;
}
.fc .fc-toolbar-title {
  font-size: var(--t-lg);
  font-weight: 600;
}
.fc .fc-event { border-radius: 6px; padding: 2px 4px; font-size: var(--t-xs); }

/* Sliders / progress */
.progress {
  height: 8px;
  background: var(--sand);
  border-radius: 4px;
  overflow: hidden;
}
.progress > .bar {
  height: 100%;
  background: var(--sage);
  border-radius: 4px;
  transition: width 400ms ease-out;
}

/* Bar chart for patterns */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: var(--s-3) 0;
}
.bar-chart .bar {
  flex: 1;
  background: var(--sage);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
  transition: height 400ms ease-out;
}
.bar-chart .bar.empty { background: var(--sand); }
.bar-chart .bar .label {
  position: absolute;
  bottom: -20px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--ink-faint);
}

/* Win celebration check */
.celebrate-check {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--sage);
  display: flex; align-items: center; justify-content: center;
  color: white;
  animation: pop 360ms cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 8px 24px rgba(91, 110, 90, 0.3);
}
.celebrate-check svg { width: 40px; height: 40px; }

/* Streak counter */
.streak {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 12px;
  background: var(--terracotta-faint);
  color: var(--terracotta);
  border-radius: var(--radius-pill);
  font-size: var(--t-sm);
  font-weight: 500;
}

/* Toggle row (calendar visibility) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--sand);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-label {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-md);
  color: var(--ink);
}
.toggle-row .toggle-label .swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
}

/* Switch */
.switch {
  position: relative;
  width: 44px; height: 26px;
  background: var(--sand);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch.on { background: var(--sage); }
.switch.on::after { transform: translateX(18px); }

/* Utility */
.center { text-align: center; }
.row { display: flex; gap: var(--s-3); align-items: center; }
.row.between { justify-content: space-between; }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.hidden { display: none !important; }

/* Logo wordmark */
.wordmark {
  font-size: var(--t-3xl);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--sage);
  font-family: 'Iowan Old Style', 'Charter', 'Georgia', serif;
}

/* Floating Action Button — quick capture */
#capture-fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tap) + env(safe-area-inset-bottom, 0px) + 12px);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--terracotta);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(201, 112, 100, 0.35), 0 2px 6px rgba(0,0,0,0.1);
  z-index: 60;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}
#capture-fab:hover { transform: scale(1.05); }
#capture-fab:active { transform: scale(0.95); }
#capture-fab svg { width: 24px; height: 24px; }

/* Modal */
#capture-modal, .modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: flex-end;
  animation: fadeIn 200ms ease-out;
}
@media (min-width: 600px) {
  #capture-modal, .modal { align-items: center; }
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 18, 12, 0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--paper);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--s-6) var(--s-5);
  padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  animation: slideUp 280ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
@media (min-width: 600px) {
  .modal-card {
    border-radius: var(--radius-lg);
    margin: var(--s-6);
  }
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.modal-close:hover { background: var(--paper-2); color: var(--ink); }

/* Inbox / pending list rows */
.list-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  margin-bottom: var(--s-3);
}
.list-row .row-content { flex: 1; min-width: 0; }
.list-row .row-text {
  font-size: var(--t-md);
  color: var(--ink);
  line-height: 1.4;
  word-break: break-word;
}
.list-row .row-meta {
  margin-top: var(--s-1);
  font-size: var(--t-xs);
  color: var(--ink-faint);
}
.list-row .row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.row-icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--sand);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.row-icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.row-icon-btn.danger:hover { background: var(--terracotta-faint); color: var(--terracotta); border-color: var(--terracotta-soft); }
.row-icon-btn.success:hover { background: var(--sage-faint); color: var(--sage); border-color: var(--sage-soft); }

/* Section in inbox/parking */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: var(--s-6) 0 var(--s-3);
}
.section-header h2 {
  margin: 0;
}
.section-count {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  font-weight: 500;
}

/* Empty section */
.empty-section {
  text-align: center;
  padding: var(--s-6) var(--s-4);
  color: var(--ink-faint);
  font-size: var(--t-sm);
}

/* Money — currency display */
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.amount.income { color: var(--sage); }
.amount.expense { color: var(--terracotta); }
.amount.neutral { color: var(--ink); }
.amount.large { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.01em; }
.amount.huge { font-size: var(--t-4xl); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }

/* Money summary row */
.money-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.money-summary > .card { margin: 0; padding: 16px; }
.money-summary .label {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.money-summary .value {
  font-size: var(--t-xl);
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Money section identity — gold/sand accent */
.money-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.money-header .accent-tag {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--gold);
  background: rgba(201, 152, 92, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
}

/* Category swatch */
.cat-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Category type chip */
.cat-type {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.cat-type.essential { background: var(--terracotta-faint); color: var(--terracotta); }
.cat-type.discretionary { background: rgba(201, 152, 92, 0.15); color: var(--gold); }
.cat-type.income { background: var(--sage-faint); color: var(--sage); }
.cat-type.savings { background: var(--sage-faint); color: var(--sage); }
.cat-type.debt { background: var(--terracotta-faint); color: var(--terracotta); }

/* Transaction row */
.txn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--sand);
  cursor: pointer;
  transition: background var(--transition);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 8px;
}
.txn-row:hover { background: var(--paper-2); }
.txn-row .txn-content { flex: 1; min-width: 0; }
.txn-row .txn-desc {
  font-size: var(--t-md);
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txn-row .txn-meta {
  margin-top: 2px;
  font-size: var(--t-xs);
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.txn-row .txn-amount {
  flex-shrink: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Progress bar with target overlay */
.budget-bar {
  position: relative;
  height: 8px;
  background: var(--sand);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.budget-bar > .fill {
  height: 100%;
  background: var(--sage);
  border-radius: 4px;
  transition: width 400ms ease-out;
}
.budget-bar > .fill.over { background: var(--terracotta); }
.budget-bar > .fill.warning { background: var(--gold); }

/* Bill row */
.bill-row {
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bill-row.upcoming { border-color: var(--gold); background: rgba(201, 152, 92, 0.05); }
.bill-row.overdue { border-color: var(--terracotta); background: var(--terracotta-faint); }
.bill-row .bill-due {
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bill-row.upcoming .bill-due { color: var(--gold); }
.bill-row.overdue .bill-due { color: var(--terracotta); }
.bill-row.fine .bill-due { color: var(--ink-faint); }

/* ──────────────────────────────────────────────────────────
   Tile-grid landing (TwoNests-style home)
   ────────────────────────────────────────────────────────── */
.home-header { margin-bottom: 24px; }
.home-greeting {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-family: 'Iowan Old Style', 'Charter', 'Georgia', serif;
  color: var(--ink);
  margin-bottom: 6px;
}
.home-quickrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.quick-stat:active { transform: scale(0.98); }
.quick-stat .quick-num {
  font-size: 32px;
  font-weight: 600;
  color: var(--sage);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.quick-stat .quick-label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  text-align: center;
}
.quick-stat.done .quick-num { color: var(--sage); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px 16px;
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 130px;
}
.tile:active { transform: scale(0.97); }
.tile:hover { box-shadow: var(--shadow-soft); border-color: var(--sand-line); }
.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  margin-bottom: 12px;
}
.tile-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.tile-desc {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.35;
}
.tile--sage       .tile-icon { color: var(--sage); }
.tile--sage-deep  .tile-icon { color: var(--sage-deep); }
.tile--gold       .tile-icon { color: var(--gold); }
.tile--terracotta .tile-icon { color: var(--terracotta); }

@media (min-width: 540px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .home-quickrow { max-width: 480px; }
}

/* ──────────────────────────────────────────────────────────
   TwoNests-style week calendar
   ────────────────────────────────────────────────────────── */
.cal-week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
}
.cal-range {
  font-size: var(--t-xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-family: 'Iowan Old Style', 'Charter', 'Georgia', serif;
}
.cal-nav-btn {
  width: 40px; height: 40px;
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: 12px;
  font-size: 22px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.cal-nav-btn:hover { background: var(--paper-2); color: var(--ink); }
.cal-nav-btn:active { transform: scale(0.94); }

.day-card {
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.day-card.today {
  border-color: var(--sage);
  background: var(--sage-faint);
}
.day-card.past { opacity: 0.7; }
.day-card.drop-target {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 152, 92, 0.15);
}
.day-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-card-header:active { background: var(--paper-2); }
.day-card.today .day-card-header:active { background: var(--sage-soft); }
.day-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.day-card.today .day-name { color: var(--sage-deep); }
.day-date {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.day-add-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px dashed var(--sand-line);
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.day-card-header:hover .day-add-btn { border-color: var(--sage); color: var(--sage); }
.day-card.today .day-add-btn { border-color: var(--sage); color: var(--sage); border-style: solid; }
.day-empty {
  padding: 0 18px 14px;
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}
.day-events { padding: 0 12px 12px; }
.event-chip {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--paper);
  border-left: 3px solid var(--chip-color, var(--sage));
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.event-chip:hover { background: var(--paper-2); }
.event-chip:active { transform: scale(0.99); }
.event-chip .event-time {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 90px;
}
.event-chip .event-title {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.priority-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--sage-faint);
  color: var(--sage-deep);
  border: 1px solid var(--sage-soft);
  border-radius: var(--radius-pill);
  font-size: 13px;
  cursor: grab;
  user-select: none;
  transition: transform var(--transition);
}
.priority-pill:active, .priority-pill.dragging { cursor: grabbing; transform: scale(0.96); opacity: 0.7; }
.priority-pill strong { font-weight: 600; }

/* ──────────────────────────────────────────────────────────
   Improved modal / dialog
   ────────────────────────────────────────────────────────── */
.modal-card h2 {
  font-family: 'Iowan Old Style', 'Charter', 'Georgia', serif;
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.modal.closing { animation: fadeOut 180ms ease-out forwards; }
.modal.closing .modal-card { animation: slideDown 180ms ease-out forwards; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes slideDown {
  to { transform: translateY(20px); opacity: 0; }
}
.modal-card { box-shadow: 0 -8px 40px rgba(0,0,0,0.18), 0 -2px 8px rgba(0,0,0,0.08); }
@media (min-width: 600px) {
  .modal-card { box-shadow: 0 8px 40px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.1); }
}
.modal-card .field:last-of-type { margin-bottom: 24px; }
.modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--transition);
}
.modal-close:hover {
  background: var(--paper-2);
  color: var(--ink);
}
.modal-close:active { transform: scale(0.93); }

/* Thermometer / progress bar */
.thermometer {
  position: relative;
  width: 100%;
  height: 36px;
  background: var(--paper-2);
  border: 1px solid var(--sand);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.thermometer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--gold), #d9b074);
  border-radius: 18px;
  transition: width 600ms cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 1px 4px rgba(201, 152, 92, 0.3);
}
.thermometer-fill.complete {
  background: linear-gradient(90deg, var(--sage), var(--sage-deep));
  box-shadow: 0 1px 4px rgba(91, 110, 90, 0.3);
}
.thermometer-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 50%);
  border-radius: 18px;
}
.thermometer-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(255,255,255,0.6);
  z-index: 2;
}
@media (prefers-color-scheme: dark) {
  .thermometer-label { text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
}

/* Hero strip — Pots dashboard summary at the top of home */
.hero-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.hero-strip .hero-card--primary {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--paper) 0%, var(--paper-2) 100%);
  border-color: var(--gold);
}
.hero-card {
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 110px;
}
.hero-card:active { transform: scale(0.98); }
.hero-card:hover { box-shadow: var(--shadow-soft); }
.hero-card--warning { border-color: var(--gold); background: rgba(201, 152, 92, 0.06); }
.hero-card .hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 6px;
}
.hero-card .hero-amount {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.hero-card--primary .hero-amount { font-size: 36px; }
.hero-card .hero-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: auto;
}
.hero-card .hero-bar {
  height: 6px;
  margin: 8px 0 4px;
}

@media (min-width: 540px) {
  .hero-strip { grid-template-columns: repeat(3, 1fr); }
  .hero-strip .hero-card--primary { grid-column: span 3; }
}
