.layout {
  display: grid;
  grid-template-columns: 1fr 440px;
  height: 100vh;
  background: #050507;
}

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 60% at center, rgba(20, 184, 166, 0.04), transparent 70%),
    #07070a;
}

.phone-frame {
  position: relative;
  width: 402px;
  height: 874px;
  background: #0f0f12;
  border-radius: 54px;
  padding: 14px;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.7),
    0 0 0 2px rgba(255, 255, 255, 0.06),
    inset 0 0 0 2px rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  transform: scale(min(0.72, calc((100vh - 40px) / 902)));
  transform-origin: center;
}

.phone-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 100;
  pointer-events: none;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 40px;
  overflow: hidden;
  background: #0a0a0a;
}

.controls {
  display: flex;
  flex-direction: column;
  background: #0b0b0e;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  color: #f5f5f5;
}

.controls-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.controls-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}

.controls-actions {
  display: flex;
  gap: 8px;
}

.btn-primary,
.btn-ghost {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  letter-spacing: -0.1px;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary {
  background: #14B8A6;
  color: #001815;
  box-shadow: 0 0 16px rgba(20, 184, 166, 0.4);
}

.btn-primary:hover {
  background: #0EA394;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.save-status {
  margin-top: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  min-height: 14px;
  font-variant-numeric: tabular-nums;
}

.save-status.success {
  color: #5EEAD4;
}

.save-status.error {
  color: #FF6B6B;
}

.controls-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 40px;
}

.controls-body::-webkit-scrollbar {
  width: 8px;
}

.controls-body::-webkit-scrollbar-track {
  background: transparent;
}

.controls-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}

.controls-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

.ctrl-section {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

.ctrl-section-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.ctrl-section-head:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ctrl-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.85);
}

.ctrl-section-caret {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  transition: transform 0.2s;
}

.ctrl-section.collapsed .ctrl-section-caret {
  transform: rotate(-90deg);
}

.ctrl-section.collapsed .ctrl-section-body {
  display: none;
}

.ctrl-section-body {
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctrl-sub-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 10px;
  margin-bottom: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ctrl-sub-header:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.ctrl {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 24px;
}

.ctrl-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SFMono-Regular", ui-monospace, monospace;
}

.ctrl-value {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", ui-monospace, monospace;
}

.ctrl-range-wrap {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-range-wrap .ctrl-label {
  flex: 1;
}

.ctrl-range-wrap input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  appearance: none;
  outline: none;
  margin-top: 4px;
}

.ctrl-range-wrap input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5EEAD4;
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.6), 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.ctrl-range-wrap input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5EEAD4;
  border: none;
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.6);
  cursor: pointer;
}

.ctrl input[type="color"] {
  width: 36px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.ctrl input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ctrl input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.ctrl input[type="text"] {
  width: 120px;
  padding: 5px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #f5f5f5;
  font-family: "SFMono-Regular", ui-monospace, monospace;
  outline: none;
}

.ctrl input[type="text"]:focus {
  border-color: #5EEAD4;
  background: rgba(255, 255, 255, 0.06);
}

.swipe-sim {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.swipe-sim-slider {
  width: 100%;
}

.swipe-sim-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.swipe-sim-presets button {
  flex: 1;
  min-width: 44px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-family: "SFMono-Regular", ui-monospace, monospace;
}

.swipe-sim-presets button:hover {
  background: rgba(94, 234, 212, 0.12);
  color: #5EEAD4;
  border-color: rgba(94, 234, 212, 0.3);
}

.toggle-preview {
  display: flex;
  gap: 6px;
}

.toggle-preview button {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
}

.toggle-preview button.active {
  background: rgba(20, 184, 166, 0.2);
  color: #5EEAD4;
  border-color: rgba(94, 234, 212, 0.4);
}

.flip-btn {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(20, 184, 166, 0.12);
  color: #5EEAD4;
  border: 1px solid rgba(94, 234, 212, 0.25);
  border-radius: 8px;
  width: 100%;
}

.flip-btn:hover {
  background: rgba(20, 184, 166, 0.2);
}

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

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal-body {
  position: relative;
  background: #0f0f12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  width: min(600px, 90vw);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
}

.modal-body h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-body textarea {
  width: 100%;
  height: 300px;
  background: #050507;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  font-family: "SFMono-Regular", ui-monospace, monospace;
  font-size: 11px;
  color: #A5F3FC;
  resize: none;
  outline: none;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 380px;
  }
}
