:root {
  --bg-root: #ffffff;
  --bg-bar: #f7f8fa;
  --bg-cell: #ffffff;
  --border: #e2e5ea;
  --border-strong: #c8cdd6;
  --text-primary: #111318;
  --text-secondary: #525866;
  --text-muted: #848b99;
  --accent: #d97706;        /* solar / terminator */
  --pick: #2563eb;          /* picked point (blue) */
  --anti: #db2777;          /* antipode (magenta) */
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar,
.duo-bar {
  flex-shrink: 0;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 8px 18px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.master-clocks {
  display: flex;
  align-items: center;
  gap: 14px;
}

.clock-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.readout-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.readout-time {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.ctrl-btn:hover {
  background: #eef0f4;
  color: var(--text-primary);
}

.ctrl-btn.active {
  border-color: rgba(217, 119, 6, 0.65);
  color: var(--accent);
  background: rgba(217, 119, 6, 0.06);
}

#btn-snap.active {
  border-color: rgba(37, 99, 235, 0.6);
  color: var(--pick);
  background: rgba(37, 99, 235, 0.06);
}

/* Dual readout bar */
.duo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 8px 18px;
  background: var(--bg-root);
  border-bottom: 1px solid var(--border);
}

.duo-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.duo-hint strong {
  color: var(--text-primary);
  font-weight: 600;
}

.duo-cards {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.point-card {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  background: var(--bg-cell);
}

.point-card.pick { border-left: 3px solid var(--pick); }
.point-card.anti { border-left: 3px solid var(--anti); }

.pc-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot-pick { background: var(--pick); }
.dot-anti { background: var(--anti); }

.pc-coords {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-place {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11.5px;
}

.pc-time {
  color: var(--text-primary);
  font-weight: 600;
}

.pc-status {
  color: var(--text-secondary);
}
.pc-status.day   { color: var(--accent); }
.pc-status.night { color: #475569; }

.duo-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  padding: 0 2px;
}

.link-line {
  width: 1px;
  flex: 1;
  min-height: 8px;
  background: repeating-linear-gradient(180deg, var(--border-strong) 0 3px, transparent 3px 6px);
}

.link-badge {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.swatch.terminator {
  height: 2px;
  width: 14px;
  background: var(--accent);
}

.swatch.twilight {
  background: linear-gradient(90deg, #e2e5ea, #14161a);
  border: 1px solid var(--border-strong);
}

.swatch.sw-pick {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--pick);
}
.swatch.sw-anti {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--anti);
}

/* Map stage */
.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--bg-root);
  overflow: hidden;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

#world-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#world-canvas.panning {
  cursor: grabbing;
}

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 14px rgba(17, 19, 24, 0.12);
  border-radius: 4px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary);
  z-index: 10;
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 860px) {
  .map-legend { display: none; }
  .brand-sub { display: none; }
}

@media (max-width: 680px) {
  .topbar {
    padding: 6px 12px;
    gap: 6px 10px;
  }
  .brand h1 { font-size: 13px; }
  .duo-bar { padding: 7px 12px; }
  .duo-cards { flex-direction: column; gap: 7px; }
  .duo-link { flex-direction: row; width: 100%; }
  .duo-link .link-line { height: 1px; width: auto; min-height: 0; background: repeating-linear-gradient(90deg, var(--border-strong) 0 3px, transparent 3px 6px); }
  .pc-coords { font-size: 13px; }
  .ctrl-btn { padding: 6px 10px; }
}
