/* Mirepoix styles (D13). Tokens come from docs/mockups; light and dark follow
   the system. System fonts only: nothing to download. */

:root {
  --paper: #FBF8F3;
  --surface: #FFFFFF;
  --sunken: #F3EEE6;
  --ink: #2A2622;
  --ink-2: #6B635A;
  --line: #E4DCCF;
  --carrot: #A84A18;
  --carrot-soft: #FBE8DA;
  --on-carrot: #FFFFFF;
  --celery: #4E6B26;
  --celery-soft: #E8F0DA;
  --on-celery: #FFFFFF;
  --warn: #8A5A0B;
  --warn-soft: #FCF1D6;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --gutter: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1C1A17;
    --surface: #25221E;
    --sunken: #2C2824;
    --ink: #EEE8E0;
    --ink-2: #A9A096;
    --line: #3A352F;
    --carrot: #F0894A;
    --carrot-soft: #3B2A1E;
    --on-carrot: #1C1A17;
    --celery: #A3C46B;
    --celery-soft: #28311C;
    --on-celery: #1C1A17;
    --warn: #E7B85C;
    --warn-soft: #3A2F1C;
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--carrot); }

/* Views style elements by class, and display rules would beat the attribute. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--carrot);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  max-width: 960px;
  min-height: 100dvh;
  margin: 0 auto;
}

@media (min-width: 992px) {
  #app { border-inline: 1px solid var(--line); }
}

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

a.button { text-decoration: none; }
.button.primary { background: var(--carrot); color: var(--on-carrot); }
.button.quiet { background: transparent; color: var(--ink-2); padding-inline: 4px; font-weight: 500; }
.button.danger { background: transparent; color: var(--carrot); box-shadow: inset 0 0 0 1.5px currentColor; }

.danger-zone {
  margin-top: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 960px) / 2 + 20px), env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 10;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--carrot);
  color: var(--on-carrot);
  box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}

.fab::before,
.fab::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 3px;
  margin: -1.5px 0 0 -12px;
  border-radius: 2px;
  background: currentColor;
}

.fab::after { transform: rotate(90deg); }

/* Top bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding:
    calc(6px + env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    6px
    max(var(--gutter), env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

/* The name is lettered inside the logo image (D13), so no font is involved. */
.wordmark {
  margin: 0;
  line-height: 0;
}

.brand img {
  display: block;
  width: auto;
  height: 34px;
}

.logo {
  display: block;
  margin: 0 auto 18px;
  border-radius: 17px;
  box-shadow: 0 6px 18px rgb(0 0 0 / .14);
}

.bar-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

.edit-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--ink-2);
  text-decoration: none;
}

.edit-link:hover { color: var(--carrot); }

.back::before {
  content: "";
  width: .5em;
  height: .5em;
  margin-left: 4px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--celery-soft); color: var(--celery); }
.chip.alert { background: var(--carrot-soft); color: var(--carrot); }

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Page content */

.page {
  flex: 1;
  padding-bottom: env(safe-area-inset-bottom);
}

.empty {
  max-width: 34ch;
  margin: 18vh auto 0;
  padding: 0 24px;
  text-align: center;
  color: var(--ink-2);
}

.empty h1,
.empty h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

.empty p { margin: 0; }

/* Recipe list */

.search-bar {
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 2px max(var(--gutter), env(safe-area-inset-left));
}

.search {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface) no-repeat 12px center / 18px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8178' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E");
  color: var(--ink);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search:focus-visible {
  border-color: var(--carrot);
  outline-offset: 0;
}

.count {
  margin: 12px 2px 4px;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.results .empty { margin-top: 10vh; }

.list {
  margin: 0;
  padding: 0; /* the footer below leaves room to scroll out from under + */
  list-style: none;
}

.list li {
  border-bottom: 1px solid var(--line);
}

.list a {
  display: block;
  min-height: 44px;
  padding: 10px var(--gutter);
  color: inherit;
  text-decoration: none;
}

.list a:hover { background: var(--sunken); }

.list .title {
  font-family: var(--serif);
  font-size: 1.125rem;
}

.list .source {
  font-size: .8125rem;
  color: var(--ink-2);
}

/* Editor */

.editor {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px max(var(--gutter), env(safe-area-inset-right)) 32px max(var(--gutter), env(safe-area-inset-left));
}

.fields {
  display: grid;
  gap: 12px;
}

@media (min-width: 560px) {
  .fields { grid-template-columns: 1fr auto; }
}

/* Each box has its preview: right under it on a phone, beside it when wider. */
.columns {
  display: grid;
  grid-template-areas: "ingredients" "ingredients-preview" "preparation" "preparation-preview" "more";
  gap: 16px;
  align-items: start;
}

.columns > .ingredients-box { grid-area: ingredients; }
.columns > .preview { grid-area: ingredients-preview; }
.columns > .preparation-box { grid-area: preparation; }
.columns > .steps-preview { grid-area: preparation-preview; }

.columns > .more-boxes {
  display: grid;
  grid-area: more;
  gap: 16px;
}

@media (min-width: 760px) {
  .columns {
    grid-template-areas:
      "ingredients ingredients-preview"
      "preparation preparation-preview"
      "more .";
    grid-template-columns: 1fr 1fr;
  }

  /* Line each preview up with its box rather than with the box's label. */
  .columns > .preview { margin-top: 22px; }
}

.chip.neutral { background: var(--sunken); color: var(--ink-2); }

.preview-steps { padding: 6px 14px 10px; }

.preview-steps .steps li {
  padding: 4px 0 4px 2px;
  font-size: .95rem;
}

.preview-steps .group-heading {
  margin: 10px 0 2px;
  font-size: 1rem;
}

@media (min-width: 560px) {
  .field.makes { width: 12rem; }
}

#preparation { min-height: 11rem; }

.more {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.more summary {
  padding: 9px 12px;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink-2);
  list-style: none;
  cursor: pointer;
}

.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; font-weight: 800; color: var(--carrot); }
.more[open] summary::before { content: "– "; }

.more textarea {
  min-height: 6rem;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
}

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > label,
.field > legend {
  display: block;
  float: left; /* lets a legend sit above its fieldset's content like a label */
  width: 100%;
  margin-bottom: 4px;
  padding: 0;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible {
  border-color: var(--carrot);
  outline-offset: 0;
}

.segmented {
  display: flex;
  clear: both;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.segmented label {
  position: relative;
  flex: 1;
}

.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 9px 14px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  color: var(--ink-2);
}

.segmented input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--carrot);
  outline-offset: -2px;
}

.title-input {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
}

textarea {
  min-height: 15rem;
  line-height: 1.7;
  resize: vertical;
}

.hint {
  margin: 6px 2px 0;
  font-size: .8rem;
  color: var(--ink-2);
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sunken);
  font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  font-size: .9em;
  color: var(--ink);
}

.alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}

/* "How Mirepoix reads it" */

.preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.preview-head h2 {
  margin: 0;
  font-size: .9rem;
}

.preview .placeholder {
  margin: 0;
  padding: 16px 14px;
  color: var(--ink-2);
}

.preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.preview th[scope="col"] {
  padding: 6px 10px;
  background: var(--sunken);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  color: var(--ink-2);
}

.preview td {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  vertical-align: baseline;
}

.preview .qty {
  width: 3.5em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.preview .unit { white-space: nowrap; }
.preview .name { font-family: var(--serif); font-size: 1rem; }
.preview .note,
.preview .alt,
.preview .muted { color: var(--ink-2); }
.preview .muted { font-style: italic; font-weight: 400; }
.preview .alt { display: block; font-size: .8rem; }

.preview tr.group th {
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1rem;
  text-align: left;
}

.preview tr.flagged td { background: var(--warn-soft); }

.preview td.flag {
  padding-top: 0;
  border-top: 0;
  font-size: .8rem;
  font-weight: 600;
  color: var(--warn);
}

.preview td.flag::before { content: "⚠︎ "; }

/* A recipe, to read */

.recipe {
  max-width: 46rem;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 48px max(var(--gutter), env(safe-area-inset-left));
}

.recipe-title {
  margin: 20px 0 4px;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.12;
  text-wrap: balance;
}

.recipe-section { margin-top: 22px; }

.section-label {
  margin: 0 0 6px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--carrot);
}

.group-heading {
  margin: 16px 0 2px;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}

/* Amounts line up in one column across every group; names in the next. */
.ingredient-groups {
  display: grid;
  grid-template-columns: fit-content(45%) 1fr;
  column-gap: 14px;
}

.ingredient-groups > .group-heading { grid-column: 1 / -1; }

.ingredients {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredients li {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.ingredients .amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.ingredients .alt {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-2);
}

.ingredients .name {
  font-family: var(--serif);
  font-size: 1.05rem;
}

.ingredients .note { color: var(--ink-2); }

.nothing-yet {
  margin: 0;
  color: var(--ink-2);
  font-style: italic;
}
.meta {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-2);
}

.steps {
  margin: 0;
  padding-left: 1.9em;
}

.steps li {
  padding: 5px 0 5px 4px;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.5;
}

.steps li::marker {
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 800;
  color: var(--carrot);
}

.bullets {
  margin: 0;
  padding-left: 1.3em;
}

.bullets li {
  padding: 3px 0;
  font-family: var(--serif);
  font-size: 1.05rem;
}

.bullets li::marker { color: var(--carrot); }

.note-text {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.5;
}
/* Keep a copy */

a.chip { text-decoration: none; }

.button.secondary {
  background: transparent;
  color: var(--carrot);
  box-shadow: inset 0 0 0 1.5px currentColor;
}

/* Hidden from sight, still reachable by keyboard and assistive tech. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.visually-hidden:focus-visible + .button {
  outline: 2px solid var(--carrot);
  outline-offset: 2px;
}

.backup {
  max-width: 46rem;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 48px max(var(--gutter), env(safe-area-inset-left));
}

.backup p { margin: 0 0 12px; }

.backup .lead { color: var(--ink-2); }

/* Save as Markdown, quietly at the end of a recipe */
.recipe-copy {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: .9rem;
}

.recipe-copy .link {
  min-height: 44px;
  font-weight: 600;
  color: var(--carrot);
}

.recipe-copy .status {
  min-height: 0;
  margin: 0;
  font-weight: 500;
  color: var(--ink-2);
}

.status {
  min-height: 1.5em;
  margin-top: 20px;
  font-weight: 600;
}

.empty .aside {
  margin-top: 16px;
  font-size: .9rem;
}
/* Small print, the privacy page, and the analytics question */

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 28px max(var(--gutter), env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  font-size: .85rem;
}

/* The language switch is a button that looks like the links beside it. */
.app-footer a,
.app-footer .link {
  color: var(--ink-2);
}

/* Ko-fi (R2.0.1, D16): our own small badge rather than Ko-fi's widget, so
   nothing loads from Ko-fi until someone follows the link. */
.app-footer a.kofi {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--carrot);
  font-weight: 600;
  text-decoration: none;
}

.app-footer a.kofi:hover { text-decoration: underline; }

.kofi::before {
  content: "";
  width: 1.2em;
  height: 1.2em;
  background: currentColor;
  -webkit-mask: var(--cup) center / contain no-repeat;
  mask: var(--cup) center / contain no-repeat;
  --cup: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h12v5a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5z'/%3E%3Cpath d='M16 10.5h1.5a2.5 2.5 0 0 1 0 5H16'/%3E%3Cpath d='M8 3.5c0 1.2 1 1.3 1 2.5M12 3.5c0 1.2 1 1.3 1 2.5'/%3E%3C/svg%3E");
}

.link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.prose {
  max-width: 46rem;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 48px max(var(--gutter), env(safe-area-inset-left));
}

.prose p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.prose .lead { color: var(--ink-2); }

.choice {
  margin: 4px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.updated {
  margin-top: 28px;
  font-size: .85rem;
  color: var(--ink-2);
}

.consent {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px max(var(--gutter), env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -6px 24px rgb(0 0 0 / .12);
}

.consent p {
  flex: 1 1 22rem;
  margin: 0;
  font-size: .9rem;
}

.consent-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Sync (R2): connecting a device, and how syncing goes */

.sync {
  max-width: 46rem;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 48px max(var(--gutter), env(safe-area-inset-left));
}

.sync p { margin: 0 0 12px; }

.sync .lead { color: var(--ink-2); }

/* A padlock before the promise that recipes are encrypted. */
.lead.secure {
  display: flex;
  gap: 10px;
}

.lead.secure::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  background: var(--celery);
  -webkit-mask: var(--lock) center / contain no-repeat;
  mask: var(--lock) center / contain no-repeat;
  --lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
}

.connect {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.connect .field .hint { margin-top: 4px; }

.hint.warn {
  color: var(--warn);
  font-weight: 600;
}

input.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  font-size: .9rem;
}

.connect > .button { justify-self: start; }

.button:disabled {
  opacity: .6;
  cursor: progress;
}

.how {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: .9rem;
}

.how summary {
  padding: 9px 12px;
  font-weight: 700;
  color: var(--carrot);
  cursor: pointer;
}

.how ol {
  margin: 0;
  padding: 0 14px 0 34px;
}

.how li { padding: 3px 0; }

.how p { margin: 8px 14px 12px; }

.how .caveat { color: var(--ink-2); }

.checks {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .95rem;
}

.checks li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.checks li::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.checks li.done::before {
  background: var(--celery);
  -webkit-mask: var(--tick) center / contain no-repeat;
  mask: var(--tick) center / contain no-repeat;
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E");
}

.checks li.working::before {
  border: 2.5px solid var(--line);
  border-top-color: var(--celery);
  animation: spin 900ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .checks li.working::before { animation: none; }
}

.sync-status {
  margin: 4px 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.sync-status p:last-child { margin-bottom: 0; }

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.fix:empty { display: none; }

.fix { margin-bottom: 12px; }

.actions { margin-top: 4px; }

.sync .aside { margin-top: 24px; }

/* Icons (R3): line drawings from docs/mockups, used as masks so they take
   the color of the text around them, in light and dark. */

.pot, .pen, .sun, .done-link, .stamp {
  --icon-size: 1.15em;
}

.pot { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10h16v6a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z'/%3E%3Cpath d='M2 10h2M20 10h2M9 6.5c0-1 1-1.5 1-2.5M13.5 6.5c0-1 1-1.5 1-2.5'/%3E%3C/svg%3E"); }
.pen, .last-time { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4z'/%3E%3Cpath d='M13.5 6.5l4 4'/%3E%3C/svg%3E"); }
.sun { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4'/%3E%3C/svg%3E"); }
.done-link { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.stamp { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E"); }
:root { --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }

.pot::before, .pen::before, .sun::before, .done-link::before, .stamp::before, .last-time::before {
  content: "";
  flex: none;
  width: var(--icon-size, 18px);
  height: var(--icon-size, 18px);
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

/* An action bar that stays at the bottom: Start cooking, Note for next time */

.foot {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  justify-items: center;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.button.wide {
  width: 100%;
  max-width: 30rem;
  min-height: 48px;
  border-radius: 14px;
}

.foot-status {
  margin: 0;
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  color: var(--celery);
}

/* Always there, even empty, so screen readers hear it when it speaks. */
.foot-status:not(:empty) { margin-bottom: 6px; }

/* Tags (R3.4, R3.5): pills inside 44 px targets (D13). Pressed means picked. */

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.tag > span {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag:hover > span { border-color: var(--ink-2); }
.tag:focus-visible { outline: none; }
.tag:focus-visible > span { outline: 2px solid var(--carrot); outline-offset: 2px; }

.tag[aria-pressed="true"] > span {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.tag-list,
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list { margin-top: 4px; }
.tag-list .tag > span { border-color: transparent; background: var(--sunken); }
.tag-list .tag:hover > span { color: var(--carrot); }
.tag-picker { clear: both; margin-top: 2px; }

/* On a phone the list's tags scroll sideways in one row; wider, they wrap. */
.tag-filter {
  display: flex;
  gap: 0 6px;
  margin: 2px calc(-1 * var(--gutter)) -6px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}

.tag-filter::-webkit-scrollbar { display: none; }

@media (min-width: 760px) {
  .tag-filter {
    flex-wrap: wrap;
    margin-inline: 0;
    padding-inline: 0;
  }
}

/* Cook's notes (R3.3): "Last time" up top, and the whole log further down */

.last-time {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  margin: 16px 0 4px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--celery-soft);
}

.last-time::before {
  grid-row: 1 / span 2;
  margin-top: 1px;
  color: var(--celery);
}

.last-time-label {
  margin: 0;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--celery);
}

.last-time-text {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.45;
  white-space: pre-line;
}

.cooks-notes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cooks-notes li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.cooks-notes time {
  font-size: .8rem;
  font-weight: 700;
  color: var(--celery);
}

.cooks-notes p {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.45;
  white-space: pre-line;
}

/* Cook mode (R3.1, R3.2): big type, read at arm's length (D13) */

.cook-bar {
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
}

.cook-bar > :first-child { justify-self: start; }
.cook-bar > :last-child { justify-self: end; }

.cook-bar .bar-title {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.done-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

.chip.sun { --icon-size: 14px; }

.cook {
  max-width: 46rem;
  padding: 4px max(var(--gutter), env(safe-area-inset-right)) 32px max(var(--gutter), env(safe-area-inset-left));
  font-size: 1.15rem;
}

@media (min-width: 760px) {
  .cook { font-size: 1.3rem; }
}

.cook .meta { margin-top: 12px; }

.cook .recipe-section {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 12px;
}

.cook .recipe-section > :not(.section-label, .progress) { grid-column: 1 / -1; }
.cook .group-heading { margin: 14px 0 4px; font-size: 1em; }

.progress {
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

/* How much to make: ×½ ×1 ×2 ×3, or a number typed. For this screen only. */
.scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
  margin: 2px 0 10px;
  padding: 0;
  border: 0;
  font-size: 1rem;
}

.scale .segmented span {
  min-width: 48px;
  padding: 11px 10px;
  font-variant-numeric: tabular-nums;
}

.scale-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
}

.scale-custom span {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.scale input.scale-amount {
  width: 4.5em;
  min-height: 44px;
  padding: 6px 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
}

.scale input.scale-amount[aria-invalid="true"] { border-color: var(--warn); }

.scale-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: .85rem;
  color: var(--ink-2);
}

/* Rows run edge to edge, their text inset. */
.cook-list {
  margin: 0 calc(-1 * var(--gutter));
  padding: 0;
  list-style: none;
}

.cook-list li {
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  /* clear of the bars above and below when brought into view */
  scroll-margin: 72px 0 96px;
}

.tick {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  line-height: 1.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.tick input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.cook-list li:has(input:focus-visible) {
  outline: 2px solid var(--carrot);
  outline-offset: -2px;
}

.tick .box {
  position: relative;
  flex: none;
  width: 1.4em;
  height: 1.4em;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--ink-2);
}

.tick input:checked + .box {
  background: var(--celery);
  box-shadow: none;
}

.tick input:checked + .box::after {
  content: "";
  position: absolute;
  inset: 18%;
  background: var(--on-celery);
  -webkit-mask: var(--check) center / contain no-repeat;
  mask: var(--check) center / contain no-repeat;
}

.cook-list .amount { font-variant-numeric: tabular-nums; }
.cook-list .alt { font-size: .85em; color: var(--ink-2); }
.cook-list .name { font-family: var(--serif); }
.cook-list .note { color: var(--ink-2); }

.cook-list input:checked ~ .line {
  color: var(--ink-2);
  text-decoration: line-through;
}

.cook-steps .line {
  font-family: var(--serif);
  font-size: 1.1em;
  line-height: 1.45;
}

.cook-steps input:checked ~ .line { text-decoration: none; }

.cook-steps .number {
  flex: none;
  width: 1.4em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--carrot);
}

/* A step done: its number becomes a celery tick. */
.cook-steps input:checked + .number {
  color: transparent;
  background: var(--celery);
  -webkit-mask: var(--check) center / 80% no-repeat;
  mask: var(--check) center / 80% no-repeat;
}

.cook-steps li[aria-current="step"] {
  background: var(--carrot-soft);
  box-shadow: inset 4px 0 0 var(--carrot);
}

/* Timers from steps: each time in a step sets one; they wait in a tray above the bottom bar.
   Celery, like the ticks: help while cooking. Time's up turns carrot, to be seen. */

.cook-steps .time {
  text-decoration: underline dotted var(--celery);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.step-timers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -2px;
  padding: 0 0 12px calc(1.4em + 12px);
}

.timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px 6px 10px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--celery);
  color: var(--celery);
  font: inherit;
  font-size: .8em;
  font-weight: 700;
  cursor: pointer;
}

.timer-chip::before {
  content: "";
  width: 1.1em;
  height: 1.1em;
  background: currentColor;
  -webkit-mask: var(--stopwatch) center / contain no-repeat;
  mask: var(--stopwatch) center / contain no-repeat;
}

:root {
  --stopwatch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='14' r='7'/%3E%3Cpath d='M12 10.5V14l2 1.5M10 3h4M12 3v4M18.5 7.5l1.5-1.5'/%3E%3C/svg%3E");
}

.timers {
  width: 100%;
  max-width: 30rem;
}

.timer-list {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.timer {
  padding: 6px 6px 6px 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timer-label {
  min-width: 0;
  overflow: hidden;
  font-size: .8rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.timer-remove {
  flex: none;
  width: 36px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.timer-body {
  display: flex;
  align-items: center;
  gap: 4px;
}

.timer-clock {
  flex: 1;
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.timer-body .button.quiet {
  min-height: 44px;
  padding-inline: 8px;
  font-size: .85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-body .button.quiet:disabled { opacity: .4; cursor: default; }

.timer-main {
  min-width: 6.5em;
  min-height: 44px;
  background: var(--sunken);
  color: var(--ink);
}

.timer[data-state="ready"] .timer-main {
  background: var(--celery);
  color: var(--on-celery);
}

.timer[data-state="running"] .timer-clock { color: var(--celery); }

.timer[data-state="done"] {
  background: var(--carrot-soft);
  box-shadow: inset 0 0 0 2px var(--carrot);
}

.timer[data-state="done"] .timer-clock { color: var(--carrot); }

@media (prefers-reduced-motion: no-preference) {
  .timer[data-state="done"] .timer-clock { animation: ring 1s steps(2, jump-none) infinite; }
}

@keyframes ring {
  from { opacity: 1; }
  to { opacity: .35; }
}

/* The note sheet: up from the bottom on a phone, in the middle when wider */

.sheet {
  width: 100%;
  max-width: 40rem;
  max-height: calc(100dvh - 24px);
  margin: auto auto 0;
  padding: 10px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -8px 30px rgb(0 0 0 / .18);
}

/* Literal colors: older WebKit doesn't pass custom properties to ::backdrop. */
.sheet::backdrop { background: rgb(28 24 20 / .45); }

.sheet form::before {
  content: "";
  display: block;
  width: 40px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 3px;
  background: var(--line);
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    padding-top: 22px;
    border-radius: 20px;
  }

  .sheet form::before { display: none; }
}

.sheet h2 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
}

.sheet .sub {
  margin: 0 0 12px;
  font-size: .9rem;
  color: var(--ink-2);
}

.sheet .alert { margin-bottom: 12px; }

.sheet textarea {
  min-height: 8rem;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.45;
}

.stamp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 2px 14px;
  font-size: .8rem;
  color: var(--ink-2);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.sheet-actions .button {
  min-height: 48px;
  border-radius: 14px;
}

.sheet-actions .button.quiet { box-shadow: inset 0 0 0 1px var(--line); }

/* Disabled until there's a note to save: nothing is busy. */
.sheet-actions .button:disabled { cursor: default; }
