/* The owner's Edit screen (/edit/). A phone app first: one column, big rows, one Save button at the bottom.
   iPad: a 640px column, and the dish editor opens as a panel over it. Wide screens (1100px+): the list and the editor side by side
   in a frame up to 1440px; Home page text and Contact in two columns; Hours one row per day. Tokens from tokens.css only. */
body { background: var(--bg); }
body.locked { overflow: hidden; }
.loadfail { margin: 0; padding: var(--s-4); background: var(--danger); color: #fff; font-weight: 600; }
.loadfail a { color: #fff; }
.err { margin: var(--s-2) 0 0; color: var(--danger); font-weight: 600; font-size: var(--t-sm); }

.pin { max-width: 360px; margin: 12vh auto 0; padding: 0 var(--s-4); }
.pin h1 { font-size: var(--t-2xl); margin: var(--s-4) 0 var(--s-2); }
.pin input { width: 100%; min-height: 56px; margin: var(--s-4) 0 var(--s-3); padding: 0 var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-md); font-size: var(--t-xl); letter-spacing: .2em; background: #fff; }

/* Top: who, links, and the three parts */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); box-shadow: 0 1px 0 var(--line); }
.top-in, .seg, main { max-width: var(--page); margin-inline: auto; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4) 0; }
.who { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.who img { width: 36px; height: 36px; flex: none; }
.who .wordmark { margin: 0; font-size: 17px; color: var(--brand); } /* Italiana is a hairline face: 15px was hard to read */
.who h1 { margin: 2px 0 0; font: 800 var(--t-xl)/1 var(--font-display); }
.top-links { display: flex; gap: var(--s-1); }
.top-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-3); border-radius: var(--r-md); font-weight: 600; font-size: var(--t-sm); color: var(--brand); text-decoration: none; }
.top-links a:hover { background: var(--surface); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: var(--s-3); padding: 0 var(--s-4) var(--s-3); }
.seg button { min-height: 44px; border: 0; border-radius: var(--r-md); background: var(--surface); font-weight: 700; font-size: var(--t-sm); color: var(--ink-2); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-selected=true] { background: var(--brand); color: var(--brand-ink); }

main { padding: var(--s-4) var(--s-4) 140px; }
.hint { margin: var(--s-3) 0 0; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.45; }
.empty { padding: var(--s-8) 0; color: var(--ink-2); text-align: center; }

/* Dishes */
.find-row { display: flex; gap: var(--s-2); }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-2); min-height: 52px; padding: 0 var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; color: var(--ink-3); }
.search:focus-within { border-color: var(--brand); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: var(--t-md); color: var(--ink); min-height: 48px; }
.find-row .btn { min-height: 52px; flex: none; }
.cat { margin-top: var(--s-6); }
.cat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding-bottom: var(--s-1); }
.cat-head h2 { margin: 0; font-size: var(--t-lg); }
.cat-head h2 span { margin-inline-start: var(--s-2); color: var(--ink-3); font: 600 var(--t-sm) var(--font-body); }
.link-btn { min-height: 44px; padding: 0 var(--s-2); border: 0; background: none; color: var(--brand); font-weight: 700; font-size: var(--t-sm); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--brand-deep); }
.link-btn.danger { color: var(--danger); margin-top: var(--s-6); padding: 0; }
.dishes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.dishes li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.dish { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-3); min-height: 76px; padding: var(--s-2) 0; border: 0; background: none; text-align: start; }
.dish:hover .tx b { text-decoration: underline; text-underline-offset: 3px; }
.dish .th { width: 60px; height: 60px; flex: none; border-radius: var(--r-md); background: var(--surface); overflow: hidden; display: grid; place-items: center; }
.dish .th img { width: 100%; height: 100%; object-fit: cover; }
.dish .th svg { width: 88%; height: 88%; }
.dish .tx { flex: 1; min-width: 0; }
.dish .tx b { display: block; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.dish .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); margin-top: 3px; color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.dish .chev { flex: none; color: var(--ink-3); }
.dish.is-hidden .th, .dish.is-hidden .tx b { opacity: .5; }
.flag { padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink); font-size: var(--t-xs); line-height: 20px; }
.flag.off { background: var(--ink); color: #fff; }
.reordering .chev { display: none; }
.reordering .dish { cursor: default; }
.moves { display: flex; gap: 4px; flex: none; }
.moves button { width: 48px; height: 48px; border: 0; border-radius: var(--r-md); background: var(--surface); display: grid; place-items: center; color: var(--ink); }
.moves button:hover { background: var(--surface-2); }
.moves button[disabled] { opacity: .3; cursor: default; }

/* Forms */
.form { display: grid; gap: var(--s-5); margin-top: var(--s-4); }
.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field > legend { padding: 0; }
.field > label, .field > legend { display: block; margin-bottom: var(--s-2); font-weight: 700; }
.field input:not([type=file]), .field textarea, .field select {
  width: 100%; min-height: 52px; padding: 12px var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; font-size: var(--t-md); line-height: 1.45;
}
.field textarea { resize: vertical; }
.field select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%234a5650' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center / 20px; padding-inline-end: 44px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.sub { margin: var(--s-2) 0 0; color: var(--ink-2); font-size: var(--t-sm); }
.was { margin: var(--s-2) 0 0; color: var(--signal-text); font-size: var(--t-sm); font-weight: 600; }
.affix { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; }
.affix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.affix.bad { border-color: var(--danger); }
.affix > span { padding-inline-start: var(--s-4); color: var(--ink-2); font-weight: 700; }
.field .affix input { border: 0 !important; box-shadow: none !important; padding-inline-start: 4px; background: none; }
.affix.price input { font: 700 var(--t-lg) var(--font-display); font-variant-numeric: tabular-nums; }
.affix.price.sm { width: 128px; flex: none; }
.affix.price.sm input { min-height: 48px; font-size: var(--t-md); }
.affix.price.sm > span { padding-inline-start: var(--s-3); font-size: var(--t-sm); }
#dGroups { display: grid; gap: var(--s-4); }
#dGroups:empty { display: none; }
.grp-h { margin: var(--s-2) 0 calc(var(--s-1) * -1); font: 800 var(--t-lg) var(--font-display); }
.grp legend { margin-bottom: var(--s-1) !important; }
.grp .sub { margin: 0 0 var(--s-2); }
.field > label.opt { display: flex; margin: 0; font-weight: 600; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 6px 0; border-bottom: 1px solid var(--line); }
.opt > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 44px; padding: 0 var(--s-4); border: 1.5px solid var(--line); border-radius: 22px; background: #fff; font-weight: 700; font-size: var(--t-sm); }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip[aria-pressed=true]::before { content: ""; display: inline-block; width: 12px; height: 7px; margin-inline-end: 8px; border: solid currentColor; border-width: 0 0 2.4px 2.4px; transform: translateY(-3px) rotate(-45deg); }

/* Switch (same look as the orders screen) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; border-block: 1px solid var(--line); }
.switch-row b { display: block; }
.switch-row small { display: block; margin-top: 2px; color: var(--ink-2); font-size: var(--t-sm); }
.sw { flex: none; position: relative; width: 60px; height: 34px; padding: 0; border: 0; border-radius: 17px; background: #b9b3a6; transition: background-color .15s; }
.sw span { position: absolute; top: 4px; inset-inline-start: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s var(--ease); }
.sw[aria-checked=true] { background: var(--ok); }
.sw[aria-checked=true] span { transform: translateX(26px); }
.sw::before { content: ""; position: absolute; inset: -6px; } /* 46px tap area */

/* Home page: the text guests read, then how to reach the café */
.home-form { gap: var(--s-8); }
.form-group { display: grid; gap: var(--s-5); min-width: 0; }
.form-h { margin: 0; font: 800 var(--t-lg)/1.2 var(--font-display); color: var(--brand); }

/* Hours */
.hours { display: grid; gap: 0; border-top: 1px solid var(--line); }
.day { padding: var(--s-3) 0 var(--s-4); border-bottom: 1px solid var(--line); }
.day-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
.day-top b { font-size: var(--t-lg); }
.day-sub { margin: 0; color: var(--ink-2); font-size: var(--t-sm); }
.day.closed .day-sub { color: var(--danger); font-weight: 600; }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-3); }
.times label span { display: block; margin-bottom: 4px; color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.times input { width: 100%; min-height: 52px; padding: 0 var(--s-3); border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; font: 700 var(--t-md) var(--font-body); font-variant-numeric: tabular-nums; }
.times input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

/* Save bar: always at the bottom, Save on the right, what happened on the left */
.savebar { position: fixed; inset-inline: 0; width: 100%; bottom: 0; z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) max(var(--s-4), calc((100% - var(--page)) / 2 + var(--s-4))) calc(var(--s-3) + env(safe-area-inset-bottom)); background: var(--bg); box-shadow: var(--shadow-bar); }
.savestate { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; font-size: var(--t-sm); min-width: 0; }
.savestate svg { color: var(--ok); flex: none; }
.btn.big { min-height: 56px; min-width: 132px; font-size: var(--t-lg); }

/* Dish editor: full screen on a phone, slides in from the side */
.editor { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); transform: translateX(100%); transition: transform .25s var(--ease); }
.editor.show { transform: none; }
.ed-top { display: flex; align-items: center; gap: var(--s-2); min-height: 60px; padding: var(--s-2) var(--s-4) var(--s-2) var(--s-2); box-shadow: 0 1px 0 var(--line); }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 var(--s-3) 0 var(--s-1); border: 0; border-radius: var(--r-md); background: none; color: var(--brand); font-weight: 700; flex: none; }
.back:hover { background: var(--surface); }
.ed-top h2 { margin: 0; min-width: 0; font-size: var(--t-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-scroll { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-4) var(--s-12); -webkit-overflow-scrolling: touch; }
.ed-photo .ph { aspect-ratio: 4 / 3; border-radius: var(--r-lg); background: var(--surface); overflow: hidden; display: grid; place-items: center; position: relative; }
.ed-photo .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ed-photo .ph svg { width: 62%; height: 80%; }
.ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin-top: var(--s-3); }
.ph-actions .btn { cursor: pointer; }
.ph-actions .btn.off { opacity: .5; cursor: default; }
.ph-actions .btn.busy { opacity: .7; pointer-events: none; }
.ph-actions label:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.savebar.in-editor { position: static; padding-inline: var(--s-4); box-shadow: 0 -1px 0 var(--line); }

/* Toast with Undo, above the save bar */
.toast { position: fixed; left: 50%; bottom: 96px; z-index: 30; display: flex; align-items: center; gap: var(--s-3); width: max-content; max-width: calc(100vw - 32px); padding: 6px 6px 6px 16px; min-height: 48px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 600; font-size: var(--t-sm); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s var(--ease); }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast #toastText { padding-block: 8px; }
.toast-undo { min-height: 44px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-sm); background: var(--signal); color: var(--signal-ink); font-weight: 800; }
.toast-undo[hidden] + *, .toast:has(.toast-undo[hidden]) { padding-inline-end: 16px; }

/* The editor's empty state: only seen when it's docked beside the list with no dish open */
.ed-empty { display: none; }
.ed-empty p { margin: 0; max-width: 28ch; color: var(--ink-2); }
.ed-empty b { display: block; margin-bottom: var(--s-1); color: var(--ink); font: 800 var(--t-lg)/1.25 var(--font-display); }

@media (min-width: 760px) {
  main { padding-top: var(--s-6); }
  .editor { inset-inline-start: auto; width: 520px; box-shadow: -12px 0 40px rgba(18, 28, 38, .16); }
  body.locked::after { content: ""; position: fixed; inset: 0; z-index: 15; background: rgba(23, 36, 30, .3); }

  /* Editor: the photo as a thumbnail beside its buttons, and Name and Price on one line, so the fields show without scrolling */
  .ed-photo { display: grid; grid-template-columns: 168px minmax(0, 1fr); column-gap: var(--s-4); align-items: center; }
  .ed-photo .ph { grid-row: 1 / span 2; }
  .ph-actions { margin-top: 0; flex-direction: column; align-items: flex-start; gap: var(--s-1); }
  .ed-photo .sub { grid-column: 2; margin-top: 0; }
  #dishForm { grid-template-columns: minmax(0, 1fr) 168px; column-gap: var(--s-4); }
  #dishForm > * { grid-column: 1 / -1; }
  #dishForm > .f-name { grid-column: 1; }
  #dishForm > .f-price { grid-column: 2; }

  /* Hours: one row per day, the times beside the day; the Opens / Closes labels show on the first row only (still read out on every row) */
  .day { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 1.4fr); column-gap: var(--s-8); align-items: center; padding-block: var(--s-3); }
  .day-top, .day-sub { grid-column: 1; }
  .times { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  .day + .day .times label span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Wide screens: a wider frame, compact tabs, Home page in two columns */
@media (min-width: 1024px) {
  .top-in, .seg, main { max-width: 1440px; }
  .top-in, .seg, main { padding-inline: var(--s-8); }
  .seg { grid-template-columns: repeat(3, minmax(0, 168px)); }
  .savebar { padding-inline: max(var(--s-8), calc((100% - 1440px) / 2 + var(--s-8))); }
  .home-form { grid-template-columns: minmax(0, 680px) minmax(280px, 380px); column-gap: var(--s-12); align-items: start; }
  .home-form > .link-btn { grid-column: 1; justify-self: start; }
  #v-hours { max-width: 860px; }
  .list-pane { max-width: 760px; } /* until the editor docks beside it (1100px+) */
}

/* 1100px+: the list and the dish editor side by side; the editor stays in view under the header and scrolls on its own */
@media (min-width: 1100px) {
  #v-dishes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(480px, 600px); column-gap: var(--s-8); align-items: start; }
  .list-pane { min-width: 0; max-width: none; container-type: inline-size; }
  .editor.docked {
    position: sticky; inset: auto; top: calc(var(--top-h, 125px) + var(--s-4)); z-index: 1;
    width: auto; height: calc(100dvh - var(--top-h, 125px) - var(--s-8)); transform: none; transition: none;
    border-radius: var(--r-lg); box-shadow: 0 0 0 1px var(--line), 0 8px 24px rgba(18, 28, 38, .06); overflow: hidden;
  }
  .editor.docked .back { display: none; } /* nothing to go back to: the list is right there (Escape still closes) */
  .editor.docked .ed-top { padding-inline-start: var(--s-4); }
  .editor.docked .savebar.in-editor { box-shadow: 0 -1px 0 var(--line); }
  .editor.idle > :not(.ed-empty) { display: none; }
  .editor.idle .ed-empty { display: grid; place-items: center; height: 100%; padding: var(--s-8); text-align: center; }
  .dish { margin-inline: calc(var(--s-2) * -1); padding-inline: var(--s-2); border-radius: var(--r-md); }
  .dish:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
  .dish[aria-current="true"] { background: var(--surface); }
  .dish[aria-current="true"] .tx b { color: var(--brand); }
}
/* A roomy list (about 1600px screens): dishes in two columns. Not while reordering, where up and down must read as one column. */
@container (min-width: 700px) {
  .dishes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-8); }
  .cat.reordering .dishes { display: block; }
}
