/* Reusable UI components — buttons, segmented controls, sliders, panels. */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}
.btn:hover { border-color: var(--ink-faint); background: #202a3a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary {
  background: var(--ice-soft);
  border-color: var(--ice);
  color: var(--ice);
  font-weight: 600;
}
.btn.primary:hover { background: #6cc4ff40; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 0.76rem; }
.btn.icon { padding: 6px 8px; min-width: 34px; }

/* ---- Segmented control ---- */
.seg {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg button {
  padding: 4px 10px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--hairline-soft);
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 0.78rem;
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--ice-soft); color: var(--ice); }

/* ---- Panel sections (right controls column) ---- */
.panel-section {
  background: var(--bg-panel);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.panel-title::after { content: ""; flex: 1; height: 1px; background: var(--hairline-soft); }

.ctl-row { display: flex; align-items: center; gap: 8px; }
.ctl-row label { min-width: 86px; color: var(--ink-dim); font-size: 0.8rem; }
.ctl-row .val {
  min-width: 68px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
}
.hint { color: var(--ink-faint); font-size: 0.74rem; }

/* ---- Big instrument readout ---- */
.readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.readout .ro-label { color: var(--ink-dim); font-size: 0.78rem; }
.readout .ro-value {
  font-family: var(--mono);
  font-size: 1.25rem;
  color: var(--ice);
  font-variant-numeric: tabular-nums;
}
.readout .ro-unit { color: var(--ink-faint); font-size: 0.75rem; }

/* Provenance tags on readouts */
.tag {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid currentColor;
  opacity: 0.85;
  cursor: help;
}
.tag.measured { color: var(--tag-measured); }
.tag.modeled { color: var(--tag-modeled); }
.tag.illustrated { color: var(--tag-illustrated); }

/* ---- Range sliders ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--hairline);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ice);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px var(--ice-glow);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ice);
  border: 2px solid var(--bg-panel);
}
input[type="range"]:disabled { opacity: 0.4; }

select {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--ink);
}

/* ---- Keyboard chip ---- */
.kbd {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--ink-dim);
}

/* ---- Tool rail (floating on the stage) ---- */
.tool-rail {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #0b0f15d8;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 5;
  backdrop-filter: blur(3px);
}
.tool-btn {
  width: 34px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-size: 0.95rem;
  cursor: pointer;
}
.tool-btn:hover { color: var(--ink); background: var(--bg-raised); }
.tool-btn.active { color: var(--ice); background: var(--ice-soft); border-color: var(--ice); }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-sep { height: 1px; background: var(--hairline-soft); margin: 3px 2px; }

/* ---- Presets gallery ---- */
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.05rem; letter-spacing: 0.06em; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  width: min(760px, 84vw);
}
.preset-card {
  background: var(--bg-raised);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
}
.preset-card:hover { border-color: var(--ice); }
.preset-card canvas { width: 100%; border-radius: var(--radius-sm); display: block; }
.preset-name { font-weight: 600; font-size: 0.85rem; margin-top: 6px; }
.preset-desc { color: var(--ink-dim); font-size: 0.74rem; margin-top: 2px; }

/* ---- Floating chart box (stage instrument) ---- */
.chart-box {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: #0b0f15d8;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 4;
  backdrop-filter: blur(3px);
}
.chart-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 10px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  cursor: pointer;
  border-bottom: 1px solid var(--hairline-soft);
  user-select: none;
}
.chart-box-head:hover { color: var(--ink); }
.chart-box-hint { font-weight: 400; letter-spacing: 0.02em; color: var(--ink-faint); }
.chart-tab-btn {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 2px 4px;
}
.chart-tab-btn:hover { color: var(--ink-dim); }
.chart-tab-btn.active { color: var(--ice); }

/* ---- Toasts ---- */
.toast-wrap {
  position: fixed;
  right: 14px; bottom: calc(var(--status-h) + 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--ice);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  max-width: 320px;
  box-shadow: 0 8px 30px #00000080;
  animation: toast-in 0.18s ease-out;
}
.toast.warn { border-left-color: var(--warn); }
.toast .toast-title { font-weight: 600; font-size: 0.85rem; }
.toast .toast-desc { color: var(--ink-dim); font-size: 0.76rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
