.l4d2-studio {
  --l4d2-bg: #ffffff;
  --l4d2-border: #f0f0f0;
  --l4d2-border-strong: #dcdcdc;
  --l4d2-text: #0f0f0f;
  --l4d2-muted: #6f6f6f;
  --l4d2-surface: #ffffff;
  --l4d2-shadow: 0 20px 60px rgba(0, 0, 0, 0.05);
  --l4d2-shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.035);
  --l4d2-code-bg: #f9f9f9;
  --l4d2-add: #edf7ef;
  --l4d2-remove: #faf0f0;
  background: var(--l4d2-bg);
  color: var(--l4d2-text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  padding: 28px;
}

.l4d2-studio * {
  box-sizing: border-box;
}

.l4d2-studio__hero,
.l4d2-studio__card {
  background: var(--l4d2-surface);
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  box-shadow: var(--l4d2-shadow-soft);
}

.l4d2-studio__hero {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.8fr) minmax(240px, 0.8fr);
  padding: 28px;
  margin-bottom: 24px;
}

.l4d2-studio__eyebrow,
.l4d2-studio__section-kicker,
.l4d2-studio__control-group > header p {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--l4d2-muted);
}

.l4d2-studio__title,
.l4d2-studio__section-title {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.l4d2-studio__section-title {
  font-size: 1.17em;
  line-height: 1.35;
}

.l4d2-studio__title {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  max-width: 14ch;
}

.l4d2-studio__subtitle,
.l4d2-studio__section-note,
.l4d2-studio__control-copy p,
.l4d2-studio__match-top p,
.l4d2-studio__empty {
  margin: 0;
  color: var(--l4d2-muted);
  line-height: 1.65;
}

.l4d2-studio__control-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--l4d2-muted);
}

.l4d2-studio__control-hint--shared,
.l4d2-studio__control-hint--warning {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
}

.l4d2-studio__control-hint--shared {
  border: 1px solid #e8d79a;
  background: #fff9e6;
  color: #92400e;
}

.l4d2-studio__control-hint--warning {
  border: 1px solid #f1b6bd;
  background: #fff1f3;
  color: #9f1239;
}

.l4d2-studio__hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: flex-end;
  gap: 10px;
}

.l4d2-studio__meta-chip,
.l4d2-studio__match-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--l4d2-border);
  border-radius: 999px;
  color: var(--l4d2-muted);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
}

.l4d2-studio__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.l4d2-studio__stack {
  display: grid;
  gap: 24px;
}

.l4d2-studio__card {
  padding: 22px;
}

.l4d2-studio__section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.l4d2-studio__section-head > .l4d2-studio__collapse-toggle {
  flex: 1 1 auto;
  min-width: 0;
}

.l4d2-studio__section-head--actions {
  align-items: center;
}

.l4d2-studio__section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.l4d2-studio__collapse-toggle {
  appearance: none;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  cursor: pointer;
}

.l4d2-studio__collapse-toggle--plain::after {
  display: none;
}

.l4d2-studio__collapse-toggle::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 7px;
  border-right: 1.5px solid var(--l4d2-muted);
  border-bottom: 1.5px solid var(--l4d2-muted);
  transform: rotate(45deg);
  transition: transform 150ms ease;
}

.l4d2-studio__collapsible-section.is-collapsed > .l4d2-studio__section-head .l4d2-studio__collapse-toggle::after,
.l4d2-studio__collapsible-section.is-collapsed > .l4d2-studio__control-group-head .l4d2-studio__collapse-toggle::after {
  transform: rotate(-45deg);
}

.l4d2-studio__collapse-toggle:focus-visible {
  outline: 2px solid #111;
  outline-offset: 4px;
}

.l4d2-studio__collapse-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.l4d2-studio__collapse-meta {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--l4d2-border);
  border-radius: 999px;
  color: var(--l4d2-muted);
  font-size: 12px;
  line-height: 1.4;
}

.l4d2-studio__dropzone {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--l4d2-border-strong);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0));
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.l4d2-studio__dropzone.is-dragover {
  transform: translateY(-1px);
  border-color: #c6c6c6;
  box-shadow: var(--l4d2-shadow);
}

.l4d2-studio__dropzone-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.l4d2-studio__dropzone-subtitle {
  max-width: 54ch;
  color: var(--l4d2-muted);
  line-height: 1.6;
}

.l4d2-studio__file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.l4d2-studio__upload-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.l4d2-studio__label {
  display: block;
  margin-bottom: 6px;
  color: var(--l4d2-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.l4d2-studio__controls {
  display: grid;
  gap: 18px;
}

.l4d2-studio__bindings {
  display: grid;
  gap: 14px;
}

.l4d2-studio__control-group {
  display: grid;
  gap: 12px;
}

.l4d2-studio__control-group-head {
  margin: 0;
}

.l4d2-studio__collapse-toggle--sub {
  width: auto;
  padding: 2px 0;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.l4d2-studio__collapse-toggle--sub strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.l4d2-studio__collapse-toggle--sub::after {
  margin-top: 0;
}

.l4d2-studio__collapse-toggle--icon {
  width: auto;
  min-width: 0;
  height: auto;
  padding: 4px;
  justify-content: center;
  align-items: center;
}

.l4d2-studio__collapse-toggle--icon::after {
  margin-top: 0;
}

.l4d2-studio__control-group [data-collapsible-content] {
  display: grid;
  gap: 12px;
}

.l4d2-studio__binding,
.l4d2-studio__control {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  background: #fff;
}

.l4d2-studio__control.is-locked {
  border-color: #e2d7b0;
  background: #fffdf6;
}

.l4d2-studio__control-top {
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
}

.l4d2-studio__binding-top {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.l4d2-studio__control-header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.l4d2-studio__control-header strong {
  font-size: 16px;
}

.l4d2-studio__control-header code,
.l4d2-studio__match-top code,
.l4d2-studio__control-value {
  padding: 4px 8px;
  border-radius: 4px;
  background: #fafafa;
  border: 1px solid var(--l4d2-border);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.l4d2-studio__control-value {
  min-width: 64px;
  text-align: center;
  align-self: center;
}

.l4d2-studio__check {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.l4d2-studio__check input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.l4d2-studio__check span {
  width: 22px;
  height: 22px;
  border: 1px solid var(--l4d2-border-strong);
  border-radius: 4px;
  background: #fff;
}

.l4d2-studio__check input:checked + span {
  background: #111;
  border-color: #111;
  box-shadow: inset 0 0 0 4px #fff;
}

.l4d2-studio__slider-row input[type="range"] {
  --range-percent: 50%;
  width: 100%;
  height: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.l4d2-studio__slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #111 0%,
    #111 var(--range-percent),
    #ddd var(--range-percent),
    #ddd 100%
  );
}

.l4d2-studio__slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #111;
  border: 0;
  margin-top: -6px;
}

.l4d2-studio__slider-row input[type="range"]::-moz-range-track {
  height: 2px;
  border: 0;
  border-radius: 999px;
  background: #ddd;
}

.l4d2-studio__slider-row input[type="range"]::-moz-range-progress {
  height: 2px;
  border-radius: 999px;
  background: #111;
}

.l4d2-studio__slider-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #111;
  border: 0;
  cursor: pointer;
}

.l4d2-studio__slider-row input[type="range"]:disabled {
  opacity: 0.35;
}

.l4d2-studio__text-input,
.l4d2-studio__select-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.l4d2-studio__text-input:disabled,
.l4d2-studio__select-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.l4d2-studio__binding-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.l4d2-studio__binding-row {
  display: grid;
  gap: 6px;
}

.l4d2-studio__binding-keybox {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.l4d2-studio__binding-preset-toggle {
  min-width: 92px;
}

.l4d2-studio__binding-preset-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: grid;
  gap: 12px;
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--l4d2-border-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--l4d2-shadow);
}

.l4d2-studio__binding-preset-group {
  display: grid;
  gap: 8px;
}

.l4d2-studio__binding-preset-group strong {
  font-size: 12px;
  color: var(--l4d2-muted);
}

.l4d2-studio__binding-preset-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.l4d2-studio__binding-preset-key {
  appearance: none;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--l4d2-border-strong);
  border-radius: 6px;
  background: #fafafa;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.l4d2-studio__binding-preset-key:hover {
  transform: translateY(-1px);
}

.l4d2-studio__binding-preset-key.is-active {
  border-color: #111;
  background: #111;
  color: #fff;
}

.l4d2-studio__binding-preview code {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  background: var(--l4d2-code-bg);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.l4d2-studio__toggle {
  position: relative;
  display: inline-flex;
  width: 58px;
  height: 28px;
}

.l4d2-studio__toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.l4d2-studio__toggle-rail {
  width: 58px;
  height: 28px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #fff;
  position: relative;
  transition: background 150ms ease;
}

.l4d2-studio__toggle-rail::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #111;
  transition: transform 150ms ease, background 150ms ease;
}

.l4d2-studio__toggle input:checked + .l4d2-studio__toggle-rail {
  background: #111;
}

.l4d2-studio__toggle input:checked + .l4d2-studio__toggle-rail::after {
  transform: translateX(28px);
  background: #fff;
}

.l4d2-studio__toggle input:disabled + .l4d2-studio__toggle-rail,
.l4d2-studio__toggle input:disabled + .l4d2-studio__toggle-rail::after {
  opacity: 0.35;
}

.l4d2-studio__matches {
  display: grid;
  gap: 12px;
}

.l4d2-studio__match {
  padding: 16px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
}

.l4d2-studio__match-editor {
  display: grid;
  gap: 6px;
  min-width: min(320px, 100%);
  flex: 1 1 260px;
}

.l4d2-studio__match-editor--toggle {
  align-items: start;
}

.l4d2-studio__match-top,
.l4d2-studio__match-meta,
.l4d2-studio__actions,
.l4d2-studio__preview-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.l4d2-studio__match-top {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.l4d2-studio__match-meta {
  align-items: flex-start;
}

.l4d2-studio__terminal {
  position: sticky;
  top: 20px;
}

.l4d2-studio__terminal-card {
  min-height: 720px;
}

.l4d2-studio__button,
.l4d2-studio__preview-tabs button {
  appearance: none;
  border: 1px solid var(--l4d2-border-strong);
  background: #fff;
  color: #111;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.l4d2-studio__button:hover,
.l4d2-studio__preview-tabs button:hover,
.l4d2-studio__button:focus-visible,
.l4d2-studio__preview-tabs button:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--l4d2-shadow-soft);
  outline: none;
}

.l4d2-studio__button--primary,
.l4d2-studio__preview-tabs button.is-active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.l4d2-studio__button--ghost {
  min-width: 72px;
}

.l4d2-studio__panel {
  display: none;
}

.l4d2-studio__panel.is-active {
  display: block;
}

.l4d2-studio__code,
.l4d2-studio__diff {
  margin: 0;
  min-height: 590px;
  max-height: 720px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  background: var(--l4d2-code-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: normal;
}

.l4d2-studio .token-command {
  color: #1f1f1f;
  font-weight: 600;
}

.l4d2-studio .token-value {
  color: #5c5c5c;
}

.l4d2-studio .token-comment {
  color: #8c8c8c;
}

.l4d2-studio__diff {
  display: grid;
  gap: 2px;
}

.l4d2-studio__preview-row,
.l4d2-studio__diff-line {
  display: grid;
  align-items: start;
}

.l4d2-studio__preview-row {
  grid-template-columns: 3ch minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
}

.l4d2-studio__line-number {
  color: #9a9a9a;
  text-align: right;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.l4d2-studio__diff-line {
  grid-template-columns: 3ch 3ch 1ch minmax(0, 1fr);
  gap: 8px;
  padding: 2px 8px;
  border-radius: 4px;
}

.l4d2-studio__diff-line.is-add {
  background: var(--l4d2-add);
}

.l4d2-studio__diff-line.is-remove {
  background: var(--l4d2-remove);
}

.l4d2-studio__preview-row code,
.l4d2-studio__diff-line code {
  display: block;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.l4d2-studio__toast {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  z-index: 9999;
}

.l4d2-studio__toast-dialog {
  min-width: 280px;
  max-width: 420px;
  padding: 18px 20px;
  border: 1px solid var(--l4d2-border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--l4d2-shadow);
  text-align: center;
}

.l4d2-studio__toast-dialog strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

@media (max-width: 1100px) {
  .l4d2-studio {
    padding: 18px;
  }

  .l4d2-studio__hero,
  .l4d2-studio__layout {
    grid-template-columns: 1fr;
  }

  .l4d2-studio__hero-meta {
    justify-content: flex-start;
  }

  .l4d2-studio__terminal {
    position: static;
  }
}

@media (max-width: 720px) {
  .l4d2-studio__upload-meta,
  .l4d2-studio__binding-top,
  .l4d2-studio__control-top,
  .l4d2-studio__section-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .l4d2-studio__binding-keybox {
    grid-template-columns: 1fr;
  }

  .l4d2-studio__binding-preset-toggle {
    width: 100%;
  }


  .l4d2-studio__collapse-toggle {
    gap: 10px;
  }

  .l4d2-studio__section-actions {
    justify-content: flex-start;
  }

  .l4d2-studio__match-top {
    flex-direction: column;
  }

  .l4d2-studio__actions {
    width: 100%;
  }

  .l4d2-studio__actions .l4d2-studio__button {
    flex: 1 1 0;
  }
}
