:root {
  color-scheme: dark;
  --page: #3f403f;
  --source: #496f62;
  --panel: #191d1c;
  --panel-line: #303735;
  --text: #f3f7f5;
  --muted: #aebbb6;
  --accent: #36c18a;
  --danger: #ef5b5b;
  --pause: #f0c64a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #07110d;
  cursor: pointer;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

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

.studio-shell {
  height: 100vh;
  overflow: visible;
  padding: clamp(20px, 5vw, 62px);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  overflow: visible;
}

.lightning-strike {
  position: fixed;
  inset: -40vmax;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(135deg, transparent 44%, rgb(255 255 255 / 0.95) 50%, transparent 56%);
  transform: translate(-35%, -35%);
}

.lightning-strike.is-active {
  animation: lightning-pass 200ms linear;
}

@keyframes lightning-pass {
  0% {
    opacity: 0;
    transform: translate(-35%, -35%);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(35%, 35%);
  }
}

.desktop-frame {
  position: relative;
  width: min(84vw, 1200px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--source);
  box-shadow: 0 12px 24px rgb(0 0 0 / 0.45), 0 2px 8px rgb(0 0 0 / 0.5);
  cursor: crosshair;
  transform: perspective(500px) translate(calc(var(--pan-x, 0px) + var(--shake-x, 0px)), calc(var(--pan-y, 0px) + var(--shake-y, 0px))) scale(var(--zoom, 1)) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotateZ(var(--tilt-z, 0deg));
  transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.desktop-frame.is-shaking {
  animation: pane-shake 120ms steps(2, end) infinite;
  transition: none;
}

.desktop-frame.is-rotating {
  animation: pane-rotate 1400ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-style: preserve-3d;
  transition: none;
}

@keyframes pane-shake {
  0%,
  100% {
    --shake-x: 0px;
    --shake-y: 0px;
  }

  25% {
    --shake-x: 10px;
    --shake-y: -10px;
  }

  50% {
    --shake-x: -10px;
    --shake-y: 10px;
  }

  75% {
    --shake-x: 10px;
    --shake-y: 10px;
  }
}

@keyframes pane-rotate {
  from {
    transform: perspective(500px) translate(calc(var(--pan-x, 0px) + var(--shake-x, 0px)), calc(var(--pan-y, 0px) + var(--shake-y, 0px))) scale(var(--zoom, 1)) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotateZ(var(--tilt-z, 0deg));
  }

  to {
    transform: perspective(500px) translate(calc(var(--pan-x, 0px) + var(--shake-x, 0px)), calc(var(--pan-y, 0px) + var(--shake-y, 0px))) scale(var(--zoom, 1)) rotateX(calc(var(--tilt-x, 0deg) + 360deg)) rotateY(calc(var(--tilt-y, 0deg) + 360deg)) rotateZ(calc(var(--tilt-z, 0deg) + 360deg));
  }
}

.screen-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--source);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: rgb(255 255 255 / 0.9);
}

.empty-state strong {
  font-size: clamp(24px, 4vw, 46px);
  line-height: 1;
}

.empty-state span {
  color: rgb(255 255 255 / 0.7);
  font-size: clamp(14px, 2vw, 18px);
}

.screen-preview.is-active + .empty-state {
  display: none;
}

.camera-preview {
  position: absolute;
  right: 8vw;
  bottom: 8vh;
  width: clamp(180px, 27vw, 400px);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  background: #262b29;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.12);
  clip-path: circle(50%);
  cursor: grab;
  touch-action: none;
  transform: translate(var(--cam-x, 0px), var(--cam-y, 0px));
  user-select: none;
}

.camera-preview.is-dragging {
  cursor: grabbing;
}

.camera-preview:not(.is-active) {
  display: none;
}

.camera-video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.center-cross {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 5;
  width: 72px;
  height: 72px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.center-cross::before,
.center-cross::after {
  position: absolute;
  content: "";
  background: #ffffff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.55);
}

.center-cross::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

.center-cross::after {
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

.recording-indicator {
  position: fixed;
  top: 22px;
  right: 18px;
  z-index: 12;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4f5753;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.28);
}

.recording-indicator.is-recording {
  background: var(--danger);
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.28), 0 0 18px rgb(239 91 91 / 0.9);
}

.recording-indicator.is-paused {
  background: var(--pause);
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.28), 0 0 18px rgb(240 198 74 / 0.85);
}

.effects-help {
  margin-top: auto;
}

.effects-help ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}

.effects-help kbd {
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 4px;
  background: rgb(255 255 255 / 0.08);
  color: var(--text);
  font-size: 12px;
  padding: 1px 5px;
}

.control-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  align-content: start;
  gap: 12px;
  width: min(360px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--panel-line);
  background: rgb(25 29 28 / 0.96);
  box-shadow: none;
  padding: 18px 14px;
}

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

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h1,
.panel-section h2,
.panel-header p,
.panel-section p {
  margin: 0;
}

.panel-header h1 {
  font-size: 20px;
}

.panel-header p,
.panel-section p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: #252b29;
  color: var(--text);
}

.panel-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--panel-line);
  padding-top: 12px;
}

.panel-section h2 {
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.record-grid button {
  min-width: 0;
  padding: 0 8px;
}

.source-panel-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  background: #050706;
  object-fit: contain;
}

#recordButton {
  background: var(--danger);
  color: #fff;
}

.playback {
  width: 100%;
  border-radius: 6px;
  background: #000;
}

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

  .desktop-frame {
    width: 100%;
  }

  .camera-preview {
    right: 8px;
    bottom: 34px;
    width: clamp(130px, 38vw, 190px);
    transform: translate(0, 20%);
  }

}
