:root {
  --bg: #ffffff;
  --panel-bg: #f7f7f8;
  --border: #e2e2e5;
  --text: #1b1b1f;
  --muted: #6b6b74;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --danger: #d64545;
  --safe: #2f9e44;
  --unknown: #9aa0a6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#sidebar {
  width: 340px;
  min-width: 340px;
  overflow-y: auto;
  padding: 16px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
}

#map {
  flex: 1;
  height: 100%;
}

h1 {
  font-size: 18px;
  margin: 4px 0 2px;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.4;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0 0 8px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#result-count {
  font-weight: 600;
  font-size: 14px;
}

#refresh-btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

#refresh-btn:hover { opacity: 0.9; }
#refresh-btn:disabled { opacity: 0.5; cursor: default; }

#refresh-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  min-height: 14px;
}

.price-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.price-row input[type="range"] {
  width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
  cursor: pointer;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.4;
}

.quick-select {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.quick-select button {
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
}

.quick-select button:hover { border-color: var(--accent); }

.check-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.check-list .count {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}

#paste-box {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
}

#manual-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#manual-form input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
}

.form-row {
  display: flex;
  gap: 6px;
}

.form-row input { width: 33%; }

#manual-form button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 2px;
}

#unscraped-list a {
  display: block;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 4px;
}

#unscraped-list .note {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: -2px 0 6px;
}

.leaflet-popup-content {
  font-size: 13px;
  min-width: 200px;
}

.popup-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
}

.popup-price {
  font-weight: 700;
  font-size: 15px;
}

.popup-addr {
  margin: 2px 0 6px;
}

.popup-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.popup-liq {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.popup-liq.safe { background: #e6f6ea; color: var(--safe); }
.popup-liq.danger { background: #fbeaea; color: var(--danger); }
.popup-liq.unknown { background: #f0f0f1; color: var(--unknown); }

.popup-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.popup-delete {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171b;
    --panel-bg: #1d1f24;
    --border: #2c2e34;
    --text: #eceef1;
    --muted: #9199a6;
    --accent: #5b8dfb;
    --accent-contrast: #0b0d10;
  }
  .popup-liq.safe { background: #123420; }
  .popup-liq.danger { background: #3a1616; }
  .popup-liq.unknown { background: #2c2e34; }
}
