:root {
  color-scheme: dark;
  --bg: #071a1f;
  --panel: #0c242b;
  --panel-2: #102f38;
  --text: #eef8f7;
  --muted: #9fc4c2;
  --line: #1e4852;
  --accent: #2dd4bf;
  --accent-dark: #0f766e;
  --warn: #fbbf24;
  --danger: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input {
  font: inherit;
}

textarea {
  font: inherit;
}

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.map-toolbar,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 8px 2px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
  line-height: 1.4;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
  padding: 16px;
}

.stack {
  display: grid;
  gap: 14px;
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081e24;
  color: var(--text);
  padding: 10px 12px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #03201d;
  padding: 0 14px;
}

.full-width {
  width: 100%;
  margin-top: 12px;
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
}

.icon-button {
  min-width: 40px;
}

.session-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.map-panel {
  min-height: 690px;
}

.map {
  width: 100%;
  height: 600px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #082129;
}

.map-fallback {
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.side-column {
  display: grid;
  gap: 16px;
}

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

.buddy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081e24;
  padding: 12px;
}

.buddy-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.buddy-name {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 3px 8px;
  white-space: nowrap;
}

.pi-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081e24;
  color: var(--muted);
  line-height: 1.4;
  padding: 12px;
  word-break: break-word;
  margin-top: 10px;
}

.telemetry-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.telemetry-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081e24;
  padding: 10px;
}

.command-box {
  width: 100%;
  min-height: 90px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06191e;
  color: var(--muted);
  padding: 10px;
  resize: vertical;
}

.setup-qr {
  width: 166px;
  min-height: 166px;
  margin: 12px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081e24;
  display: grid;
  place-items: center;
  padding: 8px;
}

.setup-qr img,
.setup-qr canvas {
  width: 148px;
  height: 148px;
  image-rendering: pixelated;
}

.leaflet-container {
  background: #082129;
  color: #0b2025;
}

.boat-marker {
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 999px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
}

@media (max-width: 940px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .map-toolbar,
  .section-header {
    align-items: flex-start;
  }

  .session-grid {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: auto;
  }

  .map {
    height: 52vh;
    min-height: 360px;
  }
}
