:root {
  color-scheme: light;
  --page: #f3f3f1;
  --surface: #ffffff;
  --soft: #e7e7e4;
  --line: #d4d4cf;
  --ink: #272725;
  --muted: #6f6f69;
  --dark: #3f3f3c;
  --danger: #8d3b3b;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(243, 243, 241, .94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  padding: 4px 0;
}

.shell { width: min(100%, 920px); margin: 0 auto; padding: 24px 16px 64px; }
.view[hidden] { display: none; }
.hero { padding: 30px 0 22px; }
.hero h1, .section-heading h1, .panel h1 { margin: 3px 0 8px; letter-spacing: -.035em; }
.hero h1 { font-size: clamp(2.25rem, 10vw, 4.5rem); }
.hero p:last-child { color: var(--muted); max-width: 500px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); font-size: .73rem; font-weight: 800; }

.home-grid, .stack { display: grid; gap: 12px; }
.home-card {
  text-align: left;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  box-shadow: 0 3px 10px rgba(0,0,0,.025);
}
.home-card:hover, .home-card:focus-visible { border-color: #999993; transform: translateY(-1px); }
.home-card-title { color: var(--ink); font-size: 1.22rem; font-weight: 800; }
.restore-row { margin-top: 18px; text-align: center; }
.link-button, .back { border: 0; background: transparent; color: var(--muted); text-decoration: underline; padding: 7px 0; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 20px; }
.section-heading h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}
.button-primary { background: var(--dark); border-color: var(--dark); color: white; }
.button-quiet { background: var(--soft); }
.button-small { padding: 7px 9px; font-size: .72rem; }
.button-wide { width: 100%; margin-top: 12px; padding: 14px; }

.panel, .recipe-card, .history-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.recipe-card h2, .history-card h2 { margin: 0 0 6px; font-size: 1.15rem; }
.recipe-card p, .history-card p { color: var(--muted); margin: 0 0 14px; }
.card-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

label { display: grid; gap: 7px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfa;
  color: var(--ink);
  padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid #d7d7d2; border-color: #888883; }
textarea { resize: vertical; }
small, .hint, .note { color: var(--muted); font-weight: 400; }
.hint, .note { margin: 4px 0 0; font-size: .86rem; }
.note { margin-top: 12px; }

.row-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 10px; }
.row-title h2 { margin: 0; font-size: 1.12rem; }
.icon-button {
  width: 31px; height: 31px; border-radius: 50%; border: 1px solid #a5a59f;
  background: var(--soft); color: var(--ink); font-size: 1.25rem; line-height: 1;
}
.ingredient-list, .budget-lines { display: grid; gap: 10px; }
.ingredient-row, .budget-line {
  display: grid;
  grid-template-columns: 1fr 1fr 32px;
  align-items: end;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ecece8;
}
.remove-line { border: 0; background: transparent; color: var(--danger); font-size: 1.5rem; min-height: 42px; }
.budget-line { grid-template-columns: 1fr; position: relative; padding-right: 38px; }
.budget-line-info { display: grid; grid-template-columns: 1.25fr .75fr; gap: 8px; }
.budget-line .remove-line { position: absolute; right: 0; top: 3px; }
.money-input { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; background: #fbfbfa; }
.money-input input { border: 0; padding-left: 2px; background: transparent; }
.money-input input:focus { outline: 0; }
.cost-label { font-size: .86rem; color: var(--muted); }
.fields-grid { display: grid; gap: 14px; }
.compact-label { width: min(100%, 270px); font-size: .84rem; color: var(--muted); }

.total-card { background: var(--dark); color: white; border-radius: var(--radius); padding: 18px; margin: 12px 0; }
.total-card > div { display: flex; justify-content: space-between; gap: 20px; padding: 7px 0; color: #dededb; }
.total-card strong { color: white; }
.total-card .grand-total { border-top: 1px solid #6d6d68; margin-top: 8px; padding-top: 16px; font-size: 1.22rem; font-weight: 800; color: white; }
.history-meta { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.history-total { font-size: 1.35rem; font-weight: 850; }
.empty { text-align: center; color: var(--muted); border: 1px dashed #bdbdb7; border-radius: var(--radius); padding: 34px 18px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #252524; color: white; border-radius: 999px; padding: 10px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 20; white-space: nowrap;
}

@media (min-width: 680px) {
  .shell { padding: 38px 24px 80px; }
  .topbar { padding: 16px 28px; }
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  .home-card { min-height: 180px; }
  .panel { padding: 22px; }
  .budget-line { grid-template-columns: 1fr 210px 32px; padding-right: 0; }
  .budget-line .remove-line { position: static; }
  .fields-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .topbar { align-items: flex-start; }
  .brand { white-space: nowrap; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .ingredient-row { grid-template-columns: 1fr 92px 30px; }
  .ingredient-row label { font-size: .82rem; }
}
