:root {
  color-scheme: light dark;
  --bg: #f7f7f7;
  --fg: #222;
  --accent: #0066cc;
  --panel-bg: rgba(255, 255, 255, 0.9);
  --border: #ccc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header,
footer {
  background: #0b1f33;
  color: #fff;
  padding: 0.75rem 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.toolbar button {
  margin-right: 0.5rem;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 350px) 1fr;
  gap: 1rem;
  padding: 1rem;
}

.controls {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-y: auto;
}

.controls h2 {
  margin-top: 0;
}

.control-group {
  margin-bottom: 1rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.3rem;
}

.control-group select,
.control-group input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.hint {
  font-size: 0.85rem;
  color: #555;
}

.waypoint-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.waypoint-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.waypoint-card header {
  background: none;
  color: inherit;
  padding: 0;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.waypoint-card h3 {
  margin: 0;
  font-size: 1rem;
}

.waypoint-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.waypoint-controls label {
  font-size: 0.8rem;
}

.waypoint-controls input,
.waypoint-controls select,
.waypoint-controls textarea {
  width: 100%;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
}

.waypoint-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.map-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.map-toolbar {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
}

.map {
  flex: 1;
  min-height: 360px;
}

.profile-container {
  border-top: 1px solid var(--border);
  background: #fafafa;
  padding: 0.5rem 1rem 1rem;
}

.profile-container h2 {
  margin-top: 0.25rem;
  font-size: 1rem;
}

#profileCanvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover,
button:focus {
  opacity: 0.85;
}

button.secondary {
  background: #444;
}

button.danger {
  background: #b0413e;
}

.fullscreen main {
  grid-template-columns: 1fr;
}

.fullscreen .controls {
  display: none;
}

.fullscreen .map-panel {
  position: fixed;
  inset: 64px 0 0 0;
  border-radius: 0;
  z-index: 10;
}

@media (max-width: 960px) {
  main {
    grid-template-columns: 1fr;
  }

  .controls {
    max-height: 260px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f5f5f5;
    --panel-bg: rgba(22, 22, 22, 0.95);
    --border: #2c2c2c;
  }

  .waypoint-card,
  .map-panel,
  .profile-container {
    background: #1e1e1e;
  }

  #profileCanvas {
    background: #111;
  }
}
