:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #667085;
  --soft: #eef2f7;
  --line: #d9e0ea;
  --panel: #ffffff;
  --accent: #147d73;
  --accent-dark: #0f625a;
  --coral: #e65f4f;
  --gold: #f2b84b;
  --sky: #5f8fd8;
  --shadow: 0 18px 50px rgba(31, 44, 61, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 8%, rgba(242, 184, 75, 0.28), transparent 26rem),
    linear-gradient(135deg, #f7fafc 0%, #edf4f2 46%, #f9f5ef 100%);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 17.5rem 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid rgba(217, 224, 234, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
}

.brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 0.85rem;
}

.nav-list,
.setup-panel,
.control-column,
.caption-layout,
.export-grid {
  display: grid;
  gap: 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.82rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active {
  background: #e7f3f1;
  border-color: #c7e2dd;
  color: var(--accent-dark);
  font-weight: 700;
}

.setup-panel {
  margin-top: auto;
  padding: 1rem;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 48rem;
  font-size: clamp(1.55rem, 2.4vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-actions,
.edit-tools,
.inline-actions,
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

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

.language-field {
  display: grid;
  gap: 0.25rem;
  min-width: 11rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.language-field select {
  min-height: 2.5rem;
}

[dir="rtl"] .app-shell {
  direction: rtl;
}

[dir="rtl"] .sidebar {
  border-right: 0;
  border-left: 1px solid rgba(217, 224, 234, 0.9);
}

[dir="rtl"] .nav-item,
[dir="rtl"] .topbar,
[dir="rtl"] .panel,
[dir="rtl"] .track-row {
  direction: rtl;
}

.section-heading {
  justify-content: space-between;
}

.primary-button,
.ghost-button,
.icon-button,
.segment,
.transition {
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0 0.95rem;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(20, 125, 115, 0.22);
}

.primary-button.recording {
  border-color: var(--coral);
  background: var(--coral);
  box-shadow: 0 12px 24px rgba(230, 95, 79, 0.24);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.small {
  min-height: 2.2rem;
  padding-inline: 0.75rem;
  font-size: 0.9rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 1rem;
  align-items: start;
}

.preview-area {
  position: relative;
  overflow: hidden;
  min-height: 28rem;
  border: 1px solid rgba(217, 224, 234, 0.88);
  border-radius: 0.5rem;
  background: #111827;
  box-shadow: var(--shadow);
}

.preview-toolbar {
  position: absolute;
  z-index: 3;
  top: 0.8rem;
  left: 0.8rem;
  right: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  background: rgba(17, 24, 39, 0.72);
}

#recordDot {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 999px;
  background: #9ca3af;
}

#recordDot.live {
  background: var(--coral);
  box-shadow: 0 0 0 0.35rem rgba(230, 95, 79, 0.28);
}

#recordTime {
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  background: rgba(17, 24, 39, 0.72);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

#mixCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 28rem;
  aspect-ratio: 16 / 9;
}

#screenVideo,
#webcamVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(31, 44, 61, 0.06);
}

.panel h2 {
  margin-bottom: 0.85rem;
}

.segmented,
.transition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.segment,
.transition {
  padding-inline: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.segment.active,
.transition.active {
  border-color: var(--accent);
  background: #e7f3f1;
  color: var(--accent-dark);
}

.field,
.toggle-row {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

input[type="checkbox"] {
  accent-color: var(--accent);
}

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

input[type="color"] {
  width: 100%;
  height: 2.45rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: white;
}

select,
textarea,
input[type="number"],
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: white;
  color: var(--ink);
}

select,
input[type="number"],
input[type="email"],
input[type="password"],
input[type="text"] {
  min-height: 2.45rem;
  padding: 0 0.65rem;
}

textarea {
  resize: vertical;
  padding: 0.85rem;
  line-height: 1.45;
}

.file-drop {
  display: grid;
  min-height: 4.5rem;
  place-items: center;
  border: 1px dashed #9db7c7;
  border-radius: 0.5rem;
  background: #f5faf9;
  color: var(--accent-dark);
  font-weight: 800;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.slide-list {
  display: grid;
  max-height: 12rem;
  gap: 0.45rem;
  margin: 0.8rem 0;
  overflow: auto;
}

.slide-thumb,
.cut-item,
.caption-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 0.86rem;
}

.slide-thumb.active {
  border-color: var(--gold);
  background: #fff8e8;
  color: #8a5d00;
}

.inline-actions {
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
}

.icon-button {
  width: 2.5rem;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(20rem, 1.5fr) minmax(18rem, 1fr);
  gap: 1rem;
}

.playback-panel {
  grid-row: span 2;
}

#playback,
#editCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 0.8rem;
  border-radius: 0.5rem;
  background: #111827;
}

#editCanvas {
  display: none;
  touch-action: none;
}

#sourceVideo,
#sourceAudio {
  display: none;
}

.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.import-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.permission-list {
  display: grid;
  gap: 0.5rem;
}

.permission-list span {
  padding: 0.58rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: #f7fafc;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.permission-list span.ready {
  border-color: #c7e2dd;
  background: #e7f3f1;
  color: var(--accent-dark);
}

.permission-list span.blocked {
  border-color: #f1c0b9;
  background: #fff0ee;
  color: #a33c30;
}

.timeline {
  position: relative;
  height: 5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background:
    linear-gradient(90deg, rgba(95, 143, 216, 0.25) 0 20%, transparent 20% 22%),
    linear-gradient(90deg, #e7f3f1, #f8f1dd);
}

.timeline::before {
  content: "";
  position: absolute;
  inset: 0.8rem;
  border-radius: 0.35rem;
  background: repeating-linear-gradient(
    90deg,
    rgba(24, 33, 47, 0.18) 0 0.35rem,
    transparent 0.35rem 1rem
  );
}

.cut-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0.25rem;
  background: var(--coral);
}

.pro-editor {
  grid-template-columns: minmax(26rem, 1.35fr) minmax(23rem, 1fr);
}

.timeline-ruler {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.timeline-ruler span:not(:first-child) {
  text-align: center;
}

.multitrack {
  display: grid;
  height: auto;
  min-height: 23rem;
  gap: 0.35rem;
  padding: 0.6rem;
  overflow-x: auto;
  background: #f7fafc;
  touch-action: pan-x pan-y;
}

.multitrack::before {
  display: none;
}

.track-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(44rem, 1fr);
  gap: 0.55rem;
  min-height: 3.4rem;
}

.track-label {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.track-lane {
  position: relative;
  overflow: hidden;
  border: 1px solid #d6dde8;
  border-radius: 0.45rem;
  background:
    repeating-linear-gradient(90deg, rgba(24, 33, 47, 0.08) 0 1px, transparent 1px 4rem),
    #ffffff;
}

.clip {
  position: absolute;
  top: 0.45rem;
  bottom: 0.45rem;
  display: flex;
  align-items: center;
  min-width: 3rem;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 0.45rem;
  padding: 0 0.65rem;
  color: white;
  font-size: 0.8rem;
  font-weight: 850;
  white-space: nowrap;
  user-select: none;
  touch-action: none;
}

.clip.selected {
  border-color: #18212f;
  box-shadow: 0 0 0 3px rgba(24, 33, 47, 0.14);
}

.clip-video {
  background: #147d73;
}

.clip-audio {
  background: #5f8fd8;
}

.clip-image {
  background: #f2b84b;
  color: #3b2a03;
}

.clip-text,
.clip-captions {
  background: #e65f4f;
}

.clip-transitions {
  background: #59606d;
}

.clip-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0.45rem;
  background: rgba(255, 255, 255, 0.52);
}

.clip-handle.left {
  left: 0;
  cursor: ew-resize;
}

.clip-handle.right {
  right: 0;
  cursor: ew-resize;
}

.inspector-panel {
  grid-row: span 2;
}

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.caption-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.muted-copy {
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.waveform-panel {
  grid-column: 1 / -1;
}

#waveformCanvas {
  display: block;
  width: 100%;
  height: 10rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, rgba(95, 143, 216, 0.12), rgba(20, 125, 115, 0.08)),
    #ffffff;
}

#exportProgress {
  display: block;
  width: 100%;
  height: 0.9rem;
  margin: 0.75rem 0;
  accent-color: var(--accent);
}

.cut-list,
.caption-blocks {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.caption-layout,
.export-grid,
.asset-workspace,
.suite-grid,
.photo-studio-grid {
  grid-template-columns: minmax(18rem, 0.95fr) minmax(20rem, 1.05fr);
}

.asset-workspace,
.suite-grid,
.photo-studio-grid {
  display: grid;
  gap: 1rem;
}

.suite-grid,
.photo-studio-grid {
  grid-template-columns: repeat(2, minmax(18rem, 1fr));
}

.photo-canvas-panel {
  grid-row: span 2;
}

#photoCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #111827;
  touch-action: none;
}

.photo-tool {
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: white;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.photo-tool.active {
  border-color: var(--accent);
  background: #e7f3f1;
  color: var(--accent-dark);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.65rem;
}

.asset-card,
.module-card {
  display: grid;
  gap: 0.45rem;
  min-height: 8rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fbfcfe;
}

.asset-card strong,
.module-card strong {
  color: var(--ink);
}

.asset-card span,
.module-card span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

#scopeCanvas {
  display: block;
  width: 100%;
  height: 13rem;
  margin-top: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #111827;
}

.engine-list {
  display: grid;
  gap: 0.5rem;
}

.engine-list span {
  padding: 0.7rem;
  border-radius: 0.45rem;
  background: #f7fafc;
  color: var(--muted);
  font-weight: 800;
}

.engine-list span.ready {
  background: #e7f3f1;
  color: var(--accent-dark);
}

.checklist {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.checklist li {
  padding: 0.75rem 0.85rem;
  border-radius: 0.5rem;
  background: #f7fafc;
  color: var(--muted);
  font-weight: 750;
}

.checklist li.done {
  background: #e7f3f1;
  color: var(--accent-dark);
}

.subscription-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.58);
}

.subscription-modal.active {
  display: grid;
}

.subscription-dialog {
  width: min(34rem, 100%);
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.subscription-dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.2;
}

.subscription-check {
  margin-top: 0.85rem;
}

.subscription-dialog .edit-tools {
  margin-top: 1rem;
}

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

  .sidebar {
    position: sticky;
    z-index: 5;
    top: 0;
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    padding-inline: 0.35rem;
  }

  .setup-panel {
    display: none;
  }

  .stage-grid,
  .editor-layout,
  .caption-layout,
  .export-grid,
  .asset-workspace,
  .suite-grid,
  .photo-studio-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 0.85rem;
  }

  .topbar-actions,
  .edit-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions > *,
  .edit-tools > * {
    width: 100%;
  }

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

  h1 {
    font-size: 1.55rem;
  }
}
