@layer reset, theme, components;
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body { margin: 0; }
  button, input, select, textarea { font: inherit; }
  button, a, input, select { -webkit-tap-highlight-color: transparent; }
  button { cursor: pointer; }
  a { color: inherit; }
  img { max-width: 100%; display: block; }
  [hidden] { display: none !important; }
}
@layer theme {
  :root { --canvas: #faf7f2; --paper: #fff; --olive: #344c3d; --ink: #243026; --muted: #626e64; --sage: #e6ece3; --line: #e8e2d8; --clay: #b85c42; --clay-dark: #93432e; --clay-wash: #f9ebe6; --wash: #f1eee7; --shadow: 0 7px 25px -12px #344c3d25; --radius: 22px; --app-width: 720px; }
  html { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: #eae9e1; color: var(--ink); font-size: 15px; scroll-behavior: smooth; }
  body { background: var(--canvas); min-height: 100dvh; max-width: var(--app-width); margin-inline: auto; box-shadow: 0 0 70px #344c3d08; }
  h1, h2, h3, .serif { font-family: 'Playfair Display', Georgia, serif; color: var(--olive); }
  h1 { font-size: clamp(30px, 7vw, 38px); line-height: 1.16; letter-spacing: -.025em; margin: 7px 0 10px; font-weight: 600; }
  h2 { font-size: 24px; line-height: 1.3; margin: 0 0 12px; font-weight: 600; }
  h3 { font-size: 20px; line-height: 1.35; margin: 0 0 6px; }
  p { line-height: 1.65; margin: 0 0 12px; }
  small { font-size: 12px; line-height: 1.55; }
  button:disabled { opacity: .43; cursor: not-allowed; }
  :focus-visible { outline: 3px solid var(--clay); outline-offset: 3px; }
  ::selection { background: #dbe5d5; }
}
@layer components {
  .app-header { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); background: #faf7f2f5; backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 8px; min-height: 70px; }
  .brand { flex-shrink: 0; text-decoration: none; }
  .brand img { width: 140px; height: 35px; }
  .header-tools { display: flex; align-items: center; gap: 8px; }
  .save-status { font-size: 10px; line-height: 1.3; display: flex; gap: 5px; align-items: center; color: var(--muted); max-width: 96px; }
  .status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--olive); flex-shrink: 0; }
  .save-status.error { color: var(--clay-dark); }
  .save-status.error .status-dot { background: var(--clay); }
  .icon { width: 21px; height: 21px; display: inline-block; flex-shrink: 0; vertical-align: middle; }
  .icon-button { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; min-width: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--wash); color: var(--olive); text-decoration: none; }
  .app-main { padding: 28px 20px calc(115px + env(safe-area-inset-bottom)); min-height: calc(100dvh - 72px); }
  .page-intro { margin-bottom: 24px; }
  .page-intro p { color: var(--muted); font-size: 14px; max-width: 52ch; }
  .eyebrow { display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: .13em; font-size: 10px; font-weight: 700; color: var(--clay-dark); }
  .eyebrow::before { content: ''; width: 6px; height: 6px; background: var(--clay); border-radius: 50%; }
  .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .card-pad { padding: 20px; }
  .stack { display: flex; flex-direction: column; gap: 16px; }
  .row { display: flex; align-items: center; gap: 10px; }
  .between { justify-content: space-between; }
  .wrap { flex-wrap: wrap; }
  .grow { flex: 1; min-width: 0; }
  .muted { color: var(--muted); }
  .tiny { font-size: 11px; }
  .small { font-size: 13px; }
  .strong { font-weight: 700; }
  .mt { margin-top: 16px; }
  .mb { margin-bottom: 16px; }
  .divider { height: 1px; background: var(--line); margin: 18px 0; }
  .button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 52px; padding: 12px 20px; border: 0; border-radius: 30px; background: var(--olive); color: #fff; font-weight: 600; font-size: 14px; text-align: center; text-decoration: none; line-height: 1.4; }
  .button:hover { filter: brightness(.95); }
  .button:active { transform: translateY(1px); }
  .button.secondary { background: var(--sage); color: var(--olive); }
  .button.ghost { background: transparent; color: var(--olive); border: 1px solid var(--line); }
  .button.clay { background: var(--clay-dark); }
  .button.danger { background: var(--clay-wash); color: var(--clay-dark); }
  .button.full { width: 100%; }
  .button.compact { min-height: 48px; padding-inline: 15px; font-size: 12px; }
  .text-button { border: 0; background: transparent; color: var(--olive); min-height: 48px; padding: 8px 10px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
  .field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
  .field > label, .field-label { font-size: 12px; font-weight: 700; color: var(--olive); }
  input:not([type=checkbox]):not([type=file]), select, textarea { color: var(--ink); background: var(--canvas); border: 1px solid #c8cfc4; border-radius: 13px; width: 100%; min-height: 48px; padding: 12px; font-size: 14px; }
  select { cursor: pointer; padding-right: 22px; }
  textarea { resize: vertical; line-height: 1.6; }
  input[type=checkbox] { accent-color: var(--olive); width: 22px; height: 22px; flex-shrink: 0; margin: 0; cursor: pointer; }
  .segmented { display: flex; padding: 4px; gap: 4px; border-radius: 30px; background: var(--wash); }
  .segmented button { flex: 1; min-height: 48px; border: 0; background: transparent; border-radius: 26px; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 8px; }
  .segmented button.active { background: var(--paper); color: var(--olive); box-shadow: 0 2px 6px #344c3d0c; }
  .segmented button .icon { width: 17px; height: 17px; margin-right: 3px; }
  .check-toggle { display: flex; align-items: center; gap: 13px; min-height: 58px; cursor: pointer; padding-block: 7px; }
  .check-toggle span { flex: 1; }
  .check-toggle strong { display: block; font-size: 13px; color: var(--olive); margin-bottom: 4px; }
  .check-toggle small { display: block; color: var(--muted); }
  .pick-button { margin-top: 4px; }
  .recipe-hero { width: 100%; aspect-ratio: 1.9; object-fit: cover; background: var(--sage); }
  .hero-wrap { position: relative; }
  .hero-wrap::after { content: ''; position: absolute; inset: 60% 0 0; background: linear-gradient(transparent, #15291d6b); pointer-events: none; }
  .hero-badge { position: absolute; left: 16px; bottom: 15px; z-index: 1; background: #fffef5eb; color: var(--olive); padding: 7px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; }
  .recipe-title { font-size: 25px; line-height: 1.3; }
  .badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 20px; font-size: 10px; font-weight: 600; background: var(--sage); color: var(--olive); line-height: 1.5; }
  .badge.clay { color: var(--clay-dark); background: var(--clay-wash); }
  .badge.neutral { background: var(--wash); color: var(--muted); }
  .badge .icon { height: 13px; width: 13px; }
  .ingredient-list { list-style: none; padding: 0; margin: 8px 0; }
  .ingredient-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.55; }
  .ingredient-list li:last-child { border-bottom: 0; }
  .ingredient-list .quantity { flex-shrink: 0; font-weight: 700; color: var(--olive); max-width: 46%; text-align: right; }
  .quantity.proposed { color: var(--clay-dark); }
  .legend { color: var(--clay-dark); background: var(--clay-wash); padding: 11px 13px; border-radius: 12px; font-size: 11px; line-height: 1.7; margin-top: 13px; }
  .note { color: var(--muted); background: var(--wash); padding: 13px 15px; border-radius: 14px; font-size: 12px; line-height: 1.7; }
  .section-caption { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 11px; font-weight: 700; }
  .empty { text-align: center; padding: 32px 20px; border-radius: var(--radius); background: var(--paper); border: 1px dashed #c4ccb9; }
  .empty .empty-icon { display: flex; justify-content: center; align-items: center; width: 66px; height: 66px; margin: 0 auto 17px; background: var(--sage); color: var(--olive); border-radius: 50%; }
  .empty .icon { width: 29px; height: 29px; }
  .empty p { font-size: 13px; color: var(--muted); }
  .bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--app-width); z-index: 25; display: grid; grid-template-columns: repeat(4,1fr); padding: 8px 9px calc(8px + env(safe-area-inset-bottom)); background: #fffffff5; backdrop-filter: blur(15px); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #344c3d04; }
  .bottom-nav a { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 5px; text-decoration: none; padding: 9px 4px; border-radius: 16px; color: var(--muted); font-size: 10px; font-weight: 500; min-height: 57px; }
  .bottom-nav a.active { background: var(--sage); color: var(--olive); font-weight: 700; }
  .category-section { margin-bottom: 14px; }
  .category-toggle { border: 0; width: 100%; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 72px; background: var(--paper); color: var(--olive); text-align: left; }
  .category-toggle .serif { font-size: 22px; }
  .category-icon { width: 43px; height: 43px; border-radius: 50%; background: var(--sage); display: grid; place-items: center; }
  .recipe-tiles { padding: 0 14px 14px; display: grid; gap: 10px; }
  .recipe-tile { display: flex; align-items: center; gap: 13px; background: var(--canvas); border-radius: 16px; border: 1px solid var(--line); padding: 10px; text-decoration: none; }
  .recipe-tile img { width: 80px; height: 86px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
  .recipe-tile h3 { font-size: 16px; line-height: 1.4; margin-bottom: 4px; }
  .recipe-tile .badge { margin-top: 5px; }
  .back-row { display: flex; justify-content: space-between; align-items: center; margin-top: -12px; margin-bottom: 12px; gap: 8px; }
  .back-row .text-button { padding-left: 0; }
  .steps { list-style: none; padding: 0; margin: 0; counter-reset: steps; display: grid; gap: 12px; }
  .steps li { counter-increment: steps; display: flex; align-items: flex-start; gap: 12px; background: var(--canvas); border-radius: 15px; padding: 15px; font-size: 13px; line-height: 1.7; }
  .steps li::before { content: counter(steps); width: 27px; height: 27px; min-width: 27px; background: var(--olive); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 12px; line-height: 1; }
  .shortcut-list { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip { min-height: 48px; border: 1px solid var(--line); background: var(--wash); color: var(--olive); border-radius: 24px; padding: 9px 13px; font-size: 11px; line-height: 1.4; font-weight: 600; }
  .chip.active { background: var(--olive); border-color: var(--olive); color: #fff; }
  .selected-meal { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
  .selected-meal:last-child { border-bottom: 0; }
  .selected-meal h3 { font-size: 15px; margin-bottom: 4px; }
  .selected-meal small { font-size: 10px; }
  .stepper { display: flex; align-items: center; border: 1px solid var(--line); background: var(--canvas); border-radius: 26px; flex-shrink: 0; }
  .stepper button { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; background: transparent; color: var(--olive); border-radius: 50%; }
  .stepper output { min-width: 22px; font-size: 15px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
  .stepper .icon { width: 17px; }
  .selected-meal .remove { min-width: 48px; width: 48px; border: 0; background: transparent; color: var(--muted); }
  .shopping-group { margin-top: 23px; }
  .group-title { display: flex; align-items: center; gap: 8px; font-family: 'Plus Jakarta Sans',sans-serif; font-size: 12px; font-weight: 700; color: var(--olive); margin-bottom: 10px; }
  .group-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
  .check-row { display: flex; align-items: center; gap: 12px; min-height: 65px; padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .check-row:last-child { border-bottom: 0; }
  .check-row .name { display: block; font-size: 13px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
  .check-row .quantity { font-size: 12px; color: var(--olive); font-weight: 700; flex-shrink: 0; max-width: 38%; text-align: right; line-height: 1.6; }
  .check-row .quantity.proposed { color: var(--clay-dark); }
  .check-row.checked { background: #e6ece355; }
  .check-row.checked .name { color: var(--muted); }
  .present-label { display: block; color: var(--olive); font-size: 9px; line-height: 1.5; margin-top: 4px; }
  .proposal-label { font-size: 10px; color: var(--clay-dark); }
  .summary-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--sage); color: var(--olive); padding: 14px 16px; border-radius: 15px; font-size: 12px; margin: 15px 0; }
  .search-box { position: relative; }
  .search-box > .icon { position: absolute; left: 14px; top: 15px; color: var(--muted); width: 18px; height: 18px; }
  .search-box input { padding-left: 43px !important; }
  .filter-row { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
  .pantry-check .badge { flex-shrink: 0; }
  .sheet { width: min(100% - 24px, 650px); max-height: 85dvh; background: var(--canvas); color: var(--ink); border: 1px solid var(--line); border-radius: 24px; padding: 20px; overscroll-behavior: contain; box-shadow: 0 20px 80px #13201733; }
  .sheet::backdrop { background: #1e35275c; backdrop-filter: blur(3px); }
  .sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .sheet-header h2 { margin: 0; font-size: 24px; }
  .picker-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .picker-row strong { display: block; font-size: 13px; }
  .sheet-footer { position: sticky; bottom: -20px; margin: 16px -20px -20px; padding: 15px 20px; border-top: 1px solid var(--line); background: var(--canvas); }
  .toast { position: fixed; bottom: calc(95px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 80; width: max-content; max-width: min(90%, 640px); background: var(--olive); color: #fff; padding: 13px 19px; border-radius: 16px; font-size: 12px; line-height: 1.6; box-shadow: 0 5px 25px #0002; }
  .toast.error { background: var(--clay-dark); }
  .update-banner { position: fixed; bottom: calc(94px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 60; width: min(95%,650px); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--olive); color: white; padding: 12px 16px; border-radius: 15px; font-size: 12px; }
  .update-banner button { border: 0; background: white; color: var(--olive); border-radius: 20px; padding: 10px 15px; min-height: 48px; font-weight: 600; }
  .week-day { padding: 19px; }
  .week-day h3 { font-size: 22px; margin-bottom: 16px; }
  .week-day .field { margin-top: 12px; }
  .recipe-editor { display: grid; gap: 20px; }
  .editor-ingredient { padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 12px; }
  .editor-quantity { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .editor-step { display: flex; align-items: flex-start; gap: 8px; }
  .editor-step textarea { min-height: 100px; }
  .editor-step .icon-button { width: 48px; }
  .editor-alternative { border: 1px solid var(--line); border-radius: 18px; background: var(--wash); padding: 15px; }
  .editor-choice { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
  .settings-item { display: flex; align-items: flex-start; gap: 13px; padding-block: 15px; }
  .settings-item .icon { color: var(--clay-dark); margin-top: 2px; }
  .settings-item strong { display: block; font-size: 14px; margin-bottom: 5px; }
  .settings-item p { font-size: 12px; color: var(--muted); margin-bottom: 0; }
  .cooking-card { padding: 27px 23px; background: var(--paper); border-radius: 24px; border: 1px solid var(--line); min-height: 210px; }
  .cooking-step-text { font-family: 'Playfair Display', Georgia, serif; font-size: clamp(22px,5vw,30px); line-height: 1.65; color: var(--olive); }
  .progress { width: 100%; height: 5px; border-radius: 10px; background: var(--line); overflow: hidden; margin-top: 18px; }
  .progress > span { display: block; background: var(--clay); height: 100%; border-radius: inherit; }
  .cooking-controls { display: flex; align-items: center; gap: 10px; }
  .cooking-controls .button { flex: 1; }
  .timer { padding: 17px; border: 1px solid var(--line); background: var(--sage); border-radius: 18px; }
  .timer-time { font-size: 29px; color: var(--olive); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 92px; }
  .timer input { max-width: 95px; background: white !important; }
  .timer .button { padding-inline: 14px; }
  .loading { padding-top: 25px; }
  .notice { background: var(--clay-wash); color: var(--clay-dark); border-radius: 15px; padding: 17px; font-size: 13px; line-height: 1.7; }
  .fatal { padding: 30px; }
  .skip-link { position: fixed; left: 15px; top: -100px; padding: 12px; background: white; color: var(--olive); z-index: 100; }
  .skip-link:focus { top: 12px; }
  details > summary { cursor: pointer; padding-block: 12px; min-height: 48px; color: var(--olive); font-weight: 600; font-size: 13px; }
  @media (min-width: 620px) {
    .app-main { padding-inline: 34px; }
    .header-inner { padding-inline: 34px; }
    .recipe-tiles { grid-template-columns: 1fr 1fr; }
    .recipe-tile img { width: 67px; height: 86px; }
    .save-status { font-size: 11px; max-width: none; }
  }
  @media (max-width: 360px) {
    .app-main { padding-inline: 14px; }
    .header-inner { padding-inline: 14px; }
    .brand img { width: 125px; }
    .save-status { max-width: 70px; }
    .card-pad { padding: 16px; }
    .selected-meal { gap: 6px; }
    .selected-meal .stepper button { width: 44px; }
    .pantry-check { gap: 8px; }
  }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
}
