/* Tokens first. The shell's slot is the one that must survive every redesign:
   inside the Second Draft shell a 48px round button floats in the bottom-right
   corner, 16px in from each edge, above everything. Nothing tappable goes
   there. Applied everywhere, shell or not, so one stylesheet stays right. */
:root {
  --shell-switcher-size: 48px;
  --shell-switcher-inset: 16px;
  --shell-switcher-gap: 16px;
  --shell-slot: 80px; /* inset + size + gap: the corner the shell owns */

  --ink: #1f1d1b;
  --quiet: #6b6560;
  --paper: #f7f5f2;
  --card: #ffffff;
  --line: #e4dfd9;
  --accent: #5b3a5e;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
body { min-height: 100dvh; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px calc(env(safe-area-inset-bottom, 0px) + var(--shell-slot));
}
.page-heading { font-size: 1.6rem; margin: 0 0 8px; }
.quiet { color: var(--quiet); margin: 0; }

button, input, select, textarea { font: inherit; }
.button {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.button--quiet { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

#content { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

.month-nav { display: flex; align-items: center; gap: 12px; }
.month-nav strong { flex: 1; text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card h2 { margin: 0; font-size: 1.05rem; }

.budget-bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.budget-bar-fill { height: 100%; background: var(--accent); }
.budget-bar-fill--over { background: #b3413a; }
.warn { color: #b3413a; margin: 0; }

.budget-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.budget-form input { width: 110px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

.insights { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 6px; }

.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.category-list li { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px; }
.category-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.category-bar span { display: block; height: 100%; background: var(--accent); }

.transaction-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.transaction-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.transaction-list li:first-child { border-top: 0; padding-top: 0; }
.transaction-desc { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.transaction-list select { padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); }
.one-off-toggle { display: flex; align-items: center; gap: 4px; color: var(--quiet); font-size: 0.9rem; }

.rule-suggestion {
  background: var(--card); border: 1px solid var(--accent); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.rule-suggestion p { margin: 0; }
.rule-suggestion-actions { display: flex; gap: 8px; }

/* Messages that are not the page: keep out of the shell's 80×80 corner. */
#toast {
  position: fixed; left: 16px; right: var(--shell-slot);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--shell-switcher-inset));
  pointer-events: none;
}
#toast:empty { display: none; }
#toast > * { background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 16px; }
