:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64706d;
  --line: #d8dfdd;
  --surface: #f7f8f5;
  --panel: #ffffff;
  --green: #14362f;
  --green-soft: #e5f0ea;
  --amber: #b56a00;
  --blue: #1768a6;
  --red: #b42318;
  --shadow: 0 12px 28px rgba(23, 33, 31, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--green);
  color: #fff;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f8c35a;
  color: var(--green);
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.15;
}

.brand p {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 126px;
  padding: 8px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
}

.map-pane {
  position: relative;
  min-height: calc(100vh - 61px);
  overflow: hidden;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 480px;
  background:
    linear-gradient(90deg, rgba(20, 54, 47, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(20, 54, 47, 0.08) 1px, transparent 1px),
    #edf2ef;
  background-size: 46px 46px;
}

.map-credit {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 500;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 11px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.secondary-button,
.primary-button,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 12px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(23, 33, 31, 0.08);
}

.secondary-button {
  background: var(--green-soft);
  color: var(--green);
  box-shadow: none;
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button:active {
  background: var(--green-soft);
}

.primary-button {
  width: 100%;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.panel {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
}

.search-panel {
  display: grid;
  gap: 9px;
}

.location-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: end;
  gap: 8px;
}

.location-field {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

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

.compact-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.72fr);
  gap: 8px;
}

.result-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.choice-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-controls label {
  min-width: 0;
}

.compact-controls input,
.compact-controls select,
.result-controls select {
  min-height: 40px;
  padding: 0 8px;
}

.result-controls label {
  min-width: 0;
}

.chip-group {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.chip-group::-webkit-scrollbar {
  display: none;
}

.radius-group,
.genre-group {
  grid-auto-flow: column;
}

.option-chip {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.option-chip:has(input:checked) {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.option-chip input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.notice {
  margin: 14px 0;
  padding: 10px;
  border: 1px solid #efc38f;
  border-radius: 8px;
  background: #fff8ed;
  color: #66410a;
  font-size: 13px;
  line-height: 1.55;
}

.live-status {
  position: relative;
  margin: -2px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px 9px 34px;
  background: #f4f7f6;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.live-status::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
  opacity: 0.7;
}

.live-status.active {
  border-color: #b7d3c3;
  background: #eef8f1;
  color: #25543a;
}

.live-status.loading {
  border-color: #c9d9ef;
  background: #f1f6fd;
  color: #175c95;
}

.live-status.loading::before {
  background: transparent;
  border: 2px solid rgba(23, 92, 149, 0.25);
  border-top-color: #175c95;
  animation: spin 0.85s linear infinite;
}

.live-status.error {
  border-color: #f0b8b3;
  background: #fff6f5;
  color: var(--red);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.tab-safe.active {
  background: var(--green);
  border-color: var(--green);
}

.tab-caution.active {
  background: var(--red);
  border-color: var(--red);
}

.tab-count {
  display: inline-grid;
  min-width: 26px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef3f1;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.spot-list {
  display: grid;
  gap: 10px;
}

.spot-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(23, 33, 31, 0.06);
}

.spot-card.rank-B {
  border-left-color: var(--blue);
}

.spot-card.rank-C {
  border-left-color: var(--amber);
}

.spot-card.rank-CAUTION {
  border-left-color: var(--red);
  background: #fffdfc;
}

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

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

.spot-title h2 {
  min-width: 0;
}

.genre-label {
  flex: 0 0 auto;
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef2f0;
  color: #41504c;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.spot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.rank-A .badge {
  background: var(--green-soft);
  color: var(--green);
}

.rank-B .badge {
  background: #e8f2fa;
  color: var(--blue);
}

.rank-C .badge {
  background: #fff0d4;
  color: #7a4600;
}

.rank-CAUTION .badge {
  background: #fef3f2;
  color: var(--red);
}

.badge.warning {
  background: #fff0d4;
  color: #7a4600;
}

.rank-CAUTION .badge.warning {
  background: #fff0d4;
  color: #7a4600;
}

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

.spot-quick-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.spot-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.spot-actions a,
.spot-actions button {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  min-width: 0;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.loading-card {
  height: 114px;
  border: 1px solid var(--line);
  border-left: 5px solid #c8d0cd;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent),
    linear-gradient(#e9eeec 0 0) 16px 18px / 54% 16px no-repeat,
    linear-gradient(#eef2f0 0 0) 16px 48px / 76% 12px no-repeat,
    linear-gradient(#eef2f0 0 0) 16px 74px / 42% 12px no-repeat,
    #fff;
  background-size:
    180px 100%,
    54% 16px,
    76% 12px,
    42% 12px;
  animation: shimmer 1.15s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position:
      -180px 0,
      16px 18px,
      16px 48px,
      16px 74px;
  }

  100% {
    background-position:
      calc(100% + 180px) 0,
      16px 18px,
      16px 48px,
      16px 74px;
  }
}

@keyframes spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.drive-lock {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 16, 15, 0.72);
}

.drive-lock.hidden {
  display: none;
}

.drive-lock-panel {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.drive-lock-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.drive-lock-panel p {
  margin: 0 0 16px;
  color: var(--muted);
}

.drive-lock-panel span {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fef3f2;
  color: var(--red);
  font-weight: 800;
}

.fallback-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 480px;
  overflow: hidden;
}

.fallback-point {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
}

.map-error {
  position: absolute;
  inset: 0;
  z-index: 450;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
  color: var(--ink);
  text-align: center;
}

.map-error-inner {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.map-error h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.map-error p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 880px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 54vh auto;
  }

  .map-pane {
    min-height: 54vh;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    padding: 10px;
  }

  .brand p {
    display: none;
  }

  .status-pill {
    min-width: 110px;
    font-size: 12px;
  }
}

@media (min-width: 881px) {
  .search-panel {
    gap: 12px;
  }

  .compact-controls {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 520px) {
  .topbar {
    gap: 8px;
  }

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

  .field-row {
    grid-template-columns: 1fr;
  }

  .compact-controls {
    grid-template-columns: minmax(0, 1fr) minmax(112px, 0.72fr);
    gap: 7px;
  }

  .compact-controls input,
  .compact-controls select,
  .result-controls select {
    min-height: 38px;
    padding: 0 7px;
    font-size: 13px;
  }

  .spot-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Password gate */
.password-gate {
  position: fixed;
  inset: 0;
  background: rgba(23, 33, 31, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.password-gate.hidden {
  display: none;
}

.password-gate-panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow);
}

.password-gate-panel h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--green);
}

.password-gate-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.password-gate-panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.password-gate-panel input[type="password"] {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

.password-gate-panel input[type="password"]:focus {
  outline: none;
  border-color: var(--green);
}

.password-error {
  color: var(--red) !important;
  font-size: 0.85rem !important;
  min-height: 1.2em;
  margin: 0 0 12px !important;
}
}
