@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600;700;800;900&display=swap");

:root {
  color-scheme: light;
  font-family: "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --bg: #eef1f4;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #657180;
  --line: #d7dde4;
  --accent: #d92d20;
  --shadow: 0 16px 42px rgba(32, 42, 54, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.video-app {
  height: 100vh;
  display: grid;
  grid-template-columns: 640px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.control-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid rgba(23, 32, 42, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 16px;
  overflow: auto;
}

.preview-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 16px;
  overflow: hidden;
}

.brand-row,
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.18;
}

h2 {
  font-size: 20px;
}

.version-tag {
  color: var(--muted);
  font-size: 12px;
  vertical-align: middle;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

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

.field:has(#templateGroup) {
  display: none;
}

label {
  color: #2c3744;
  font-size: 14px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

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

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.12);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.asset-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 8px;
}

#mediaInput {
  display: none;
}

.asset-card {
  position: relative;
  min-height: 82px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  cursor: grab;
}

.asset-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 45, 32, 0.16);
}

.asset-thumb {
  width: 100%;
  height: 82px;
  object-fit: cover;
  display: block;
}

.asset-index,
.asset-type {
  position: absolute;
  top: 6px;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.asset-index {
  left: 6px;
}

.asset-type {
  right: 6px;
  padding: 0 7px;
}

.asset-actions {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: flex;
  gap: 4px;
}

.asset-actions button,
.asset-add {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-weight: 900;
}

.asset-actions button {
  width: 24px;
  height: 24px;
  padding: 0;
}

.asset-add {
  min-height: 82px;
  font-size: 28px;
}

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

.segment-list {
  display: grid;
  gap: 8px;
}

.segment-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 32px;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  padding: 8px;
}

.segment-card textarea {
  min-height: 78px;
}

.segment-card input {
  height: 42px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344050;
  font-weight: 900;
}

.brand-actions .icon-button {
  width: 42px;
  height: 42px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented.four {
  grid-template-columns: repeat(4, 1fr);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #f7f9fb;
  color: #344050;
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #17202a;
  color: #fff;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
}

#clearCoverBtn {
  margin-top: 8px;
}

.primary-button {
  margin-top: 12px;
  border: 0;
  background: var(--accent);
  color: #fff;
}

.export-progress {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 18, 26, 0.42);
  backdrop-filter: blur(4px);
}

.export-progress.hidden {
  display: none;
}

.export-progress-card {
  width: min(420px, 92vw);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(12, 18, 26, 0.28);
  padding: 22px;
}

.export-progress-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.export-progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf0;
}

.export-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.12s linear;
}

.export-progress-text {
  color: #344050;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #f7f9fb;
  color: #2f3b49;
}

.status-pill {
  border-radius: 999px;
  background: #f2f5f8;
  color: #344050;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 900;
}

.phone-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #dce2e8 25%, transparent 25%),
    linear-gradient(-45deg, #dce2e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce2e8 75%),
    linear-gradient(-45deg, transparent 75%, #dce2e8 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  padding: 14px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  box-shadow: 0 18px 48px rgba(20, 28, 38, 0.26);
}

@media (max-width: 980px) {
  body {
    height: auto;
    overflow: auto;
  }

  .video-app {
    height: auto;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .preview-panel {
    height: 760px;
    order: 1;
  }

  .control-panel {
    order: 2;
  }
}
