:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #20201d;
  --muted: #68645d;
  --line: #ddd6c9;
  --accent: #d83f2a;
  --accent-strong: #a72718;
  --green: #3b7d4c;
  --blue: #376fa7;
  --yellow: #c99019;
  --shadow: 0 18px 50px rgba(42, 35, 26, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial,
    sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover,
.file-button:hover {
  border-color: #b9aa96;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
}

.brand {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 22px 22px 18px;
}

.brand {
  order: 1;
}

.decision-panel {
  order: 2;
}

.search-panel {
  order: 3;
}

.results-section {
  order: 4;
}

.data-panel,
.add-panel {
  order: 5;
}

.brand h1 {
  font-size: 29px;
  line-height: 1;
  margin: 4px 0 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.panel {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.decision-panel {
  background:
    linear-gradient(135deg, rgba(216, 63, 42, 0.94), rgba(46, 113, 91, 0.92)),
    #d83f2a;
  color: #fff;
  padding: 18px;
}

.decision-panel h2 {
  font-size: 24px;
  line-height: 1.1;
  margin: 4px 0 6px;
}

.decision-panel p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.decision-panel .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.decision-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1.2fr 1fr 1fr;
  margin-top: 14px;
}

.decision-actions button {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(255, 255, 255, 0.32);
  color: #20201d;
  font-size: 13px;
  font-weight: 800;
}

.decision-actions .primary-action {
  background: #20201d;
  border-color: #20201d;
  color: #fff;
}

.field,
.range-field {
  display: grid;
  gap: 7px;
}

.field span,
.range-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 38px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 63, 42, 0.16);
  outline: none;
}

.quick-row,
.tool-row,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  background: #f4efe4;
  min-height: 34px;
  padding: 6px 10px;
}

.filter-grid,
.form-grid {
  display: grid;
  gap: 11px;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.advanced-filters {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.advanced-filters summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style-position: outside;
}

.check,
.map-toggle {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  gap: 7px;
}

.check input,
.map-toggle input {
  accent-color: var(--accent);
  height: 16px;
  min-height: 16px;
  padding: 0;
  width: 16px;
}

.range-field {
  margin-top: 14px;
}

.range-field input {
  accent-color: var(--accent);
  min-height: auto;
  padding: 0;
}

.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-action:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.file-button {
  display: inline-grid;
  place-items: center;
  position: relative;
}

.file-button input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 10px 0 0;
}

.hidden {
  display: none !important;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  font-size: 15px;
  margin: 0;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 18px;
  justify-content: center;
  min-height: 34px;
  padding: 0;
  width: 34px;
}

.count-pill {
  background: #efe6d6;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
}

.results-section {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  min-height: 0;
  padding: 16px 18px 0;
}

.results-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  overflow: visible;
  padding-bottom: 18px;
}

.place-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}

.food-visual {
  align-items: end;
  color: #fff;
  display: flex;
  gap: 12px;
  min-height: 96px;
  padding: 14px;
  position: relative;
}

.food-visual::after,
.detail-hero::after {
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.38), transparent 18%),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.22), transparent 16%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.24));
  content: "";
  inset: 0;
  position: absolute;
}

.food-visual > *,
.detail-hero > * {
  position: relative;
  z-index: 1;
}

.food-visual span {
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  display: flex;
  font-size: 20px;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.food-visual b,
.detail-hero b {
  display: block;
}

.food-visual small,
.detail-hero small {
  color: rgba(255, 255, 255, 0.82);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.card-title-row {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 12px 0;
}

.place-card:hover,
.place-card.active {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(42, 35, 26, 0.1);
}

.place-card h3 {
  font-size: 15px;
  margin: 0 0 7px;
}

.save-pill {
  border-radius: 999px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
  min-height: 28px;
  padding: 4px 9px;
}

.save-pill.active,
.mini-actions button.active,
.detail-actions button.active {
  background: #20201d;
  border-color: #20201d;
  color: #fff;
}

.reason-line {
  color: #3f3a33;
  font-size: 13px;
  line-height: 1.45;
  margin: 9px 12px;
}

.meta-line,
.tag-line {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px;
}

.tag {
  background: #f4efe4;
  border-radius: 999px;
  color: #5d5143;
  padding: 3px 7px;
}

.place-card > .meta-line,
.place-card > .tag-line {
  padding-left: 12px;
  padding-right: 12px;
}

.menu-preview {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr;
  margin: 10px 12px;
}

.menu-preview span {
  align-items: center;
  background: #f8f2e8;
  border: 1px solid #eadfce;
  border-radius: 7px;
  color: #3f3a33;
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  min-height: 30px;
  padding: 6px 8px;
}

.menu-preview b {
  color: var(--accent-strong);
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 12px 12px;
}

.mini-actions button {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 9px;
}

.scan-summary {
  background: #f4efe4;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 11px;
}

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

.scan-grid div {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 7px;
  padding: 8px;
}

.scan-grid strong {
  display: block;
  font-size: 18px;
}

.scan-grid span,
.scan-summary p {
  color: var(--muted);
  font-size: 12px;
}

.scan-summary p {
  line-height: 1.45;
  margin: 8px 0 0;
}

.map-shell {
  min-width: 0;
  position: relative;
}

.map {
  background: #e8e0d0;
  height: 100%;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  width: 100%;
}

.tile-layer,
.grid-layer,
.marker-layer {
  inset: 0;
  position: absolute;
}

.tile-layer,
.grid-layer {
  pointer-events: none;
}

.marker-layer {
  pointer-events: none;
}

.marker-layer button,
.marker-layer .user-marker {
  pointer-events: auto;
}

.tile-layer img {
  height: 256px;
  image-rendering: auto;
  position: absolute;
  width: 256px;
}

.grid-layer {
  background:
    linear-gradient(rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    radial-gradient(circle at 38% 40%, rgba(59, 125, 76, 0.2), transparent 24%),
    radial-gradient(circle at 62% 58%, rgba(55, 111, 167, 0.18), transparent 21%),
    #ded4c2;
  background-size:
    64px 64px,
    64px 64px,
    100% 100%,
    100% 100%,
    100% 100%;
}

.grid-label {
  color: rgba(32, 32, 29, 0.48);
  font-size: 12px;
  font-weight: 700;
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.marker {
  align-items: center;
  --pin: var(--accent);
  background: var(--pin);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(20, 18, 15, 0.22);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  position: absolute;
  transform: translate(-50%, -100%);
  width: 30px;
}

.marker::after {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 9px solid var(--pin);
  bottom: -7px;
  content: "";
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
}

.marker[data-color="green"] {
  --pin: var(--green);
}

.marker[data-color="blue"] {
  --pin: var(--blue);
}

.marker[data-color="yellow"] {
  --pin: var(--yellow);
}

.marker.active {
  height: 38px;
  width: 38px;
  z-index: 5;
}

.user-marker {
  background: #1f74d1;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow:
    0 0 0 8px rgba(31, 116, 209, 0.16),
    0 8px 22px rgba(20, 18, 15, 0.2);
  height: 18px;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 18px;
  z-index: 7;
}

.map-toolbar {
  align-items: center;
  display: flex;
  gap: 8px;
  left: 16px;
  position: absolute;
  top: 16px;
  z-index: 20;
}

.map-button,
.map-toggle {
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 8px 24px rgba(42, 35, 26, 0.12);
}

.map-button {
  font-size: 18px;
  font-weight: 800;
  min-height: 40px;
  padding: 0;
  width: 40px;
}

.map-button.wide {
  font-size: 13px;
  padding: 0 12px;
  width: auto;
}

.map-button.strong {
  background: #20201d;
  border-color: #20201d;
  color: #fff;
}

.map-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
}

.crosshair {
  border: 1px solid rgba(32, 32, 29, 0.34);
  border-radius: 50%;
  height: 18px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
}

.crosshair::before,
.crosshair::after {
  background: rgba(32, 32, 29, 0.34);
  content: "";
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.crosshair::before {
  height: 1px;
  width: 28px;
}

.crosshair::after {
  height: 28px;
  width: 1px;
}

.status-toast {
  background: rgba(32, 32, 29, 0.78);
  border-radius: 999px;
  bottom: 18px;
  color: #fff;
  font-size: 12px;
  left: 50%;
  padding: 8px 12px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  z-index: 10;
}

.attribution {
  background: rgba(255, 253, 248, 0.88);
  border-radius: 6px;
  bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 7px;
  position: absolute;
  right: 10px;
  z-index: 12;
}

.detail-card {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  max-height: min(78vh, 720px);
  max-width: min(460px, calc(100% - 32px));
  overflow: auto;
  padding: 0;
  position: absolute;
  right: 18px;
  z-index: 25;
}

.detail-close {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 999px;
  display: flex;
  font-size: 22px;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 36px;
  z-index: 3;
}

.empty-state {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.detail-card h2 {
  font-size: 22px;
  line-height: 1.15;
  margin: 4px 0 0;
}

.detail-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 10px 0 0;
}

.detail-card > .meta-line,
.detail-card > .detail-actions {
  padding-left: 16px;
  padding-right: 16px;
}

.detail-hero {
  color: #fff;
  min-height: 150px;
  padding: 20px;
  position: relative;
}

.detail-hero span {
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  display: flex;
  font-size: 28px;
  font-weight: 900;
  height: 58px;
  justify-content: center;
  margin-bottom: 18px;
  width: 58px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.detail-section h3 {
  font-size: 13px;
  margin: 0 0 8px;
}

.detail-section p {
  margin-top: 0;
}

.menu-list {
  display: grid;
  gap: 8px;
}

.menu-list div,
.detail-facts div {
  align-items: center;
  background: #f8f2e8;
  border: 1px solid #eadfce;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  min-height: 40px;
  padding: 9px 10px;
}

.menu-list span {
  color: #34302b;
  font-size: 13px;
  font-weight: 700;
}

.menu-list b {
  color: var(--accent-strong);
  font-size: 13px;
}

.detail-facts {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  padding: 14px 16px;
}

.detail-facts div {
  align-items: flex-start;
  display: grid;
  justify-content: stretch;
}

.detail-facts strong {
  font-size: 13px;
}

.detail-facts span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding-bottom: 16px;
  padding-top: 12px;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
  }

  .sidebar {
    border-right: 0;
    flex: 1 1 auto;
    max-height: none;
    order: 1;
    overflow: auto;
  }

  .map-shell {
    flex: 0 0 38vh;
    min-height: 300px;
    order: 2;
  }

  .map-toolbar {
    flex-wrap: wrap;
    left: 10px;
    right: 10px;
    top: 10px;
  }

  .detail-card {
    bottom: 10px;
    left: 10px;
    right: 10px;
    max-height: 72vh;
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }

  .decision-panel {
    order: 1;
  }

  .results-section {
    flex: 0 0 auto;
    min-height: auto;
    order: 2;
  }

  .results-list {
    max-height: none;
    overflow: visible;
  }

  .search-panel {
    order: 3;
  }

  .data-panel,
  .add-panel {
    order: 4;
  }
}

@media (max-width: 520px) {
  .filter-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .brand {
    padding: 18px;
  }

  .brand h1 {
    font-size: 24px;
  }

  .panel,
  .results-section {
    padding-left: 14px;
    padding-right: 14px;
  }

  .decision-actions {
    grid-template-columns: 1fr;
  }
}
