/* Calm. A quiet, uncluttered page: the floor plan and the booking steps read
   easily, the owner's side stays discreet. Colours, type, radii and the
   spacing that gives the page its rhythm live here as custom properties;
   everything below uses them, never a written-out colour. */

/* Tokens first. The shell's slot is the one that must survive every redesign:
   inside an older Second Draft shell a 48px round button floats in the
   bottom-right corner, 16px in from each edge, above everything. This app draws
   its own note trigger instead, so second-draft-note.css sets --shell-slot to
   0 and puts it back only inside such a shell. Keep clear of the corner with
   var(--shell-slot), never a fixed 80px, and the space is there exactly when
   the button is. */
:root {
  --shell-switcher-size: 48px;
  --shell-switcher-inset: 16px;
  --shell-switcher-gap: 16px;
  --shell-slot: 80px; /* inset + size + gap: the corner the shell owns */

  --paper: #fbfaf7;
  --ink: #2a2b29;
  --soft: #4b4b47;
  --muted: #6a6963;
  --rule: #e4e1d9;
  --mark: #aaa79e;
  --accent: #4a6578;
  --card: #fbfaf7;
  --wash: #f3f0ea;
  --on-accent: #fbfaf7;
  --danger: #8a2f3d;

  --serif: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;

  --radius-pill: 999px;
  --radius-round: 50%;
  --radius-card: 14px;
  --gutter: 14px;
  color-scheme: light dark;
}
/* The same page on a phone set to dark. --paper here is the dark theme-color
   tag in index.html, as --paper above is the light one: change them together. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #242220;
    --ink: #f1ede8;
    --soft: #cfc9c0;
    --muted: #a9a29b;
    --rule: #3b3835;
    --mark: #6a6963;
    --accent: #a8c5d4;
    --card: #2b2926;
    --wash: #2e2c29;
    --on-accent: #1d2225;
    --danger: #e8909c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
body { min-height: 100dvh; }
a, button { font: inherit; color: inherit; }

/* The shell gives the page the whole window, behind the clock at the top and
   the gesture bar at the bottom: the background is ours to cover, the content
   ours to keep clear of both. */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding-right: calc(20px + max(var(--shell-safe-right, 0px), env(safe-area-inset-right, 0px)));
  padding-bottom: calc(max(var(--shell-safe-bottom, 0px), env(safe-area-inset-bottom, 0px)) + var(--shell-slot));
  padding-left: calc(20px + max(var(--shell-safe-left, 0px), env(safe-area-inset-left, 0px)));
}

/* The app's bar: the width of the window, in the flow of the page. */
.top-bar {
  position: sticky; top: 0; z-index: 1; background: var(--paper);
  display: flex; align-items: flex-start; gap: 12px;
  margin: 0; padding-bottom: 8px;
  padding-top: calc(24px + max(var(--shell-safe-top, 0px), env(safe-area-inset-top, 0px)));
  padding-right: calc(20px + max(var(--shell-safe-right, 0px), env(safe-area-inset-right, 0px)));
  padding-left: calc(20px + max(var(--shell-safe-left, 0px), env(safe-area-inset-left, 0px)));
}
.top-bar .page-heading { flex: 1; min-width: 0; margin: 0; }
@media (min-width: 760px) {
  .top-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 600px) minmax(0, 1fr); gap: 0; }
  .top-bar .page-heading { grid-column: 2; }
  .top-bar .top-actions { grid-column: 3; justify-self: end; }
}
.page-heading {
  font-family: var(--serif);
  font-weight: 350;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

/* The note trigger: the app's own control, in the app's own colours. */
.note-trigger {
  appearance: none; flex: none;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--rule); border-radius: var(--radius-round);
  background: var(--card); color: var(--accent);
}
.top-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.install-app {
  appearance: none; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--rule); border-radius: var(--radius-pill);
  background: var(--card); color: var(--accent); font: inherit; font-weight: 500;
}
.install-app:focus-visible,
.note-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sd-mark { width: 24px; height: 24px; }

/* ---------- Calm rows: a margin note, then the writing ---------- */
.row { display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: var(--gutter); align-items: baseline; }
.label {
  font-family: var(--serif);
  font-variant-caps: all-small-caps;
  font-size: 15px; font-weight: 400; letter-spacing: 0.09em; line-height: 1;
  color: var(--muted);
}
.label.own { color: var(--accent); }
.day {
  font-family: var(--serif); font-weight: 300;
  font-size: 44px; line-height: 1.02; letter-spacing: -0.012em;
  margin: 0;
}
.greet { margin: 18px 0 0; font-family: var(--serif); font-weight: 350; font-size: 21px; line-height: 1.4; }
.intro { margin: 6px 0 0; font-size: 15px; font-weight: 300; line-height: 1.55; color: var(--muted); text-wrap: balance; }
.say { font-family: var(--serif); font-weight: 350; font-size: 21px; line-height: 1.42; margin: 0; text-wrap: balance; }
.note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.sec { margin-top: 44px; }
.rule-top { border-top: 1px solid var(--rule); }
.item { padding: 15px 0 16px; }
.item + .item { border-top: 1px solid var(--rule); }

/* ---------- Controls ---------- */
.field { margin-top: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="tel"],
.field input[type="date"],
.field input[type="time"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--rule); border-radius: var(--radius-pill);
  background: var(--card); color: var(--ink);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button {
  appearance: none; border: 0; border-radius: var(--radius-pill); padding: 13px 22px;
  background: var(--accent); color: var(--on-accent); cursor: pointer; font-weight: 500;
  min-height: 48px;
}
.button.quiet { background: transparent; color: var(--accent); border: 1px solid var(--rule); }
.button:disabled { opacity: 0.55; cursor: default; }
.quiet { color: var(--muted); margin: 0; }
.error-text { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* ---------- The room ---------- */
.room {
  position: relative;
  margin-top: 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  background: var(--card);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}
.room .room-tag {
  position: absolute; left: 12px; top: 10px;
  font-family: var(--serif); font-variant-caps: all-small-caps; font-size: 13px; letter-spacing: 0.08em;
  color: var(--muted);
}
.table-dot {
  position: absolute; transform: translate(-50%, -50%);
  display: grid; place-items: center;
  border: 1px solid var(--mark);
  background: var(--paper); color: var(--ink);
  cursor: pointer; padding: 0;
  min-width: 56px; min-height: 56px;
  font-size: 13px; font-weight: 500;
}
.table-dot.round { border-radius: var(--radius-round); aspect-ratio: 1; }
.table-dot.square { border-radius: var(--radius-card); }
.table-dot .seats { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.table-dot[aria-pressed="true"] { border: 2px solid var(--accent); color: var(--accent); }
.table-dot.taken { border-style: dashed; color: var(--muted); background: var(--wash); cursor: not-allowed; }
.table-dot.temporary::after {
  content: 'special';
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap;
}
.room-legend { display: flex; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.room-legend i { display: inline-block; width: 10px; height: 10px; border-radius: var(--radius-round); border: 1px solid var(--mark); margin-right: 6px; vertical-align: baseline; }
.room-legend .is-taken { background: var(--wash); border-style: dashed; }
.room-legend .is-mine { background: var(--accent); border-color: var(--accent); }

/* ---------- Dishes ---------- */
.dish { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 13px 0; align-items: center; }
.dish + .dish { border-top: 1px solid var(--rule); }
.dish .what { font-size: 16px; }
.dish .meta { font-size: 13px; color: var(--muted); }
.dish .pre { font-size: 12px; color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 44px; height: 44px; border-radius: var(--radius-round);
  border: 1px solid var(--rule); background: var(--card); color: var(--accent);
  font-size: 20px; line-height: 1;
}
.stepper output { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Tabs & footer ---------- */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--rule); margin-top: 26px; }
.tabs button, .tabs a {
  appearance: none; background: none; border: 0; padding: 12px 0 10px;
  font-size: 14px; color: var(--muted); text-decoration: none; cursor: pointer;
}
.tabs [aria-current="true"] {
  color: var(--ink); text-decoration: underline; text-underline-offset: 6px;
  text-decoration-thickness: 1px; text-decoration-color: var(--accent);
}
.foot {
  position: sticky; bottom: 0; background: var(--paper);
  border-top: 1px solid var(--rule);
  padding-bottom: max(var(--shell-safe-bottom, 0px), env(safe-area-inset-bottom, 0px));
}
.foot nav {
  max-width: 640px; margin: 0 auto; padding: 6px 20px 14px;
  display: flex; gap: 26px;
}
.foot a {
  display: inline-block; padding: 12px 0 6px;
  font-size: 13px; color: var(--muted); text-decoration: none;
}
.foot a[aria-current] {
  color: var(--ink); text-decoration: underline; text-underline-offset: 6px;
  text-decoration-thickness: 1px; text-decoration-color: var(--accent);
}

/* ---------- Admin ---------- */
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 13px 0; align-items: center; }
.kv + .kv { border-top: 1px solid var(--rule); }
.kv .what { font-size: 16px; }
.kv .meta { font-size: 13px; color: var(--muted); }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--rule); font-size: 12px; color: var(--muted);
}
.pill.accent { color: var(--accent); border-color: var(--accent); }
.inline-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mini {
  appearance: none; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--rule); border-radius: var(--radius-pill);
  background: var(--card); color: var(--accent); font-size: 14px;
}
.mini.danger { color: var(--danger); }
.editor { border: 1px solid var(--rule); border-radius: var(--radius-card); padding: 14px; margin-top: 14px; background: var(--card); }
.editor h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin: 0 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 > * { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); margin-top: 12px; }
.check input { width: 22px; height: 22px; }

/* ---------- Wide window: a layout, not a strip ---------- */
@media (min-width: 900px) {
  .page { max-width: 1060px; }
  /* The heading keeps the content's column: 1020px is the page less its padding. */
  .top-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1020px) minmax(0, 1fr); }
  .split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
  /* Booking reads better with the room beside the time, and the dishes beside the booking. */
  #app.book { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 0 48px; align-items: start; }
  #app.book > header { grid-column: 1 / -1; }
  .foot nav { max-width: 1060px; }
}

/* Messages that are not the page: keep out of the shell's corner. */
#toast {
  position: fixed; left: 16px; right: var(--shell-slot);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--shell-switcher-inset));
  pointer-events: none;
}
#toast:empty { display: none; }
#toast > * { background: var(--ink); color: var(--paper); border-radius: var(--radius-card); padding: 12px 16px; }

button, input, select, textarea { font: inherit; }
