:root {
  --bg: #0b1220;
  --panel: rgba(255, 255, 255, 0.96);
  --text: #0b1220;
  --muted: rgba(11, 18, 32, 0.65);
  --chip: rgba(255, 255, 255, 0.92);
  --chip-border: rgba(11, 18, 32, 0.12);
  --chip-active: #0b1220;
  --chip-active-text: #ffffff;
  --btn: #0b1220;
  --btn-text: #ffffff;
  --btn-secondary: rgba(11, 18, 32, 0.06);
  --btn-secondary-text: #0b1220;
  --shadow: 0 10px 30px rgba(0,0,0,0.18);
}

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
}

#map {
  height: 100%;
}

.topbar {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 10px 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.10);
}

.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.advanced-controls {
  margin-top: 8px;
}

body.adv-collapsed .advanced-controls {
  display: none;
}

.file {
  display: block;
  border: 1px solid rgba(11, 18, 32, 0.14);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
}

.file input {
  display: block;
  width: 100%;
}

.key {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(11, 18, 32, 0.14);
  background: rgba(255, 255, 255, 0.92);
  font-size: 14px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.5;
}

.btn-secondary {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  border: 1px solid rgba(11, 18, 32, 0.12);
}

.filters {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
  align-items: center;
}

.filter-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  padding-right: 2px;
}

.btn-compact {
  padding: 8px 10px;
}

.stats {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(11, 18, 32, 0.75);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(11, 18, 32, 0.12);
  background: rgba(255, 255, 255, 0.86);
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--chip-border);
  background: var(--chip);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.active {
  background: var(--chip-active);
  color: var(--chip-active-text);
}

@media (max-width: 520px) {
  .topbar {
    padding: 6px 6px 4px;
  }

  .topbar-row {
    gap: 6px;
  }

  .file {
    padding: 6px;
    border-radius: 10px;
  }

  .key {
    padding: 6px;
    font-size: 12px;
  }

  .btn {
    padding: 7px 8px;
    font-size: 12px;
    border-radius: 10px;
  }

  .chip {
    padding: 7px 10px;
    font-size: 12px;
  }

  .stats {
    display: none;
  }

  .filters {
    margin-top: 6px;
  }
}

.progress {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.35);
}

.auth {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,0.35);
}

.auth.hidden {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(11, 18, 32, 0.12);
  box-shadow: 0 20px 60px rgba(11,18,32,0.22);
  padding: 16px;
}

.auth-title {
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 10px;
}

.auth-row {
  margin-top: 10px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 420px) {
  .auth-actions {
    grid-template-columns: 1fr;
  }
}

.auth-msg {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(11, 18, 32, 0.75);
  white-space: pre-wrap;
}

.progress.hidden {
  display: none;
}

.progress-card {
  width: min(420px, calc(100vw - 28px));
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.progress-title {
  font-weight: 800;
  font-size: 16px;
}

.progress-text {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
}

.progress-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.detail {
  position: fixed;
  z-index: 1500;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--panel);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px 12px 14px;
}

.detail.hidden {
  display: none;
}

.detail-handle {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.18);
  margin: 0 auto 8px;
}

.detail-title {
  font-size: 18px;
  font-weight: 900;
}

.detail-row {
  margin-top: 6px;
  font-size: 14px;
}

.label {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-right: 8px;
}

.detail-section {
  margin-top: 10px;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.status {
  border: 1px solid rgba(11, 18, 32, 0.12);
  background: rgba(11, 18, 32, 0.05);
  border-radius: 12px;
  padding: 10px 8px;
  font-weight: 800;
}

.status.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: transparent;
}

textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(11, 18, 32, 0.12);
  font-size: 14px;
}

.detail-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

@media (max-width: 380px) {
  .topbar-row {
    grid-template-columns: 1fr;
  }
  .detail-actions {
    grid-template-columns: 1fr;
  }
  .status-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}
