:root {
  color-scheme: light dark;
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #17181a;
  --muted: #6b7280;
  --border: #e6e3dd;
  --accent: #b8501f;
  --accent-text: #ffffff;
  --star: #d99a1e;
  --danger: #b3261e;
  --radius: 14px;
  --gap: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 15, 0.06), 0 6px 20px rgba(20, 18, 15, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113;
    --surface: #16191c;
    --text: #e9eaec;
    --muted: #99a1aa;
    --border: #262b31;
    --accent: #f0864a;
    --accent-text: #1a1108;
    --star: #e8b33e;
    --danger: #f2685e;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Taps register immediately (no double-tap-zoom delay) and don't start a text selection. */
a,
button,
.tab,
.chip,
.button {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.005em;
}

h3 {
  font-size: 1rem;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  /* Opaque on phones: backdrop-filter would make the fixed tab bar inside it pin to the header. */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.topbar-title .title {
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -10px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.back:active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.container {
  max-width: 660px;
  margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.narrow {
  max-width: 420px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.row > label {
  flex: 1 1 140px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* Bottom tab bar on phones, inline nav on wider screens. */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.7rem;
}

.tab.active {
  color: var(--accent);
}

.tab-label {
  letter-spacing: 0.01em;
}

@media (min-width: 720px) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
  }

  /* Tabs sit in the header here; keep the gear after them, at the far right. */
  .topbar .nav {
    margin-left: auto;
  }

  .topbar-action {
    order: 1;
    margin-left: 4px;
  }

  .nav {
    position: static;
    border-top: none;
    background: none;
    backdrop-filter: none;
    padding: 0;
    gap: 4px;
  }

  .tab {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .tab.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }

  .container {
    padding-bottom: 48px;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

@media (hover: hover) {
  .button:hover {
    opacity: 0.85;
  }

  .place:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  }
}

.button,
.chip,
.place,
.tab {
  transition: transform 0.12s ease, opacity 0.12s ease, background-color 0.12s ease;
}

.button:active:not(:disabled),
.chip:active:not(:disabled) {
  transform: scale(0.97);
  opacity: 0.8;
}

.tab:active {
  transform: scale(0.92);
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: none;
}

.button.small {
  min-height: 36px;
  padding: 0 13px;
  font-size: 0.85rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

label.checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  color: var(--text);
}

label.checkbox input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--accent);
}

label.checkbox span {
  display: flex;
  flex-direction: column;
}

.stars {
  display: inline-flex;
  gap: 2px;
  vertical-align: middle;
}

.star {
  fill: color-mix(in srgb, var(--muted) 30%, transparent);
}

.star.on {
  fill: var(--star);
}

.rating-picker {
  display: flex;
  gap: 6px;
}

.rating-star {
  padding: 4px;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 0;
  color: inherit;
}

.rating-star svg {
  fill: color-mix(in srgb, var(--muted) 28%, transparent);
  transition: fill 0.12s ease;
}

.rating-star.on svg {
  fill: var(--star);
}

.review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.review-author {
  font-weight: 600;
}

.review-place {
  display: block;
  margin-bottom: 6px;
}

.place-name {
  font-weight: 550;
  border-bottom: 1px solid var(--border);
}

.review-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.review-body {
  margin-top: 8px;
  white-space: pre-wrap;
}

.place {
  display: block;
}


.place-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.place-header .review-meta {
  margin-top: 10px;
}

.place-header .links {
  margin-top: 12px;
}

.profile-header .counts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.counts strong {
  color: var(--text);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 32px 4px;
}

.hero h1 {
  font-size: 1.9rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.feed-label {
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.feed-url {
  display: block;
  overflow-x: auto;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
}

.chip:disabled {
  opacity: 0.5;
}

.chip.on {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--accent);
}

.chip-note {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

.chip.on .chip-note {
  color: inherit;
  opacity: 0.75;
}

.badge {
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.saved-line {
  line-height: 1.7;
}

.list-chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 550;
  white-space: nowrap;
}

.button.small.danger {
  min-height: 32px;
}

.empty,
.error-note,
.saved {
  padding: 14px 0;
  color: var(--muted);
  font-size: 0.925rem;
}

.error-note {
  color: var(--danger);
}

.saved {
  color: var(--accent);
}

.spinner {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 40px 0;
}

.spinner span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.1s ease-in-out infinite;
}

.spinner span:nth-child(2) {
  animation-delay: 0.15s;
}

.spinner span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

.pin-map {
  height: 280px;
  border-radius: 12px;
  overflow: hidden;
  z-index: 0;
}

/* The teardrop is drawn on ::before: rotating the icon itself would also rotate Leaflet's
   translate3d positioning and throw the pin off the map. */
.pin-marker::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #e4572e;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.4);
}

/* Search: one pill field with live suggestions underneath, like a maps app. */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field .field-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding: 12px 44px 12px 42px;
  border-radius: 999px;
  background: var(--surface);
  -webkit-appearance: none;
  appearance: none;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.button.block {
  width: 100%;
}

.section-label {
  margin: 4px 4px 8px;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Grouped list, like a native table view: one rounded surface, hairline dividers. */
.list-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px 10px 16px;
  color: inherit;
  text-decoration: none;
}

.list-row + .list-row {
  border-top: 1px solid var(--border);
}

.list-row:active {
  background: color-mix(in srgb, var(--muted) 10%, transparent);
}

.list-row > .field-icon {
  flex: none;
  color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.list-row-main {
  flex: 1;
  min-width: 0;
}

.list-row-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row-meta {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-button {
  align-self: center;
  min-height: 44px;
  padding: 0 8px;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.add-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.add-head .link-button {
  margin-right: -8px;
}

.button.provider {
  gap: 10px;
  min-height: 48px;
  text-decoration: none;
}

.search-box {
  position: relative;
  z-index: 5;
}

.field-clear {
  position: absolute;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.field-clear .field-icon {
  position: static;
}

.field-spinner {
  position: absolute;
  right: 16px;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--muted) 30%, transparent);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(60vh, 440px);
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
}

.suggestion > .field-icon {
  flex: none;
  color: var(--muted);
}

.suggestion.highlighted,
.suggestion:active {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}

@media (hover: hover) {
  .suggestion:hover {
    background: color-mix(in srgb, var(--muted) 12%, transparent);
  }
}

.suggestion-text {
  min-width: 0;
}

.suggestion-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-meta {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-empty {
  margin: 0;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.925rem;
}

.selected-place {
  padding: 0;
  overflow: hidden;
}

.selected-place .pin-map {
  height: 220px;
  border-radius: 0;
}

.selected-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.selected-body .row {
  margin-top: 6px;
}

/* Place card actions: round icon buttons with a label underneath, like a maps app. */
.place-cuisine {
  margin: -4px 0 0;
  font-weight: 550;
  text-transform: capitalize;
}

.place-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.925rem;
}

.place-links a {
  color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 10px -6px 0;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.action-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.action.on .action-icon {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.action:active .action-icon {
  transform: scale(0.92);
}

.action-label {
  white-space: nowrap;
}

.selected-body h1 {
  font-size: 1.4rem;
}

.small-note {
  font-size: 0.85rem;
}

/* Bottom sheet */
.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.38);
  animation: fade-in 0.2s ease;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgb(0 0 0 / 0.18);
  animation: slide-up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.sheet-handle {
  width: 38px;
  height: 5px;
  margin: 4px auto 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 35%, transparent);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-right: -6px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
  cursor: pointer;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.sheet-open {
  overflow: hidden;
}

.check-row {
  flex-direction: row;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
}

.check-row input {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--accent);
}

.new-list {
  display: flex;
  gap: 8px;
}

.new-list input {
  flex: 1;
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.section-title {
  margin: 8px 4px -4px;
}

/* Header icon link (the settings gear on your profile). */
.topbar-action {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  border-radius: 50%;
  color: var(--text);
}

.topbar-action:active {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
}

/* Lists tab */
.list-row-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
}

.list-row-icon.pinned {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.list-row-chevron {
  flex: none;
  color: color-mix(in srgb, var(--muted) 60%, transparent);
  line-height: 0;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: -8px;
}

.section-row .section-label {
  margin: 0 4px;
}

.section-row .link-button {
  min-height: 36px;
}
