/* Kedroski Recipe Box: mobile first, light and dark themes from the same color tokens. */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1f2a28;
  --muted: #5d6b68;
  --line: #dcd8cc;
  --accent: #0d6a63;
  --accent-ink: #ffffff;
  --accent-soft: #e1efec;
  --tag: #f0e3b8;
  --tag-ink: #4a3a05;
  --danger: #a3321f;
  --shadow: 0 8px 28px rgba(20, 35, 32, 0.14);
  --display: "Newsreader", Georgia, serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121817;
    --surface: #1b2422;
    --ink: #e7eeeb;
    --muted: #9aaba6;
    --line: #2e3b38;
    --accent: #4fc3b8;
    --accent-ink: #06201d;
    --accent-soft: #1d3532;
    --tag: #4a4020;
    --tag-ink: #f2e4b0;
    --danger: #ff8a75;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121817;
  --surface: #1b2422;
  --ink: #e7eeeb;
  --muted: #9aaba6;
  --line: #2e3b38;
  --accent: #4fc3b8;
  --accent-ink: #06201d;
  --accent-soft: #1d3532;
  --tag: #4a4020;
  --tag-ink: #f2e4b0;
  --danger: #ff8a75;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--accent); border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { font-family: var(--display); font-size: 21px; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }

/* Account menu */
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.account-menu {
  position: absolute; right: 0; top: 44px; width: 240px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.account-menu p { margin: 0; overflow-wrap: anywhere; }
.account-name { font-weight: 600; }
.account-email { color: var(--muted); font-size: 14px; margin-bottom: 12px !important; }
.account-backup { display: grid; gap: 8px; padding: 10px 0 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.account-backup .btn { justify-content: flex-start; text-align: left; }

/* Search and filters */
.search {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 16px;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip-count { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: inherit; opacity: 0.8; }
.count { color: var(--muted); font-size: 14px; margin: 14px 0 10px; }

/* Recipe cards */
.grid { display: grid; gap: 10px; padding-bottom: 96px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; } }
.card {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card-title { margin: 0; font-family: var(--display); font-size: 20px; line-height: 1.2; font-weight: 600; overflow-wrap: anywhere; }
.card-variation { margin: 0; font-size: 14px; color: var(--accent); }
.card-preview {
  margin: 0; color: var(--muted); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 6px; border: 0;
  background: var(--tag); color: var(--tag-ink); font-size: 13px; font-weight: 500;
}
button.tag { cursor: pointer; min-height: 30px; }

/* Editable tags on the recipe page */
.tag-area.saving { opacity: 0.6; pointer-events: none; }
.tag-item { display: inline-flex; align-items: stretch; }
.tag-item .tag { border-radius: 6px 0 0 6px; }
.tag-x {
  display: inline-grid; place-items: center; min-width: 30px; min-height: 30px; padding: 0 6px;
  border: 0; border-left: 1px solid color-mix(in srgb, var(--tag-ink) 25%, transparent); border-radius: 0 6px 6px 0;
  background: var(--tag); color: var(--tag-ink); font-size: 16px; line-height: 1; cursor: pointer;
}
.tag-x:hover { background: color-mix(in srgb, var(--tag) 80%, var(--tag-ink)); }
.add-tag {
  min-height: 30px; padding: 2px 10px; border: 1px dashed var(--muted); border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
}
.add-tag:hover { color: var(--accent); border-color: var(--accent); }
.tag-panel {
  margin: 10px 0 4px; padding: 14px; max-width: 560px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.tag-panel .label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 8px; }
.tag-suggest {
  min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); font-size: 14px; cursor: pointer;
}
.tag-suggest:hover { border-color: var(--accent); color: var(--accent); }
.new-tag-form { margin-top: 6px; }
.new-tag-row { display: flex; gap: 8px; }
.new-tag-input {
  flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px;
}
.tag-panel > .btn.ghost { margin-top: 12px; }
.empty { padding: 48px 8px; text-align: center; color: var(--muted); }
.empty-title { font-family: var(--display); font-size: 22px; color: var(--ink); margin: 0 0 6px; }

/* Floating add button */
.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 6;
  display: inline-flex; align-items: center; gap: 6px; min-height: 52px; padding: 12px 20px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none; box-shadow: var(--shadow);
}
.fab span { font-size: 22px; line-height: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.header-add { display: none; }
@media (min-width: 720px) {
  .header-add { display: inline-flex; }
  .fab { display: none; }
  .grid { padding-bottom: 48px; }
}

/* Reading view */
.recipe { padding: 18px 0 48px; }
.recipe h1 { font-family: var(--display); font-size: 34px; line-height: 1.12; font-weight: 600; margin: 6px 0 8px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.recipe h1:focus { outline: none; }
.title-row { display: flex; align-items: flex-start; gap: 12px; }
.title-row h1 { flex: 1; min-width: 0; }
.title-row .rename { flex: none; margin-top: 10px; }
.rename-form { flex: 1; min-width: 0; max-width: 720px; margin: 6px 0 10px; }
.rename-form .label { display: block; font-weight: 600; margin-bottom: 6px; }
.rename-input {
  width: 100%; min-height: 50px; padding: 8px 12px;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--surface);
  font-family: var(--display); font-size: 24px; font-weight: 600;
}
.rename-actions { display: flex; gap: 8px; margin-top: 10px; }
.confirm-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; cursor: pointer; }
.confirm-check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.byline { color: var(--muted); font-size: 15px; margin: 0 0 10px; }
.recipe .tags { margin: 10px 0 4px; }
.description { font-size: 17px; }
.section-title {
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 28px 0 10px;
}
.subhead { font-size: 16px; font-weight: 600; margin: 16px 0 6px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { border-bottom: 1px solid var(--line); }
.ingredients label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; min-height: 44px; }
.ingredients input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.steps { margin: 0; padding-left: 24px; }
.steps li { margin-bottom: 14px; padding-left: 4px; max-width: 68ch; }
.steps li::marker { color: var(--accent); font-weight: 600; }
.notes p { margin: 0 0 10px; max-width: 68ch; }
.versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.versions a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--ink); }
.versions small { display: block; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 10px; }
@media (min-width: 900px) {
  .recipe-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 40px; align-items: start; }
  .narrow.wide-ok { max-width: 1040px; }
}

/* Forms */
.form { padding: 18px 0 48px; }
.form h1 { font-family: var(--display); font-size: 30px; font-weight: 600; margin: 6px 0 4px; }
.form h1:focus { outline: none; }
.banner { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin: 12px 0 4px; }
.field { margin-top: 18px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.field input[type="text"], .field input[type="email"], .field input[type="number"], .field input[type="date"], .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px;
}
.field textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.field textarea.short { min-height: 90px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.tag-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tag-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tag-pick span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; cursor: pointer;
}
.tag-pick input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { color: var(--danger); margin: 12px 0 0; }
.error:empty { display: none; }

/* Confirmation panel (delete) */
.sheet {
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto;
  padding: 22px 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(10, 18, 16, 0.55); }
.sheet h2 { font-family: var(--display); font-size: 24px; font-weight: 600; margin: 0 0 8px; }
.sheet p { margin: 0 0 10px; }
.sheet .actions { margin-top: 20px; }

/* Family invites */
.invite-next { margin-top: 18px; }
.invite-next p { margin: 0 0 6px; }
.invite-next ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.invites { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.invites li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.invites li + li { border-top: 1px solid var(--line); }
.invite-who { min-width: 0; display: grid; }
.invite-email { font-weight: 600; overflow-wrap: anywhere; }
.invite-meta { color: var(--muted); font-size: 14px; }
.invite-status.joined { flex: none; color: var(--accent); font-weight: 600; font-size: 14px; }

/* Sign-in and simple states */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: min(400px, 100%); text-align: center; }
.signin-card h1 { font-family: var(--display); font-size: 32px; font-weight: 600; margin: 14px 0 4px; }
.signin-card .btn { margin-top: 22px; }
.fine { color: var(--muted); font-size: 14px; margin-top: 14px; }
.splash, .state { padding: 64px 16px; text-align: center; color: var(--muted); }
.state h1 { font-family: var(--display); color: var(--ink); font-weight: 600; }
