@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Open Sans";
  src: url("fonts/OpenSans-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("fonts/Lato-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("fonts/Lato-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("fonts/Lato-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("fonts/Lato-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-strong: #e5ebf1;
  --ink: #17202a;
  --muted: #667386;
  --line: #d6dee7;
  --blue: #246bfe;
  --green: #16814a;
  --amber: #b66a00;
  --red: #bd2b2b;
  --violet: #6750d8;
  --teal: #087c86;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.08);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  border-color: #9daabd;
  background: var(--surface-soft);
}

button.primary,
.item.active {
  border-color: var(--blue);
  background: #e8f0ff;
}

button.danger {
  border-color: rgba(189, 43, 43, 0.35);
  color: var(--red);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1fr);
}

.login-brand {
  padding: 42px;
  color: #f9fbfd;
  background:
    linear-gradient(135deg, rgba(36, 107, 254, 0.18), transparent 45%),
    linear-gradient(180deg, #14202c 0%, #101820 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand-lockup,
.brand-button,
.topbar-actions,
.button-row,
.inline-actions,
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-mark.small {
  width: 30px;
  height: 30px;
}

.brand-name {
  display: block;
  font-weight: 800;
  line-height: 1;
}

.brand-subtitle {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.login-brand .brand-subtitle {
  color: #aeb9c6;
}

.login-statement {
  max-width: 540px;
}

.login-statement span {
  color: #9fb3c8;
  font-size: 13px;
  text-transform: uppercase;
}

.login-statement strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

.login-form {
  padding: 56px clamp(34px, 8vw, 110px);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.login-form h1 {
  margin: 4px 0 4px;
  font-size: 46px;
  letter-spacing: 0;
}

.login-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.workspace-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-button {
  justify-content: flex-start;
  min-height: 46px;
  border: 0;
  background: transparent;
  padding: 0;
}

.topbar-context h1 {
  margin: 2px 0 2px;
  font-size: 20px;
}

.user-badge,
.status-pill,
.app-card em,
.data-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.status-pill.ok { color: var(--green); border-color: rgba(22, 129, 74, 0.35); }
.status-pill.warn { color: var(--amber); border-color: rgba(182, 106, 0, 0.35); }
.status-pill.bad { color: var(--red); border-color: rgba(189, 43, 43, 0.35); }

.app-canvas {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.dashboard-hero {
  min-height: 170px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  margin: 4px 0 0;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

.dashboard-live {
  min-width: 220px;
  display: grid;
  gap: 4px;
  text-align: right;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.app-card {
  min-height: 170px;
  padding: 18px;
  text-align: left;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  white-space: normal;
}

.app-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(23, 32, 42, 0.12);
}

.app-card.active {
  border-color: var(--app-color, var(--blue));
  box-shadow: inset 0 3px 0 var(--app-color, var(--blue)), var(--shadow);
}

.app-card.live { --app-color: var(--green); }
.app-card.editor { --app-color: var(--blue); }
.app-card.projects { --app-color: var(--violet); }
.app-card.nodes { --app-color: var(--teal); }
.app-card.quads { --app-color: var(--green); }
.app-card.zoom { --app-color: var(--blue); }
.app-card.sources { --app-color: var(--amber); }
.app-card.events { --app-color: var(--red); }

.app-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--app-color, var(--blue));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.app-card strong {
  display: block;
  font-size: 22px;
}

.app-card small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.summary-strip,
.event-state {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-strip > div,
.event-state > div,
.tool-panel,
.app-toolbar,
.app-body,
.editor-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-strip > div,
.event-state > div {
  padding: 14px;
  display: grid;
  gap: 4px;
}

.app-toolbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px;
  margin-bottom: 14px;
}

.app-toolbar h2,
.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.app-toolbar p {
  margin: 4px 0 0;
}

.app-toolbar p:empty {
  display: none;
}

.app-body,
.editor-body {
  padding: 14px;
}

.app-body.empty,
.editor-body.empty {
  min-height: 240px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.split-app {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.tool-panel {
  overflow: hidden;
}

.tool-panel.grow {
  min-height: 520px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.inline-head {
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
}

.stack,
.node-grid,
.card-grid {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.node-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.mini-form {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.project-action-panel {
  padding: 12px;
  background: var(--surface-soft);
}

.project-action-panel button {
  width: 100%;
  justify-content: center;
}

.item {
  width: 100%;
  min-height: 86px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  white-space: normal;
}

.item strong,
.scene-card strong,
.surface-row strong {
  display: block;
  font-weight: 800;
}

.project-item {
  display: grid;
  gap: 10px;
}

.project-card-summary {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
}

.project-card-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.project-card-main > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-state {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
}

.project-card-state.ok {
  color: var(--green);
  border-color: rgba(22, 129, 74, 0.35);
  background: #ecfbf3;
}

.project-card-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.project-card-controls button {
  min-width: 0;
  padding: 0 8px;
}

.control-strip,
.data-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.control-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.data-panel {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.form-block {
  display: grid;
  gap: 8px;
}

.form-block h3,
.section-title h3 {
  margin: 0;
  font-size: 14px;
}

.compact-form {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 2px;
}

.scene-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 0;
  position: relative;
  overflow: visible;
}

.scene-card.live {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.live-take-grid button.live-scene-take {
  border: 1px solid var(--blue);
  box-shadow: inset 3px 0 0 var(--blue), 0 0 0 2px rgba(36, 107, 254, 0.22);
}

.live-take-grid button.live-scene-take .live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #19c37d;
  box-shadow: 0 0 0 3px rgba(25, 195, 125, 0.28);
  vertical-align: middle;
}

.scene-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scene-name-row strong {
  display: inline;
}

.live-badge {
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
  background: #edf7f2;
}

/* Canvas on-air / editing indicator (preview-label badge). */
.preview-live-tag {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.preview-live-tag.live {
  background: #1f9d57;
  color: #fff;
}
.preview-live-tag.offair {
  background: rgba(255, 255, 255, 0.14);
  color: #ffd479;
  border: 1px solid rgba(255, 212, 121, 0.5);
}

/* "Edit" scene button highlight when that scene is the one on the canvas. */
.scene-edit-button.active {
  border-color: var(--blue);
  color: var(--blue);
}

.scene-card.selected {
  outline: 2px solid rgba(36, 107, 254, 0.18);
}

.scene-card.collapsed {
  background: #fbfcfd;
}

.surface-row.hidden {
  opacity: 0.55;
}

/* Cosmetic scene-transition feedback. The node owns the real crossfade; this
   just animates the live indicator while a scene take is in flight so the
   badge dissolves between scenes instead of snapping. */
.scene-card .live-badge,
.live-take-grid button.live-scene-take,
.control-source-card,
.control-grid-card {
  transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.scene-card.scene-transitioning {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 rgba(36, 107, 254, 0.45);
  animation: pxSceneTransition 1.1s ease-in-out infinite;
}

.live-badge.transitioning {
  animation: pxBadgeDissolve 0.9s ease-in-out infinite;
}

.live-take-grid button.scene-transitioning {
  border: 1px dashed var(--blue);
  box-shadow: inset 3px 0 0 rgba(36, 107, 254, 0.45);
  animation: pxSceneTransition 1.1s ease-in-out infinite;
}

.live-take-grid button.scene-transitioning .live-dot {
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.28);
  animation: pxLivePulse 1s ease-in-out infinite;
}

.control-source-card.scene-transitioning,
.control-grid-card.scene-transitioning {
  border-color: rgba(36, 107, 254, 0.55);
  animation: pxSceneTransition 1.1s ease-in-out infinite;
}

@keyframes pxSceneTransition {
  0%, 100% { box-shadow: inset 3px 0 0 rgba(36, 107, 254, 0.18); }
  50% { box-shadow: inset 3px 0 0 rgba(36, 107, 254, 0.7); }
}

@keyframes pxBadgeDissolve {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .scene-card.scene-transitioning,
  .live-take-grid button.scene-transitioning,
  .live-take-grid button.scene-transitioning .live-dot,
  .control-source-card.scene-transitioning,
  .control-grid-card.scene-transitioning,
  .live-badge.transitioning {
    animation: none;
  }
}

.preview-surface.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.scene-card.disabled {
  border-style: dashed;
}

.scene-card.disabled .scene-name-row,
.scene-card.disabled .surface-list {
  opacity: 0.55;
}

.scene-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
}

.scene-top .inline-actions {
  width: 100%;
  gap: 6px;
  justify-content: flex-start;
}

.scene-collapse-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: start;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
}

.scene-collapse-button:hover {
  background: transparent;
  color: var(--blue);
}

.collapse-glyph {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.collapse-glyph .chevron-icon {
  width: 7px;
  height: 7px;
  border-width: 2px;
}

.scene-title-block {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.scene-title-block strong,
.surface-row-main strong {
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
}

.scene-options-button,
.surface-icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.scene-options-button:hover,
.surface-icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: #e8f0ff;
}

.scene-options-popout {
  width: min(360px, calc(100vw - 24px));
  max-height: min(78vh, 620px);
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(23, 32, 42, 0.18);
}

.scene-options-popout.floating {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3000;
}

.popout-head {
  display: grid;
  gap: 2px;
}

.scene-options-popout .field-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-top: 0;
}

.scene-options-popout label {
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.field-grid.compact {
  grid-template-columns: repeat(6, minmax(70px, 1fr));
}

.field-grid.surface-name-grid {
  grid-template-columns: minmax(220px, 420px);
}

.field-grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.color-grid {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.surface-source-fields {
  margin-top: 10px;
}

.modal-subhead {
  display: grid;
  gap: 2px;
}

.surface-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.surface-type-button {
  justify-content: center;
}

.surface-type-button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #e8f0ff;
}

.surface-source-panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.designer-panel {
  display: grid;
  gap: 10px;
}

.designer-panel textarea {
  min-height: 112px;
  resize: vertical;
}

.hsv-picker {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.hsv-picker label {
  min-width: 0;
}

.hsv-picker label:not(.color-swatch-field) {
  grid-column: 2;
}

.hsv-picker input[type="range"] {
  padding: 0;
}

.color-swatch-field {
  grid-row: span 5;
}

.color-swatch-field input[type="color"] {
  width: 72px;
  height: 72px;
  padding: 3px;
}

.hsv-preview {
  width: 72px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.color-control {
  min-width: 0;
}

.color-control > span:first-child {
  display: block;
  margin-bottom: 4px;
}

.color-input-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.color-swatch-input {
  width: 42px;
  min-width: 42px;
  height: 34px;
  min-height: 34px;
  padding: 2px;
  border-radius: 7px;
  cursor: pointer;
}

.color-text-input {
  min-width: 0;
}

.surface-list {
  margin: 0 8px 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  padding-top: 8px;
}

.surface-empty {
  padding: 8px 2px;
  color: var(--muted);
  font-size: 12px;
}

.surface-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-height: 44px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #f8fafc;
  cursor: pointer;
}

.surface-row:last-child {
  border-bottom: 1px solid transparent;
}

.surface-row.selected {
  background: #e8f0ff;
  border-color: rgba(36, 107, 254, 0.36);
}

.surface-row:hover {
  border-color: var(--line);
  background: #ffffff;
}

.surface-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.surface-icon-button.danger {
  color: var(--red);
  border-color: rgba(189, 43, 43, 0.28);
  background: #fff;
}

.surface-icon-button.danger:hover {
  color: var(--red);
  border-color: rgba(189, 43, 43, 0.44);
  background: #fff5f5;
}

.surface-row.hidden .surface-dot {
  background: var(--muted);
  box-shadow: none;
}

.surface-row.hidden .surface-icon-button[data-surface-toggle] {
  color: var(--blue);
  border-color: rgba(36, 107, 254, 0.24);
}

.surface-row-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding-top: 6px;
}

.surface-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.12);
}

.preview-wrap {
  display: grid;
  grid-template-columns: minmax(300px, 560px) 1fr;
  gap: 12px;
  align-items: start;
}

.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111827;
  border: 1px solid #0b1220;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.preview-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.preview-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 60;
  display: flex;
  gap: 6px;
}

.preview-tools button {
  min-height: 28px;
  padding: 0 9px;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.74);
  color: #fff;
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.preview-tools button.active {
  border-color: rgba(34, 197, 94, 0.9);
  background: rgba(22, 101, 52, 0.8);
}

.preview-bg-color,
.preview-bg-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-surface {
  position: absolute;
  border: 0;
  outline: 1px solid rgba(255, 255, 255, 0.85);
  outline-offset: -1px;
  color: #fff;
  font-size: 11px;
  overflow: hidden;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  transform-origin: top left;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

/* Resize handles — 8 points on the selected surface. overflow:visible while
   selected lets the edge/corner handles sit on the border without clipping. */
.preview-surface.selected {
  overflow: visible;
}
.preview-surface-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #2b7cff;
  border: 1.5px solid #ffffff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  z-index: 5;
  display: none;
  pointer-events: auto;
  touch-action: none;
}
.preview-surface.selected .preview-surface-handle {
  display: block;
  /* Higher specificity than `.preview-surface > * { pointer-events: none }`
     so the handles are actually grabbable for resize. */
  pointer-events: auto;
}
.preview-surface-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.preview-surface-handle.n  { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.preview-surface-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.preview-surface-handle.e  { top: 50%; right: -6px; transform: translateY(-50%); cursor: ew-resize; }
.preview-surface-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.preview-surface-handle.s  { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.preview-surface-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.preview-surface-handle.w  { top: 50%; left: -6px; transform: translateY(-50%); cursor: ew-resize; }
.aspect-lock-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  cursor: pointer;
}
.aspect-lock-toggle input {
  width: auto;
  margin: 0;
}

.preview-surface.overlay {
  outline-style: dashed;
}

.preview-surface.is-text {
  overflow: visible;
  outline: 1px solid transparent;
  outline-offset: -1px;
  text-shadow: none;
}

.preview-stage.dragging,
.preview-surface:active,
.preview-surface.dragging {
  cursor: grabbing;
}

.preview-surface > * {
  pointer-events: none;
}

.preview-media,
.preview-web-frame,
.preview-text-surface,
.preview-zoom-grid,
.preview-placeholder {
  width: 100%;
  height: 100%;
}

.preview-media,
.preview-web-frame {
  display: block;
  border: 0;
}

.preview-text-surface {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: none;
}

.preview-text-dom-surface {
  overflow: visible;
}

.preview-text-dom-content {
  display: inline-block;
  width: max-content;
  max-width: none;
}

.preview-text-raster-surface {
  position: relative;
  overflow: visible;
  padding: 0;
  background: transparent;
}

.preview-text-raster-image {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.preview-zoom-grid {
  display: grid;
  gap: 3px;
  padding: 3px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
}

.preview-zoom-grid span {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  aspect-ratio: 16 / 9;
  align-self: center;
  justify-self: center;
  width: 100%;
  max-height: 100%;
  border: 1px solid rgba(147, 197, 253, 0.3);
  background: rgba(37, 99, 235, 0.26);
  color: #dbeafe;
  overflow: hidden;
  padding: 4px 5px;
  font-size: 10px;
}

.preview-zoom-grid b,
.preview-zoom-grid small {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-zoom-grid b {
  align-self: end;
  font-size: 11px;
  line-height: 1.15;
}

.preview-zoom-grid small {
  align-self: start;
  color: rgba(219, 234, 254, 0.72);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-surface.is-text.selected,
.preview-surface.is-text:hover {
  outline: 1px solid rgba(255, 255, 255, 0.95);
  outline-offset: -1px;
}

.preview-surface.is-text.overlay.selected,
.preview-surface.is-text.overlay:hover {
  outline-style: dashed;
}

.snap-guide {
  position: absolute;
  z-index: 55;
  pointer-events: none;
  opacity: 0;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.75);
}

.snap-guide.on {
  opacity: 1;
}

.snap-guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.snap-guide-h {
  left: 0;
  right: 0;
  height: 1px;
}

.preview-placeholder {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.72);
  color: #dbeafe;
  text-align: center;
}

.preview-placeholder span {
  max-width: 100%;
  color: #b9c6d8;
  font-size: 10px;
  overflow-wrap: anywhere;
}

/* Live stream sources (NDI / capture / Zoom) — browsers can't decode the feed,
   so the surface shows a clear "mapped source" card with a LIVE badge. */
.preview-placeholder.preview-live {
  position: relative;
  gap: 6px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.94));
  color: #e8f0ff;
}
.preview-placeholder.preview-live strong {
  font-size: 12px;
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.preview-live-icon {
  line-height: 0;
  color: #7fbcff;
}
.preview-live-icon .lucide-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #7fbcff;
  stroke-width: 2;
}
.preview-live-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.preview-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pxLivePulse 1.6s ease-in-out infinite;
}
@keyframes pxLivePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.preview-surface-label {
  position: absolute;
  left: 5px;
  bottom: 5px;
  max-width: calc(100% - 10px);
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-surface.is-text .preview-surface-label,
.preview-surface.is-color .preview-surface-label {
  opacity: 0;
}

.preview-surface.selected .preview-surface-label,
.preview-surface:hover .preview-surface-label {
  opacity: 1;
}

.preview-label {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 58;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  pointer-events: none;
}

.live-take-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.data-list {
  min-height: 80px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
}

.data-chip {
  min-height: 24px;
  margin: 2px;
  padding: 0 8px;
  background: var(--surface-soft);
}

.events-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.events-log,
.project-events-log {
  min-height: 420px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.events-log {
  background: #101721;
  color: #d8e2ef;
}

.project-events-log {
  background: var(--surface);
  color: var(--ink);
}

.event-entry {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 0;
}

.project-events-log .event-entry {
  border-bottom-color: var(--line);
}

.event-entry strong {
  color: #8fb3ff;
}

.project-events-log .event-entry strong {
  color: var(--blue);
}

.event-entry pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 4px 0 0;
  color: #b9c6d8;
}

.project-events-log .event-entry pre {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 14px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

/* Product shell pass */
.topbar {
  min-height: 58px;
  grid-template-columns: auto minmax(160px, 1fr) auto auto;
  gap: 14px;
  padding: 8px 18px;
}

.brand-button {
  min-height: 40px;
}

.topbar-context {
  min-width: 0;
}

.topbar-context h1 {
  margin: 1px 0 0;
  font-size: 17px;
}

.topbar-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.topbar-nav button {
  min-height: 32px;
}

.topbar-nav button.active {
  border-color: var(--blue);
  background: #e8f0ff;
}

.topbar-actions {
  justify-content: flex-end;
}

.dashboard-hero {
  min-height: 112px;
  align-items: center;
  padding: 20px;
}

.dashboard-hero h2 {
  font-size: 34px;
  line-height: 1;
}

.apps-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 240px));
  justify-content: start;
  gap: 16px;
  margin: 18px 0;
}

.app-card {
  aspect-ratio: 1 / 1;
  min-height: 0;
  align-content: space-between;
}

.summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.split-app {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 14px;
}

.node-grid .item,
.stack .item {
  min-height: 84px;
  text-align: left;
  white-space: normal;
}

.node-item {
  display: grid;
  gap: 10px;
  align-content: start;
  cursor: pointer;
}

.node-card-summary,
.node-card-title,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.node-card-title {
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.node-card-title > span:first-child {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--blue);
  background: #e8f0ff;
}

.node-card-title strong,
.node-card-title small,
.node-card-meta span,
.node-interface-meta span {
  overflow-wrap: anywhere;
}

.node-card-title small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.node-card-meta,
.node-interface-meta,
.node-management-subhead {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.node-card-meta span,
.node-interface-meta span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.node-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.node-card-actions button,
.node-management-modal button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mapping-modal.node-management-modal {
  width: min(1160px, calc(100vw - 28px));
  height: min(860px, calc(100vh - 32px));
  height: min(860px, calc(100dvh - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto auto minmax(0, 1fr);
}

.node-management-head {
  align-items: flex-start;
}

.node-management-head > div:first-child {
  min-width: 0;
}

.node-management-head .button-row {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.node-management-head h2 {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.node-management-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.node-management-tabs button {
  flex: 0 0 auto;
}

.node-management-tabs button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #e8f0ff;
}

.node-management-scroll {
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.node-management-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.node-management-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.node-management-section .field-grid,
.node-management-section .field-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  align-items: end;
}

.node-management-section.span-2 {
  grid-column: 1 / -1;
}

.node-management-section .span-2 {
  grid-column: 1 / -1;
}

.node-management-section h3,
.section-head h3 {
  margin: 0;
  font-size: 15px;
}

.node-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.node-metric-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.node-metric {
  min-height: 58px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.node-metric span {
  color: var(--muted);
  font-size: 12px;
}

.node-metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.node-metric strong.ok { color: var(--green); }
.node-metric strong.warn { color: var(--amber); }
.node-metric strong.bad { color: var(--red); }

.node-display-grid,
.node-interface-grid,
.node-quad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 10px;
}

.node-quad-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

.node-display-card,
.node-interface-card,
.node-quad-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.node-interface-card .field-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.node-quad-card .node-card-title {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: start;
}

.node-quad-card .node-card-title .status-pill {
  justify-self: end;
}

.node-quad-card .field-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.node-quad-card .field-grid.compact .span-2 {
  grid-column: 1 / -1;
}

.node-display-card .field-grid.compact {
  grid-template-columns: minmax(0, 1fr) auto;
}

.node-edid-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 8px;
}

.node-edid-card {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.node-edid-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.node-edid-main strong,
.node-edid-main small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.node-edid-main small {
  color: var(--muted);
}

.node-quad-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.node-quad-actions button {
  min-width: 0;
  width: 100%;
}

.node-mode-tabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow-x: auto;
}

.node-mode-tabs button {
  border: 0;
  background: transparent;
  min-width: 132px;
}

.node-mode-tabs button.active {
  color: var(--blue);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(23, 32, 42, 0.12);
}

.quads-app-body {
  padding: 0;
  background: transparent;
}

.quads-app-grid {
  align-items: start;
}

.quads-node-toolbar {
  grid-column: 1 / -1;
}

.quads-node-status {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.quads-node-status .muted {
  overflow-wrap: anywhere;
}

.quads-app-body > .node-management-grid > .node-management-grid {
  grid-column: 1 / -1;
}

.node-callout {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.node-callout.warning {
  border-color: rgba(182, 106, 0, 0.35);
  background: #fff8ea;
  color: #8a5200;
}

.node-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.node-command-grid button {
  min-height: 42px;
}

.node-json-field {
  min-height: 180px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.node-management-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.danger-text {
  color: var(--red);
}

.danger-zone {
  border-color: rgba(189, 43, 43, 0.35);
  background: #fff8f8;
}

body[data-active-app="editor"] {
  overflow: hidden;
}

body[data-active-app="editor"] .app-canvas {
  max-width: none;
  padding: 0;
}

body[data-active-app="editor"] .topbar,
body[data-active-app="editor"] #editorView .app-toolbar {
  display: none;
}

body[data-active-app="editor"] #editorView {
  height: 100vh;
}

body[data-active-app="editor"] #editorView .app-toolbar {
  min-height: 58px;
  margin: 0;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
  padding: 10px 16px;
}

body[data-active-app="editor"] #editorView .app-toolbar h2 {
  font-size: 16px;
}

body[data-active-app="editor"] #editorView .app-toolbar p {
  max-width: 72vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-workspace {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(320px, 390px);
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  background: #171a1f;
}

.editor-shell {
  height: 100vh;
  padding: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.editor-mode-tabs {
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.editor-back-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px 0 10px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.editor-back-button .chevron-icon {
  width: 7px;
  height: 7px;
  border-width: 2px;
}

.editor-back-button:hover {
  border-color: rgba(36, 107, 254, 0.32);
  color: var(--blue);
}

.editor-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.editor-publish-group {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.editor-publish-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.editor-publish-toggle button {
  min-height: 26px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.editor-publish-toggle button.active {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.editor-publish-toggle button[data-editor-publish-mode="live"].active {
  border-color: rgba(17, 126, 75, 0.28);
  color: #117e4b;
}

.editor-publish-status {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.editor-publish-status.live {
  background: #e8f8ef;
  color: #117e4b;
}

.editor-push-live-button {
  min-height: 30px;
  padding: 0 12px;
  white-space: nowrap;
}

.editor-mode-tab {
  min-height: 30px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.editor-mode-tab span {
  min-width: 20px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
}

.editor-mode-tab.active {
  border-color: var(--line);
  background: #eef4ff;
  color: var(--blue);
}

.editor-workspace.left-collapsed {
  grid-template-columns: 52px minmax(0, 1fr) minmax(320px, 390px);
}

.editor-workspace.right-collapsed {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) 52px;
}

.editor-workspace.left-collapsed.right-collapsed {
  grid-template-columns: 52px minmax(0, 1fr) 52px;
}

.editor-left-panel,
.editor-properties {
  min-height: 0;
  background: var(--surface-soft);
  padding: 12px;
  position: relative;
}

.editor-left-panel {
  border-right: 1px solid var(--line);
  overflow: visible;
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
}

.editor-left-panel.collapsed,
.editor-properties.collapsed {
  padding: 8px;
  place-items: stretch;
  background: #f4f7fa;
}

.panel-edge-toggle {
  position: absolute;
  top: 50%;
  z-index: 12;
  width: 22px;
  min-width: 22px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  transform: translateY(-50%);
}

.panel-edge-toggle:hover {
  color: var(--blue);
  border-color: rgba(36, 107, 254, 0.32);
}

.panel-edge-toggle-left {
  right: -11px;
  border-radius: 0 7px 7px 0;
}

.panel-edge-toggle-right {
  left: -11px;
  border-radius: 7px 0 0 7px;
}

.chevron-icon {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.lucide-icon {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chevron-left {
  transform: rotate(135deg);
}

.chevron-right {
  transform: rotate(-45deg);
}

.chevron-down {
  transform: rotate(45deg);
}

.chevron-up {
  transform: rotate(-135deg);
}

.editor-panel-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.editor-panel-head strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.icon-button {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 800;
}

.editor-panel-rail {
  width: 100%;
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
}

.editor-panel-rail span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

.editor-canvas-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    #171a1f;
  background-size: 28px 28px;
}

.editor-properties {
  border-left: 1px solid var(--line);
  overflow: auto;
}

.editor-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.editor-tab {
  min-height: 38px;
  justify-content: center;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.editor-tab span {
  min-width: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.editor-tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #e8f0ff;
}

.editor-tab.active span {
  background: #ffffff;
  color: var(--blue);
}

.editor-tab-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: visible;
}

.editor-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.editor-left-panel .scene-card {
  box-shadow: 0 1px 0 rgba(23, 32, 42, 0.02);
}

.editor-left-panel .control-strip,
.editor-properties .control-strip {
  grid-template-columns: 1fr;
}

.control-workspace {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  background: #101317;
}

.control-workspace.control-run-mode {
  grid-template-columns: minmax(0, 1fr);
}

.control-workspace.left-collapsed {
  grid-template-columns: 52px minmax(0, 1fr);
}

.control-drawer {
  grid-template-rows: auto minmax(0, 1fr);
}

.control-drawer-scroll {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.control-drawer-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.control-drawer-section-head {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  text-align: left;
}

.control-drawer-section-head:hover {
  background: #f8fafc;
  color: var(--blue);
}

.control-drawer-section-head > span:last-child,
.control-overlay-title span {
  min-width: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.control-source-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.control-source-card {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  justify-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
  cursor: grab;
}

.control-source-card:active {
  cursor: grabbing;
}

.control-source-card strong,
.control-source-card small {
  grid-column: 2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-source-card small {
  color: var(--muted);
  font-size: 11px;
}

.control-source-card.active {
  border-color: rgba(36, 107, 254, 0.38);
  background: #edf4ff;
}

.control-source-status {
  grid-row: span 2;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.control-source-card.active .control-source-status {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(36, 107, 254, 0.14);
}

.control-overlay-group {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.control-overlay-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.control-grid-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    #14181d;
  background-size: 30px 30px;
  padding: 14px;
}

.control-grid-head {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #ffffff;
}

.control-grid-head-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-grid-head h2 {
  margin: 0;
  font-size: 15px;
}

.control-mode-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.control-mode-toggle button {
  min-height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  box-shadow: none;
}

.control-mode-toggle button.active {
  background: #ffffff;
  color: var(--ink);
}

.control-grid {
  --control-row-height: 72px;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--control-columns), minmax(0, 1fr));
  grid-auto-rows: var(--control-row-height);
  grid-template-rows: repeat(var(--control-rows), var(--control-row-height));
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding: 2px;
  position: relative;
  overscroll-behavior: contain;
}

.control-grid.dragging-control-card,
.control-grid.resizing-control-card {
  user-select: none;
}

.control-grid-empty {
  grid-column: 1 / -1;
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.58);
}

.control-grid-card {
  min-width: 0;
  min-height: 0;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  cursor: grab;
  touch-action: none;
  transform: translate3d(0, 0, 0);
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease,
    transform 120ms ease;
  will-change: transform;
}

.control-grid.run-mode .control-grid-card {
  cursor: pointer;
  touch-action: manipulation;
}

.control-grid.run-mode .control-card-button {
  cursor: pointer;
}

.control-grid.run-mode .control-card-button:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.9);
  outline-offset: -2px;
}

.control-grid.run-mode .control-card-remove,
.control-grid.run-mode .control-drag-handle,
.control-grid.run-mode .control-resize-handle {
  display: none;
}

.control-grid-card.dragging {
  z-index: 40;
  cursor: grabbing;
  opacity: 0.94;
  outline: 2px solid rgba(36, 107, 254, 0.9);
  outline-offset: 2px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
  transition: box-shadow 120ms ease, opacity 120ms ease;
  pointer-events: none;
}

.control-grid-card.resizing {
  z-index: 35;
  cursor: nwse-resize;
  transition: box-shadow 120ms ease;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.32);
}

.control-grid-drop-target {
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(96, 165, 250, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(34, 197, 94, 0.12));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  pointer-events: none;
  z-index: 1;
}

.control-grid-card.selected {
  outline: 2px solid rgba(36, 107, 254, 0.9);
  outline-offset: 2px;
}

.control-grid-card.active {
  border-color: rgba(59, 130, 246, 0.72);
  background: #eef6ff;
}

.control-card-button {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
  cursor: inherit;
}

.control-card-button:hover {
  background: rgba(36, 107, 254, 0.06);
}

.control-card-button strong,
.control-card-button small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-card-button small {
  color: var(--muted);
}

.control-card-button.has-preview {
  align-content: stretch;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 10px;
}

.control-grid-card.has-visibility .control-card-button {
  padding-bottom: 34px;
}

.control-zoom-grid-preview {
  min-height: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #020617;
  overflow: hidden;
}

.control-zoom-grid-preview.empty {
  display: grid;
  place-items: center;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.control-zoom-grid-preview .preview-zoom-grid {
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 2px;
  padding: 2px;
}

.control-zoom-grid-preview .preview-zoom-grid span {
  padding: 3px;
  font-size: 9px;
}

.control-zoom-grid-preview .preview-zoom-grid b {
  font-size: 10px;
}

.control-zoom-grid-preview .preview-zoom-grid small {
  font-size: 8px;
}

.control-card-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-card-state span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.control-grid-card.active .control-card-state span {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(36, 107, 254, 0.12);
}

.control-card-remove,
.control-card-visibility,
.control-drag-handle,
.control-resize-handle {
  position: absolute;
  z-index: 4;
}

.control-visibility-toggle {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  box-shadow: none;
}

.control-visibility-toggle:hover {
  border-color: rgba(36, 107, 254, 0.36);
  background: #e8f0ff;
  color: var(--blue);
}

.control-visibility-toggle.is-hidden {
  color: var(--blue);
  border-color: rgba(36, 107, 254, 0.26);
}

.control-source-visibility {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: end;
}

.control-card-visibility {
  left: 6px;
  bottom: 6px;
}

.control-card-remove {
  top: 6px;
  right: 6px;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  box-shadow: none;
}

.remove-icon {
  width: 10px;
  height: 10px;
  display: block;
  position: relative;
}

.remove-icon::before,
.remove-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 0;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.remove-icon::before {
  transform: rotate(45deg);
}

.remove-icon::after {
  transform: rotate(-45deg);
}

.control-drag-handle {
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: grab;
  background:
    radial-gradient(circle, #64748b 1.2px, transparent 1.4px) 6px 6px / 7px 7px,
    rgba(255, 255, 255, 0.82);
}

.zoom-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 0;
  background: #101317;
}

.zoom-app-body {
  min-height: calc(100vh - 190px);
  padding: 0;
  overflow: hidden;
}

.zoom-app-body .zoom-workspace {
  min-height: calc(100vh - 190px);
}

.project-zoom-workspace.left-collapsed {
  grid-template-columns: 52px minmax(0, 1fr);
}

.zoom-command-panel,
.zoom-participants-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.zoom-command-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-soft);
  position: relative;
  overflow: visible;
}

.zoom-command-panel.collapsed {
  padding: 8px;
}

.zoom-participants-panel {
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    #14181d;
  background-size: 30px 30px;
}

.zoom-panel-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.zoom-panel-head,
.zoom-participants-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.zoom-panel-head h2,
.zoom-participants-head h2 {
  margin: 0;
  font-size: 15px;
}

.zoom-account-line,
.zoom-meeting-card {
  display: grid;
  gap: 3px;
}

.zoom-account-line strong,
.zoom-meeting-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.zoom-join-form {
  display: grid;
  gap: 8px;
}

.zoom-camera-block {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.zoom-camera-block select {
  width: 100%;
}

.zoom-hint {
  padding: 8px 10px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 7px;
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
  font-size: 12px;
  line-height: 1.35;
}

.zoom-join-form button {
  justify-self: start;
}

.zoom-participants-head {
  color: #ffffff;
  margin-bottom: 4px;
}

.zoom-participants-head input {
  width: min(280px, 40vw);
  background: #ffffff;
}

.zoom-participant-section {
  display: grid;
  gap: 10px;
}

.zoom-participant-section + .zoom-participant-section {
  margin-top: 16px;
}

.zoom-participant-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #ffffff;
}

.zoom-participant-section-head h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
}

.zoom-participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.zoom-participant-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
  cursor: grab;
}

.zoom-participant-card.active {
  background: #eef6ff;
  border-color: rgba(59, 130, 246, 0.64);
}

.zoom-participant-card.waiting {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.68);
  cursor: default;
}

.zoom-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--blue);
  font-weight: 800;
}

.zoom-participant-card strong,
.zoom-participant-card span,
.zoom-participant-card code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-participant-card div:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.zoom-participant-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.zoom-participant-card code {
  grid-column: 1 / -1;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.07);
  color: var(--muted);
  font-size: 11px;
}

.zoom-empty {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.58);
}

.zoom-empty.compact {
  min-height: 88px;
}

.control-drag-handle:active {
  cursor: grabbing;
}

.control-resize-handle {
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 45%, rgba(100, 116, 139, 0.75) 46%, rgba(100, 116, 139, 0.75) 54%, transparent 55%),
    linear-gradient(135deg, transparent 62%, rgba(100, 116, 139, 0.75) 63%, rgba(100, 116, 139, 0.75) 71%, transparent 72%);
}

.editor-left-panel .field-grid,
.editor-properties .field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.surface-properties {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.surface-properties.empty {
  min-height: 170px;
}

.compact-head {
  padding: 12px;
}

.property-group {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.property-group h3 {
  margin: 0;
  font-size: 13px;
}

.property-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.text-property-group .property-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-label {
  min-height: 34px;
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox-label input {
  width: auto;
  min-height: 0;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 16, 24, 0.42);
}

.mapping-modal {
  width: min(860px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.source-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.source-map-grid.compact {
  max-height: 260px;
  padding: 0;
  margin-top: 10px;
}

.source-picker-block {
  margin-top: 12px;
}

.source-map-card {
  min-height: 96px;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 8px;
  white-space: normal;
  text-align: left;
}

.source-map-card.selected {
  border-color: var(--blue);
  background: #e8f0ff;
}

.source-map-card small {
  max-width: 100%;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.source-kind {
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.modal-scroll {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.add-surface-modal {
  width: min(960px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
}

.create-project-modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
}

.add-surface-form {
  display: grid;
  gap: 14px;
}

.create-project-modal-form {
  display: grid;
  gap: 14px;
}

.create-project-fields {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 200px);
}

.create-resolution-fields {
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto;
  align-items: end;
}

.create-resolution-limit {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.create-method-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.create-method-toggle label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.create-method-toggle input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.create-method-toggle label:has(input:checked) {
  border-color: var(--blue);
  background: #e8f0ff;
  color: var(--blue);
}

.create-method-toggle label:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.create-ppt-panel {
  margin-top: 12px;
}

.create-server-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.create-server-card {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.create-server-card input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.create-server-card span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.create-server-card strong,
.create-server-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.create-server-card small {
  color: var(--muted);
}

.create-server-card em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.create-server-card.online em {
  color: var(--green);
}

.create-project-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions {
  justify-items: end;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.editor-preview.preview-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.editor-preview .preview-stage {
  width: min(100%, calc((100vh - 150px) * 1.777));
  max-height: calc(100vh - 150px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.editor-preview .data-panel {
  display: none;
}

.preview-surface.draggable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.preview-surface.draggable:active {
  cursor: grabbing;
}

body.surface-dragging,
body.surface-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.preview-surface.selected {
  border-color: #ffffff;
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .login-screen,
  .topbar,
  .split-app,
  .events-columns,
  .summary-strip,
  .event-state,
  .preview-wrap,
  .data-panel,
  .control-strip {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .dashboard-live {
    text-align: left;
  }

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

  .topbar-nav,
  .topbar-actions {
    justify-content: flex-start;
  }

  body[data-active-app="editor"] {
    overflow: auto;
  }

  body[data-active-app="editor"] #editorView,
  .editor-workspace {
    height: auto;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
  }

  .editor-canvas-pane {
    min-height: 420px;
  }

  .editor-left-panel,
  .editor-properties {
    border: 0;
  }

  .node-management-grid,
  .node-display-grid,
  .node-interface-grid,
  .node-quad-grid,
  .node-edid-grid,
  .node-metric-grid,
  .node-metric-grid.compact,
  .node-command-grid,
  .node-management-section .field-grid,
  .node-management-section .field-grid.compact,
  .node-display-card .field-grid.compact,
  .node-interface-card .field-grid.compact {
    grid-template-columns: 1fr;
  }

  .create-resolution-fields {
    grid-template-columns: 1fr 1fr;
  }

  .create-resolution-limit {
    grid-column: 1 / -1;
  }

  .node-management-section.span-2 {
    grid-column: auto;
  }

  .mapping-modal.node-management-modal {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .node-management-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .node-mode-tabs {
    width: 100%;
  }

  .node-mode-tabs button {
    flex: 1 1 0;
  }

  .node-management-head {
    flex-direction: column;
    align-items: stretch;
  }

  .node-management-head .button-row {
    justify-content: flex-start;
  }

  .node-card-actions button {
    flex: 1 1 130px;
  }

  .scene-options-popout:not(.floating) {
    width: min(300px, calc(100vw - 42px));
  }
}

@media (max-width: 560px) {
  .modal-layer {
    padding: 8px;
  }

  .mapping-modal.node-management-modal {
    width: 100%;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    border-radius: 8px;
  }

  .node-management-head,
  .node-management-tabs,
  .node-management-scroll {
    padding: 10px;
  }

  .node-management-head .button-row,
  .node-card-actions,
  .node-quad-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .node-management-head .button-row button,
  .node-card-actions button,
  .node-quad-actions button {
    width: 100%;
    min-width: 0;
  }

  .node-management-section,
  .node-display-card,
  .node-interface-card,
  .node-quad-card {
    padding: 10px;
  }

  .node-quad-card .field-grid.compact,
  .node-quad-actions {
    grid-template-columns: 1fr;
  }

  .node-quad-card .node-card-title {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .node-quad-card .node-card-title .status-pill {
    grid-column: 2;
    justify-self: start;
  }

  .node-interface-meta span,
  .node-card-meta span {
    width: 100%;
  }

  .node-json-field {
    min-height: 220px;
  }
}

/* ---- AI assistant panel ------------------------------------------- */

#aiAssistantToggle.active {
  border-color: var(--violet);
  background: #f0edff;
  color: var(--violet);
}

.ai-assistant-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 60;
  overflow: hidden;
}

.ai-assistant-panel[hidden] {
  display: none;
}

.ai-assistant-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.ai-assistant-head h2 {
  margin: 0;
  font-size: 15px;
}

.ai-assistant-head .muted {
  margin: 2px 0 0;
  font-size: 11px;
}

.ai-assistant-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-assistant-head-actions button {
  padding: 4px 9px;
  font-size: 12px;
}

.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  max-width: 92%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.user {
  align-self: flex-end;
  background: #e8f0ff;
  border: 1px solid #c8dbff;
}

.ai-msg.assistant {
  align-self: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.ai-msg.notice {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  background: transparent;
  border: 0;
  padding: 0 4px;
  text-align: center;
}

.ai-msg.pending {
  align-self: flex-start;
  color: var(--muted);
  font-style: italic;
  background: var(--surface-soft);
  border: 1px dashed var(--line);
}

.ai-action-card {
  align-self: stretch;
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  display: grid;
  gap: 6px;
}

.ai-action-card.applied {
  border-left-color: var(--green);
}

.ai-action-card.failed {
  border-left-color: var(--red);
}

.ai-action-kind {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--violet);
  font-weight: 700;
}

.ai-action-card.applied .ai-action-kind {
  color: var(--green);
}

.ai-action-summary {
  margin: 0;
  font-size: 13px;
}

.ai-action-meta {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.ai-action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-action-buttons button {
  padding: 5px 12px;
  font-size: 12px;
}

.ai-run-card {
  align-self: stretch;
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  display: grid;
  gap: 6px;
}

.ai-run-card.ok { border-left-color: var(--green); }
.ai-run-card.failed { border-left-color: var(--red); }
.ai-run-card.warn { border-left-color: var(--amber, #d99a1c); }

.ai-run-kind {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--violet);
  font-weight: 700;
}

.ai-run-status { color: var(--muted); }
.ai-run-card.ok .ai-run-status { color: var(--green); }
.ai-run-card.failed .ai-run-status { color: var(--red); }

.ai-run-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.ai-run-step {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.ai-run-step-status {
  flex: 0 0 auto;
  min-width: 86px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.ai-run-step.ok .ai-run-step-status { color: var(--green); }
.ai-run-step.failed .ai-run-step-status { color: var(--red); }
.ai-run-step.warn .ai-run-step-status { color: var(--amber, #d99a1c); }
.ai-run-step.running .ai-run-step-status { color: var(--violet); }

.ai-run-step-summary { flex: 1; }

.ai-run-gate {
  flex: 0 0 auto;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber, #d99a1c);
  border: 1px solid var(--amber, #d99a1c);
  border-radius: 999px;
  padding: 0 6px;
}

.ai-run-verify {
  margin: 0;
  font-size: 12px;
  color: var(--green);
}

.ai-run-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-run-buttons button {
  padding: 5px 12px;
  font-size: 12px;
}

.ai-assistant-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.ai-assistant-form textarea {
  flex: 1;
  resize: none;
  font-size: 13px;
}

.ai-assistant-form button {
  align-self: flex-end;
}

@media (max-width: 640px) {
  .ai-assistant-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: min(540px, calc(100vh - 80px));
  }
}

/* ---- Slash command palette ---------------------------------------- */

.ai-slash-palette {
  border-top: 1px solid var(--line);
  background: var(--surface);
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ai-slash-palette[hidden] {
  display: none;
}

.ai-slash-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--surface-strong);
  background: transparent;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}

.ai-slash-item strong {
  color: var(--violet);
  min-width: 110px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.ai-slash-item span {
  color: var(--muted);
}

.ai-slash-item.active,
.ai-slash-item:hover {
  background: var(--surface-soft);
}

/* ---- Ops app -------------------------------------------------------- */

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.ops-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.ops-panel.ops-audit {
  grid-column: 1 / -1;
}

.ops-list {
  display: grid;
  gap: 8px;
}

.ops-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  display: grid;
  gap: 6px;
  background: var(--surface-soft);
  font-size: 13px;
}

.ops-item .muted {
  font-size: 11.5px;
  word-break: break-word;
}

.ops-audit-item {
  padding: 6px 10px;
}

.ops-form {
  display: grid;
  gap: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.ops-form .field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ops-form label.ops-wide {
  grid-column: 1 / -1;
}

.ops-check-grid {
  display: grid;
  gap: 4px;
}

.ops-check {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.ops-check input[type="checkbox"] {
  width: auto;
}

@media (max-width: 980px) {
  .ops-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Zoom join extras ----------------------------------------------- */

.zoom-claim-host {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.zoom-claim-host input[type="checkbox"] {
  width: auto;
}

.zoom-join-hint {
  font-size: 11px;
  margin: 6px 0 0;
}

/* ===================================================================
   Responsive / mobile shell  (added 2026-06-21)
   Compact top bar with a hamburger drawer, plus mobile-friendly
   dashboard, spacing, and toolbar overrides. These rules are appended
   last so they layer on top of the earlier 980px / 560px blocks.
   =================================================================== */

/* Hamburger toggle — hidden on the desktop grid bar, shown on mobile. */
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 40px;
  padding: 0;
}

.topbar-menu-icon,
.topbar-menu-icon::before,
.topbar-menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.topbar-menu-icon {
  position: relative;
}

.topbar-menu-icon::before,
.topbar-menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.topbar-menu-icon::before { top: -6px; }
.topbar-menu-icon::after { top: 6px; }

/* Animate to an "X" while the drawer is open. */
body.nav-open .topbar-menu-icon { background: transparent; }
body.nav-open .topbar-menu-icon::before { transform: translateY(6px) rotate(45deg); }
body.nav-open .topbar-menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 980px) {
  /* --- Compact top bar + hamburger drawer ------------------------- */
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 12px;
    grid-template-columns: none;
    min-height: 54px;
    padding: 8px 14px;
  }

  .topbar-context {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-menu-btn {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .topbar-nav,
  .topbar-actions {
    flex-basis: 100%;
    width: 100%;
  }

  /* Drawer hidden until the menu button opens it. */
  body:not(.nav-open) .topbar-nav,
  body:not(.nav-open) .topbar-actions {
    display: none;
  }

  body.nav-open .topbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    justify-content: flex-start;
  }

  body.nav-open .topbar-nav button {
    flex: 1 1 calc(50% - 4px);
    min-height: 42px;
    justify-content: center;
  }

  body.nav-open .topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-start;
  }

  body.nav-open .topbar-actions > * {
    min-height: 38px;
  }

  /* --- Canvas + dashboard ----------------------------------------- */
  .app-canvas {
    padding: 14px;
  }

  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* Kill the 1:1 aspect ratio that made each full-width card ~screen tall. */
  .app-card {
    aspect-ratio: auto;
    min-height: 0;
  }
}

@media (max-width: 700px) {
  /* Stack section toolbars (title block over its action buttons). */
  .app-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-height: 0;
  }

  .app-toolbar .button-row {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-canvas {
    padding: 10px;
  }

  .dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-height: 0;
    padding: 18px;
  }

  .dashboard-live {
    min-width: 0;
    text-align: left;
  }

  .app-card {
    min-height: 132px;
  }

  /* Two-up form grids get cramped on a phone — go single column. */
  .ops-form .field-grid,
  .create-project-fields,
  .create-resolution-fields {
    grid-template-columns: 1fr;
  }

  .create-resolution-limit {
    grid-column: auto;
  }
}

/* ===================================================================
   Icon-only buttons + Quads view polish  (added 2026-06-21)
   Buttons render as `<icon><span>Label</span>`; `.icon-btn` keeps the
   icon, hides the label (the title/aria-label carry it), and renders a
   compact square control. Used in the Quads view + node management.
   =================================================================== */

.icon-btn {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-btn > span {
  display: none;
}

.icon-btn .lucide-icon {
  width: 18px;
  height: 18px;
}

/* Compact, right-aligned action footer on each quad output card. */
.node-quad-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.node-quad-actions .icon-btn {
  width: 38px;
  min-width: 38px;
}

/* Save-outputs row: keep the primary save icon button to the right. */
.node-quad-save-row {
  justify-content: flex-end;
}

/* Quad Outputs summary metrics: a clean 2x2 grid instead of a tall,
   full-width stack on phones/tablets. */
@media (max-width: 980px) {
  .node-quad-summary-section .node-metric-grid,
  .node-quad-summary-section .node-metric-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .node-metric {
    min-height: 0;
  }

  /* Action footer stays compact (don't fall back to stretched buttons). */
  .node-quad-actions {
    display: flex;
    grid-template-columns: none;
  }

  .node-quad-actions .icon-btn {
    width: 38px;
    min-width: 38px;
  }
}

/* ============================================================
   Startup splash, mobile landscape enforcement, scroll polish
   ============================================================ */

/* --- Startup welcome splash --------------------------------------------- */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(900px 520px at 50% -8%, rgba(103, 80, 216, 0.16), transparent 62%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.app-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.app-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}
.app-splash-mark {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #6750d8, #8a78e8);
  box-shadow: 0 18px 44px rgba(103, 80, 216, 0.4);
  animation: splashPulse 1.8s ease-in-out infinite;
}
.app-splash-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.app-splash-sub {
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
}
.app-splash-spinner {
  margin-top: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(103, 80, 216, 0.2);
  border-top-color: #6750d8;
  animation: splashSpin 0.8s linear infinite;
}
.app-splash-msg {
  font-size: 12px;
  color: var(--muted);
}
@keyframes splashSpin { to { transform: rotate(360deg); } }
@keyframes splashPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* --- Mobile scroll + horizontal-overflow safety (all viewports) --------- */
html,
body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
body {
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 700px) {
  .app-canvas { padding: 14px; }
  .modal-layer {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mapping-modal {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}

/* --- Mobile landscape enforcement --------------------------------------- */
/* Web cannot hard-lock orientation outside an installed PWA / fullscreen, so on
   a portrait touch device we cover the UI with a "rotate" prompt until the user
   turns the device. Scoped to touch + portrait + small width so desktop (mouse,
   any window size) and tablets in landscape are unaffected. */
.rotate-notice { display: none; }
@media (orientation: portrait) and (max-width: 920px) and (hover: none) and (pointer: coarse) {
  .rotate-notice {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 4500;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    background: var(--bg);
    background-image: radial-gradient(720px 480px at 50% 0%, rgba(103, 80, 216, 0.14), transparent 60%);
  }
  .rotate-notice-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 320px;
  }
  .rotate-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, #6750d8, #8a78e8);
    font-size: 32px;
    animation: rotateHint 2.2s ease-in-out infinite;
  }
  .rotate-title { font-size: 20px; font-weight: 800; color: var(--ink); }
  .rotate-text { font-size: 14px; line-height: 1.5; color: var(--muted); }
}
@keyframes rotateHint { 0%, 55%, 100% { transform: rotate(0deg); } 28% { transform: rotate(90deg); } }

@media (prefers-reduced-motion: reduce) {
  .app-splash-mark,
  .app-splash-spinner,
  .rotate-icon { animation: none; }
}
