:root {
  --bg: #f6f3ec;
  --surface: #fffdf9;
  --ink: #1d1a15;
  --muted: #6b6357;
  --line: #e2dacb;
  --accent: #23543f;
  --accent-ink: #ffffff;
  --good: #2f8f5b;
  --neutral: #a87a12;
  --bad: #c4452d;
  --none: #9a9184;
  --good-soft: #e3f1e8;
  --neutral-soft: #f6ecd2;
  --bad-soft: #f8e2dc;
  --shadow: 0 6px 24px rgba(40, 30, 10, 0.14);
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --surface: #1f1c17;
    --ink: #f1ece2;
    --muted: #a49b8c;
    --line: #353028;
    --accent: #7fc8a3;
    --accent-ink: #10231a;
    --good: #5cc48c;
    --neutral: #dcb04a;
    --bad: #ee7a62;
    --none: #7b7366;
    --good-soft: #1c3327;
    --neutral-soft: #3a2f14;
    --bad-soft: #43201a;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--sans);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 100vh;
  height: 100dvh;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 24px;
}

.mapwrap { position: relative; min-width: 0; min-height: 0; }
.map { position: absolute; inset: 0; }
.tabs { display: none; }

/* ---------- header and search ---------- */

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 18px;
}

.wordmark {
  flex: 1;
  font: 600 22px/1.1 var(--serif);
  letter-spacing: -0.01em;
}
/* The release beside the name, as in ClassPlease: "v1.2". */
.wordmark .version {
  margin-left: 3px;
  font: 400 13px/1 var(--sans);
  letter-spacing: 0;
  color: var(--muted);
}

.sync-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; color: var(--good); }
.sync-mark[data-state="busy"] { color: var(--muted); }
.sync-mark[data-state="error"] { color: var(--bad); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--line); color: var(--ink); }
.icon-btn.small { width: 32px; height: 32px; flex: none; }
.icon-btn.small svg { width: 16px; height: 16px; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 14px 10px;
  padding: 0 6px 0 14px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--muted);
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.searchbar input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  appearance: none;
}
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar input::placeholder, .sheet input::placeholder, .sheet textarea::placeholder { color: var(--muted); opacity: 0.8; }

.menu {
  position: absolute;
  top: 54px;
  right: 12px;
  z-index: 30;
  width: 260px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.menu button, .menu-item {
  display: block;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  text-align: left;
  text-decoration: none;
}
.menu button:hover:not(:disabled), .menu-item:hover { background: var(--bg); }
.menu-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: center; }
.menu-primary:hover { background: var(--accent); filter: brightness(1.08); }
.menu hr { margin: 6px 0; border: 0; border-top: 1px solid var(--line); }
.menu-note { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.menu-account { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 8px; }
.menu-who { font-weight: 600; overflow-wrap: anywhere; }
.menu-sync { font-size: 13px; color: var(--muted); }

/* ---------- near me ---------- */

.quick { padding: 0 14px 10px; }
.here-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
}
.here-btn svg { width: 18px; height: 18px; }
.here-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- filters ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 2px 14px 10px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: transparent;
  font-size: 14px;
  color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.sort { display: flex; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.sort button { padding: 6px 12px; border: 0; background: transparent; font-size: 14px; color: var(--muted); }
.sort button[aria-pressed="true"] { background: var(--line); color: var(--ink); font-weight: 600; }

/* ---------- rows ---------- */

.list-head {
  padding: 14px 18px 6px;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.rows li:first-child .row { border-top-color: transparent; }
.row:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }

.dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--none);
}
.dot[data-verdict="good"] { background: var(--good); }
.dot[data-verdict="neutral"] { background: var(--neutral); }
.dot[data-verdict="bad"] { background: var(--bad); }

.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-dist { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.row-note {
  font-size: 14px;
  font-style: italic;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.verdict-word { font-weight: 600; }
.verdict-word[data-verdict="good"] { color: var(--good); }
.verdict-word[data-verdict="neutral"] { color: var(--neutral); }
.verdict-word[data-verdict="bad"] { color: var(--bad); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tag {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--line);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.tag[data-again="yes"] { background: var(--good-soft); }
.tag[data-again="no"] { background: var(--bad-soft); text-decoration: line-through; text-decoration-color: var(--bad); }
.tag[data-again="more"] { background: transparent; border: 1px dashed var(--muted); color: var(--muted); padding: 1px 8px; }

.add-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}
.add-mark svg { width: 16px; height: 16px; }
.row-hand .add-mark { background: transparent; border: 1.5px dashed var(--muted); color: var(--muted); }

.none { padding: 10px 18px 14px; color: var(--muted); font-size: 15px; }
.footnote { padding: 18px 18px 0; font-size: 13px; color: var(--muted); }
.link { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; font-size: inherit; }
.footnote a, .empty-signin a { color: var(--accent); font-weight: 600; }
.empty-signin { margin-top: 14px !important; }
.banner { margin: 0 14px 10px; padding: 10px 14px; border-radius: 10px; background: var(--bad-soft); font-size: 14px; }

.empty { padding: 36px 26px; text-align: center; }
.empty h2 { font: 600 22px/1.2 var(--serif); margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 30ch; margin: 0 auto; }

/* ---------- sheet ---------- */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.sheet-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px 8px;
}
.sheet-status { flex: 1; font-size: 13px; color: var(--muted); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 28px; }

.title-input {
  width: 100%;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  font: 600 26px/1.2 var(--serif);
  outline: none;
}
.title-input:focus { border-bottom-color: var(--accent); }
.sheet-sub { margin-top: 4px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.sheet-sub a { color: var(--accent); }
.hint { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--neutral-soft); font-size: 14px; }

.verdicts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.verdict {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 600;
}
.verdict .dot { margin: 0; }
.verdict[aria-pressed="true"][data-verdict="good"] { background: var(--good-soft); border-color: var(--good); }
.verdict[aria-pressed="true"][data-verdict="neutral"] { background: var(--neutral-soft); border-color: var(--neutral); }
.verdict[aria-pressed="true"][data-verdict="bad"] { background: var(--bad-soft); border-color: var(--bad); }

.section {
  margin: 26px 0 8px;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-body input:not([type="checkbox"]):not(.title-input),
.sheet-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}
.sheet-body input:not(.title-input):focus, .sheet-body textarea:focus { border-color: var(--accent); }
.sheet-body textarea { display: block; resize: none; min-height: 92px; line-height: 1.45; }

.dish { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.dish input { flex: 1 1 150px; min-width: 0; }
.again { display: flex; flex: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.again button { height: 42px; padding: 0 11px; border: 0; background: transparent; font-size: 14px; color: var(--muted); white-space: nowrap; }
.again button + button { border-left: 1px solid var(--line); }
.again button[aria-pressed="true"][data-again="yes"] { background: var(--good-soft); color: var(--ink); font-weight: 600; }
.again button[aria-pressed="true"][data-again="no"] { background: var(--bad-soft); color: var(--ink); font-weight: 600; }

.dish-add { display: flex; gap: 6px; }
.dish-add input { flex: 1; min-width: 0; }

.btn {
  flex: none;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
}
.btn-quiet { height: 36px; border-color: transparent; background: transparent; color: var(--accent); }
.btn-primary { width: 100%; height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 17px; }
.btn-danger { height: 36px; border-color: transparent; background: transparent; color: var(--bad); font-weight: 500; padding: 0 4px; }

.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 24px; font-weight: 600; cursor: pointer; }
.switch-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.next-time { margin-top: 10px; }

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.sheet-save { padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 11px 18px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- map chrome ---------- */

.maplibregl-ctrl-group { border-radius: 12px; overflow: hidden; }

/* ---------- phones ---------- */

/* The import from Google Maps (google-sheet.js) */
.import-title { font: 600 22px/1.25 var(--serif); margin: 8px 0 10px; }
.import-text { margin: 0 0 12px; line-height: 1.5; }
.import-help { margin: -4px 0 10px; font-size: 14px; color: var(--muted); }
.steps { margin: 4px 0 18px; padding-left: 22px; line-height: 1.5; }
.steps li { margin-bottom: 8px; }
.steps a { color: var(--accent); font-weight: 600; }
.file-btn { display: grid; place-items: center; cursor: pointer; }
.import-progress { width: 100%; height: 8px; accent-color: var(--accent); }
.import-list { list-style: none; margin: 0 0 8px; padding: 0; }
.import-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.import-list li:first-child .import-row { border-top-color: transparent; }
.import-row input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.import-missing { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; border-top: 1px solid var(--line); }
.import-ask { display: flex; flex-direction: column; gap: 3px; padding: 12px 0 14px; border-top: 1px solid var(--line); }
.import-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.import-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 48px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); text-align: left;
}
.import-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.import-skip { justify-content: center; color: var(--muted); font-weight: 600; }

@media (max-width: 760px) {
  .app { display: flex; flex-direction: column; }
  .panel { border-right: 0; }
  .app[data-tab="list"] .panel { flex: 1; }
  .app[data-tab="list"] .mapwrap { display: none; }
  .app[data-tab="map"] .panel { flex: none; }
  .app[data-tab="map"] .panel-body { display: none; }
  .app[data-tab="map"] .mapwrap { flex: 1; }
  .top { padding-top: calc(10px + env(safe-area-inset-top)); }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: none;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .tabs button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
  }
  .tabs button[aria-pressed="true"] { color: var(--accent); }

  .sheet { position: fixed; padding-top: env(safe-area-inset-top); }
  .toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
