/* dotdot — tokens from the validated reference palette (dataviz skill).
   Light is the default; dark follows the OS setting. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;   /* categorical slot 1 — forward strand */
  --accent-2: #eb6834; /* categorical slot 2 — reverse strand */
  --critical: #d03b3b;
  --panel: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-2: #d95926;
    --critical: #e66767;
    --panel: #161615;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font: 13px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--page);
  color: var(--ink);
  overflow: hidden;
  /* An app, not a document: without this, WebKit browsers treat plot drags
     as text-selection gestures (I-beam cursor, no pan). */
  -webkit-user-select: none;
  user-select: none;
}

/* Typing fields and data readouts stay selectable/copyable. */
input,
textarea,
#hover-card,
#stats,
#readout,
#help-pop {
  -webkit-user-select: text;
  user-select: text;
}

kbd {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 3px;
  color: var(--ink-2);
}

/* ---- header / footer ------------------------------------------------- */

#topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

#wordmark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#wordmark span {
  color: var(--accent);
}

#tagline {
  color: var(--ink-2);
  font-size: 12px;
}

#statusbar {
  flex: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

#hints {
  color: var(--muted);
}

/* ---- layout ----------------------------------------------------------- */

#layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

#sidebar {
  flex: none;
  width: 292px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 10px 12px 24px;
  background: var(--page);
}

.panel {
  padding: 10px 2px 12px;
  border-bottom: 1px solid var(--border);
}

.panel:last-child {
  border-bottom: none;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- help popovers ----------------------------------------------------- */

.help {
  flex: none;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.help:hover {
  color: var(--accent);
  border-color: var(--accent);
}

#help-pop {
  position: fixed;
  z-index: 30;
  max-width: 290px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}

#help-pop b {
  color: var(--ink);
}

#help-pop[hidden] {
  display: none;
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
  margin: 8px 0;
}

/* ---- controls ---------------------------------------------------------- */

.ctl {
  margin: 8px 0;
}

.ctl > label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--ink-2);
  margin-bottom: 3px;
}

.ctl output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0;
}

select,
input.combo {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input.combo {
  font-variant-numeric: tabular-nums;
}

input.combo:focus,
.ctl input[type='number']:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.ctl input[type='number'] {
  width: 56px;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.region-row {
  display: flex;
  gap: 6px;
}

.region-row input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.region-row input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  margin: 4px 0;
  cursor: pointer;
}

.checks input {
  accent-color: var(--accent);
  margin: 0;
}

.swatch {
  width: 22px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: inline-block;
}

/* ---- buttons ----------------------------------------------------------- */

.btn {
  font: inherit;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--baseline);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.primary {
  width: 100%;
  margin-top: 6px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.subtle {
  color: var(--ink-2);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.linklike {
  font: inherit;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* ---- file rows --------------------------------------------------------- */

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.file-row input[type='file'] {
  display: none;
}

.file-btn {
  flex: none;
  width: 108px;
  text-align: center;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  cursor: pointer;
  color: var(--ink);
}

.file-btn:hover {
  border-color: var(--baseline);
}

.chip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.chip.loaded {
  color: var(--ink);
}

/* ---- legend / stats / hover ------------------------------------------- */

#legend .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: var(--ink-2);
}

#legend .ramp {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

#legend .lab {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  min-width: 34px;
}

#stats {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
}

#stats dt {
  color: var(--muted);
}

#stats dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hover-card {
  font-variant-numeric: tabular-nums;
}

#hover-card .line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

#hover-card .line span:first-child {
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

/* ---- plot area --------------------------------------------------------- */

#plot-root {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

#plot-root canvas {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

/* Must out-specify `#plot-root canvas` above — that rule turns the canvas
   stack hit-test-invisible, and this one turns the top layer back on for
   real pointers. (ID+ID beats ID+element.) */
#plot-root #overlay {
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}

#glcanvas[hidden] {
  display: none;
}

#zoomctl {
  position: absolute;
  right: 22px;
  bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
}

#zoomctl button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink-2);
  font: 600 16px/1 system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.85;
}

#zoomctl button:hover {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

#tooltip {
  position: absolute;
  z-index: 5;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  padding: 7px 10px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

#tooltip .t-ident {
  color: var(--ink-2);
}

/* ---- empty state / progress / toast ------------------------------------ */

#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-2);
  pointer-events: none;
}

#empty-state .linklike {
  pointer-events: auto;
}

#empty-state .dots {
  font-size: 64px;
  font-weight: 700;
  color: var(--baseline);
  line-height: 1;
  transform: rotate(-45deg);
}

#empty-state[hidden],
#progress[hidden],
#tooltip[hidden],
#toast[hidden] {
  display: none;
}

#plot-root.dragover::after {
  content: 'drop to load';
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  z-index: 9;
}

#progress {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--page) 55%, transparent);
  z-index: 8;
}

#progress-panel {
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  text-align: center;
}

#progress-label {
  color: var(--ink-2);
  margin-bottom: 10px;
}

#progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--grid);
  overflow: hidden;
  margin-bottom: 12px;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 120ms linear;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 44px;
  max-width: 420px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 10px 14px;
  z-index: 20;
}

#toast.error {
  border-left-color: var(--critical);
}
