/* AeroGyan graph plotter. Every class starts with gp-. Uses the app's theme variables. */
.gp-root {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
  color: var(--text-primary);
  font-size: 14px;
}
.gp-side,
.gp-graph {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.gp-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: min(78vh, 720px);
  overflow: auto;
}
.gp-main { min-width: 0; }

/* ---- header: Add + Rad/Deg ---- */
.gp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-surface);
}
.gp-seg { display: inline-flex; gap: 0; }
.gp-seg .btn { border-radius: 0; min-width: 48px; }
.gp-seg .btn:first-child { border-radius: 6px 0 0 6px; }
.gp-seg .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1.5px; }
.gp-seg .btn-primary { border: 1.5px solid transparent; }

/* ---- expression rows ---- */
.gp-list { display: flex; flex-direction: column; }
.gp-row {
  --gp-c: var(--brand-500);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
}
.gp-row.gp-sel { border-left-color: var(--gp-c); background: var(--bg-surface-2); }
.gp-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--gp-c);
  background: var(--gp-c);
  padding: 0;
  cursor: pointer;
  flex: none;
}
.gp-dot:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.gp-off .gp-dot { background: transparent; }
.gp-off .gp-input { color: var(--text-tertiary); }
.gp-input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font: 15px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.gp-row.gp-sel .gp-input { background: var(--bg-surface); }
.gp-input:focus { outline: none; border-color: var(--brand-500); background: var(--bg-surface); }
.gp-input[aria-invalid="true"] { border-color: #e5484d; }
.gp-del {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 15px;
}
.gp-del:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.gp-err,
.gp-range { grid-column: 2 / 4; }
.gp-err { color: #c62828; font-size: 12.5px; line-height: 1.35; }
.gp-err[hidden], .gp-range[hidden] { display: none; }
.gp-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}
.gp-rname { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; }
.gp-rin {
  width: 72px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font: 13px ui-monospace, Menlo, Consolas, monospace;
}
.gp-range.gp-bad .gp-rin { border-color: #e5484d; }

/* ---- sliders ---- */
.gp-sliders { padding: 6px 10px 10px; border-bottom: 1px solid var(--border-subtle); }
.gp-sliders[hidden] { display: none; }
.gp-sl-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 4px 0 2px;
}
.gp-sl { padding: 8px 0; border-top: 1px dashed var(--border-subtle); }
.gp-sl:first-of-type { border-top: 0; }
.gp-sl-top { display: flex; align-items: center; gap: 8px; }
.gp-sl-name { font: 700 15px ui-monospace, Menlo, Consolas, monospace; color: var(--text-primary); }
.gp-sl-val {
  width: 90px;
  padding: 5px 8px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font: 14px ui-monospace, Menlo, Consolas, monospace;
}
.gp-sl-val.gp-bad { border-color: #e5484d; }
.gp-sl-play { margin-left: auto; width: 34px; padding-left: 0; padding-right: 0; }
.gp-sl-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.gp-sl-range { flex: 1; min-width: 0; accent-color: var(--brand-500); height: 24px; }
.gp-sl-lim {
  width: 46px;
  padding: 3px 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: 12px ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
}

/* ---- example chips ---- */
.gp-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px;
  margin-top: auto;
}
.gp-ex-label { font-size: 12px; color: var(--text-tertiary); }
.gp-chip {
  border: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 3px 10px;
  font: 12px ui-monospace, Menlo, Consolas, monospace;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gp-chip:hover { border-color: var(--brand-500); color: var(--text-primary); }

/* ---- graph ---- */
.gp-graph {
  position: relative;
  height: min(78vh, 720px);
  min-height: 360px;
  overflow: hidden;
}
.gp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.gp-canvas.gp-grabbing { cursor: grabbing; }
.gp-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gp-zoom .gp-zbtn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.gp-zoom .gp-zbtn:hover { background: var(--bg-surface-3); }

/* ---- bar under the graph ---- */
.gp-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 10px;
}
.gp-readout {
  flex: 1 1 220px;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.gp-bar-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.gp-latex {
  margin-top: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  padding: 10px;
}
.gp-latex[hidden] { display: none; }
.gp-latex-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.gp-latex-code {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow: auto;
}

/* ---- dark themes ---- */
html[data-theme="dark"] .gp-err,
html[data-theme="dim"] .gp-err { color: #ff8a8a; }
html[data-theme="dark"] .gp-input[aria-invalid="true"],
html[data-theme="dim"] .gp-input[aria-invalid="true"] { border-color: #ff6b6b; }

/* ---- phones and small tablets: list above the graph ---- */
@media (max-width: 820px) {
  .gp-root { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .gp-side { max-height: none; overflow: visible; }
  .gp-head { position: static; }
  .gp-graph { height: 62vh; min-height: 320px; }
  .gp-input { font-size: 16px; } /* stops iOS zoom on focus */
  .gp-sl-play,
  .gp-zoom .gp-zbtn { width: 44px; height: 44px; }
  .gp-del { width: 40px; height: 40px; }
  .gp-bar-btns { width: 100%; }
  .gp-bar-btns .btn { flex: 1 1 140px; }
}
