/* Phone first. One column, large touch targets, warm and quiet. */

:root {
  color-scheme: light dark;
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #26221d;
  --subtle: #6b6359;
  --line: #e4ddd2;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-line: #d9a514;
  --error: #b3261e;
  --radius: 0.75rem;
  --tap: 2.875rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --card: #26231f;
    --text: #f1ebe2;
    --subtle: #b3a999;
    --line: #3b362f;
    --accent: #5fb389;
    --accent-text: #10241a;
    --warn-bg: #3a3118;
    --warn-line: #b88a12;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  width: min(100% - 1.5rem, 44rem);
  margin: 0 auto;
  padding: 0.75rem 0 5rem;
}
main:focus { outline: none; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 0.75rem 0 0.25rem; }
p { margin: 0.5rem 0; }
a { color: var(--accent); }

.skip-link { position: absolute; left: -999rem; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; background: var(--card); padding: 0.5rem; z-index: 10; }

/* Navigation */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top nav { display: flex; gap: 0.125rem; font-size: 0.9375rem; overflow-x: auto; width: min(100%, 44rem); margin: 0 auto; padding: 0.375rem 0.5rem; }
.top a {
  flex: 0 0 auto; min-height: var(--tap); display: inline-flex; align-items: center;
  padding: 0 0.625rem; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 600;
}
.top a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.top a.secondary { margin-left: auto; font-weight: 400; color: var(--subtle); }
.top a.secondary[aria-current="page"] { color: var(--accent-text); }

/* Status and banners */
.status {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 6;
  padding: 0.375rem 0.875rem; border-radius: 999px; font-size: 0.9375rem; font-weight: 600;
  background: var(--text); color: var(--bg); pointer-events: none;
}
.status:empty { display: none; }
.status[data-state="error"] { background: var(--error); color: #fff; }

.banner { width: min(100% - 1.5rem, 44rem); margin: 0.75rem auto 0; padding: 0.75rem; border-radius: var(--radius); }
.banner-warn, .notice { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.banner-error { border: 2px solid var(--error); background: var(--card); }
.notice { padding: 0.625rem 0.75rem; border-radius: var(--radius); }
[hidden] { display: none !important; }

/* Cards and layout helpers */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.875rem; margin: 0 0 0.75rem;
}
.stack > * + * { margin-top: 0.625rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.625rem; align-items: end; }
.row > * { flex: 1 1 8rem; }
.title-row { display: flex; gap: 0.5rem; align-items: start; justify-content: space-between; }
.title-row h1, .title-row h2 { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.subtle, .hint { color: var(--subtle); font-size: 0.9375rem; }
.subtle { display: block; }
h2 .subtle { display: inline; font-weight: 400; }
.tag {
  display: inline-block; padding: 0 0.5rem; border-radius: 999px; font-size: 0.8125rem;
  border: 1px solid var(--line); color: var(--subtle); white-space: nowrap;
}
ul.plain, .components, .events { list-style: none; padding: 0; margin: 0; }
.chips { display: flex; gap: 0.5rem; overflow-x: auto; margin-bottom: 0.75rem; }
.chips a { padding: 0.25rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; white-space: nowrap; }
.chips a[aria-current="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.9375rem; }
label.inline, form.inline { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: var(--tap); margin-top: 0.25rem; padding: 0.5rem 0.625rem;
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--subtle); border-radius: 0.5rem;
}
label.inline input, form.inline input { width: auto; margin-top: 0; }
input[type="number"] { max-width: 100%; }
label.inline input[type="number"], form.inline input[type="number"] { width: 5.5rem; }
input[type="checkbox"] { width: 1.5rem; height: 1.5rem; min-height: 0; accent-color: var(--accent); flex: 0 0 auto; }
textarea { min-height: 5rem; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; margin: 0; }
legend { font-weight: 600; padding: 0 0.25rem; }

button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap);
  padding: 0 1rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); border-radius: 0.5rem; background: var(--accent); color: var(--accent-text);
}
button.quiet, .button-link.quiet { background: transparent; color: var(--accent); }
button.danger { color: var(--error); border-color: var(--error); }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
button:disabled, [aria-busy="true"] { opacity: 0.55; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
form[data-unsaved-draft] button[type="submit"]::after { content: " •"; }

/* Plan */
.day .events li { font-size: 0.9375rem; color: var(--subtle); }
.day .events li.busy { color: var(--text); font-weight: 600; }
.evening > summary, details > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
.component { border-top: 1px solid var(--line); padding: 0.625rem 0; overflow-wrap: anywhere; }
.component:first-child { border-top: 0; }
.timing.over { color: var(--error); font-weight: 600; }

dialog {
  width: min(100% - 1.5rem, 30rem); max-height: 85vh; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 1rem;
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog .stack button, #calendar-choices button, #import-result button { width: 100%; justify-content: flex-start; text-align: left; }

/* Recipes */
.ingredient-row { display: grid; grid-template-columns: 5rem 5rem 1fr; gap: 0.375rem; padding-bottom: 0.625rem; border-bottom: 1px solid var(--line); }
.ingredient-row [name="ingredient_key"] { grid-column: 1 / -1; grid-row: 1; }
.ingredient-row input, .ingredient-row select { margin-top: 0; }

/* Shopping */
.item { overflow-wrap: anywhere; }
.item.done strong, .check-row.done span { text-decoration: line-through; color: var(--subtle); }
.check-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0; border-bottom: 1px solid var(--line); }
.check-row label { flex: 1; display: flex; align-items: center; gap: 0.75rem; min-height: 3.25rem; font-weight: 400; font-size: 1.0625rem; overflow-wrap: anywhere; }
.check-row input[type="checkbox"] { width: 1.75rem; height: 1.75rem; }

/* Sign in */
body.signin { min-height: 100vh; display: grid; place-items: center; }
body.signin main { width: min(100% - 2rem, 22rem); padding: 0; }
body.signin button { width: 100%; margin-top: 1rem; }
[role="alert"].signin-error { border: 1px solid var(--error); color: var(--error); border-radius: 0.5rem; padding: 0.75rem; }

@media (min-width: 48rem) {
  body { font-size: 1rem; }
  .ingredient-row { grid-template-columns: 5rem 6rem 2fr 1fr 9rem auto auto; }
  .ingredient-row [name="ingredient_key"] { grid-column: auto; grid-row: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .status { transition: opacity 0.2s; }
}
