:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #65716d;
  --line: #d9e2de;
  --soft: #f5f7f2;
  --paper: #ffffff;
  --brand: #0f8b6f;
  --accent: #f05a3d;
  --gold: #d6a83a;
  --sky: #2877b7;
  --danger: #bd2d35;
  --shadow: 0 16px 36px rgba(19, 33, 28, 0.11);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 139, 111, 0.08), transparent 280px),
    var(--soft);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    background 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
}

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

.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 139, 111, 0.22);
}

.ghost {
  background: #eef4f1;
  color: var(--ink);
  border: 1px solid #d8e3df;
}

.danger {
  background: #fff0ef;
  color: var(--danger);
  border: 1px solid #f1c9c5;
}

.full {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(16px, 3vw, 34px) 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

.top-actions,
.inline-actions,
.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(320px, 1fr) minmax(310px, 390px);
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 34px) 28px;
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 226, 222, 0.98);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head.slim {
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #35413d;
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: 0;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 139, 111, 0.14);
}

input[type="color"] {
  padding: 3px;
  height: 42px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--brand);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-badge {
  min-width: 52px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #fff6de;
  color: #84600d;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.canvas-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto auto auto;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #dbe6e0 25%, transparent 25%),
    linear-gradient(-45deg, #dbe6e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dbe6e0 75%),
    linear-gradient(-45deg, transparent 75%, #dbe6e0 75%);
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(68vh, 720px);
  border-radius: 8px;
  background: #f8faf9;
  box-shadow: 0 18px 45px rgba(24, 37, 31, 0.2);
}

.safe-zone {
  pointer-events: none;
  position: absolute;
  inset: 8%;
  border: 1px dashed rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(12, 20, 17, 0.08);
}

.hidden {
  display: none !important;
}

.timeline {
  margin-top: 12px;
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.asset-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.upload-box {
  align-content: center;
  min-height: 78px;
  margin: 0;
  padding: 12px;
  border: 1px dashed #aebdb7;
  border-radius: 8px;
  background: #f9fbf8;
  text-align: center;
  color: #41504b;
}

.upload-box input {
  margin-top: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: 11px;
}

.thumb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  margin-top: 12px;
  overflow-x: auto;
}

.asset-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #eef3f0;
  overflow: hidden;
  cursor: pointer;
}

.asset-thumb.active {
  border-color: var(--brand);
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  min-height: 34px;
  padding: 0 8px;
  background: #eef3ef;
  border: 1px solid transparent;
  color: #3a4742;
  font-size: 12px;
}

.tab.active {
  background: #fff;
  border-color: var(--brand);
  color: var(--brand);
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.scene-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 2px;
}

.scene-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.scene-row label {
  margin-bottom: 0;
}

.scene-row label:nth-of-type(2),
.scene-row label:nth-of-type(3) {
  grid-column: 2;
}

.scene-meta {
  display: grid;
  align-content: start;
  gap: 8px;
}

.scene-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e9f4ef;
  color: var(--brand);
  font-weight: 950;
}

.scene-duration {
  max-width: 62px;
  padding: 8px;
}

.status-box,
.premium-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
  color: #44514d;
  line-height: 1.45;
  margin: 12px 0;
}

.premium-box ul {
  margin: 0;
  padding-left: 18px;
}

.premium-box li {
  margin: 5px 0;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.check-row input {
  width: auto;
}

.export-check {
  margin: 12px 0;
}

.download-link {
  display: block;
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #eaf6f1;
  color: var(--brand);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

@media (max-width: 1180px) {
  .studio-grid {
    grid-template-columns: 340px minmax(320px, 1fr);
  }

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

  .scene-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .two-col,
  .asset-strip,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .canvas-panel {
    grid-template-rows: auto auto auto auto auto;
  }

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

  canvas {
    max-height: 64vh;
  }

  .scene-row {
    grid-template-columns: 1fr;
  }

  .scene-row label:nth-of-type(2),
  .scene-row label:nth-of-type(3) {
    grid-column: 1;
  }

  .scene-meta {
    grid-template-columns: 48px 80px;
    align-items: center;
  }

  .stack-on-mobile {
    align-items: stretch;
    flex-direction: column;
  }

  .stack-on-mobile button {
    width: 100%;
  }
}
