/* Dinner Picker — mobile first, light + dark. */
:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-2: #f4ede4;
  --text: #2a211b;
  --muted: #74675c;
  --line: #e7ddd1;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fde6d8;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --safe: #0f766e;
  --while: #a16207;
  --wild: #7c3aed;
  --shadow: 0 1px 2px rgb(60 40 20 / 8%), 0 4px 14px rgb(60 40 20 / 8%);
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1612;
    --surface: #27201a;
    --surface-2: #322921;
    --text: #f3ebe3;
    --muted: #b3a597;
    --line: #3d3229;
    --accent: #fb923c;
    --accent-ink: #1c1612;
    --accent-soft: #4a2a17;
    --good: #4ade80;
    --good-soft: #173823;
    --bad: #f87171;
    --bad-soft: #451c1c;
    --safe: #2dd4bf;
    --while: #facc15;
    --wild: #c4b5fd;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 680px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
  outline: none;
}
h1 { font-size: 1.6rem; margin: 4px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.75rem; font-weight: 600;
}
.tabs a.on { color: var(--accent); }
.tab-ico { font-size: 1.35rem; line-height: 1; filter: grayscale(0.6); }
.tabs a.on .tab-ico { filter: none; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; border-radius: 10px; }
.btn.big { min-height: 52px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; border-radius: 12px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.no.on { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.chip.lv-love { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.chip.lv-like { background: color-mix(in srgb, var(--good-soft) 50%, var(--surface)); border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.chip.lv-avoid { background: color-mix(in srgb, var(--bad-soft) 50%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.chip.lv-never { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; }
.segmented button {
  flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap; padding: 4px 10px;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.hint { font-size: 0.8rem; color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], input[type="tel"], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.label-row { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; }
.label-row h2, .label-row h3 { margin: 0; }
.section-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 16px 0 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.pick { position: relative; overflow: hidden; }
.pick::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--slot); }
.pick.safe { --slot: var(--safe); }
.pick.while { --slot: var(--while); }
.pick.wild { --slot: var(--wild); }
.slot-name { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--slot); }
.pick h2 { margin: 4px 0 2px; font-size: 1.3rem; }
.pick .meta { color: var(--muted); font-size: 0.875rem; }
.pick .why { margin: 10px 0; }
.mode-note { font-size: 0.85rem; color: var(--while); margin: 0 0 8px; }
.dishes { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.dishes li { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.dishes .who { font-weight: 700; }
.dishes .reason { color: var(--muted); font-size: 0.85rem; }
.pick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pick-actions .btn.primary { grid-column: 1 / -1; }
.links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 0.9rem; font-weight: 600; }
.links a { text-decoration: none; }
.pick.leaving { opacity: 0.4; transition: opacity 0.2s; }

.controls { margin-bottom: 8px; }
.controls .section-label:first-child { margin-top: 4px; }
.more-toggle { margin: 6px 0 0; }

.week { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.week::-webkit-scrollbar { display: none; }
.day {
  flex: none; min-width: 84px; max-width: 130px; padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); font-size: 0.8rem; text-decoration: none; color: var(--text);
}
.day b { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.day span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day.empty-day { color: var(--muted); border-style: dashed; background: transparent; }

.nag {
  display: flex; gap: 10px; align-items: center; background: var(--accent-soft); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 0.92rem;
}
.nag .grow { min-width: 0; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list-item {
  display: flex; gap: 12px; align-items: center; padding: 12px 4px; min-height: 56px;
  color: var(--text); text-decoration: none; width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.list-item .end { margin-left: auto; color: var(--muted); font-size: 0.85rem; text-align: right; flex: none; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); vertical-align: middle;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.search { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0 10px; }

/* ---------- log ---------- */
.place-results { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.place-results .list-item { padding: 10px 12px; }
.chosen { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); }
.chosen .title { font-weight: 700; }
.person-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); }
.person-block + .person-block { margin-top: 10px; }
.person-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 8px; }
.dish-pick { display: flex; flex-direction: column; gap: 6px; }
.dish-chosen { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 6px 6px 6px 12px; }
.dish-chosen .grow { font-weight: 600; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rate {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; padding: 6px 2px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 0.72rem; font-weight: 600; color: var(--muted);
}
.rate .em { font-size: 1.4rem; line-height: 1.1; }
.rate.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.checkbox { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; min-height: 36px; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- place detail ---------- */
.detail-head h1 { margin-bottom: 4px; }
.feel-row { display: flex; flex-direction: column; gap: 8px; }
.feel-person { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.menu-cat { margin-top: 18px; }
.menu-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.menu-item:last-child { border-bottom: 0; }
.menu-item .name { font-weight: 600; }
.menu-item .desc { color: var(--muted); font-size: 0.85rem; }
.menu-item .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.menu-item .price { margin-left: auto; font-weight: 600; flex: none; }
.menu-item.inactive { opacity: 0.5; }
.hist-meal { padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist-meal:last-child { border-bottom: 0; }

/* ---------- history ---------- */
.bar-row { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; margin: 6px 0; font-size: 0.875rem; }
.bar { height: 10px; border-radius: 6px; background: var(--accent); min-width: 4px; }
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: 0.8rem; }

/* ---------- prefs ---------- */
.pref-group { margin-bottom: 14px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; margin-bottom: 10px; }

/* ---------- dialogs, toast, misc ---------- */
dialog.sheet {
  width: min(560px, 100vw); max-width: 100vw; max-height: 92vh; margin: auto auto 0; padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 20px 20px 0 0; background: var(--bg); color: var(--text); overflow-y: auto;
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 20px; } }
dialog.sheet::backdrop { background: rgb(0 0 0 / 45%); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 12px 0 8px; }
.sheet-head h2 { margin: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.92rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .btn { margin-top: 10px; }
.loading { display: flex; gap: 6px; justify-content: center; padding: 40px 0; }
.loading .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.loading .dot:nth-child(2) { animation-delay: 0.15s; }
.loading .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .loading .dot { animation: none; opacity: 0.7; } .toast { transition: none; } }

/* ---------- setup + login ---------- */
.setup, .login { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.setup form, .login form { text-align: left; margin-top: 20px; }
.hero-emoji { font-size: 3.5rem; }
.lead { color: var(--muted); font-size: 1.05rem; }
.error-text { color: var(--bad); font-size: 0.9rem; min-height: 1.3em; }
