/* Graphing Calculator — Desmos-style workspace */

#panel-graphcalc.panel.active {
  display: block;
  min-height: calc(100vh - 100px);
}

body.gc-tab-active #panel-graphcalc {
  background: #0e1117;
}

.gc-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 110px);
  min-height: 520px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem 0.75rem;
  box-sizing: border-box;
  color: #e8ecf4;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.gc-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

.gc-top h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  color: #f4f6fb;
}

.gc-hint {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(180, 190, 210, 0.85);
  max-width: 48rem;
}

.gc-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.gc-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(28, 34, 48, 0.95);
  color: #e8ecf4;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.gc-btn:hover {
  border-color: rgba(120, 170, 255, 0.45);
  background: rgba(40, 50, 70, 0.98);
}

.gc-btn.is-active {
  border-color: rgba(90, 160, 255, 0.65);
  background: rgba(35, 55, 90, 0.95);
  color: #dcecff;
}

.gc-btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(200, 210, 230, 0.9);
}

.gc-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 0.55rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #12151c;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 860px) {
  .gc-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, 38vh) minmax(280px, 1fr);
  }
}

.gc-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #161a24;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.gc-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(170, 185, 210, 0.8);
}

.gc-expr-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem;
}

.gc-expr-row {
  display: grid;
  grid-template-columns: 1.4rem 2.1rem minmax(0, 1fr) 1.6rem;
  gap: 0.3rem;
  align-items: start;
  padding: 0.35rem 0.3rem;
  margin-bottom: 0.3rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 12, 18, 0.55);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.gc-expr-row.is-focus {
  border-color: rgba(100, 160, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(80, 140, 255, 0.15);
}

.gc-expr-row.has-error {
  border-color: rgba(255, 100, 100, 0.45);
}

.gc-expr-idx {
  font-size: 0.72rem;
  font-weight: 800;
  color: rgba(150, 160, 180, 0.85);
  padding-top: 0.45rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.gc-style-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding-top: 0.25rem;
}

.gc-color-wrap {
  position: relative;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  flex-shrink: 0;
}

.gc-color-wrap.is-hidden {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.gc-color-wrap.is-action-swatch {
  opacity: 0.5;
  cursor: default;
}

.gc-color-input {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  padding: 0;
  border: none;
  cursor: pointer;
  background: transparent;
}

.gc-color-input:disabled {
  cursor: default;
}

.gc-vis-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(180, 200, 230, 0.85);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.1rem;
  cursor: pointer;
  border-radius: 4px;
}

.gc-vis-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.gc-vis-btn.is-off {
  color: rgba(120, 130, 150, 0.7);
}

.gc-opacity-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) 2.4rem;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.15rem;
  padding: 0.15rem 0.2rem 0.1rem;
}

.gc-opacity-lab {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(150, 165, 190, 0.8);
}

.gc-opacity-range {
  width: 100%;
  accent-color: #6aa8ff;
  height: 0.35rem;
}

.gc-opacity-val {
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: Consolas, monospace;
  color: #a8c8f0;
  text-align: right;
}

.gc-expr-input {
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: #f0f3fa;
  font: 600 0.92rem/1.35 "Cascadia Code", "Consolas", "Segoe UI", monospace;
  padding: 0.35rem 0.15rem;
  resize: vertical;
  min-height: 1.8rem;
  max-height: 6rem;
  outline: none;
}

.gc-expr-input::placeholder {
  color: rgba(140, 150, 170, 0.65);
  font-weight: 500;
}

.gc-expr-err {
  grid-column: 2 / -1;
  font-size: 0.68rem;
  color: #ff9a9a;
  margin: 0 0 0.1rem 0.15rem;
  line-height: 1.3;
}

.gc-expr-del {
  border: none;
  background: transparent;
  color: rgba(160, 170, 190, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
}

.gc-expr-del:hover {
  color: #ffb0b0;
  background: rgba(80, 30, 30, 0.4);
}

.gc-add-row {
  padding: 0.35rem 0.55rem 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.gc-add-row .gc-btn {
  width: 100%;
}

.gc-sliders {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  max-height: 38%;
  overflow: auto;
  padding: 0.45rem 0.55rem 0.55rem;
  background: rgba(8, 10, 16, 0.45);
}

.gc-sliders h3 {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(160, 180, 210, 0.75);
}

.gc-slider-block {
  margin-bottom: 0.55rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gc-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
  font-family: "Cascadia Code", Consolas, monospace;
}

.gc-slider-head strong {
  font-size: 0.85rem;
  color: #c8d4ef;
}

.gc-slider-val {
  font-size: 0.75rem;
  color: #9ec4ff;
  font-variant-numeric: tabular-nums;
}

.gc-slider-block input[type="range"] {
  width: 100%;
  accent-color: #5b9cff;
  margin: 0.15rem 0 0.3rem;
}

.gc-slider-bounds {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.3rem;
}

.gc-slider-bounds input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c0e14;
  color: #e8ecf4;
  font: 600 0.72rem/1 Consolas, monospace;
}

.gc-expr-row.is-action {
  border-color: rgba(220, 170, 60, 0.45);
  background: rgba(48, 36, 10, 0.45);
}

.gc-expr-row.is-assign {
  border-color: rgba(80, 180, 120, 0.3);
  background: rgba(12, 36, 24, 0.35);
}

.gc-expr-row.is-list {
  border-color: rgba(100, 160, 255, 0.35);
  background: rgba(12, 24, 44, 0.4);
}

.gc-expr-hint {
  grid-column: 2 / -1;
  font-size: 0.65rem;
  color: rgba(160, 180, 200, 0.75);
  margin: 0 0 0.05rem 0.15rem;
}

.gc-action-bar {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin: 0.15rem 0 0.2rem 0.1rem;
}

.gc-action-run {
  appearance: none;
  border: 1px solid rgba(255, 200, 80, 0.55);
  background: rgba(80, 55, 10, 0.9);
  color: #ffe8b0;
  font: 700 0.72rem/1 "Segoe UI", sans-serif;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
}

.gc-action-run:hover {
  background: rgba(120, 80, 15, 0.95);
  border-color: rgba(255, 220, 120, 0.75);
}

.gc-action-tick {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 650;
  color: #e8d8a8;
  cursor: pointer;
  user-select: none;
}

.gc-action-tick input {
  accent-color: #e0a020;
}

.gc-action-arrow {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffd878;
  letter-spacing: 0.02em;
}

.gc-ticker-ms-lab {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: rgba(180, 190, 210, 0.9);
}

.gc-ticker-ms-lab input {
  width: 3.4rem;
  padding: 0.3rem 0.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 14, 22, 0.95);
  color: #e8ecf4;
  font: 600 0.75rem Consolas, monospace;
}

.gc-ticker-status {
  font-size: 0.7rem;
  color: rgba(160, 190, 220, 0.85);
  font-variant-numeric: tabular-nums;
}

.gc-ticker-status.is-running {
  color: #8dffb0;
  font-weight: 700;
}

.gc-slider-block.is-running {
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(100, 220, 140, 0.35);
  background: rgba(20, 48, 32, 0.35);
}

.gc-run-dot {
  color: #5dff8a;
  font-size: 0.65rem;
  animation: gc-pulse 0.9s ease-in-out infinite;
  margin-right: 0.15rem;
}

@keyframes gc-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.gc-param-anim {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.gc-param-play {
  appearance: none;
  border: 1px solid rgba(100, 200, 140, 0.45);
  background: rgba(20, 50, 32, 0.9);
  color: #c8f5d4;
  font: 700 0.68rem/1 "Segoe UI", sans-serif;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.gc-param-play.is-on {
  border-color: rgba(120, 240, 160, 0.75);
  background: rgba(30, 90, 50, 0.95);
  color: #e8ffe8;
  box-shadow: 0 0 10px rgba(60, 200, 100, 0.25);
}

.gc-param-play:hover {
  filter: brightness(1.08);
}

.gc-param-mode {
  font: 600 0.68rem/1.2 "Segoe UI", sans-serif;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0c0e14;
  color: #e0e8f4;
  max-width: 7.5rem;
}

.gc-param-speed {
  flex: 1;
  min-width: 4rem;
  accent-color: #6ad4ff;
}

/* Image → sketch (img2desmos-style) */
.gc-sketch-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.55rem 0.6rem 0.7rem;
  background: rgba(8, 14, 24, 0.55);
  max-height: 48%;
  overflow: auto;
}

.gc-sketch-head {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ec8ff;
  margin-bottom: 0.25rem;
}

.gc-sketch-sub {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(160, 180, 210, 0.75);
  font-size: 0.68rem;
}

.gc-sketch-hint {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  line-height: 1.35;
  color: rgba(170, 185, 210, 0.85);
}

.gc-sketch-lab {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(150, 165, 190, 0.8);
  margin: 0.35rem 0 0.15rem;
}

.gc-sketch-select,
.gc-sketch-num,
.gc-sketch-file {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c0e14;
  color: #e8ecf4;
  margin-bottom: 0.25rem;
}

.gc-sketch-file {
  font-size: 0.72rem;
  padding: 0.3rem;
}

.gc-sketch-preview-wrap {
  margin: 0.35rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #111;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gc-sketch-preview {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.gc-btn-accent {
  background: linear-gradient(180deg, rgba(50, 100, 180, 0.95), rgba(30, 70, 140, 0.95));
  border-color: rgba(120, 170, 255, 0.45);
  width: 100%;
  margin-top: 0.35rem;
}

.gc-btn-accent:hover {
  filter: brightness(1.08);
}

#gc-sketch-clear {
  width: 100%;
  margin-top: 0.25rem;
}

.gc-sketch-status {
  margin: 0.4rem 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: rgba(160, 200, 255, 0.9);
  min-height: 1.2em;
}

.gc-sketch-status.is-err {
  color: #ff9a9a;
}

.gc-sketch-status.is-ok {
  color: #8dffb0;
}

.gc-sketch-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0 0.25rem;
  font-size: 0.72rem;
  color: rgba(180, 195, 220, 0.9);
  cursor: pointer;
}

.gc-sketch-check code {
  font-size: 0.68rem;
  color: #9ec8ff;
}

.gc-sketch-check input {
  accent-color: #5b9cff;
}

.gc-sketch-numpick {
  margin: 0.25rem 0 0.35rem;
}

.gc-sketch-numrow {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) 2.2rem;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.gc-sketch-numrow .gc-btn {
  padding: 0.35rem 0.25rem;
  min-width: 0;
}

#gc-sketch-num-go {
  width: 100%;
}

.gc-graph-wrap {
  position: relative;
  min-height: 0;
  background: #f7f8fc;
  display: flex;
  flex-direction: column;
}

.gc-canvas-host {
  position: relative;
  flex: 1;
  min-height: 0;
  cursor: grab;
  touch-action: none;
  overflow: hidden;
}

.gc-canvas-host.is-panning {
  cursor: grabbing;
}

.gc-canvas-host.is-crosshair {
  cursor: crosshair;
}

#gc-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.gc-readout {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  z-index: 3;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(16, 20, 30, 0.88);
  color: #e8ecf4;
  font: 600 0.75rem/1.35 Consolas, monospace;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  max-width: min(90%, 22rem);
}

.gc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  padding: 0.4rem 0.5rem;
  background: #161a24;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.gc-toolbar .gc-btn {
  font-size: 0.72rem;
  padding: 0.32rem 0.55rem;
}

.gc-view-label {
  margin-left: auto;
  font-size: 0.68rem;
  font-family: Consolas, monospace;
  color: rgba(170, 185, 210, 0.8);
  font-variant-numeric: tabular-nums;
}

.gc-help-panel {
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 22, 32, 0.92);
  font-size: 0.75rem;
  line-height: 1.45;
  color: rgba(190, 200, 220, 0.9);
}

.gc-help-panel[hidden] {
  display: none !important;
}

.gc-help-panel code {
  font-family: Consolas, monospace;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.05rem 0.28rem;
  border-radius: 4px;
  color: #c8dcff;
}

.gc-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.45rem 1rem;
  margin-top: 0.35rem;
}
