:root {
  --bg: #F6F7F9; --surface: #FFFFFF; --line: #DCE0E7; --text: #1F232A; --muted: #5F6673;
  --rim: #1E3F94; --warn: #B5371F; --press: #E9ECF1;
  --radius: 10px; --gutter: 16px; --tab-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #13161B; --surface: #1B1F26; --line: #2C323C; --text: #E7E9ED; --muted: #9AA2AF;
          --rim: #86A6F2; --warn: #F08A73; --press: #242A33; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
}
main { max-width: 560px; margin: 0 auto; padding: 0 var(--gutter); outline: none; }
.top { max-width: 560px; margin: 0 auto; padding: 18px var(--gutter) 8px; display: flex; align-items: baseline;
       justify-content: space-between; gap: 12px; }
.top h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 28px 0 4px; font-weight: 750; }
h2 .step { display: inline-block; width: 1.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.warn { color: var(--warn); }
a { color: inherit; }

/* Buttons: graphite primary, outlined secondary; never the rim color. */
.button { text-decoration: none; }
button, .button {
  font: inherit; min-height: 44px; padding: 0 16px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
button:active { background: var(--press); }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 650; }
button.primary.wide { width: 100%; margin: 12px 0 4px; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0 8px; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--rim); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); min-height: 44px; padding: 8px 12px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }

/* Day rows: the menu-board column on the left, enamel rim marks status. */
.days { list-style: none; margin: 8px 0; padding: 0; border-top: 1px solid var(--line); }
.day { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
       padding: 12px 0 12px 12px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; }
.day.rim { border-left-color: var(--rim); }
.day .wd { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.day .main { min-width: 0; }
.day .name { font-weight: 600; overflow-wrap: anywhere; }
.day .meta { color: var(--muted); font-size: 14px; }
.day.off .wd, .day.off .name { color: var(--muted); }
.day .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.day .actions button { min-height: 40px; padding: 0 12px; font-size: 15px; }
.day.empty .name { color: var(--warn); }
/* Menu rows: actions go under the dish so long names keep the full width. */
.day.menu { grid-template-columns: 52px 1fr; align-items: start; }
.day.menu .wd { padding-top: 2px; }
.day.menu .actions { grid-column: 2; justify-content: flex-start; }
.check-row { display: flex; gap: 12px; align-items: center; font-weight: 400; min-height: 44px; }
.check-row input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--rim); }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

details.recipe { margin-top: 6px; }
details.recipe summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 32px; }
details.recipe ul, details.recipe ol { margin: 6px 0; padding-left: 20px; }

.hint { border-left: 4px solid var(--line); padding: 8px 12px; margin: 10px 0; color: var(--muted); font-size: 14px; }
.hint.rim { border-left-color: var(--rim); color: var(--text); }
.hint.warn { border-left-color: var(--warn); color: var(--text); }

/* Shopping list */
.list { list-style: none; padding: 0; margin: 4px 0 16px; }
.list li { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.list li button.check { flex: 1; text-align: left; border: 0; background: none; padding: 8px 0; min-height: 48px;
                         display: flex; gap: 12px; align-items: center; border-radius: 0; }
.list .box { width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 6px; flex: none; }
.list li.done .box { background: var(--rim); border-color: var(--rim); }
.list li.done .label { color: var(--muted); text-decoration: line-through; }
.list .amount { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 8px; }
.list .changed { color: var(--rim); font-size: 13px; }
h3 { font-size: 15px; margin: 18px 0 2px; color: var(--muted); font-weight: 650; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; display: inline-flex;
       align-items: center; gap: 4px; background: var(--surface); }
.tag button { min-height: 28px; padding: 0 8px; border: 0; background: none; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > button { flex: none; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface);
        border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 14px;
          min-height: var(--tab-h); display: flex; align-items: center; justify-content: center;
          border-top: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 700; border-top-color: var(--rim); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
         transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px;
         border-radius: var(--radius); max-width: calc(100% - 32px); font-size: 15px; opacity: 0;
         pointer-events: none; transition: opacity .15s; z-index: 10; }
#toast.show { opacity: 1; }
#toast.warn { background: var(--warn); color: #fff; }

.loading { padding: 32px 0; color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
         width: min(520px, calc(100% - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.print-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.print-table th, .print-table td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.print-table td:first-child { font-weight: 800; }
.print-sub { color: var(--text); font-size: 17px; }
