* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #16213e;
  border-bottom: 1px solid #334;
  flex-shrink: 0;
}

#toolbar button {
  padding: 6px 14px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #445;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

#toolbar button:hover { background: #1a4a80; }
#toolbar button.active { background: #e94560; border-color: #e94560; }

#toolbar select {
  padding: 4px 8px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #445;
  border-radius: 4px;
  font-size: 13px;
}

#status-bar {
  font-size: 13px;
  color: #aaa;
  margin-left: 8px;
}

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

#map-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#map-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

#map-viewport.grabbing { cursor: grabbing; }

#hex-svg {
  transform-origin: 0 0;
  display: block;
}

/* Hex styling */
.hex-poly {
  fill: rgba(15, 52, 96, 0.15);
  stroke: #335;
  stroke-width: 1;
  cursor: pointer;
  transition: fill 0.15s;
}
.hex-poly:hover { fill: rgba(15, 52, 96, 0.45); }
.hex-poly.selected { fill: rgba(233, 69, 96, 0.25); stroke: #e94560; stroke-width: 2; }
.hex-poly.route-source { fill: rgba(68, 187, 51, 0.3); stroke: #44bb33; stroke-width: 2; }

.coord-label {
  fill: #667;
  font-size: 11px;
  pointer-events: none;
  user-select: none;
}

.system-name {
  fill: #ddd;
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}

.system-icon {
  font-size: 22px;
  pointer-events: none;
  user-select: none;
}

.system-label {
  fill: #ccc;
  font-size: 11px;
  pointer-events: none;
  user-select: none;
}

.route-line {
  stroke-linecap: round;
  pointer-events: none;
}

/* Sidebar — desktop: right panel */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #16213e;
  border-left: 1px solid #334;
  padding: 16px;
  overflow-y: auto;
}

#sidebar-handle { display: none; }

#sidebar .hint {
  color: #667;
  font-size: 13px;
  font-style: italic;
}

#sidebar h3 {
  margin-bottom: 12px;
  color: #e94560;
  font-size: 15px;
}

#sidebar label {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 12px;
  color: #999;
}

#sidebar input[type="text"],
#sidebar textarea,
#sidebar select {
  width: 100%;
  padding: 6px 8px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #445;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

#sidebar textarea { resize: vertical; min-height: 60px; }

#sidebar .btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

#sidebar button {
  padding: 6px 12px;
  border: 1px solid #445;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  background: #0f3460;
  color: #e0e0e0;
}
#sidebar button:hover { background: #1a4a80; }
#sidebar button.primary { background: #44bb33; border-color: #44bb33; color: #000; }
#sidebar button.danger { background: #e94560; border-color: #e94560; color: #fff; }

.obsidian-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.obsidian-link {
  display: inline-block;
  padding: 3px 10px;
  background: #4a3080;
  color: #d4bfff;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.obsidian-link:hover { background: #6040a0; }

.route-list { margin-top: 12px; }
.route-list .route-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #223;
  font-size: 12px;
}
.route-item .route-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

/* ── Mobile: sidebar becomes bottom drawer ── */
@media (max-width: 768px) {
  #main {
    flex-direction: column;
  }

  #map-container {
    flex: 1;
  }

  #sidebar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 55vh;
    border-left: none;
    border-top: 1px solid #334;
    border-radius: 12px 12px 0 0;
    padding: 8px 16px 16px;
    transform: translateY(calc(100% - 32px));
    transition: transform 0.3s ease;
    z-index: 10;
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateY(0);
  }

  #sidebar-handle {
    display: block;
    width: 40px;
    height: 5px;
    background: #445;
    border-radius: 3px;
    margin: 4px auto 10px;
    cursor: pointer;
  }

  #toolbar {
    padding: 6px 10px;
    gap: 6px;
  }

  #toolbar button { font-size: 12px; padding: 5px 10px; }
  #toolbar select { font-size: 12px; }
  #status-bar { font-size: 12px; }
}
