.linear-lab-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid #d5def0;
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(40, 85, 217, .12), transparent 42%),
    linear-gradient(180deg, #ffffff, #f6f8ff);
  box-shadow: 0 10px 28px rgba(26, 41, 77, .08);
}
.linear-lab-launch-copy {
  min-width: 0;
}
.linear-lab-launch-copy span {
  display: block;
  color: #2855d9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.linear-lab-launch-copy strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.25;
}
.linear-lab-launch-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.linear-lab-open {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(40, 85, 217, .22);
}
.linear-lab-open:hover { filter: brightness(.96); }
.linear-lab-open:focus-visible { outline: 3px solid rgba(40, 85, 217, .28); outline-offset: 2px; }

dialog.linear-lab-dialog {
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #eef2f8;
}
dialog.linear-lab-dialog::backdrop {
  background: rgba(15, 23, 42, .72);
}
.linear-lab-dialog .dialog-head {
  min-height: 64px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
}
.linear-lab-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - 64px);
  min-height: 0;
  gap: 0;
}

.linear-lab-eq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  padding: 12px 18px 8px;
}
.linear-lab-variants {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.linear-lab-variant {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #d8e0ee;
  border-radius: 999px;
  color: #334155;
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}
.linear-lab-variant.is-active {
  border-color: #2855d9;
  color: #fff;
  background: #2855d9;
}
.linear-lab-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px 16px;
  border: 1px solid #d7e0f0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(26, 41, 77, .06);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 700;
}
.linear-lab-formula-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.linear-lab-hide-coeffs {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #d8e0ee;
  border-radius: 10px;
  color: #64748b;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.04em;
  cursor: pointer;
}
.linear-lab-hide-coeffs:hover { background: #f8fafc; }
.linear-lab-hide-coeffs[aria-pressed="true"] {
  border-color: #2855d9;
  color: #fff;
  background: #2855d9;
}
.linear-lab-formula.is-hidden-coeffs input {
  color: #94a3b8;
}
.linear-lab-formula.is-hidden-coeffs input::placeholder {
  color: #94a3b8;
  opacity: 1;
}
.linear-lab-formula.is-compact { font-size: clamp(20px, 2.6vw, 30px); }
.linear-lab-formula.is-compact .linear-lab-field input {
  width: 4.4em;
  min-height: 42px;
  font-size: 18px;
}
.linear-lab-formula .sym {
  color: #1e293b;
  font-style: italic;
}
.linear-lab-formula .op { color: #64748b; font-style: normal; }
.linear-lab-formula sup { font-size: .62em; }
.linear-lab-formula .root { font-style: normal; font-size: 1.05em; }
.linear-lab-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.linear-lab-colors {
  display: flex;
  gap: 6px;
}
.linear-lab-color {
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #d8e0ee;
  cursor: pointer;
}
.linear-lab-color.is-active { box-shadow: 0 0 0 2px #2855d9; }
.linear-lab-draw-btn[aria-pressed="true"] {
  border-color: #2855d9;
  color: #fff;
  background: #2855d9;
}
.linear-lab-field {
  display: grid;
  gap: 2px;
  justify-items: center;
}
.linear-lab-field small {
  color: #2855d9;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.linear-lab-field input {
  width: 5.4em;
  min-height: 48px;
  padding: 0 8px;
  border: 2px solid #c7d7fe;
  border-radius: 12px;
  color: #1d4ed8;
  background: #f8fbff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}
.linear-lab-field input:focus {
  outline: 0;
  border-color: #2855d9;
  box-shadow: 0 0 0 4px rgba(40, 85, 217, .16);
}
.linear-lab-reset {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #d8e0ee;
  border-radius: 12px;
  color: #334155;
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}
.linear-lab-reset:hover { background: #f8fafc; }

.linear-lab-plot-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 16px 8px;
}
.linear-lab-plot-stack {
  position: relative;
  width: min(100%, calc(100vh - 240px), 980px);
  height: min(100%, calc(100vh - 240px), 980px);
  max-height: 100%;
  aspect-ratio: 1;
}
.linear-lab-plot {
  width: 100%;
  height: 100%;
  border: 1px solid #d5deec;
  border-radius: 20px;
  background: #fffef8;
  box-shadow: 0 16px 40px rgba(26, 41, 77, .1);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.linear-lab-draw {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  pointer-events: none;
  touch-action: none;
}
.linear-lab-plot-stack.is-drawing .linear-lab-draw {
  pointer-events: all;
  cursor: crosshair;
}
.linear-lab-plot-stack.is-drawing .linear-lab-plot { cursor: crosshair; }
.linear-lab-plot.is-dragging { cursor: grabbing; }
.linear-lab-plot text { pointer-events: none; }
.linear-lab-plot svg {
  display: block;
  width: 100%;
  height: 100%;
}

.linear-lab-hint {
  padding: 8px 18px 16px;
  color: #64748b;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

@media (max-width: 720px) {
  .linear-lab-launch { flex-direction: column; align-items: stretch; }
  .linear-lab-open { width: 100%; }
  .linear-lab-formula { font-size: 24px; padding: 8px 10px; }
  .linear-lab-field input { min-height: 44px; font-size: 18px; }
  .linear-lab-body { height: calc(100vh - 60px); }
  .linear-lab-plot { width: 100%; height: auto; }
  .linear-lab-plot-stack { width: min(100%, calc(100vw - 24px)); height: auto; }
}
