:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --surface-muted: #eef3fb;
  --line: #dde7f4;
  --line-strong: #cddbf0;
  --text: #172033;
  --muted: #6e7a91;
  --primary: #7b61ff;
  --primary-strong: #6547ff;
  --primary-soft: #efeaff;
  --teal: #12c7b1;
  --shadow: 0 18px 40px rgba(33, 53, 85, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  font-family: Inter, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(123, 97, 255, 0.08), transparent 24%),
    radial-gradient(circle at bottom right, rgba(18, 199, 177, 0.08), transparent 22%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1560px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0 28px;
}

.studio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(221, 231, 244, 0.9);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.studio-brand strong {
  display: block;
  font-size: 1rem;
}

.studio-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.studio-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #9f8cff);
}

.studio-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-btn {
  position: relative;
  overflow: hidden;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-btn span,
.primary,
.ghost,
.apk-link,
.mode-btn,
.quick-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.upload-btn span,
.primary {
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 10px 22px rgba(123, 97, 255, 0.22);
}

.ghost,
.apk-link,
.quick-chip {
  padding: 11px 14px;
  border-radius: 999px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.upload-btn:hover span,
.primary:hover,
.ghost:hover,
.apk-link:hover,
.mode-btn:hover,
.quick-chip:hover {
  transform: translateY(-1px);
}

.editor-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 18px;
  margin-top: 18px;
}

.left-rail,
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rail-card,
.editor-stage,
.control-card,
.timeline-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.rail-card {
  padding: 18px;
  border-radius: var(--radius-lg);
}

.rail-label {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rail-card h1 {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.02;
}

.rail-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.rail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.rail-badges span {
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

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

.quick-chip {
  width: 100%;
  min-height: 72px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  font-weight: 600;
}

.mobile-cta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--teal), #0ea5e9);
}

.mobile-cta span {
  font-size: 0.84rem;
  opacity: 0.88;
}

.editor-stage {
  border-radius: var(--radius-xl);
  padding: 18px;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.stage-toolbar h2 {
  margin: 0;
  font-size: 1.3rem;
}

.stage-toolbar p,
.card-copy,
.mode-caption,
.hint,
#videoTimeLabel {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  padding: 10px 13px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.canvas-surface {
  margin-top: 18px;
  padding: 28px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, #edf3fb, #e8eff8);
  border: 1px solid var(--line);
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 480px;
}

#previewCanvas {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 24px 40px rgba(23, 32, 51, 0.14);
  cursor: default;
}

#previewCanvas.is-draggable {
  cursor: grab;
}

#previewCanvas.is-dragging {
  cursor: grabbing;
}

.mode-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.mode-btn {
  padding: 11px 15px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.mode-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 10px 18px rgba(123, 97, 255, 0.2);
}

.timeline-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

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

.control-card {
  padding: 16px;
  border-radius: 20px;
}

.control-card h3 {
  margin: 0;
  font-size: 1rem;
}

.control-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-field {
  flex: 1;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.wide {
  width: 100%;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

input[type="text"],
select {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: none;
}

input[type="text"]:focus,
select:focus {
  border-color: rgba(123, 97, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.08);
}

input[type="color"] {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: transparent;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 1280px) {
  .editor-shell {
    grid-template-columns: 240px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1080px) {
  .editor-shell {
    grid-template-columns: 1fr;
  }

  .left-rail {
    order: 1;
  }

  .editor-stage {
    order: 2;
  }

  .controls-panel {
    order: 3;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 16px, 1560px);
    padding-top: 10px;
  }

  .studio-bar,
  .stage-toolbar,
  .toolbar-actions,
  .mode-strip,
  .timeline-header {
    flex-direction: column;
    align-items: stretch;
  }

  .studio-bar {
    border-radius: 18px;
  }

  .studio-actions {
    width: 100%;
  }

  .studio-actions > * {
    flex: 1;
  }

  .quick-grid,
  .timeline-grid {
    grid-template-columns: 1fr;
  }

  .canvas-surface {
    padding: 16px;
  }

  .canvas-wrap {
    min-height: 260px;
  }
}
