:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #6b635b;
  --line: #e7e0d6;
  --accent: #d9571a;
  --accent-ink: #ffffff;
  --ok: #1f7a3d;
  --ok-bg: #e3f3e7;
  --modify: #8a5a00;
  --modify-bg: #fff1cf;
  --no: #b42318;
  --no-bg: #fde7e4;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --surface: #1f1c19;
    --ink: #f3eee8;
    --muted: #a39a90;
    --line: #34302b;
    --accent: #f07a35;
    --accent-ink: #1a0f08;
    --ok: #7fd49a;
    --ok-bg: #173022;
    --modify: #f2c45a;
    --modify-bg: #382c10;
    --no: #ff8f84;
    --no-bg: #3a1a17;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px 10px;
}

.brand { display: flex; flex-direction: column; }
.brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-sub {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reset {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

.reset:disabled { opacity: 0.35; cursor: default; }

.topbar-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.topbar-actions .reset { white-space: nowrap; }

.pos-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.pos-link:hover { border-color: var(--accent); color: var(--accent); }

/* Phones: a round POS button so the brand and "New guest" keep their one-line layout. */
@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .reset { padding: 0 14px; }
  .pos-link { justify-content: center; width: 44px; padding: 0; font-size: 0.8rem; }
}

/* Layout */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Needs panel */
.panel-title { margin: 6px 0 0; font-size: 1rem; }
.panel-hint { margin: 2px 0 10px; color: var(--muted); font-size: 0.85rem; }

.needs-group + .needs-group { margin-top: 10px; }

.needs-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.needs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.need {
  min-height: 46px;
  padding: 6px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.need[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.protocol {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82rem;
}

/* Results */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 14px -16px 0;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.summary {
  margin: 0 0 8px;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
}

.search:focus { border-color: var(--accent); outline: none; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--line);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}

.segmented button:disabled { cursor: default; color: var(--muted); }

.seg-count {
  display: inline-block;
  min-width: 1.6em;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

/* Dish list */
.group { margin-top: 18px; }

.group-title {
  display: flex;
  justify-content: space-between;
  margin: 0 0 4px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.row {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.group .row:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.group .row:last-of-type { border-bottom: 0; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

.row summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
}

.row summary::-webkit-details-marker { display: none; }

.row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.name { font-weight: 650; }

.note { color: var(--muted); font-size: 0.85rem; }
.note--no { color: var(--no); }
.note--modify { display: flex; flex-direction: column; color: var(--modify); font-weight: 600; }
.mod::before { content: "↳ "; }

.pill {
  flex: none;
  min-width: 68px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
}

.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--modify { background: var(--modify-bg); color: var(--modify); }
.pill--no { background: var(--no-bg); color: var(--no); }

.row--no .name { color: var(--muted); }

.detail {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.detail p { margin: 0 0 6px; }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.detail b { color: var(--ink); font-weight: 650; }
.diet { color: var(--ok); font-weight: 650; }
.price { font-variant-numeric: tabular-nums; }

.empty {
  margin: 24px 0;
  padding: 24px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.site-footer {
  max-width: 1200px;
  margin: 32px auto 0;
  padding: 16px 16px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p { max-width: 80ch; }

/* Phones: keep the needs grid compact so answers start sooner. */
@media (max-width: 899px) {
  .panel-title, .panel-hint { display: none; }
  .need { min-height: 42px; font-size: 0.88rem; }
  .needs-group + .needs-group { margin-top: 8px; }
  .protocol { margin-top: 10px; padding: 8px 10px; font-size: 0.78rem; }
}

/* Tablet / desktop: needs pinned on the left, answers on the right. */
@media (min-width: 900px) {
  .layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 28px;
    align-items: start;
  }

  .panel {
    position: sticky;
    top: 12px;
  }

  .needs-grid { grid-template-columns: repeat(2, 1fr); }

  .toolbar {
    margin: 0;
    padding: 6px 0 10px;
  }
}
