/* "Carta impresa de bistró": a menu typeset on warm paper. Fraunces sets the title, the
   family headings and the dish names; Source Sans 3 carries everything that is read in
   passing. Both fall back to solid system stacks if the font service is unreachable. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..700;1,9..144,400..600&family=Source+Sans+3:ital,wght@0,400..700;1,400..600&display=swap');

:root {
  /* Paper and ink. */
  --paper: #f4ede0;
  --bg: #f4ede0;
  --card-bg: #fcf9f2;
  --border: #ddd0b9;
  --rule-strong: #b8a688;
  --text: #221b17;
  --text-muted: #685a4c;
  /* One deep accent, burgundy, and a muted ochre for small ornaments (never for text). */
  --accent: #7d1f2c;
  --accent-hover: #5e1520;
  --accent-tint: #f4e6e1;
  --ochre: #b38b45;
  --danger: #a12a1f;
  --danger-tint: #f7e7e3;

  --font-serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-sans: 'Source Sans 3', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;

  --tap: 2.75rem;
  --radius: 6px;
  --shadow-paper: 0 1px 2px rgba(60, 40, 20, 0.06), 0 6px 20px -8px rgba(60, 40, 20, 0.18);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

/* Warm paper with a grain so faint it only registers as texture. */
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(110, 80, 40, 0.05) 1px, transparent 1.2px),
    radial-gradient(rgba(110, 80, 40, 0.035) 1px, transparent 1.2px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    box-shadow 150ms ease, transform 120ms ease;
}

/* One visible focus ring everywhere, drawn only for the keyboard. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

header {
  padding: calc(1.75rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 1.1rem
    calc(1rem + env(safe-area-inset-left));
  text-align: center;
}

header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 600;
  font-optical-sizing: auto;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* A small ochre rule with a dot under every title: the printer's ornament. */
header::after {
  content: '';
  display: block;
  width: 5.5rem;
  height: 7px;
  margin: 0.85rem auto 0;
  background:
    radial-gradient(circle, var(--ochre) 2.4px, transparent 3px) center / 7px 7px no-repeat,
    linear-gradient(var(--ochre), var(--ochre)) left center / 38% 1px no-repeat,
    linear-gradient(var(--ochre), var(--ochre)) right center / 38% 1px no-repeat;
}

.subtitle {
  color: var(--text-muted);
  margin: 0.35rem 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--text-muted);
  text-decoration: none;
  padding: 0 0.15rem;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover {
  color: var(--text);
}

.main-nav a.current {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 calc(1rem + env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-paper);
}

.card h2 {
  margin-top: 0;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
}

.field-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  flex: 2;
}

.field-small {
  flex: 1;
  min-width: 90px;
}

input {
  min-height: var(--tap);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: #fffdf8;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #8e8070;
}

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

textarea {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: #fffdf8;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
  resize: vertical;
}

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

.closed-message-field {
  margin-top: 1rem;
}

.field-help {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* A day with no service reads as such from across the room. */
.day-closed {
  border-color: var(--danger);
}

.day-closed textarea {
  border-color: var(--danger);
}

.notice {
  margin: 0;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--accent-tint);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sides-section {
  margin-top: 1.1rem;
  border-top: 1px dashed var(--rule-strong);
  padding-top: 0.75rem;
}

.sides-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sides-header h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

#add-side,
#add-time {
  min-height: var(--tap);
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.3rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

#add-side:hover,
#add-time:hover {
  background: var(--accent-tint);
}

.side-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
}

/* A flex item will not shrink below the width its content wants unless it is told to,
   which is what pushed this row — and the card around it — off the side of a phone. */
.side-row input {
  flex: 2;
  min-width: 0;
}

.side-row .field-small {
  flex: 1;
  min-width: 0;
}

/* On a phone the description takes the whole width and the unit, the price and the
   remove button share the line below it. Three fields abreast on 390px leaves each one
   too narrow to read what you typed. */
@media (max-width: 719px) {
  .side-row .side-description {
    flex: 1 1 100%;
  }
}

.remove-side {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

.remove-side:hover {
  background: var(--danger-tint);
}

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.5rem;
}

button.primary {
  flex: 1;
  min-height: 3rem;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.secondary {
  min-height: 3rem;
  padding: 0.65rem 1.25rem;
  background: none;
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

button.secondary:hover {
  background: var(--bg);
}

.hidden {
  display: none;
}

.edit-item {
  min-height: var(--tap);
  padding: 0 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

.edit-item:hover {
  background: var(--accent-tint);
}

.empty-state {
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-style: italic;
  text-align: center;
}

.menu-hint {
  margin: 1rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-tint);
  color: var(--text);
  font-size: 0.88rem;
}

.dishes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dish-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  background: var(--card-bg);
}

.dish-item-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

/* The name keeps a readable width; when the price and the two actions do not fit beside
   it, they drop to a line of their own, aligned right, instead of squeezing the name. */
.dish-item-header > :first-child {
  flex: 1 1 11rem;
  min-width: 0;
}

.dish-item-header > :last-child {
  margin-left: auto;
}

.dish-title {
  font-family: var(--font-serif);
  font-weight: 560;
  font-size: 1.05rem;
  line-height: 1.25;
}

.dish-extra {
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 0.88rem;
}

.dish-price {
  font-family: var(--font-serif);
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}

.delete-dish {
  min-height: var(--tap);
  padding: 0 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

.delete-dish:hover {
  background: var(--danger-tint);
}

.side-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding-left: 0.75rem;
}

.time-row .time-value {
  flex: 1;
}

.daily-dishes {
  margin-top: 1rem;
}

/* The card is the wrapper, not the row: a button cannot hold a number field, so the box
   sits beside the row inside one border and reads as part of the same item. */
.daily-dish-holder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.daily-dish,
.daily-line {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  text-align: left;
}

/* One dish and its combinados, with a handle to drag the whole dish at once. */
.daily-dish-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Lifted out of the flow and following the finger. */
.daily-dish-group.dragging {
  box-shadow: 0 10px 28px rgba(34, 27, 23, 0.25);
  border-radius: var(--radius);
  background: var(--card-bg);
}

/* The gap the dragged dish will drop into. */
.daily-drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-tint);
}

.daily-dish-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.daily-group-label {
  margin: 0 0 0.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Combinados collapse under a toggle so a dish is one short, easy-to-drag row. */
.daily-combos-toggle {
  align-self: flex-start;
  min-height: 2.25rem;
  background: none;
  border: none;
  padding: 0.15rem 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.daily-combos-toggle-active {
  color: var(--accent);
  font-weight: 600;
}

.daily-combos-caret {
  display: inline-block;
  width: 1em;
}

.daily-combos-count {
  color: var(--accent);
  font-weight: 600;
}

.daily-combos {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--ochre);
}

/* This rule comes after .hidden, so it has to re-assert the hide with more weight. */
.daily-combos.hidden {
  display: none;
}

.daily-dish-holder:active {
  background: var(--bg);
}

.daily-dish-holder:has(.daily-dish-chosen) {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.daily-dish-title {
  flex: 1;
}

.daily-dish-mark {
  visibility: hidden;
  color: var(--accent);
  font-weight: 700;
}

.daily-dish-chosen .daily-dish-mark {
  visibility: visible;
}

button.primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
}

.order-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.order-line-title {
  flex: 1;
}

/* The carta row reuses the order line's layout — name on the left, price on the right,
   allergens and ingredients wrapping onto their own line below — but it is read-only, so
   none of the pointer, selection or quantity behaviour comes with it. */
.carta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.order-line-chosen {
  border-color: var(--accent);
}

.order-line:active {
  background: var(--bg);
}

.order-line-amount {
  min-width: 1.6rem;
  text-align: right;
  font-weight: 600;
  color: var(--accent);
}

.order-line-remove {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  border-top: 1px dashed var(--rule-strong);
  padding-top: 0.9rem;
}

.time-options-label {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.time-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.time-option {
  min-height: var(--tap);
  padding: 0.45rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}

.time-option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.order-total {
  margin: 0;
  font-weight: 600;
}

.order-summary {
  margin-top: 1rem;
}

.order-summary .side-item {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  padding-left: 0;
}

.order-summary-total {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--rule-strong);
  font-size: 1.05rem;
}

.order-total span:last-child {
  color: var(--accent);
}

.drop-point-slug {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.drop-point-slug:hover {
  color: var(--accent);
}

.time-option.closed {
  color: var(--text-muted);
  background: var(--bg);
  text-decoration: line-through;
  cursor: not-allowed;
}

.kitchen-status {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.kitchen-status-live {
  color: var(--accent);
  border-color: var(--accent);
}

.kitchen-status-down {
  color: var(--danger);
  border-color: var(--danger);
}

.kitchen-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kitchen-group-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.kitchen-group-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kitchen-chip {
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

/* A batch nobody has to cook any more steps back visually without disappearing. */
.kitchen-group-ready {
  border-color: var(--accent);
}

.kitchen-group-ready .kitchen-group-count {
  color: var(--accent);
}

.kitchen-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.kitchen-line:active {
  background: var(--bg);
}

.kitchen-line-title {
  flex: 1;
}

.kitchen-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* Done is an achievement, not a dead control: the line keeps its full contrast and
   picks up the same chosen look the daily menu uses. */
.kitchen-line-done {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.kitchen-line-done .kitchen-count {
  font-size: 1.4rem;
}

.kitchen-undo {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--text-muted);
  color: white;
  font-size: 0.9rem;
  /* The arrow glyph sits high in its own box, so the badge centres it as a flex item
     instead of trusting the line box. */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

.kitchen-undo.hidden {
  display: none;
}

/* Desktop only: the phone layout below 720px stays exactly as it is. */
@media (min-width: 720px) {
  main {
    max-width: 1080px;
  }

  header h1 {
    font-size: 2.3rem;
  }

  .dishes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    column-gap: 0.75rem;
  }

  /* Rows of one-line items look ragged when a long name wraps, so every card in
     these two lists takes the height of the tallest one. */
  #daily-dishes,
  #order-lines,
  .kitchen-group .dishes-list {
    grid-auto-rows: 1fr;
  }

  /* The board is read from across the kitchen, so its cards spread over the whole
     width instead of leaving empty tracks like the lists the staff read up close. */
  .kitchen-group .dishes-list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

.day-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.day-picker input {
  flex: 1;
  min-width: 0;
}

.day-picker button {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.day-picker button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* A family's name, sitting above the dishes that belong to it. It spans the whole grid so
   the family below it starts on a fresh row instead of continuing mid-line. Set like the
   section of a printed menu: centred small capitals in the house colour between two fine
   ochre double rules, well apart from the plain dish lines under it — the first one keeps
   a smaller top gap so it does not float. */
.line-group-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 1.9rem 0 0.35rem;
  padding: 0;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-optical-sizing: auto;
}

.line-group-heading::before,
.line-group-heading::after {
  content: '';
  flex: 1 1 1.5rem;
  min-width: 1.5rem;
  height: 4px;
  border-top: 1px solid var(--ochre);
  border-bottom: 1px solid var(--ochre);
  opacity: 0.75;
}

.line-group-heading:first-child {
  margin-top: 0.25rem;
}

@media (min-width: 720px) {
  .line-group-heading {
    grid-column: 1 / -1;
  }
}

/* A dish with no price is a group; the list says so where the price would be. */
.dish-group-tag {
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* A plate that just arrived. The flash fades on its own, so a cook who looks up a few
   seconds later sees a normal board rather than a permanent badge to dismiss. */
@keyframes kitchen-arrived {
  from {
    background: #f2d6cf;
    border-color: var(--accent);
  }
  to {
    background: var(--card-bg);
    border-color: var(--border);
  }
}

.kitchen-line-new {
  animation: kitchen-arrived 2.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .kitchen-line-new {
    animation: none;
    border-color: var(--accent);
  }
}

/* The list above these can run to ninety lines, so the action stays on screen instead of
   waiting at the bottom of it. Sticky rather than fixed: the bar keeps its place in the
   flow, so it never covers the last row, and it stops sticking at the end of its own
   card — which is what a page with several forms needs. */
.form-actions,
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding-bottom: calc(0.25rem + env(safe-area-inset-bottom));
}

.sticky-actions {
  /* The wrapper sticks as one piece; the footer and the buttons inside it would otherwise
     stick separately and sit on top of each other. */
  padding-top: 0.1rem;
}

.sticky-actions .form-actions {
  position: static;
  padding-bottom: 0;
}

/* A line scrolling underneath must not read through the bar. */
.form-actions::before,
.sticky-actions::before {
  content: '';
  display: block;
  border-top: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sticky-actions .form-actions::before {
  content: none;
}

/* The bar is a flex row, so its rule has to span the whole width as a line of its own. */
.form-actions {
  flex-wrap: wrap;
}

.form-actions::before {
  flex: 1 1 100%;
  margin-bottom: 0.25rem;
}

/* The summary card's buttons are the end of a short card; a bar there would only add a
   line above two buttons nobody has to hunt for. */
#summary-card .form-actions {
  position: static;
}

#summary-card .form-actions::before {
  content: none;
}

/* Small and fixed: stretched to the row's height it dwarfed everything next to a name
   that wrapped over four lines. */
.daily-dish-stock {
  width: 4.25rem;
  height: var(--tap);
  flex: none;
  padding: 0.25rem 0.45rem;
  font-size: 0.95rem;
  text-align: right;
}

/* How many are left, under the name. Absolutely positioned so adding one never changes
   the height of the row, the same reason the amount has a fixed width. */
.order-line-left {
  position: absolute;
  left: 0.9rem;
  bottom: 0.1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.order-line:has(.order-line-left:not(:empty)) {
  padding-bottom: 1.4rem;
}

/* Nothing left: the row stays readable but stops being a control. */
.order-line-sold-out {
  background: var(--bg);
  cursor: not-allowed;
}

.order-line-sold-out .dish-title,
.order-line-sold-out .dish-price {
  color: var(--text-muted);
}

.order-line-sold-out .order-line-left {
  color: var(--danger);
}

/* The counter line: one tap sells one, so the whole row is the control and the two small
   buttons sit out of the way of a thumb aiming at it. */
.counter-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding-right: 2.6rem;
}

.counter-line:active {
  background: var(--bg);
}

.counter-line-title {
  flex: 1;
  min-width: 0;
}

.counter-breakdown {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.counter-count {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.counter-line-empty {
  background: var(--bg);
}

.counter-line-empty .counter-count {
  color: var(--text-muted);
}

/* Sold more than there was: an order placed through the app is going to come up short,
   and nobody would find out until the round went out. */
.counter-line-short {
  border-color: var(--danger);
}

.counter-short {
  color: var(--danger);
  font-weight: 600;
}

.counter-add {
  position: absolute;
  bottom: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

/* Allergens and ingredients under the name. Always there rather than behind a control:
   tapping the row adds to the order, and nobody with an allergy should have to open
   dishes one at a time to find out. */
.order-line-details {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.35rem;
  margin-top: 0.1rem;
}

/* Discreet small capitals with a hairline frame: present and legible, never shouting. */
.allergen-tag {
  padding: 0.05rem 0.4rem;
  border: 1px solid rgba(125, 31, 44, 0.38);
  border-radius: 3px;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.order-line-ingredients {
  flex: 1 1 100%;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* The order line has to wrap now that a second row hangs under the name. */
.order-line {
  flex-wrap: wrap;
}

/* The multiselect in Gestión: a chip has the shape of the tag it becomes on the carta,
   so what is marked is what will be seen. */
.allergen-field {
  margin-top: 1rem;
}

.allergen-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.allergen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.allergen-chip {
  min-height: 2.5rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.allergen-chip-on {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}

.details-field {
  margin-top: 0.75rem;
}

/* A side carries its own, so its row grows a second and third line on a phone. */
.side-row .side-ingredients,
.side-row .allergen-chips {
  flex: 1 1 100%;
  min-width: 0;
}

/* Says whether this screen will make a sound when an order comes in, and fixes it when
   the browser is holding the sound back until somebody touches the page. */
.chime-button {
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  vertical-align: middle;
}

.chime-button-muted {
  color: var(--text-muted);
}

/* Not an error, but it does need a tap, so it asks for one rather than sitting quiet. */
.chime-button-blocked {
  border-color: var(--accent);
  color: var(--accent);
}

/* Carta: the category filter bar. Chips scroll horizontally and stick to the top so the
   categories stay reachable while the list scrolls. It reaches the edges of the screen,
   and fades the chips out at either end so it is clear there are more to the side. */
.carta-categories {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin: 0 calc(-1rem - env(safe-area-inset-right)) -0.5rem calc(-1rem - env(safe-area-inset-left));
  padding: 0.55rem calc(1rem + env(safe-area-inset-right)) 0.55rem calc(1rem + env(safe-area-inset-left));
  scroll-padding-inline: 1rem;
  background: var(--paper);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 0.9rem, #000 calc(100% - 1.6rem), transparent);
  mask-image: linear-gradient(to right, transparent, #000 0.9rem, #000 calc(100% - 1.6rem), transparent);
}

.carta-categories::-webkit-scrollbar {
  display: none;
}

.carta-chip {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 1.05rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}

.carta-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.carta-chip:focus-visible {
  outline-offset: -4px;
}

.carta-chip-on,
.carta-chip-on:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.carta-chip-on:focus-visible {
  outline-color: #fff;
}

/* Gestión: the single free-text category field on the dish form. */
#tag-input {
  width: 100%;
}

/* Menú del día: the per-day ordering list. */
.daily-order {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.daily-order-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* The grab handle: touch-action none so dragging it never scrolls the page. */
.drag-handle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: var(--tap);
  cursor: grab;
  touch-action: none;
  color: var(--rule-strong);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  user-select: none;
}

.drag-handle:hover {
  color: var(--text-muted);
}

.daily-order-row.dragging {
  opacity: 0.6;
  border-color: var(--accent);
  cursor: grabbing;
}

/* The carta scrolls as a normal page — so pull-to-refresh keeps working — with the category
   bar stuck to the top, reachable however far down the dishes you are. A line under it marks
   where the fixed part ends and the list begins. */
.carta-categories {
  border-bottom: 1px solid var(--border);
}

/* ——— The carta as a printed menu ——— */

/* A line above the title says what the house is; only on the public carta. */
body:has(#carta-lines) header::before {
  content: 'Comida casera';
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

body:has(#carta-lines) header h1 {
  font-size: 2.75rem;
  font-weight: 600;
  font-style: italic;
  letter-spacing: -0.015em;
}

body:has(#carta-lines) .subtitle {
  margin-top: 0.4rem;
  font-size: 1.02rem;
}

body:has(#carta-lines) header::after {
  margin-top: 0.75rem;
}

/* The menu sheet: one page with a fine inner double frame, laid on the paper of the table. */
.card:has(> #carta-lines) {
  padding: 1.4rem 1.1rem 1.1rem;
  box-shadow:
    inset 0 0 0 5px var(--card-bg),
    inset 0 0 0 6px var(--border),
    var(--shadow-paper);
}

#carta-lines {
  gap: 0;
}

/* Less card, more list: the dishes are lines on the page, divided by a hairline. */
.dish-item.carta-line {
  gap: 0.35rem 0.6rem;
  padding: 0.85rem 0.15rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: none;
}

.dish-item.carta-line:last-child,
.dish-item.carta-line:has(+ .line-group-heading) {
  border-bottom: none;
}

/* Name, a dotted leader, then the price, as a printed menu sets them. The price takes the
   room the name leaves and draws the dots across it, so the leader always runs from the
   end of the name to the figure. Name, price and stepper share the last baseline of the
   name, which keeps the price beside a long name's final line. */
.dish-item.carta-line {
  align-items: baseline;
  align-items: last baseline;
  /* In the two-column layout a short line shares its row with a taller one; it stays at
     the top of the row instead of floating in the middle of it. */
  align-content: flex-start;
}

/* A zero basis keeps the row from wrapping the stepper away; the huge grow lets the name
   take all the room it wants, capped at its own width, and whatever is left goes to the
   leader. */
.carta-line .order-line-title {
  flex: 1000 1 0;
  min-width: 0;
  max-width: max-content;
}

.carta-line .dish-title {
  font-size: 1.12rem;
  overflow-wrap: break-word;
}

.carta-line .dish-extra {
  white-space: nowrap;
}

.carta-line .dish-price {
  flex: 1 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 1.08rem;
  line-height: 1.25;
}

.carta-line .dish-price::before {
  content: '';
  position: relative;
  top: -0.28em;
  flex: 1 1 0.75rem;
  min-width: 0.75rem;
  border-bottom: 1.5px dotted var(--rule-strong);
}

/* Carta: ordering over WhatsApp (order.js). A stepper on each line, a bar fixed to the
   bottom once something is in the order, and a sheet that slides up with the summary.
   The buttons look 36px but answer to a 44px finger: an invisible ring extends each one. */
.order-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}

.order-stepper button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.order-stepper button::after {
  content: '';
  position: absolute;
  inset: -0.3rem;
  border-radius: 50%;
}

.order-stepper button:hover {
  background: rgba(34, 27, 23, 0.06);
}

.order-stepper button:active {
  transform: scale(0.92);
}

.order-stepper .order-add,
.order-stepper .order-plus {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.order-stepper .order-add:hover,
.order-stepper .order-plus:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.order-quantity {
  min-width: 1.4rem;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}

/* A line already in the order wears a small ochre mark in the margin. */
.dish-item.carta-line:has(.order-quantity) {
  box-shadow: inset 3px 0 0 var(--ochre);
  padding-left: 0.7rem;
}

/* Leave room under the last line so the bar never covers it. */
body:has(.order-bar:not(.hidden)) main {
  padding-bottom: calc(7rem + env(safe-area-inset-bottom));
}

/* The bar rises out of the paper: a soft fade behind it keeps the lines under it from
   reading through the button. */
.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 1.5rem calc(1rem + env(safe-area-inset-right)) calc(0.85rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: linear-gradient(to top, var(--paper) 55%, rgba(244, 237, 224, 0));
  pointer-events: none;
  animation: order-rise 260ms var(--ease);
}

.order-bar > * {
  pointer-events: auto;
}

.order-bar-button,
.order-send {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: 3.25rem;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: lining-nums tabular-nums;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 8px 22px -6px rgba(94, 21, 32, 0.55);
}

.order-bar-button:hover,
.order-send:hover {
  background: var(--accent-hover);
}

.order-bar-button:active,
.order-send:active {
  transform: translateY(1px);
}

.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(34, 24, 18, 0.45);
  animation: order-fade 220ms ease-out;
}

/* The sheet is a paper slip handed up from the bottom edge: lighter stock, a grip at the
   top, and a shadow cast onto the menu behind it. */
.order-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 36rem;
  max-height: 88vh;
  max-height: 88dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.6rem calc(1.25rem + env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom))
    calc(1.25rem + env(safe-area-inset-left));
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  background-color: var(--card-bg);
  background-image:
    radial-gradient(rgba(110, 80, 40, 0.035) 1px, transparent 1.2px);
  background-size: 9px 9px;
  box-shadow: 0 -12px 40px -8px rgba(34, 24, 18, 0.35);
  animation: order-slide 320ms var(--ease);
}

.order-sheet::before {
  content: '';
  display: block;
  width: 2.5rem;
  height: 4px;
  margin: 0 auto 0.6rem;
  border-radius: 2px;
  background: var(--border);
}

@keyframes order-slide {
  from {
    transform: translateY(100%);
  }
}

@keyframes order-fade {
  from {
    opacity: 0;
  }
}

@keyframes order-rise {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

.order-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.25rem;
  border-bottom: 3px double var(--rule-strong);
}

.order-sheet-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 600;
  font-style: italic;
  line-height: 1.15;
}

.order-close {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin-right: -0.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.order-close:hover {
  background: rgba(34, 27, 23, 0.06);
  color: var(--text);
}

.order-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px dotted var(--rule-strong);
}

.order-items .order-item:last-child {
  border-bottom: none;
}

.order-item-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.3;
}

.order-item-name small {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text-muted);
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
  padding: 0.8rem 0 0;
  border-top: 1px solid var(--text);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}

.order-field-label {
  display: block;
  margin: 0.5rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.order-times {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.order-time {
  flex: 1;
  min-height: 3.1rem;
  padding: 0.6rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  font-variant-numeric: lining-nums tabular-nums;
  cursor: pointer;
}

.order-time:hover {
  border-color: var(--accent);
}

.order-time-on,
.order-time-on:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.order-error {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--danger);
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 600;
}

.order-hint {
  margin: 0.75rem auto 0;
  max-width: 26rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

/* The order sent today from this browser, above the carta: a receipt slip with the house
   colour along its top edge. */
.order-summary {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.order-summary.card {
  margin: 0;
  border-top: 3px solid var(--accent);
  padding: 1.1rem 1.15rem 1.15rem;
}

.order-summary h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 600;
}

.order-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--rule-strong);
  font-family: var(--font-serif);
  font-size: 1rem;
  font-variant-numeric: lining-nums tabular-nums;
}

.order-summary-line:last-child {
  border-bottom: none;
}

.order-summary-line span:last-child {
  white-space: nowrap;
}

.order-summary .order-total {
  border-top: 1px solid var(--text);
  margin-top: 0.3rem;
}

.order-summary-time {
  margin: 0 0 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.order-summary-edit,
.order-discard {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.order-summary-edit:hover {
  background: var(--accent-tint);
}

.order-discard {
  max-width: 32rem;
  margin: 0.6rem auto 0;
  border-color: var(--rule-strong);
  color: var(--text-muted);
  font-weight: 500;
}

.order-discard:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.order-cancel-note {
  margin: 0.75rem 0 0.25rem;
  color: var(--danger);
  font-weight: 600;
}

.order-items-cancelled .order-item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.order-items-cancelled {
  margin-bottom: 1rem;
}

/* On a wide screen the carta opens like a two-page menu: two columns of lines on one
   sheet, with the families still running across both. */
@media (min-width: 720px) {
  main:has(#carta-lines) {
    max-width: 960px;
  }

  body:has(#carta-lines) header h1 {
    font-size: 3.4rem;
  }

  .card:has(> #carta-lines) {
    padding: 2rem 2.5rem 1.75rem;
  }

  #carta-lines {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 3rem;
  }

  #carta-lines .line-group-heading {
    margin-top: 2.25rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
  }

  #carta-lines .line-group-heading:first-child {
    margin-top: 0.25rem;
  }

  /* With two lines per row, the last pair of a family both lose their rule. */
  .dish-item.carta-line:has(+ .carta-line + .line-group-heading),
  .dish-item.carta-line:nth-last-child(2) {
    border-bottom-color: transparent;
  }

  .carta-categories {
    justify-content: safe center;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .order-sheet {
    bottom: 1.5rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    max-height: calc(100vh - 3rem);
  }

  @keyframes order-slide {
    from {
      opacity: 0;
      transform: translateY(2rem);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
