/* ==========================================================================
   Online playground
   ========================================================================== */

.lab-page {
  background:
    radial-gradient(900px 500px at 80% 0%, rgba(87, 118, 238, 0.08), transparent 60%),
    var(--bg);
}

.lab-main {
  padding-top: var(--header-h);
  padding-bottom: 18px;
}

.lab-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 24px 0 18px;
}

.lab-head-copy {
  min-width: 0;
}

.lab-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: color 0.2s;
}

.lab-back .icon {
  width: 12px;
  height: 12px;
  transform: rotate(180deg);
}

.lab-back:hover {
  color: var(--primary);
}

.lab-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.lab-title-line h1 {
  font-size: clamp(28px, 3.2vw, 38px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--ink-strong);
}

.lab-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--teal) 25%, var(--line));
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--teal-strong);
  background: var(--teal-soft);
  white-space: nowrap;
}

.lab-head p {
  max-width: 660px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.lab-head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

.lab-current {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 200px;
  padding: 5px 12px;
  margin-right: 4px;
  border-left: 1px solid var(--line-strong);
}

.lab-current span {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.lab-current strong {
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lab-current strong.is-dirty::after {
  content: " *";
  color: var(--amber);
}

.lab-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-strong);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  transition: all 0.2s var(--ease);
}

.lab-action:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface);
}

.lab-action .icon {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------------------
   Shell & panels
   -------------------------------------------------------------------------- */

.lab-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  gap: 14px;
  height: clamp(680px, calc(100dvh - 248px), 880px);
}

.lab-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.lab-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

/* --------------------------------------------------------------------------
   Editor panel
   -------------------------------------------------------------------------- */

.lab-editor {
  border-color: rgba(126, 150, 200, 0.18);
  background: #0b1426;
  color: var(--code-text);
  box-shadow: 0 26px 70px rgba(8, 17, 38, 0.22);
}

.lab-editor .lab-panel-head {
  border-bottom-color: rgba(140, 165, 220, 0.12);
  background: #0c172a;
}

.file-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  align-self: stretch;
}

.file-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  align-self: stretch;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--code-muted);
  transition: color 0.2s;
}

.file-tab:hover {
  color: var(--code-text);
}

.file-tab.is-active {
  color: #eef3ff;
}

.file-tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #7d8cff, #34d3bd);
}

.tab-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--code-muted);
}

.file-tab.is-active .tab-dot {
  background: #34d3bd;
  box-shadow: 0 0 0 3px rgba(52, 211, 189, 0.12);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.editor-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #8fa2c4;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.editor-btn .icon {
  width: 11px;
  height: 11px;
}

.editor-btn:hover {
  color: #eef3ff;
  background: rgba(140, 165, 220, 0.08);
}

.editor-btn.is-primary {
  color: #071126;
  background: linear-gradient(135deg, #9aa8ff, #6fe6d4);
  border-color: transparent;
}

.editor-btn.is-primary:hover {
  color: #071126;
  background: linear-gradient(135deg, #b1bcff, #82efdd);
}

.auto-switch {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid rgba(140, 165, 220, 0.13);
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: #8fa2c4;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.auto-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 25px;
  height: 14px;
  border-radius: 7px;
  background: #25344f;
  transition: background-color 0.2s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #93a6c8;
  transition: transform 0.2s var(--ease), background-color 0.2s;
}

.auto-switch input:checked + .switch-track {
  background: rgba(52, 211, 189, 0.26);
}

.auto-switch input:checked + .switch-track::after {
  transform: translateX(11px);
  background: #6fe6d4;
}

.auto-switch input:focus-visible + .switch-track {
  outline: 2px solid #7d8cff;
  outline-offset: 2px;
}

.editor-body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

.editor-pane {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.editor-pane[hidden] {
  display: none !important;
}

.editor-scroll {
  --editor-font-size: 12.5px;
  --editor-line-height: 22px;
  --editor-pad-y: 16px;
  --editor-pad-x: 20px;
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-content: start;
  flex: 1;
  min-width: 0;
  overflow: auto;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(79, 99, 234, 0.05), transparent 60%),
    #0b1426;
  scrollbar-width: thin;
  scrollbar-color: #2b3b58 transparent;
}

.editor-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.editor-scroll::-webkit-scrollbar-thumb {
  background: #2b3b58;
  border: 3px solid #0b1426;
  border-radius: 6px;
}

.editor-scroll::-webkit-scrollbar-corner {
  background: #0b1426;
}

.editor-gutter {
  position: sticky;
  left: 0;
  z-index: 3;
  grid-column: 1;
  min-height: 100%;
  margin: 0;
  padding: var(--editor-pad-y) 10px var(--editor-pad-y) 0;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  text-align: right;
  color: #3c4d6c;
  background: #091120;
  border-right: 1px solid rgba(140, 165, 220, 0.08);
  user-select: none;
  pointer-events: none;
}

.editor-gutter span {
  display: block;
  height: var(--editor-line-height);
}

.editor-gutter span.is-active {
  color: #8fa2ff;
}

.editor-code {
  position: relative;
  grid-column: 2;
  min-width: 0;
  min-height: 100%;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: var(--editor-pad-y) var(--editor-pad-x);
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  color: var(--code-text);
  pointer-events: none;
  overflow: visible;
}

.editor-highlight code {
  font: inherit;
  color: inherit;
  white-space: inherit;
}

#editor {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: var(--editor-pad-y) var(--editor-pad-x);
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  color: transparent;
  caret-color: #ffffff;
  background: transparent;
  -webkit-text-fill-color: transparent;
}

#editor::selection {
  color: transparent;
  background: rgba(101, 130, 255, 0.34);
  -webkit-text-fill-color: transparent;
}

#editor::placeholder {
  color: #4f6080;
}

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 12px;
  border-top: 1px solid rgba(140, 165, 220, 0.1);
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: #7186a8;
  background: #0a1222;
}

.status-message {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f0a84e;
  box-shadow: 0 0 0 3px rgba(240, 168, 78, 0.12);
}

.status-dot.is-ok {
  background: #34d3bd;
  box-shadow: 0 0 0 3px rgba(52, 211, 189, 0.12);
}

.status-dot.is-error {
  background: #ff7d7d;
  box-shadow: 0 0 0 3px rgba(255, 125, 125, 0.12);
}

.status-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: #536584;
}

.status-sep {
  color: #2e3e5a;
}

.arkts-pane {
  flex-direction: column;
  background: #0b1426;
}

.arkts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(140, 165, 220, 0.1);
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: #7186a8;
}

.arkts-toolbar span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.arkts-toolbar .icon {
  width: 12px;
  height: 12px;
}

.arkts-code {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px 20px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--code-text);
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: #2b3b58 transparent;
}

/* --------------------------------------------------------------------------
   Preview panel
   -------------------------------------------------------------------------- */

.preview-head {
  padding-left: 10px;
}

.size-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.size-btn {
  height: 25px;
  padding: 0 9px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}

.size-btn:hover {
  color: var(--ink);
}

.size-btn.is-active {
  color: #fff;
  background: var(--ink-strong);
}

[data-theme="dark"] .size-btn.is-active {
  color: #071126;
  background: #eef3ff;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  transition: all 0.2s;
}

.icon-action:hover {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}

.icon-action:active {
  transform: scale(0.96);
}

.icon-action .icon {
  width: 14px;
  height: 14px;
}

.preview-stage {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 11px;
  min-height: 0;
  padding: 14px 16px;
  overflow: auto;
  background:
    radial-gradient(500px 300px at 50% 28%, rgba(255, 255, 255, 0.92), rgba(239, 244, 253, 0.92)),
    linear-gradient(180deg, #f8faff, #eef3fc);
}

[data-theme="dark"] .preview-stage {
  background:
    radial-gradient(500px 300px at 50% 28%, rgba(30, 49, 84, 0.6), rgba(10, 20, 36, 0.82)),
    linear-gradient(180deg, #0e1a2e, #081120);
}

.preview-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(50, 80, 140, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 80, 140, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, #000 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, #000 20%, transparent 80%);
  pointer-events: none;
}

.stage-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 760px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--muted);
}

.live-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent);
}

.device-card {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(21, 42, 90, 0.16), 0 2px 8px rgba(21, 42, 90, 0.06);
  overflow: hidden;
  transition: width 0.25s var(--ease);
}

[data-theme="dark"] .device-card {
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

.lab-preview[data-size="client"] .device-card {
  width: min(392px, 100%);
}

.lab-preview[data-size="wide"] .device-card {
  width: min(760px, 100%);
}

.lab-preview[data-size="auto"] .device-card {
  width: min(660px, 100%);
}

.device-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f9ff;
}

[data-theme="dark"] .device-bar {
  background: #101c31;
}

.device-dots {
  display: flex;
  gap: 4px;
}

.device-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4ddeb;
}

.device-dots i:first-child {
  background: #ff9a9a;
}

.device-dots i:nth-child(2) {
  background: #f3c766;
}

.device-dots i:nth-child(3) {
  background: #6fe0bc;
}

.device-title {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--faint);
}

.device-renderer {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--muted);
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.device-chart-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background:
    radial-gradient(300px 200px at 50% 35%, #fff, #f5f8ff);
  max-width: 100%;
  overflow: hidden;
}

[data-theme="dark"] .device-chart-wrap {
  background: radial-gradient(300px 200px at 50% 35%, #15233a, #0c1627);
}

.device-chart-wrap .chart-frame {
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(25, 48, 110, 0.08);
}

.device-chart-wrap .chart-canvas {
  background: #fff;
}

.device-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--muted);
  background: #fbfcff;
}

[data-theme="dark"] .device-foot {
  background: #0e1a2e;
}

.device-foot .status-dot {
  margin-right: 3px;
}

.stage-console {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 100%;
  max-width: 760px;
  border: 1px solid rgba(120, 145, 200, 0.16);
  border-radius: 9px;
  background: rgba(8, 17, 33, 0.92);
  overflow: hidden;
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border-bottom: 1px solid rgba(140, 165, 220, 0.1);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.04em;
  color: #687d9f;
  text-transform: uppercase;
}

.console-head span:last-child {
  color: #6fe6d4;
}

.console-body {
  max-height: 66px;
  min-height: 28px;
  padding: 6px 10px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.65;
  color: #9fb4d6;
  white-space: pre-wrap;
  scrollbar-width: thin;
}

.console-body.is-error {
  color: #ff9c9c;
}

.preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--faint);
  background: var(--surface-soft);
}

.preview-note {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.preview-note .icon {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
}

.preview-dpr {
  flex: 0 0 auto;
}

/* Fullscreen preview */

.lab-page.is-fullscreen {
  overflow: hidden;
}

.lab-preview.is-fullscreen {
  position: fixed;
  z-index: 160;
  inset: 14px;
  border-radius: 20px;
  box-shadow: 0 40px 120px rgba(3, 10, 24, 0.45);
}

.lab-preview.is-fullscreen .preview-stage {
  padding: 20px;
}

.lab-preview.is-fullscreen .stage-topline,
.lab-preview.is-fullscreen .device-card,
.lab-preview.is-fullscreen .stage-console {
  max-width: 900px;
}

.lab-preview.is-fullscreen .device-card {
  width: min(860px, 100%);
}

/* --------------------------------------------------------------------------
   Hints & footer
   -------------------------------------------------------------------------- */

.lab-hints {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--faint);
}

.lab-hints kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 8px;
  color: var(--muted-strong);
  background: var(--surface);
}

.lab-hints a {
  margin-left: auto;
  color: var(--primary);
}

.lab-footer {
  padding: 18px 0 24px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

.lab-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--faint);
}

.lab-footer-inner div {
  display: flex;
  gap: 16px;
}

.lab-footer-inner a:hover {
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   Preset modal
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 22, 0.58);
  backdrop-filter: blur(8px);
  animation: modal-fade 0.2s var(--ease);
}

@keyframes modal-fade {
  from {
    opacity: 0;
  }
}

.modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  max-height: 84vh;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 40px 120px rgba(3, 10, 24, 0.32);
  overflow: hidden;
  animation: modal-in 0.28s var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 14px;
}

.modal-head .eyebrow {
  margin-bottom: 6px;
  font-size: 9.5px;
}

.modal-head h2 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--ink-strong);
}

.modal-search {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 24px 14px;
  padding: 0 12px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.modal-search .icon {
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.modal-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
}

.modal-search input::placeholder {
  color: var(--faint);
}

.modal-count {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--faint);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 24px 24px;
  overflow: auto;
  scrollbar-width: thin;
}

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  text-align: left;
  background: var(--surface);
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.preset-card:hover {
  border-color: color-mix(in srgb, var(--preset-accent, var(--primary)) 40%, var(--line));
  background: var(--surface-soft);
  transform: translateY(-2px);
}

.preset-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.preset-card-category {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.preset-card-category i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--preset-accent, var(--primary));
}

.preset-card-arrow {
  color: var(--faint);
}

.preset-card-arrow .icon {
  width: 12px;
  height: 12px;
}

.preset-card h3 {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-strong);
}

.preset-card p {
  display: -webkit-box;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.55;
  color: var(--muted);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.preset-empty {
  grid-column: 1 / -1;
  padding: 36px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

body.modal-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .lab-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .lab-head-actions {
    width: 100%;
  }

  .lab-current {
    margin-right: auto;
  }

  .lab-shell {
    height: clamp(680px, calc(100dvh - 292px), 820px);
  }
}

@media (max-width: 980px) {
  .lab-shell {
    grid-template-columns: 1fr;
    height: auto;
    gap: 12px;
  }

  .lab-editor {
    height: 560px;
  }

  .lab-preview {
    height: 720px;
  }

  .lab-hints {
    padding-bottom: 10px;
  }
}

@media (max-width: 720px) {
  .lab-head {
    padding-top: 18px;
  }

  .lab-title-line h1 {
    font-size: 28px;
  }

  .lab-head p {
    font-size: 12px;
  }

  .lab-head-actions {
    gap: 6px;
  }

  .lab-current {
    display: flex;
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0 0 2px;
    border: 0;
  }

  .lab-current span {
    font-size: 7.5px;
  }

  .lab-current strong {
    font-size: 11px;
  }

  .lab-action {
    height: 33px;
    padding: 0 10px;
    font-size: 10.5px;
  }

  .lab-head-actions .btn {
    height: 33px;
    padding: 0 12px;
    font-size: 11px;
  }

  .lab-panel-head {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .lab-editor .lab-panel-head {
    flex-wrap: nowrap;
  }

  .file-tabs {
    order: 0;
  }

  .editor-actions {
    margin-left: auto;
  }

  .editor-btn {
    padding: 0 5px;
  }

  .editor-btn .icon {
    display: none;
  }

  .auto-switch span:last-child {
    display: none;
  }

  .auto-switch {
    padding-left: 6px;
    margin-left: 1px;
  }

  .editor-scroll {
    --editor-font-size: 11.5px;
    --editor-line-height: 20px;
    --editor-pad-y: 14px;
    --editor-pad-x: 14px;
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .editor-gutter {
    padding-right: 7px;
  }

  .lab-editor {
    height: 500px;
  }

  .lab-preview {
    height: 680px;
  }

  .preview-head {
    flex-wrap: nowrap;
  }

  .size-switch {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .size-switch::-webkit-scrollbar {
    display: none;
  }

  .size-btn {
    padding: 0 7px;
    font-size: 8px;
  }

  .preview-stage {
    padding: 10px;
    gap: 9px;
  }

  .device-card {
    border-radius: 12px;
  }

  .lab-preview[data-size="client"] .device-card {
    width: min(100%, 370px);
  }

  .device-chart-wrap {
    padding: 8px;
  }

  .stage-console {
    max-width: 100%;
  }

  .console-body {
    max-height: 48px;
  }

  .preview-foot {
    padding: 0 10px;
    font-size: 7.5px;
  }

  .preview-note {
    white-space: normal;
    line-height: 1.5;
  }

  .status-meta span:last-child {
    display: none;
  }

  .lab-hints {
    gap: 8px 14px;
    font-size: 8px;
  }

  .lab-hints a {
    margin-left: 0;
  }

  .lab-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .modal {
    padding: 12px;
  }

  .modal-dialog {
    max-height: 90vh;
    border-radius: 16px;
  }

  .modal-head {
    padding: 16px 16px 10px;
  }

  .modal-head h2 {
    font-size: 21px;
  }

  .modal-search {
    margin: 0 16px 10px;
  }

  .preset-grid {
    grid-template-columns: 1fr 1fr;
    padding: 0 16px 16px;
  }

  .preset-card {
    padding: 11px;
  }

  .lab-preview.is-fullscreen {
    inset: 8px;
  }
}

@media (max-width: 480px) {
  .lab-page .container {
    width: calc(100% - 20px);
  }

  .lab-head-actions .lab-action {
    flex: 1;
    justify-content: center;
  }

  .lab-head-actions .btn {
    flex: 1;
  }

  .lab-pill {
    display: none;
  }

  .size-btn {
    padding: 0 5px;
    font-size: 7.5px;
  }

  .lab-preview[data-size="client"] .device-card {
    width: 100%;
  }

  .lab-preview {
    height: 640px;
  }

  .lab-editor {
    height: 460px;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .preview-dpr {
    display: none;
  }
}
