:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --border: #d9e0dc;
  --text: #1d2625;
  --muted: #65716f;
  --accent: #0f766e;
  --accent-strong: #0b5e58;
  --accent-soft: #d8efec;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 16px 36px rgba(24, 39, 36, 0.08);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.filters,
.workspace-panel {
  min-width: 0;
  height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfc;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 104px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.tab-button.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 1px 2px rgba(24, 39, 36, 0.05);
}

.tab-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.brand-row,
.panel-toolbar,
.map-toolbar,
.pagination,
.toolbar-actions {
  display: flex;
  align-items: center;
}

.brand-row,
.panel-toolbar,
.map-toolbar {
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.panel-toolbar p,
.map-toolbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.pagination button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover,
.pagination button:hover,
.secondary-button:hover {
  background: var(--surface-soft);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
}

.category-filter {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.category-filter legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.category-filter label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
}

.category-filter input {
  accent-color: var(--accent);
}

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

.stats-grid div {
  min-width: 0;
  padding: 12px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.stats-grid span {
  display: block;
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.stats-grid small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.google-settings {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.google-settings label {
  color: var(--muted);
  font-size: 13px;
}

.key-row {
  display: flex;
  gap: 8px;
}

.key-row input {
  min-width: 0;
  flex: 1;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
}

.google-settings p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.results-panel,
.map-panel,
.tab-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-pane {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.tab-pane.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

.panel-toolbar,
.map-toolbar {
  min-height: 74px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.toolbar-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  flex: 1;
  padding: 14px;
  overflow: auto;
}

.result-card {
  display: grid;
  gap: 10px;
  min-height: 176px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
}

.result-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.badge {
  flex: 0 0 auto;
  max-width: 92px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.meta-line {
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta-line svg {
  flex: 0 0 auto;
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions button,
.card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.card-actions button:hover,
.card-actions a:hover {
  background: var(--surface-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 240px;
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

.pagination {
  justify-content: center;
  gap: 12px;
  min-height: 62px;
  border-top: 1px solid var(--border);
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-stage {
  position: relative;
  flex: 1;
  min-height: 420px;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map {
  background: #dbe5e1;
}

.selected-place {
  min-height: 74px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.selected-place strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
}

.selected-place a {
  color: var(--accent-strong);
  font-weight: 700;
}

.popup-name {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.popup-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.popup-note {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }

  .filters,
  .workspace-panel {
    height: auto;
    border-radius: 8px;
  }

  .workspace-panel {
    height: calc(100svh - 20px);
    min-height: 560px;
  }

  .control-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-toolbar,
  .map-toolbar,
  .brand-row {
    align-items: flex-start;
  }

  .panel-toolbar {
    flex-direction: column;
  }

  .map-toolbar {
    min-height: 64px;
    padding: 12px 14px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    flex: 1 1 130px;
  }

  .result-list {
    grid-template-columns: 1fr;
  }

  .workspace-tabs {
    position: sticky;
    top: 0;
    z-index: 3;
    min-height: 54px;
    padding: 8px;
  }

  .tab-button {
    flex: 1;
    min-width: 0;
  }

  .map-stage {
    min-height: 0;
  }

  .selected-place {
    min-height: 64px;
    padding: 10px 14px;
    font-size: 13px;
  }
}
