/* Macro Kitchen — phone-first. Swiss red accent, herb green for protein, tiles like a shopping app. */
:root {
  --bg: #f4f6f2; --surface: #ffffff; --sunk: #e8ece5; --fg: #19211b; --muted: #5d685f; --line: #d6ddd3;
  --accent: #c8281c; --accent-2: #a51f15; --accent-fg: #ffffff; --herb: #2f6448; --herb-soft: #dcebe1;
  --tile-done: #c9d0c6; --warn-soft: #f6e7cf; --warn: #8a4d00; --bad: #b3261e;
  --display: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121613; --surface: #1b211c; --sunk: #232a24; --fg: #e9eee8; --muted: #9aa69c; --line: #2e372f;
    --accent: #d93a2e; --accent-2: #b52c21; --accent-fg: #ffffff; --herb: #7fc39b; --herb-soft: #1f3327;
    --tile-done: #3a433b; --warn-soft: #3a2c16; --warn: #e6a650; --bad: #f08a80; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.wrap { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px 110px; }
.topbar { position: sticky; top: 0; z-index: 6; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); }
.topbar .in { max-width: 760px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.cross { width: 22px; height: 22px; background: var(--accent); border-radius: 5px; position: relative; flex: none; }
.cross::before, .cross::after { content: ""; position: absolute; background: var(--accent-fg); left: 50%; top: 50%; transform: translate(-50%, -50%); }
.cross::before { width: 12px; height: 4px; } .cross::after { width: 4px; height: 12px; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.red { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.on { background: var(--herb-soft); border-color: var(--herb); color: var(--herb); }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; font-size: 16px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--herb); flex: none; margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.notice { border-radius: 10px; padding: 10px 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; margin: 0; }

/* Auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: max(48px, env(safe-area-inset-top, 0px)) 16px 32px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.auth-card p { margin: 0; }

/* Chips, tags, cards */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 500; }
.chip.sel { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--sunk); color: var(--muted); font-weight: 500; }
.cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card .title { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.2; background: none; border: 0; padding: 0; text-align: left; }
.macroline { display: flex; gap: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.macroline b { color: var(--fg); font-weight: 600; } .macroline .p b { color: var(--herb); }
.cardfoot { display: flex; justify-content: flex-end; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* Recipe detail */
.label { border: 1.5px solid var(--fg); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.label .grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.label .cell { display: flex; flex-direction: column; gap: 2px; }
.label .num { font-family: var(--mono); font-size: 19px; font-variant-numeric: tabular-nums; }
.label .cell.p .num { color: var(--herb); }
.label .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.label .cap { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.ing .q { font-family: var(--mono); font-size: 13px; min-width: 78px; text-align: right; flex: none; }
.ing .n { min-width: 0; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: transparent; width: 34px; height: 34px; font-size: 18px; }
.stepper span { font-family: var(--mono); min-width: 26px; text-align: center; }

/* Plan rows */
.item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.item .nm { flex: 1; min-width: 0; }
.item .nm .from { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.item.off .nm > span:first-child { text-decoration: line-through; color: var(--muted); }
.item .qty { width: 78px; flex: none; padding: 7px 8px; text-align: right; font-family: var(--mono); }
.item .unit { font-size: 13px; color: var(--muted); width: 38px; flex: none; }
.x { border: 0; background: none; color: var(--muted); font-size: 20px; width: 32px; height: 32px; border-radius: 50%; flex: none; }
.x:hover { background: var(--sunk); color: var(--fg); }

/* Shopping tiles */
.addbar { position: relative; }
.addbar input { padding-left: 40px; font-size: 17px; }
.addbar::before { content: "+"; position: absolute; left: 14px; top: 50%; transform: translateY(-52%); font-size: 22px; color: var(--accent); font-weight: 700; pointer-events: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; max-width: 100%; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-fg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 6px; text-align: center; min-width: 0; transition: transform .08s; }
.tile:active { transform: scale(.95); }
.tile .ic { font-size: 32px; line-height: 1; }
.tile .ini { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1; opacity: .9; }
.tile .nm { font-size: 13px; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .spec { font-size: 12px; line-height: 1.1; opacity: .92; font-family: var(--mono); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile.recent { background: var(--tile-done); color: var(--fg); }
.tile.suggest { background: var(--surface); color: var(--fg); border: 1.5px dashed var(--accent); }
.tile .edit { position: absolute; top: 2px; right: 2px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 15px; opacity: .85; display: flex; align-items: center; justify-content: center; }
.tile .edit:hover { background: rgba(0,0,0,.15); }
.group { display: flex; flex-direction: column; gap: 8px; }

/* Bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 12px; }
.sheet .head { display: flex; align-items: center; gap: 10px; }
.sheet .head .ic { font-size: 30px; }
.qtychips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Tabs */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); }
nav.tabs .in { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
nav.tabs a { text-decoration: none; color: var(--muted); padding: 11px 0 13px; text-align: center; font-weight: 600; font-size: 15px; position: relative; }
nav.tabs a[aria-current="page"] { color: var(--fg); }
nav.tabs a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
nav.tabs .badge { font-family: var(--mono); font-size: 11px; background: var(--accent); color: var(--accent-fg); border-radius: 999px; padding: 1px 6px; margin-left: 4px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 8px 8px 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 10px; }
.toast button { background: transparent; border: 0; color: var(--accent); font-weight: 700; padding: 4px 10px; filter: brightness(1.4); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-width: 200px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.menu-pop form { margin: 0; }
.menu-pop .btn { width: 100%; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }
