:root {
  --bg: #080b12;
  --bg-soft: rgba(14, 18, 28, 0.88);
  --bg-panel: rgba(18, 24, 36, 0.84);
  --bg-panel-2: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7fb;
  --muted: #9aa6b8;
  --muted-2: #6f7b8d;
  --accent: #ff9f67;
  --accent-2: #7ce7cf;
  --danger: #ff6f7a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 24px;
  --radius-sm: 16px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 159, 103, 0.12), transparent 28%),
    radial-gradient(circle at right 10%, rgba(124, 231, 207, 0.12), transparent 22%),
    linear-gradient(180deg, #0b1019 0%, #080b12 100%);
}

body.dashboard {
  overflow-x: hidden;
  overflow-y: auto;
}

body.dashboard.is-license-locked {
  overflow: hidden;
}

body.is-dialog-open {
  overflow: hidden;
}

body.overlay {
  overflow: hidden;
  background: transparent;
}

body.login {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.app-root {
  min-height: 100vh;
  padding: 24px;
}

.boot-card {
  width: min(720px, 100%);
  margin: 10vh auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

.boot-title {
  font-size: 1.8rem;
  font-weight: 800;
}

.boot-subtitle {
  margin-top: 10px;
  color: var(--muted);
}

.login-root {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(620px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at top right, rgba(124, 231, 207, 0.12), transparent 28%),
    var(--bg-soft);
  box-shadow: var(--shadow);
}

.login-title {
  margin: 10px 0 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.login-copy {
  margin: 14px 0 0;
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
}

.login-button {
  display: inline-flex;
  margin-top: 24px;
}

.login-note {
  margin: 16px 0 0;
  color: var(--muted-2);
  line-height: 1.5;
  font-size: 0.92rem;
}

.studio-shell {
  max-width: 1720px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 48px);
  height: auto;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar,
.connection-bar,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  padding: 24px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
}

.topbar-aside {
  width: min(380px, 100%);
  display: grid;
  align-content: start;
}

.overlay-mini {
  padding: 16px;
}

.overlay-mini-preview {
  position: relative;
  height: 180px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 12px, rgba(255, 255, 255, 0.02) 12px 24px);
}

.brand-block {
  max-width: 860px;
}

.brand-kicker {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
}

.brand-title {
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.brand-copy {
  margin: 12px 0 0;
  max-width: 66ch;
  color: var(--muted);
  line-height: 1.55;
}

.topbar-actions,
.connection-actions,
.quick-buttons,
.layer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 11px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  background: linear-gradient(135deg, #ff9f67, #ff7d6a);
  color: #1b1110;
  border-color: transparent;
}

.button-primary:hover {
  box-shadow: 0 10px 24px rgba(255, 125, 106, 0.22);
}

.button-soft {
  background: rgba(255, 255, 255, 0.03);
}

.button-danger {
  background: rgba(255, 111, 122, 0.14);
  border-color: rgba(255, 111, 122, 0.35);
}

.connection-bar {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr) minmax(320px, 1.1fr) auto;
  gap: 14px;
  align-items: end;
}

.connection-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}

.account-card {
  z-index: 3;
}

.profile-card {
  z-index: 2;
}

.overlay-card {
  z-index: 1;
}

.connection-card-header {
  display: grid;
  gap: 4px;
}

.account-body {
  position: relative;
  display: inline-grid;
  justify-items: start;
  width: fit-content;
}

.admin-switcher {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.admin-switcher[hidden] {
  display: none;
}

.admin-target-field {
  flex: 1 1 220px;
}

.admin-target-apply {
  white-space: nowrap;
}

.profile-actions {
  gap: 8px;
}

.overlay-card {
  gap: 10px;
}

.overlay-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.overlay-qr {
  width: min(240px, 100%);
  aspect-ratio: 1 / 1;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #ffffff;
  overflow: hidden;
}

.overlay-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.account-menu-button {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
}

.account-menu-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.account-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
}

.account-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-tag {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(12, 16, 25, 0.96);
  box-shadow: var(--shadow);
  display: none;
  z-index: 20;
}

.account-menu.is-open {
  display: grid;
}

.connection-card .field {
  min-width: 0;
}

.account-menu-item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.account-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.connection-hint {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 1200px) {
  .connection-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overlay-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .connection-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .connection-card {
    padding: 14px;
  }

  .account-menu {
    min-width: min(260px, calc(100vw - 48px));
  }
}

.field {
  display: grid;
  gap: 8px;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.font-picker-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.font-picker-row .field {
  flex: 1 1 240px;
  min-width: 0;
}

.font-upload-button {
  white-space: nowrap;
}

.field-label {
  font-size: 0.86rem;
  color: var(--muted);
}

.field-input,
.field-textarea-control,
select.field-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 11px 13px;
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.03);
  outline: none;
}

.field-input,
.field-textarea-control,
select.field-input,
select.field-input option {
  color-scheme: dark;
}

select.field-input {
  appearance: auto;
  -webkit-appearance: auto;
}

select.field-input option {
  color: var(--text);
  background-color: #111722;
}

.field-input:focus,
.field-textarea-control:focus,
select.field-input:focus {
  border-color: rgba(124, 231, 207, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 231, 207, 0.12);
}

.field-color {
  align-content: start;
}

.color-control {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.color-swatch-input {
  width: 52px;
  height: 44px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.color-swatch-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-swatch-input::-webkit-color-swatch {
  border: 0;
  border-radius: 10px;
}

.color-swatch-input::-moz-color-swatch {
  border: 0;
  border-radius: 10px;
}

.color-hex-input {
  font-family: "Courier New", ui-monospace, monospace;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.effect-config {
  border: 1px solid rgba(124, 231, 207, 0.16);
  border-radius: 16px;
  padding: 12px;
  background: rgba(124, 231, 207, 0.045);
}

.inspector-segment {
  display: grid;
  gap: 12px;
}

.segment-title {
  color: var(--text);
  font-weight: 850;
  letter-spacing: 0.01em;
}

.effect-config-title {
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
  list-style: none;
}

.effect-config-title::-webkit-details-marker {
  display: none;
}

.effect-config-title::after {
  content: "Configure";
  float: right;
  color: var(--accent-2);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.effect-config[open] .effect-config-title {
  margin-bottom: 12px;
}

.field-textarea-control {
  min-height: 110px;
  resize: vertical;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(320px, 380px);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.sidebar,
.preview-panel,
.inspector {
  min-height: 0;
}

.sidebar,
.inspector {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 16px;
  overflow: visible;
}

.sidebar {
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr);
  align-self: start;
}

.cards-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 16px;
  gap: 14px;
  overflow: hidden;
  min-height: 0;
  align-self: start;
}

.panel-header {
  display: grid;
  gap: 6px;
}

.panel-header-tight {
  margin-top: 10px;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel-subtitle {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
}

.chip-muted {
  color: var(--muted);
}

.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  max-height: min(520px, 36vh);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.gift-picker {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 50;
}

.gift-picker.is-open {
  display: flex;
}

.gift-picker-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 8, 13, 0.72);
  backdrop-filter: blur(10px);
}

.gift-picker-panel {
  position: relative;
  width: min(1120px, calc(100vw - 64px));
  max-height: min(84vh, 980px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  overflow: hidden;
  z-index: 1;
  min-height: 0;
}

.gift-picker-panel .panel-header {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.gift-picker-action {
  color: var(--accent-2);
  font-size: 0.88rem;
}

.gift-picker-close {
  justify-self: end;
}

.gift-picker-grid {
  max-height: none;
  min-height: 0;
  height: 100%;
  grid-auto-rows: minmax(110px, auto);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.gift-picker-sentinel {
  height: 1px;
  width: 100%;
}

.app-dialog {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 60;
}

.app-dialog.is-open {
  display: flex;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 8, 13, 0.74);
  backdrop-filter: blur(10px);
}

.app-dialog-panel {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 22px;
  z-index: 1;
  box-shadow: var(--shadow);
}

.app-dialog-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.app-dialog-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.app-dialog-input {
  width: 100%;
}

.app-dialog-remember {
  margin-top: 2px;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.layer-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gift-tile {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 6px 6px;
  color: var(--text);
  text-align: center;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.gift-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 231, 207, 0.5);
  background: rgba(124, 231, 207, 0.08);
}

.gift-tile-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin-bottom: 6px;
}

.gift-tile-label {
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--muted);
}

.layer-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 4px;
  overscroll-behavior: contain;
  overflow-anchor: none;
  align-content: start;
  grid-auto-rows: min-content;
}

.layer-list.is-dragging-layer {
  cursor: grabbing;
}

body.is-layer-dragging,
body.is-layer-dragging .layer-list,
body.is-layer-dragging .layer-row,
body.is-layer-dragging .layer-row * {
  user-select: none;
  -webkit-user-select: none;
}

.layer-row {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.layer-row:hover,
.layer-row.is-selected {
  border-color: rgba(124, 231, 207, 0.45);
  background: rgba(124, 231, 207, 0.08);
}

.layer-row.is-dragging {
  opacity: 0.55;
}

.layer-row.is-hidden {
  opacity: 0.56;
}

.layer-row.is-hidden .layer-caption {
  color: var(--muted);
}

.layer-row.is-drop-before {
  box-shadow: inset 0 2px 0 rgba(124, 231, 207, 0.9);
}

.layer-row.is-drop-after {
  box-shadow: inset 0 -2px 0 rgba(124, 231, 207, 0.9);
}

.layer-drag-handle {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.95rem;
  letter-spacing: -0.08em;
  cursor: grab;
  touch-action: none;
  user-select: none;
  pointer-events: none;
}

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

.layer-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text);
  background: transparent;
  overflow: hidden;
}

.layer-thumb-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.layer-meta {
  min-width: 0;
  display: flex;
  align-items: center;
}

.layer-caption {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-row-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  min-width: 30px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.preview-root {
  position: relative;
  width: min(100%, 680px);
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 12px, rgba(255, 255, 255, 0.02) 12px 24px);
}

.scene-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.overlay-mini-preview .scene-shell {
  position: absolute;
  inset: 0;
}

.scene-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
}

.stage-enter {
  animation: stage-enter var(--transition-seconds, 0.35s) ease-out;
}

.scene-transition-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.scene-transition-layer.is-entering,
.scene-transition-layer.is-leaving {
  transition:
    transform var(--transition-seconds, 0.35s) cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity var(--transition-seconds, 0.35s) ease;
}

.scene-stage.has-3d-transition {
  perspective: 2200px;
  transform-style: preserve-3d;
  --box-depth: 520px;
  --box-scale: 0.764;
}

.transition-fade.is-entering {
  opacity: 0;
}

.transition-fade.is-entering.is-active {
  opacity: 1;
}

.transition-fade.is-leaving {
  opacity: 1;
}

.transition-fade.is-leaving.is-active {
  opacity: 0;
}

.transition-slide-left.is-entering {
  opacity: 0;
  transform: translate3d(64px, 0, 0);
}

.transition-slide-left.is-entering.is-active,
.transition-slide-right.is-entering.is-active,
.transition-slide-up.is-entering.is-active,
.transition-slide-down.is-entering.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.transition-slide-left.is-leaving {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.transition-slide-left.is-leaving.is-active {
  opacity: 0;
  transform: translate3d(-64px, 0, 0);
}

.transition-slide-right.is-entering {
  opacity: 0;
  transform: translate3d(-64px, 0, 0);
}

.transition-slide-right.is-leaving {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.transition-slide-right.is-leaving.is-active {
  opacity: 0;
  transform: translate3d(64px, 0, 0);
}

.transition-slide-up.is-entering {
  opacity: 0;
  transform: translate3d(0, 48px, 0);
}

.transition-slide-up.is-leaving {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.transition-slide-up.is-leaving.is-active {
  opacity: 0;
  transform: translate3d(0, -48px, 0);
}

.transition-slide-down.is-entering {
  opacity: 0;
  transform: translate3d(0, -48px, 0);
}

.transition-slide-down.is-leaving {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.transition-slide-down.is-leaving.is-active {
  opacity: 0;
  transform: translate3d(0, 48px, 0);
}

.transition-rotate-box-left.is-entering,
.transition-rotate-box-left.is-leaving,
.transition-rotate-box-right.is-entering,
.transition-rotate-box-right.is-leaving,
.transition-rotate-box-up.is-entering,
.transition-rotate-box-up.is-leaving,
.transition-rotate-box-down.is-entering,
.transition-rotate-box-down.is-leaving {
  transition:
    transform var(--transition-seconds, 0.35s) cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity var(--transition-seconds, 0.35s) ease;
}

.transition-rotate-box-left.is-entering,
.transition-rotate-box-right.is-entering,
.transition-rotate-box-up.is-entering,
.transition-rotate-box-down.is-entering {
  opacity: 0.01;
  transform-origin: 50% 50%;
}

.transition-rotate-box-left.is-entering {
  transform: rotateY(90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-right.is-entering {
  transform: rotateY(-90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-up.is-entering {
  transform: rotateX(-90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-down.is-entering {
  transform: rotateX(90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-left.is-entering.is-active,
.transition-rotate-box-right.is-entering.is-active,
.transition-rotate-box-up.is-entering.is-active,
.transition-rotate-box-down.is-entering.is-active {
  opacity: 1;
  transform: rotate3d(0, 0, 0, 0deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-left.is-leaving,
.transition-rotate-box-right.is-leaving,
.transition-rotate-box-up.is-leaving,
.transition-rotate-box-down.is-leaving {
  opacity: 1;
  transform-origin: 50% 50%;
  transform: rotate3d(0, 0, 0, 0deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-left.is-leaving.is-active,
.transition-rotate-box-right.is-leaving.is-active,
.transition-rotate-box-up.is-leaving.is-active,
.transition-rotate-box-down.is-leaving.is-active {
  opacity: 0.01;
}

.transition-rotate-box-left.is-leaving.is-active {
  transform: rotateY(-90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-right.is-leaving.is-active {
  transform: rotateY(90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-up.is-leaving.is-active {
  transform: rotateX(90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.transition-rotate-box-down.is-leaving.is-active {
  transform: rotateX(-90deg) translateZ(var(--box-depth)) scale(var(--box-scale));
}

.scene-preview .scene-stage {
  border-radius: 20px;
}

.overlay-mini-preview .scene-stage {
  border-radius: 14px;
}

.overlay-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.overlay-pairing-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
}

.overlay-pairing-card {
  width: min(620px, calc(100vw - 48px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at top right, rgba(124, 231, 207, 0.12), transparent 28%),
    rgba(10, 13, 20, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
}

.overlay-pairing-badge {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(124, 231, 207, 0.28);
  background: rgba(124, 231, 207, 0.08);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.overlay-pairing-title {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.overlay-pairing-copy {
  margin: 0;
  max-width: 50ch;
  color: var(--muted);
  line-height: 1.55;
}

.overlay-pairing-qr {
  width: min(340px, 78vw);
  aspect-ratio: 1 / 1;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #ffffff;
  overflow: hidden;
}

.overlay-pairing-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay-pairing-qr img {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay-pairing-url {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
}

.overlay-pairing-url-label {
  font-size: 0.86rem;
  color: var(--muted);
}

.overlay-pairing-url-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 11px 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}

.overlay-pairing-url-input:focus {
  border-color: rgba(124, 231, 207, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 231, 207, 0.12);
}

.overlay-pairing-detail {
  margin: 0;
  color: var(--muted-2);
  line-height: 1.45;
  font-size: 0.92rem;
}

.overlay-pairing-error {
  margin: 0;
  color: var(--danger);
  line-height: 1.45;
  font-size: 0.92rem;
}

.scene-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(540px, calc(100% - 40px));
  padding: 24px;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(9, 12, 18, 0.55);
  text-align: center;
}

.scene-empty-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.scene-empty-copy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.overlay-layer {
  position: absolute;
  transform-origin: top left;
}

.overlay-layer.is-selected {
  outline: 1px solid rgba(124, 231, 207, 0.55);
  outline-offset: 3px;
}

.overlay-layer.is-hidden {
  display: none;
}

.layer-transform {
  transform-origin: center center;
}

.layer-motion {
  transform-origin: center center;
}

.card-part-motion {
  transform-origin: center center;
}

.card-frame {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: fit-content;
  position: relative;
}

.card-image,
.image-layer {
  display: block;
  max-width: none;
  max-height: none;
}

.card-frame.anchor-text {
  justify-content: flex-end;
}

.card-frame.anchor-gift {
  justify-content: flex-start;
}

.card-caption,
.text-layer {
  width: fit-content;
  max-width: none;
}

.card-caption-shadow {
  pointer-events: none;
  user-select: none;
}

.text-fill-gradient,
.text-fill-rainbow {
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 100% 100%;
}

.text-fill-rainbow {
  background-size: 300% 100%;
  animation: text-rainbow var(--text-rainbow-speed, 2.4s) linear infinite;
}

.text-effect-flash {
  animation: text-flash var(--text-effect-speed, 1.6s) ease-in-out infinite;
}

.text-effect-strobe {
  animation: text-strobe var(--text-effect-speed, 0.28s) steps(2, jump-none) infinite;
}

.text-effect-pulse {
  animation: text-pulse var(--text-effect-speed, 1.6s) ease-in-out infinite;
}

.scene-preview .card-caption-edit-controls {
  position: absolute;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  z-index: 2;
}

.scene-preview .card-caption-edit-controls:active {
  cursor: grabbing;
}

.card-caption-line-handle,
.card-caption-resize-handle {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(124, 231, 207, 0.95);
  border-radius: 999px;
  background: rgba(124, 231, 207, 0.18);
  box-shadow: 0 0 0 2px rgba(11, 16, 25, 0.9);
  cursor: nwse-resize;
  padding: 0;
  touch-action: none;
}

.card-caption-line-handle {
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.card-caption-line-handle::before {
  content: "";
  position: absolute;
  inset: 8px 6px;
  border-top: 2px solid rgba(124, 231, 207, 0.95);
  border-bottom: 2px solid rgba(124, 231, 207, 0.95);
  border-radius: 999px;
}

.card-caption-resize-handle {
  right: -14px;
  bottom: -14px;
}

.text-layer {
  white-space: pre-wrap;
}

.motion-float {
  animation: motion-float var(--motion-duration) ease-in-out var(--motion-delay) infinite;
}

.motion-drift {
  animation: motion-drift var(--motion-duration) ease-in-out var(--motion-delay) infinite;
}

.motion-pulse {
  animation: motion-pulse var(--motion-duration) ease-in-out var(--motion-delay) infinite;
}

.motion-fade {
  animation: motion-fade var(--motion-duration) ease-in-out var(--motion-delay) infinite;
}

.motion-pop {
  animation: motion-pop var(--motion-duration) ease-in-out var(--motion-delay) infinite;
}

.motion-spin {
  animation: motion-spin var(--motion-duration) linear var(--motion-delay) infinite;
}

@keyframes motion-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(calc(-1 * var(--motion-distance)));
  }
}

@keyframes motion-drift {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(var(--motion-distance));
  }
}

@keyframes motion-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(var(--motion-scale-up));
  }
}

@keyframes motion-pop {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(var(--motion-pop-scale));
  }
  60% {
    transform: scale(var(--motion-pop-scale-2));
  }
}

@keyframes motion-fade {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@keyframes motion-spin {
  from {
    transform: rotate(var(--base-rotation)) scale(var(--base-scale));
  }
  to {
    transform: rotate(calc(var(--base-rotation) + 360deg)) scale(var(--base-scale));
  }
}

@keyframes text-rainbow {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 300% 50%;
  }
}

@keyframes text-flash {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.9);
  }
}

@keyframes text-pulse {
  0%,
  100% {
    filter: saturate(1) brightness(1);
  }
  50% {
    filter: saturate(1.35) brightness(1.35);
  }
}

@keyframes text-strobe {
  0%,
  100% {
    opacity: 1;
    filter: brightness(1.8);
  }
  50% {
    opacity: 0.18;
    filter: brightness(0.8);
  }
}

@keyframes stage-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.panel-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.panel-block-empty {
  color: var(--muted);
}

.panel-block-title,
.subsection-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subsection {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.field-grid {
  display: grid;
  gap: 10px;
}

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

.layer-header {
  display: grid;
  gap: 4px;
}

.layer-header-name {
  font-weight: 700;
  font-size: 1rem;
}

.field-range {
  gap: 8px;
}

.field-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-range-value {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.field-range-input {
  padding: 0;
  accent-color: var(--accent);
}

.empty-note {
  color: var(--muted);
  line-height: 1.5;
}

.layer-actions {
  padding-top: 2px;
}

.status-line {
  margin: 0 auto;
  max-width: 1720px;
  padding: 4px 10px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-line[data-mode="saving"] {
  color: var(--accent-2);
}

.status-line[data-mode="saved"] {
  color: #93f2a5;
}

.status-line[data-mode="dirty"] {
  color: var(--accent);
}

.status-line[data-mode="error"] {
  color: var(--danger);
}

.overlay-error {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 16px 20px;
  border-radius: 16px;
  background: rgba(10, 12, 16, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.license-lock-screen,
.license-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 500;
  backdrop-filter: blur(18px);
}

.license-lock-screen[hidden],
.license-gate[hidden] {
  display: none !important;
}

.license-lock-screen {
  background: rgba(5, 8, 14, 0.7);
}

.license-lock-screen-overlay {
  z-index: 20;
}

.license-lock-panel,
.license-gate-panel {
  width: min(640px, calc(100vw - 32px));
  padding: 28px 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(124, 231, 207, 0.14), transparent 30%),
    radial-gradient(circle at top left, rgba(255, 159, 103, 0.14), transparent 22%),
    rgba(8, 12, 18, 0.88);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.license-lock-badge,
.license-gate-badge {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
}

.license-lock-title,
.license-gate-title {
  margin: 12px 0 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.license-lock-copy,
.license-gate-copy {
  margin: 14px auto 0;
  max-width: 48ch;
  color: rgba(245, 247, 251, 0.78);
  line-height: 1.55;
}

body.dashboard.is-license-locked .studio-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(1px) saturate(0.7) brightness(0.72);
}

body.dashboard.is-license-locked .status-line {
  pointer-events: none;
}

@media (max-width: 1280px) {
  body.dashboard {
    overflow: auto;
  }

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

  .studio-shell {
    height: auto;
    min-height: calc(100vh - 48px);
  }

  .sidebar,
  .inspector {
    overflow: visible;
  }

  .sidebar {
    overflow: hidden;
  }

  .preview-panel {
    min-height: 0;
  }

  .preview-root {
    width: 100%;
    max-width: 680px;
  }

  .connection-bar {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 520px;
  }

  .preview-root {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .app-root {
    padding: 14px;
  }

  .topbar,
  .connection-bar,
  .panel {
    border-radius: 20px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-aside {
    width: 100%;
  }

  .field-grid.two-up {
    grid-template-columns: 1fr;
  }

  .gift-grid {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    max-height: min(48vh, 430px);
  }
}
