/* Dinner Tab — one stylesheet for guest and organiser screens.
   Everything scales from --fs so the A-/A+ control resizes the whole page. */

:root {
  --fs: 17px;
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f2ece2;
  --ink: #1c1814;
  --ink-2: #5a5047;
  --line: #e2d8ca;
  --accent: #a4460b;
  --accent-ink: #ffffff;
  --good: #1f6b3a;
  --good-bg: #e3f3e8;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #a3231b;
  --bad-bg: #fde6e3;
  --info-bg: #e8eef8;
  --info: #234a8a;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e; --surface: #1e1a16; --surface-2: #28221c; --ink: #f4ede3; --ink-2: #c4b8a8;
    --line: #3a322a; --accent: #f2a654; --accent-ink: #1a1208; --good: #7fd69b; --good-bg: #1c3324;
    --warn: #f3c969; --warn-bg: #3a2e12; --bad: #ff9a8f; --bad-bg: #3d1d19; --info-bg: #1c2638;
    --info: #9dbcf0; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14110e; --surface: #1e1a16; --surface-2: #28221c; --ink: #f4ede3; --ink-2: #c4b8a8;
  --line: #3a322a; --accent: #f2a654; --accent-ink: #1a1208; --good: #7fd69b; --good-bg: #1c3324;
  --warn: #f3c969; --warn-bg: #3a2e12; --bad: #ff9a8f; --bad-bg: #3d1d19; --info-bg: #1c2638;
  --info: #9dbcf0; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: 2rem; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--ink-2); }
.muted { font-size: .9rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: .75rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: .5rem 0;
}
.topbar .title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  min-width: 2.4rem; height: 2.4rem; border-radius: 10px; font-size: .95rem; cursor: pointer; padding: 0 .5rem;
}
.conn { font-size: .78rem; padding: .15rem .5rem; border-radius: 99px; background: var(--good-bg); color: var(--good); }
.conn.off { background: var(--bad-bg); color: var(--bad); }
.conn.pending { background: var(--warn-bg); color: var(--warn); }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: none; color: var(--ink-2); padding: .6rem .2rem .7rem;
  font-size: .85rem; cursor: pointer; position: relative;
}
.tabs button b { display: block; font-size: 1.15rem; line-height: 1.2; }
.tabs button[aria-selected="true"] { color: var(--accent); font-weight: 700; }
.tabs .dot { position: absolute; top: .35rem; right: 28%; background: var(--accent); color: var(--accent-ink);
  border-radius: 99px; font-size: .68rem; padding: 0 .35rem; font-weight: 700; }
.subtabs { display: flex; gap: .35rem; overflow-x: auto; padding: .5rem 0; scrollbar-width: none; }
.subtabs button { flex: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: .75rem; }
.banner { border-radius: 12px; padding: .7rem .9rem; margin: .75rem 0; font-size: .95rem; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.good { background: var(--good-bg); color: var(--good); }
section { margin: 1rem 0; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: .6rem 1rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { min-height: 2.1rem; padding: .3rem .7rem; font-size: .88rem; border-radius: 10px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.block { width: 100%; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 99px; padding: .3rem .8rem; min-height: 2.2rem; font-size: .9rem; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .7rem; width: 100%; min-height: 2.75rem;
}
input[type="checkbox"], input[type="radio"] { width: 1.3rem; height: 1.3rem; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 4rem; }
label { display: block; font-size: .9rem; color: var(--ink-2); margin: .5rem 0 .2rem; }
label.check { display: flex; gap: .6rem; align-items: center; color: var(--ink); font-size: 1rem; margin: .35rem 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- menu ---------- */
.menu-tools { position: sticky; top: 3.45rem; z-index: 10; background: var(--bg); padding: .5rem 0 .25rem; }
.catnav { display: flex; gap: .4rem; overflow-x: auto; padding: .35rem 0; scrollbar-width: none; }
.catnav::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
.filters { display: flex; gap: .4rem; overflow-x: auto; padding: .25rem 0; scrollbar-width: none; }
.cat-head { margin: 1.4rem 0 .4rem; scroll-margin-top: 9rem; }
.cat-note { color: var(--ink-2); font-size: .9rem; margin-bottom: .4rem; }
.dish { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.dish:last-child { border-bottom: 0; }
.dish-head { display: flex; gap: .75rem; align-items: flex-start; cursor: pointer; background: none; border: 0;
  width: 100%; text-align: left; padding: 0; min-height: 0; color: inherit; border-radius: 0; }
.dish-name { font-weight: 650; font-size: 1.05rem; }
.dish-price { font-weight: 650; margin-left: auto; padding-left: .5rem; }
.dish-desc { color: var(--ink-2); margin: .3rem 0; }
.dish.unavailable .dish-name { text-decoration: line-through; color: var(--ink-2); }
.dish-body { margin-top: .5rem; }
.badges { display: inline-flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.badge { font-size: .74rem; font-weight: 700; padding: .12rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); letter-spacing: .02em; }
.badge.vegan { background: var(--good-bg); color: var(--good); }
.badge.maybe { background: var(--warn-bg); color: var(--warn); }
.badge.flag { background: var(--warn-bg); color: var(--warn); }
.badge.special { background: var(--info-bg); color: var(--info); }
.badge.off { background: var(--bad-bg); color: var(--bad); }
.opts { margin: .4rem 0; padding: 0; list-style: none; }
.opts li { display: flex; justify-content: space-between; padding: .15rem 0; }
.star { font-size: 1.2rem; }

/* ---------- lines ---------- */
.line { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.line:last-child { border-bottom: 0; }
.line .who { color: var(--ink-2); font-size: .88rem; }
.line.pending { opacity: .6; }
.total-row { display: flex; justify-content: space-between; padding: .35rem 0; }
.total-row.big { font-size: 1.25rem; font-weight: 800; }
.stat { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; }
.stat dt { color: var(--ink-2); } .stat dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.state { font-size: .8rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.state.good { background: var(--good-bg); color: var(--good); }
.state.warn { background: var(--warn-bg); color: var(--warn); }
.state.bad { background: var(--bad-bg); color: var(--bad); }
.state.info { background: var(--info-bg); color: var(--info); }

/* ---------- pay ---------- */
.amount-hero { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.copyrow { display: flex; gap: .6rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.copyrow:last-child { border-bottom: 0; }
.copyrow .v { font-weight: 700; font-size: 1.1rem; word-break: break-all; }
.copyrow .k { color: var(--ink-2); font-size: .85rem; }

/* ---------- sheet / modal ---------- */
.sheet-back { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 1rem 16px calc(1.25rem + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { margin-top: .25rem; }
.stepper { display: inline-flex; align-items: center; gap: .5rem; }
.stepper button { width: 2.75rem; padding: 0; font-size: 1.3rem; }
.stepper output { min-width: 2rem; text-align: center; font-weight: 700; font-size: 1.15rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(5.5rem + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: 12px; z-index: 60;
  max-width: calc(100% - 32px); box-shadow: var(--shadow); font-size: .95rem; }
.toast.bad { background: var(--bad); color: #fff; }

.qr { background: #fff; padding: 12px; border-radius: 14px; width: min(78vw, 320px); margin: 0 auto; display: block; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.photo { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.spinner { display: inline-block; width: .9em; height: .9em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
table.plain { width: 100%; border-collapse: collapse; }
table.plain td, table.plain th { padding: .45rem .25rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.plain th { color: var(--ink-2); font-weight: 600; font-size: .85rem; }
details > summary { cursor: pointer; padding: .4rem 0; color: var(--accent); }
.editor { background: var(--surface-2); border-radius: 12px; padding: .75rem; margin-top: .5rem; }
.center { text-align: center; }
.hero { padding: 2.5rem 0 1rem; }

/* Inline forms: input grows, button stays beside it. */
.row > input.grow, .row > select.grow { width: auto; flex: 1 1 8rem; }
/* Keep the bottom tabs thumb-sized on tablets and desktops. */
.tabs { justify-content: center; }
.tabs button { max-width: 180px; }
