/* We Eat: hand-written app stylesheet. Phone-first; 16px base so iOS doesn't zoom inputs. */
:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --text: #1f1b16;
  --muted: #6d655c;
  --accent: #c2410c;
  --border: #e7e0d7;
  --danger-bg: #fdecea;
  --danger: #9f1d1d;
  --tab-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171411;
    --surface: #221e1a;
    --text: #f2ede7;
    --muted: #a39a90;
    --accent: #fb923c;
    --border: #3a332c;
    --danger-bg: #3b1616;
    --danger: #fca5a5;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
input, select, textarea, button { font: inherit; font-size: 1rem; }

#screen {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--tab-h) + 1.5rem + env(safe-area-inset-bottom));
}
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
.empty { color: var(--muted); }

/* Screen header with an optional "⋯" menu (a <details>) at the top right */
.screen-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.more-menu { position: relative; }
.more-menu > summary {
  list-style: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 0.5rem;
}
.more-menu > summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute;
  right: 0;
  z-index: 10;
  min-width: 12rem;
  margin: 0.25rem 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.menu-items a, .menu-items button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  text-decoration: none;
}

/* Bottom tab bar */
.tabs {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabs a {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.tabs a[aria-current="page"] { color: var(--accent); }

/* Error slot */
#error-slot:empty { display: none; }
#error-slot {
  position: fixed;
  inset: 0.75rem 0.75rem auto 0.75rem;
  z-index: 20;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--danger-bg);
  color: var(--danger);
}
.request-id { font-family: ui-monospace, monospace; }

/* The sheet: one native dialog styled as a bottom sheet */
#sheet {
  margin: auto 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 90dvh;
  border: 0;
  border-radius: 1rem 1rem 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--text);
}
#sheet::backdrop { background: rgb(0 0 0 / 0.4); }

/* Error page */
.error-page { padding-top: 3rem; text-align: center; }

/* Places */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.chip {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.tag-picker .chip { cursor: pointer; }
h2 { font-size: 1rem; color: var(--muted); margin: 1.25rem 0 0.5rem; }
.restaurant-card, .history-card {
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.restaurant-card h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.25rem; padding: 0; list-style: none; }
.tag { font-size: 0.85rem; color: var(--muted); text-transform: capitalize; }
.meta { margin: 0; font-size: 0.9rem; color: var(--muted); }
.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--tab-h) + 1rem + env(safe-area-inset-bottom));
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 1.75rem;
  text-decoration: none;
}

/* Add Restaurant form */
.add-restaurant label, .add-restaurant fieldset,
.import-review > label, .import-review .tag-picker { display: block; margin-bottom: 1rem; }
.add-restaurant fieldset, .import-review .tag-picker { border: 0; padding: 0; }
.add-restaurant input:not([type="hidden"]),
.fill-from-website input,
.import-review > label input, .import-review .tag-picker input:not([type="hidden"]) {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.field-error { margin: -0.5rem 0 1rem; color: var(--danger); }
.warning { margin: -0.5rem 0 1rem; color: var(--muted); }
.add-restaurant button[type="submit"],
.import-review button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
}

/* Restaurant card: the name link is stretched over the card; card buttons sit above it. */
.restaurant-card { position: relative; }
.card-open { color: inherit; text-decoration: none; }
.card-open::after { content: ""; position: absolute; inset: 0; }
.restaurant-card button, .restaurant-card form { position: relative; z-index: 1; }
.restaurant-card.shelved { opacity: 0.55; }

/* Restaurant page (in the sheet) */
.restaurant-page { min-height: 70dvh; display: flex; flex-direction: column; }
.restaurant-page .restaurant-name { font-size: 1.4rem; color: var(--text); margin: 0 0 0.35rem; }
.restaurant-page.shelved .restaurant-name::after { content: " · shelved"; font-size: 0.9rem; color: var(--muted); }
.restaurant-page .address, .restaurant-page .website { margin: 0.25rem 0; }
.restaurant-page .website a { color: var(--accent); }
.restaurant-page .actions { display: flex; gap: 0.5rem; margin: 1rem 0; }
.restaurant-page button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.restaurant-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.restaurant-footer form { margin: 0; }
.restaurant-footer .note { margin: 0; color: var(--muted); font-size: 0.9rem; }
.restaurant-page button.danger { color: var(--danger); border-color: var(--danger); }

/* Start Visit (Places card) */
.start-visit { margin: 0.6rem 0 0; }
.start-visit button, .finish-visit button, .visit-date button {
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* Visit tab */
.visit-header {
  display: block;
  width: 100%;
  margin: -0.5rem 0 1rem;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--muted);
  text-align: left;
}
.finish-visit button { width: 100%; padding: 0.75rem; }

/* Visit header panel */
.visit-date label { display: block; margin-bottom: 1rem; }
.visit-date input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.discard-visit { margin-top: 1.5rem; }
.discard-visit button {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: none;
  color: var(--danger);
}

/* Start Visit on the Restaurant page sits in the actions row. */
.restaurant-page .actions .start-visit { margin: 0; }
.restaurant-page .start-visit button { border: 1px solid var(--accent); background: var(--accent); color: var(--bg); }

/* Login pages */
.login form { display: grid; gap: 0.75rem; }
.login input[type="email"] {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
}
.login button {
  padding: 0.85rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.login .hint { color: var(--muted); }

/* Ratings on the Visit tab (§4.5): rows open the rating panel in the sheet. */
.rating-list { margin: 0 0 1rem; padding: 0; list-style: none; }
.rating-row button, .rating-row .row-static {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  text-align: left;
}
.rating-row .row-name { flex: 1; }
.rating-row .other-score { font-size: 0.85rem; color: var(--muted); }
.rating-row .my-score { min-width: 3.5rem; text-align: right; color: var(--accent); font-weight: 600; }
.rating-row.shelved { opacity: 0.55; }
/* A "For you" row (§4.7): the reason sits on its own line under the name and scores. */
.rating-row button:has(.reason) { flex-wrap: wrap; row-gap: 0.15rem; }
.rating-row .reason { order: 1; flex-basis: 100%; font-size: 0.85rem; color: var(--muted); }
#menu:empty::after { content: "No Dishes yet. Add one below."; color: var(--muted); }

/* Restaurant page Dishes and the Dish panel (§4.1) */
.dishes h3 { margin: 0.5rem 0 0.25rem; font-size: 1rem; }
.dishes .note { color: var(--muted); }
.dish-list { margin: 0 0 1rem; padding: 0; list-style: none; }
.restaurant-page .dish-row button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.dish-row .row-name { flex: 1; }
.dish-row .other-score { font-size: 0.85rem; color: var(--muted); }
.dish-row.shelved { opacity: 0.55; }
.dish-panel .back { display: inline-block; margin-bottom: 0.5rem; color: var(--accent); text-decoration: none; }
.dish-panel.shelved h2::after { content: " · shelved"; font-size: 0.9rem; color: var(--muted); }
.dish-panel .rating-summary { margin: 0 0 1rem; padding: 0; list-style: none; color: var(--muted); }
.dish-panel label { display: block; margin-bottom: 1rem; }
.dish-panel input:not([type="hidden"]) {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.dish-panel form { margin: 0 0 1rem; }
.dish-panel button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.dish-panel button[role="switch"]::after { content: ": off"; color: var(--muted); }
.dish-panel button[role="switch"][aria-checked="true"]::after { content: ": on"; color: var(--accent); }
.dish-panel button.danger { color: var(--danger); border-color: var(--danger); }
.dish-panel .note { color: var(--muted); font-size: 0.9rem; }

/* "For you" (§4.7): Dish Suggestions (rating rows with a reason) above the Menu. */
.for-you { margin: 0 0 1rem; }
.for-you-heading { display: flex; align-items: center; gap: 0.5rem; }
.for-you-heading h2 { flex: 1; margin: 0; }
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.mode-switch button { padding: 0.3rem 0.7rem; border: 0; background: none; color: var(--text); font-size: 0.85rem; }
.mode-switch button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.show-others { padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 999px; background: none; color: var(--text); }
.suggestion-list { margin: 0.5rem 0 0; }

.add-dish { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.add-dish input, .visit-notes textarea, .rating-panel textarea {
  flex: 1;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.add-dish .field-error { flex-basis: 100%; margin: 0; }
.add-dish button, .visit-notes button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: none;
  color: var(--accent);
}
.visit-notes { margin: 0 0 1.25rem; }
.visit-notes label { display: block; margin-bottom: 0.5rem; }
.visit-notes .saved { margin-left: 0.75rem; color: var(--muted); }

/* The rating panel: five large score buttons */
.rating-panel h2 { font-size: 1.3rem; color: var(--text); margin: 0 0 0.5rem; }
.rating-panel .other-rating { margin: 0 0 0.75rem; color: var(--muted); }
.rating-panel label { display: block; margin-bottom: 0.75rem; }
.scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
.scores button {
  min-height: 4rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.scores button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.remove-rating { margin-top: 1rem; }
.remove-rating button {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: none;
  color: var(--danger);
}

/* Restaurant Import (§4.8): the Fill from website box and the Review page */
.fill-from-website { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.fill-from-website label { display: block; margin-bottom: 0.5rem; }
.fill-from-website button { margin-right: 0.5rem; padding: 0.5rem 1rem; border: 1px solid var(--accent); border-radius: 8px; background: none; color: var(--accent); }
.import-section { margin: 0 0 1rem; padding: 0; border: 0; }
.import-section legend { font-weight: 600; padding: 0.25rem 0; }
.import-section input[type="checkbox"] { width: 1.25rem; height: 1.25rem; margin-right: 0.5rem; vertical-align: middle; }
.import-dishes { list-style: none; margin: 0; padding: 0; }
.import-dishes li { display: flex; align-items: flex-start; gap: 0.25rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.import-dish { flex: 1; display: flex; flex-direction: column; }
.import-dish small { color: var(--muted); }
/* Looks like text; tapping the name edits it. */
.dish-name { width: 100%; padding: 0.15rem 0; border: 0; border-bottom: 1px dashed transparent; background: none; color: var(--text); }
.dish-name:focus { border-bottom-color: var(--accent); outline: none; }

/* Finished Visits and History (§4.1). */
.history-card { position: relative; }
.history-card h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.history-card p { margin: 0.15rem 0 0; }
.history-card .visit-ratings { font-size: 0.9rem; }
.history-card .note, .visit-note { color: var(--muted); font-style: italic; }
.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
}
.banner .close { color: var(--accent); }
.restaurant-visits ul { margin: 0; padding: 0; list-style: none; }
.restaurant-visits li a { display: block; padding: 0.5rem 0; color: var(--text); border-bottom: 1px solid var(--border); }
.restaurant-visits .in-progress { color: var(--accent); }
.delete-visit { margin-top: 1rem; }
.delete-visit button { width: 100%; padding: 0.6rem; border: 1px solid var(--danger); border-radius: 8px; background: none; color: var(--danger); }
/* Suggest tab (§4.3, §7.4) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.suggest-filters { margin: 0 0 1rem; }
.suggest-filters select {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  text-transform: capitalize;
}
.suggest-filters fieldset { border: 0; padding: 0; margin: 0; }
.suggest-filters .chip input { position: absolute; opacity: 0; pointer-events: none; }
.suggest-filters .chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.suggest-filters .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.suggest-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.suggest-card {
  flex: 0 0 100%;
  scroll-snap-align: start;
  padding: 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.suggest-card h2 { font-size: 1.4rem; color: var(--text); margin: 0 0 0.35rem; }
.suggest-card .meta { margin-bottom: 0.75rem; }
.dots { display: flex; gap: 0.4rem; margin: 0 0 1rem; }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--border); }
.dot.current { background: var(--accent); }
.suggest-actions { display: flex; gap: 0.5rem; align-items: center; }
.suggest-actions .start-visit { margin: 0; }
.not-tonight {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.suggestions-empty .button { color: var(--accent); }

/* Two Members, one Visit (§4.4): notices, the stale-draft nudge, attending Members, the start offer. */
.screen-visit .notice, .stale-nudge, .add-restaurant .notice {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
}
.stale-nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.stale-nudge p { flex-basis: 100%; margin: 0; }
.stale-nudge form { margin: 0; }
.attending-members h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
.attending-members ul { margin: 0 0 0.75rem; padding: 0; list-style: none; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.attending-members form { margin: 0; }
.start-conflict { display: grid; gap: 0.75rem; }
.start-conflict h2, .start-conflict p { margin: 0; }
.start-conflict form { margin: 0; }
.start-conflict .continue, .start-conflict button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: none;
  color: var(--accent);
  text-align: center;
  text-decoration: none;
}
.start-conflict .continue { background: var(--accent); color: var(--bg); }
