:root {
  --bg: #fef6f8;
  --surface: #ffffff;
  --ink: #2b2428;
  --muted: #8f7980;
  --line: #f5dee4;
  --accent: #d1487a;
  --accent-soft: #fce7ee;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(43, 36, 40, 0.07), 0 6px 18px rgba(43, 36, 40, 0.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* Hebrew faces last: fallback is per character, and the system UI fonts
     cover Hebrew themselves, so this is only the backstop for the ones that
     don't — better a face drawn for Hebrew than whichever font happens to
     cover the block. Hebrew has no ascenders or descenders to lean on, so
     lines set for Latin read cramped: the site's own leading is Hebrew's. */
  font: 17px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        "Noto Sans Hebrew", "Arial Hebrew", sans-serif;
  padding-bottom: 3rem;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem;
}

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

header.site a.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

header.site .brand-icon {
  inline-size: 1.6rem;
  block-size: 1.6rem;
  object-fit: contain;
}

/* An arrow is one of the few things bidi won't mirror for us, and the header
   is the site's own: it reads right to left, so back points right. */
header.site a.brand.back::before { content: "\2192\00a0"; }

main { padding-top: 1.5rem; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }

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

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* ---- controls ---- */

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-height: 2.75rem;
}

button:active, .btn:active { transform: translateY(1px); }

button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.danger { color: #a11; }

button.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0.25rem;
  min-height: 0;
}

button[disabled] { opacity: 0.55; cursor: default; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  min-height: 2.75rem;
}

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

textarea { resize: vertical; line-height: 1.5; overflow: hidden; }

/* An empty dir="auto" field has no strong character to read, and the
   browser's own fallback for that is ltr, not the page it sits on — so a
   Hebrew placeholder renders flush left until something is typed.
   :placeholder-shown only matches while the field is empty, so this defers
   back to the field's own dir="auto" the moment real content exists. */
[dir="auto"]:placeholder-shown { direction: rtl; }

label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.25rem; }

.field { margin-bottom: 0.9rem; }

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.row > * { flex: 1 1 8rem; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ---- browse ---- */

.search { margin-bottom: 1.25rem; }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

.card h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.5rem; }

.tag {
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---- recipe view ---- */

.meta { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--muted); font-size: 0.875rem; margin: 0.75rem 0 0; }
.meta b { color: var(--ink); font-weight: 600; }

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

.ingredients li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.6rem;
}

.ingredients .qty { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 5rem; }

/* Logical, not left: the markers sit on the side the list reads from. */
ol.steps { padding-inline-start: 1.3rem; margin: 0; }
ol.steps li { margin-bottom: 0.85rem; }

ul.notes { padding-inline-start: 1.2rem; margin: 0; color: var(--muted); }

/* ---- editable list rows in the form ---- */

.list { display: grid; gap: 0.5rem; }

.list-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
}

.list-item .fields { flex: 1; display: grid; gap: 0.5rem; min-width: 0; }

/* Quantity and ingredient share a line even on a phone; notes go underneath. */
.list-item .fields.ingredient { grid-template-columns: 6.5rem 1fr; }
.list-item .fields.ingredient .i-notes { grid-column: 1 / -1; }
.list-item .remove { flex: 0 0 auto; align-self: center; }

.step-number {
  flex: 0 0 1.5rem;
  text-align: end;
  color: var(--muted);
  font-weight: 600;
  padding-top: 0.65rem;
}

.notice {
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.notice.error { background: #fdecea; color: #8c1d18; }
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* ---- left-to-right recipes ----
   The layout itself needs nothing: every rule above is either symmetric or
   written in logical properties, so flex, grid and list markers turn around on
   their own for an element marked dir="ltr" inside this right-to-left page.
   What is left is the typography each script wants. */

/* Alignment belongs to whatever stated a direction — the page, or the one
   recipe that turned around inside it — and is pinned in physical terms.
   `start` would be re-resolved by every nested dir, so a Hebrew step in an
   English recipe would pull itself to the far edge while its neighbours
   stayed put. Inherited left/right can't be re-resolved, so a card, an
   article or a form lines up on its own edge and only the reading order
   inside each string still varies. Leaves are marked dir="auto", which
   matches neither selector: they take the edge of whatever holds them. */
[dir="rtl"] { text-align: right; }
[dir="ltr"] { text-align: left; }

/* The site's own wording stays Hebrew inside a recipe that turned around, and
   Hebrew in a left-to-right paragraph loses its edges: a full stop jumps to
   the front, the "+" on a button jumps to the back. These read right-to-left
   wherever they sit. Anything carrying a dir attribute is holding a recipe's
   own words instead, and works them out for itself. */
[dir="ltr"] :where(label, h1, h2, p, button, .btn):not([dir]) { direction: rtl; }

/* Tracking this tight is a Latin habit, and Latin lines set for Hebrew read
   loose — both belong to the text rather than to the page. */
[dir="ltr"] { line-height: 1.55; }
[dir="ltr"] h1 { letter-spacing: -0.02em; }
[dir="ltr"] h2 { letter-spacing: -0.01em; }

@media (min-width: 40rem) {
  .list-item .fields.ingredient { grid-template-columns: 8rem 1fr 1fr; }
  .list-item .fields.ingredient .i-notes { grid-column: auto; }
}
