:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel-bg: #ffffffcc;
  --border: #d4d9e1;
  --text: #1f2430;
  --accent: #2e6ae6;
  --error: #d92d20;
  --ok: #15803d;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.toolbar h1 {
  font-size: 20px;
  margin: 0 0 8px 0;
}

.toolbar__hint {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
}

.toolbar__column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbar__column--controls {
  align-items: flex-end;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  color: var(--accent);
}

.file-picker input[type="file"] {
  display: none;
}

.status {
  font-size: 14px;
  min-height: 20px;
  color: #4b5563;
}

.status-ok {
  color: var(--ok);
}

.status-error {
  color: var(--error);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  min-height: 0;
}

.map-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.map {
  position: relative;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.map-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.date-control {
  font-size: 14px;
  color: var(--text);
}

.date-control__btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
}

.date-control__btn:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.date-control__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.date-control__display {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.date-control__display:hover {
  background: rgba(37, 99, 235, 0.12);
}

.date-control__picker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.param-panel {
  top: auto;
  bottom: 24px;
  right: 24px;
  left: auto;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  max-width: min(720px, 80vw);
  max-height: calc(100vh - 48px);
}

.param-panel[data-collapsed="true"] .param-panel__body {
  display: none;
}

.param-panel__toggle {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.param-panel__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow: auto;
}

.param-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.param-panel__title {
  font-size: 14px;
  font-weight: 600;
}

.param-panel__reset {
  border: none;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.param-panel__section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.param-panel__sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.param-panel__list {
  display: grid;
  gap: 8px;
  max-height: 100%;
}

.param-panel__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.param-field label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #334155;
}

.param-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: rgba(31, 41, 55, 0.2);
  outline: none;
  margin: 2px 0;
}

.param-field input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.35);
}

.param-field input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.35);
}

.param-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.param-field input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.param-field__value {
  align-self: flex-end;
  font-size: 11px;
  color: #64748b;
}

.smoother-toggle {
  left: 24px;
  right: auto;
  bottom: 24px;
  top: auto;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  user-select: none;
}

.toggle-switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch__slider {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-switch__slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.15);
  transition: transform 0.2s ease;
}

.toggle-switch__input:checked + .toggle-switch__slider {
  background: var(--accent);
}

.toggle-switch__input:checked + .toggle-switch__slider::after {
  transform: translateX(16px);
}

.toggle-switch__label {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.param-field__hint {
  color: #9ca3af;
  font-size: 11px;
}

.timeline-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  overflow: hidden;
}

.timeline-panel__header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.timeline-panel__header h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.timeline-panel__summary {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.timeline-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.timeline-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
}

.timeline-item__kind {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timeline-item__time {
  font-size: 13px;
  color: #4b5563;
}

.timeline-item__meta {
  grid-column: 1 / -1;
  font-size: 13px;
  color: #374151;
}

.timeline-item--stay {
  background: rgba(46, 106, 230, 0.08);
}

.timeline-item--gap {
  background: rgba(217, 45, 32, 0.08);
}

.timeline-list__empty {
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

.map-tooltip {
  font-size: 12px;
  line-height: 1.4;
  color: #111827;
}

.map-tooltip strong {
  font-size: 12px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(220px, 30%) 1fr;
  }
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .timeline-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  .timeline-list {
    max-height: 100%;
  }

  .map {
    min-height: 60vh;
  }

  .map-overlay {
    left: 50%;
    transform: translateX(-50%);
  }

  .param-panel {
    right: 16px;
    left: 16px;
    transform: none;
    bottom: 16px;
    max-width: none;
    width: auto;
  }

  .param-panel__body {
    grid-template-columns: 1fr;
    max-height: 50vh;
  }
}
