/* ═══════════════════════════════════════════════
   Polar Viewer — Styles
   ═══════════════════════════════════════════════ */

:root {
  --bg: #0e1a2b;
  --bg-panel: #152238;
  --fg: #e0e8f0;
  --fg-dim: #8899aa;
  --accent: #4ecdc4;
  --accent2: #ff6b6b;
  --ring: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.12);
  --toolbar-h: 64px;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  color-scheme: dark;
}

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

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  touch-action: none;
}

/* ── Toolbar ── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--toolbar-h);
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
#toolbar button, #toolbar select {
  font-size: 26px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}
#toolbar button:hover, #toolbar select:hover {
  border-color: var(--accent);
}
#polarSelector { flex: 0 1 200px; }
#btnDelete { padding: 4px 7px; color: var(--accent2); }
#fileInfo {
  flex: 1;
  font-size: 24px;
  color: var(--fg-dim);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Settings Panel ── */
.panel {
  position: fixed;
  top: var(--toolbar-h);
  right: 0;
  width: 260px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 0 var(--radius);
  padding: 16px;
  z-index: 20;
}
.panel.hidden { display: none; }
.panel h3 { margin-bottom: 12px; font-size: 30px; }
.panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 26px;
  cursor: pointer;
}
.panel select {
  margin-top: 4px;
  width: 100%;
  padding: 4px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel button {
  margin-top: 12px;
  width: 100%;
  padding: 6px;
  font-size: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

/* ── Main Content ── */
#mainContent {
  position: relative;
  height: calc(100% - var(--toolbar-h));
}
#mainContent canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── View Controls ── */
#viewControls {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 5;
  background: rgba(21, 34, 56, 0.85);
  border-radius: var(--radius);
  padding: 4px 14px;
  border: 1px solid var(--border);
  font-size: 24px;
}
#viewControls label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
#viewControls select {
  font-size: 22px;
  padding: 2px 6px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Legend ── */
#legend {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px 6px;
  font-size: 13px;
  padding: 3px 12px;
  background: rgba(21, 34, 56, 0.8);
  pointer-events: auto;
  z-index: 4;
  transition: bottom 0.1s;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.15s;
  user-select: none;
  line-height: 1.3;
}
.legend-item.hidden-curve { opacity: 0.3; }
.legend-swatch {
  width: 14px; height: 3px;
  border-radius: 2px;
}

/* ── Tooltip ── */
.tooltip {
  position: absolute;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 5px 8px;
  border-radius: var(--radius);
  font-size: 24px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 15;
}
.tooltip.hidden { display: none; }

/* ── Readouts bar ── */
#readouts {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 6px 12px;
  font-size: 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  z-index: 5;
}
.readout-group {
  display: flex;
  gap: 3px;
  align-items: baseline;
  white-space: nowrap;
}
.readout-group .label {
  color: var(--fg-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.readout-group .value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.readout-group.apparent .value { color: var(--accent2); }

#numericInputs {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
#numericInputs label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#numericInputs input {
  width: 56px;
  padding: 2px 4px;
  font-size: 16px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Drop Overlay ── */
#dropOverlay {
  position: fixed;
  inset: 0;
  background: rgba(14,26,43,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#dropOverlay.hidden { display: none; }
.drop-message {
  font-size: 48px;
  font-weight: 600;
  color: var(--accent);
  border: 3px dashed var(--accent);
  border-radius: 16px;
  padding: 60px 80px;
}

/* ── Responsive ── */
@media (max-width: 767px) {
  :root { --toolbar-h: 52px; }
  #toolbar { gap: 4px; padding: 0 6px; }
  #toolbar button, #toolbar select { font-size: 20px; padding: 3px 6px; }
  #polarSelector { flex: 1; }
  #fileInfo { font-size: 16px; }
  #viewControls { font-size: 16px; padding: 3px 8px; gap: 6px; }
  #viewControls select { font-size: 16px; }
  #readouts { font-size: 15px; gap: 3px 10px; padding: 5px 8px; }
  .readout-group .label { font-size: 10px; }
  #numericInputs { margin-left: auto; gap: 6px; }
  #numericInputs input { width: 48px; font-size: 14px; }
  #legend { font-size: 11px; gap: 0px 5px; padding: 2px 6px; }
  .legend-swatch { width: 10px; }
}
@media (max-width: 400px) {
  #readouts { font-size: 13px; gap: 2px 6px; padding: 4px 6px; }
  #numericInputs input { width: 42px; font-size: 13px; }
  #legend { font-size: 10px; }
}
