:root {
  --ink: #071a3d;
  --muted: #607490;
  --blue: #1261d8;
  --blue-deep: #083b8e;
  --line: #d4e1f1;
  --surface: rgba(255, 255, 255, 0.94);
  --shadow: 0 24px 70px rgba(18, 64, 120, 0.12);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, rgba(18, 97, 216, 0.12), transparent 24rem),
    radial-gradient(circle at 92% 12%, rgba(77, 180, 157, 0.08), transparent 24rem),
    linear-gradient(145deg, #f9fbfe 0%, #edf4fb 100%);
  font-family: "DM Sans", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.lab-header {
  min-height: 96px;
  padding: 14px clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(200, 216, 237, 0.9);
  backdrop-filter: blur(18px);
}
.brand-lockup { display: flex; align-items: center; gap: 15px; }
.brand-lockup img { width: 68px; height: 68px; object-fit: contain; mix-blend-mode: multiply; }
.brand-lockup div { display: grid; gap: 5px; }
.brand-lockup span, .eyebrow {
  color: var(--blue);
  font: 600 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: 0.19em;
}
.brand-lockup strong { font-size: 19px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.local-badge, .live-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid #cfe0f4;
  border-radius: 999px;
  color: #415b7b;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}
.local-badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #18a85a;
  box-shadow: 0 0 0 5px #e2f6ea;
}
.r-badge i { background: #f59e0b; box-shadow: 0 0 0 5px #fff2d9; }
.r-badge.is-online i { background: #18a85a; box-shadow: 0 0 0 5px #e2f6ea; }
.r-badge.is-offline i { background: #ef4a54; box-shadow: 0 0 0 5px #fee9eb; }
.r-badge.is-local i { background: #1261d8; box-shadow: 0 0 0 5px #dbeafe; }

.lab-shell {
  width: min(1600px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 64px;
}
.lab-banner {
  margin-bottom: 18px;
  padding: 0 4px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.lab-banner h1 {
  max-width: 810px;
  margin: 10px 0 0;
  font-size: clamp(36px, 4vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.052em;
}
.lab-banner > div > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }
.workspace--single {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.82fr);
}
.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-heading {
  min-height: 90px;
  padding: 22px 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #dce6f2;
}
.panel-heading h2 { margin: 5px 0 0; font-size: 22px; letter-spacing: -0.025em; }
.editor-heading { border-bottom: 0; padding-bottom: 16px; }
.autosave {
  color: #6c7f98;
  font: 500 11px "IBM Plex Mono", monospace;
}

.editor-stage .editor-body,
.editor-panel .editor-body { padding: 0 24px 24px; }
.editor-stage .editor-body {
  display: grid;
  gap: 18px;
}
.figure-summary {
  display: grid;
  gap: 8px;
  padding: 16px 18px 0;
}
.figure-summary__kicker {
  margin: 0;
  color: var(--blue);
  font: 600 10px "IBM Plex Mono", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.figure-summary strong {
  color: var(--ink);
  font-size: clamp(1.35rem, 2.4vw, 2.25rem);
  line-height: 1.05;
}
.figure-summary p:last-child {
  margin: 0;
  color: #667b96;
  line-height: 1.55;
}
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.controls-grid label {
  display: grid;
  align-content: start;
  gap: 7px;
  color: #2b4565;
  font-size: 12px;
  font-weight: 700;
}
.controls-grid label small {
  display: block;
  color: #7a8da6;
  font-weight: 500;
}
.control-wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c8d8eb;
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: #fbfdff;
}
input, select { min-height: 44px; padding: 10px 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px #e4efff; }
.button {
  min-height: 43px;
  padding: 10px 17px;
  border-radius: 999px;
  border: 1px solid #c5d7ec;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(18, 64, 120, 0.13); }
.button-primary { color: #fff; border-color: var(--blue); background: linear-gradient(135deg, #1261d8, #207ae9); }
.button-r { color: #fff; border-color: #174f7d; background: linear-gradient(135deg, #174f7d, #0f766e); }
.button-r.is-loading { opacity: 0.7; cursor: wait; }

.color-control, .range-control {
  min-height: 44px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #c8d8eb;
  border-radius: 12px;
  background: #fbfdff;
}
.color-control input {
  width: 38px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
}
.color-control output, .range-control output {
  color: #546c89;
  font: 600 11px "IBM Plex Mono", monospace;
}
.range-control input { min-height: auto; padding: 0; border: 0; box-shadow: none; }

.source-figure {
  overflow: hidden;
  border: 1px solid #cbdced;
  border-radius: 16px;
  background: #f5f9fe;
}
.source-figure-heading {
  padding: 11px 13px;
  display: grid;
  gap: 5px;
  border-bottom: 1px solid #d7e3f1;
}
.source-figure-heading span {
  color: var(--blue);
  font: 600 9px "IBM Plex Mono", monospace;
  letter-spacing: 0.16em;
}
.source-figure-heading strong { color: #263f5e; font-size: 12px; }
.source-figure img {
  width: 100%;
  max-height: 285px;
  display: block;
  object-fit: contain;
  background: #fff;
}
.source-figure p {
  margin: 0;
  padding: 10px 13px;
  color: #687d98;
  font-size: 11px;
  line-height: 1.45;
}

.preview-card {
  border: 1px solid #d2e0f0;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}
.preview-card--large {
  min-height: 600px;
  display: grid;
  grid-template-rows: auto auto 1fr;
}
.preview-label {
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e0e8f2;
}
.preview-label span {
  color: var(--blue);
  font: 600 10px "IBM Plex Mono", monospace;
  letter-spacing: 0.16em;
}
.preview-label strong { color: #6b7e97; font-size: 11px; }
.chart-preview {
  min-height: 470px;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: hidden;
}
.chart-preview svg {
  width: 100%;
  height: auto;
  max-height: 400px;
}
.chart-preview .r-figure {
  width: 100%;
  height: auto;
  max-height: 560px;
  object-fit: contain;
}
.chart-preview.is-rendering { opacity: 0.55; }
.export-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.integration-note {
  margin: 22px 24px 0;
  padding: 15px;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  border: 1px solid #cfe0f3;
  border-radius: 15px;
  background: #f2f7fd;
  color: #536a87;
  font-size: 12px;
  line-height: 1.5;
}
.integration-note > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}
.integration-note p { margin: 0; }
.integration-note strong { display: block; color: #18375e; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: 12px;
  color: #fff;
  background: #071a3d;
  box-shadow: 0 18px 50px #071a3d44;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .workspace,
  .workspace--single { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .lab-header { min-height: 78px; padding: 10px 14px; }
  .brand-lockup img { width: 54px; height: 54px; }
  .brand-lockup span { font-size: 9px; }
  .brand-lockup strong { font-size: 14px; }
  .local-badge:not(.r-badge) { display: none; }
  .r-badge { padding: 8px 10px; font-size: 10px; }
  .header-actions .button { padding: 9px 12px; font-size: 12px; }
  .lab-shell { width: min(100% - 20px, 1600px); padding-top: 24px; }
  .lab-banner { display: block; }
  .lab-banner h1 { font-size: 40px; }
  .panel { border-radius: 20px; }
  .panel-heading { padding: 18px; }
  .editor-stage .editor-body,
  .editor-panel .editor-body { padding: 0 16px 16px; }
  .controls-grid { grid-template-columns: 1fr; }
  .control-wide { grid-column: auto; }
  .integration-note { margin-inline: 16px; }
  .export-row { flex-direction: column; }
  .preview-card--large { min-height: 520px; }
  .chart-preview { min-height: 360px; }
}
