:root {
  color-scheme: light;
  --ink: #25231f;
  --muted: #7a756e;
  --line: #e9e2da;
  --cream: #fffaf5;
  --panel: rgba(255, 255, 255, 0.93);
  --accent: #e96f52;
  --accent-deep: #d95b3f;
  --accent-soft: #fff0e8;
  --sage: #8da68f;
  --shadow: 0 28px 80px rgba(81, 56, 37, 0.12);
  --shadow-soft: 0 12px 35px rgba(70, 48, 31, 0.08);
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(253, 218, 201, 0.55), transparent 28rem),
    radial-gradient(circle at 100% 90%, rgba(216, 228, 204, 0.55), transparent 32rem),
    #f7f4ef;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(215, 205, 194, 0.7);
  background: rgba(255, 250, 245, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border-radius: 15px 15px 17px 12px;
  background: linear-gradient(145deg, #f68a68, #dc5b44);
  box-shadow: 0 8px 18px rgba(221, 91, 67, 0.28);
  transform: rotate(-3deg);
}

.brand-mark span {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: #fff7f1;
}

.brand-mark span:nth-child(1) {
  width: 8px;
  height: 8px;
  left: 10px;
  top: 13px;
}

.brand-mark span:nth-child(2) {
  width: 8px;
  height: 8px;
  right: 10px;
  top: 13px;
}

.brand-mark span:nth-child(3) {
  width: 17px;
  height: 8px;
  bottom: 10px;
  left: 13px;
  border-radius: 4px 4px 12px 12px;
}

.brand strong {
  display: block;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.brand small {
  display: block;
  margin-top: 1px;
  color: #9b938b;
  font-family: ui-rounded, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

.privacy-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  color: #56705b;
  border: 1px solid #d8e2d4;
  border-radius: 999px;
  background: #f4f8f1;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.privacy-chip svg,
.privacy-note svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  font-weight: 800;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #d6c9bc;
  background: white;
}

.icon-button.small {
  width: 32px;
  height: 32px;
  font-size: 20px;
}

.icon-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 620px) minmax(420px, 1fr);
  width: min(1480px, 100%);
  min-height: calc(100vh - 74px);
  margin: 0 auto;
}

.editor-panel {
  padding: 42px clamp(24px, 4vw, 64px) 80px;
  border-right: 1px solid rgba(220, 210, 199, 0.8);
  background: rgba(255, 253, 249, 0.8);
}

.welcome-card .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.welcome-card .eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
}

.welcome-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif KR", serif;
  font-size: clamp(38px, 4.4vw, 58px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.055em;
}

.welcome-card p {
  max-width: 460px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 34px 0 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 8px;
  color: #8b847c;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.step span {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid #d9d0c6;
  border-radius: 50%;
  font-size: 10px;
}

.step.active,
.step:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.step.active span {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.editor-section {
  margin-top: 24px;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.section-heading,
.section-heading > div {
  display: flex;
  align-items: center;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 21px;
}

.section-heading > div {
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.035em;
}

.section-number {
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
}

.section-hint,
.count-badge {
  color: #9b938b;
  font-size: 11px;
}

.count-badge strong {
  color: var(--accent);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.field > span,
.option-group legend,
.range-field strong,
.music-field strong {
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fffdfb;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field textarea:focus,
.scene-caption:focus,
.scene-motion:focus {
  border-color: #eaa18d;
  box-shadow: 0 0 0 3px rgba(234, 132, 102, 0.12);
}

.upload-zone {
  display: flex;
  min-height: 202px;
  padding: 25px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1.5px dashed #e1b5a7;
  border-radius: 19px;
  background:
    linear-gradient(135deg, rgba(255, 244, 237, 0.75), rgba(255, 253, 250, 0.7)),
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(235, 128, 95, 0.025) 10px 20px);
  text-align: center;
  transition: 0.2s ease;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: #fff0e8;
  transform: translateY(-2px);
}

.upload-zone svg {
  width: 43px;
  margin-bottom: 11px;
  fill: none;
  stroke: #db7a5e;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.upload-zone strong {
  font-size: 13px;
}

.upload-zone > span {
  margin: 5px 0 13px;
  color: #a19991;
  font-size: 10px;
}

.secondary-button,
.primary-button,
.preview-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.secondary-button {
  padding: 9px 14px;
  color: #665f58;
  border: 1px solid #ded6cd;
  background: white;
  font-size: 11px;
}

.secondary-button:hover {
  border-color: #cfc1b4;
  box-shadow: 0 5px 14px rgba(72, 50, 35, 0.08);
}

.secondary-button.compact {
  padding: 8px 11px;
  white-space: nowrap;
}

.text-button {
  padding: 0;
  color: var(--accent-deep);
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.sample-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: #918a82;
  font-size: 10px;
}

.scene-list {
  display: grid;
  gap: 10px;
  margin-top: 15px;
}

.scene-item {
  display: grid;
  grid-template-columns: 18px 64px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffcf9;
  transition: opacity 0.2s, transform 0.2s, border-color 0.2s;
}

.scene-item.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.scene-item.drag-over {
  border-color: var(--accent);
}

.drag-handle {
  padding: 0;
  color: #bbb1a7;
  border: 0;
  background: none;
  font-size: 13px;
  letter-spacing: -4px;
  cursor: grab;
}

.scene-thumb {
  position: relative;
  height: 61px;
  overflow: hidden;
  border-radius: 10px;
  background: #eee8e1;
}

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

.scene-index {
  position: absolute;
  top: 5px;
  left: 5px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: white;
  border-radius: 50%;
  background: rgba(28, 24, 21, 0.68);
  font-size: 8px;
  font-weight: 800;
}

.scene-fields {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.scene-caption,
.scene-motion {
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: white;
  font-size: 10px;
}

.scene-motion {
  color: #746d66;
}

.scene-actions {
  display: grid;
  grid-template-columns: repeat(3, 25px);
  gap: 3px;
}

.scene-actions button {
  display: grid;
  width: 25px;
  height: 25px;
  padding: 0;
  place-items: center;
  color: #8a827a;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  font-size: 11px;
  cursor: pointer;
}

.scene-actions button:hover {
  color: var(--accent-deep);
  border-color: #e5a694;
}

.scene-actions .delete:hover {
  color: white;
  border-color: #d45443;
  background: #d45443;
}

.option-group {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.option-group legend {
  margin-bottom: 10px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f8f5f1;
}

.segmented-control button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px;
  color: #8a837b;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.segmented-control button.active {
  color: var(--accent-deep);
  background: white;
  box-shadow: 0 4px 12px rgba(57, 42, 31, 0.08);
}

.ratio-icon {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.ratio-icon.portrait {
  width: 7px;
  height: 12px;
}

.ratio-icon.landscape {
  width: 13px;
  height: 8px;
}

.ratio-icon.square {
  width: 10px;
  height: 10px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.theme-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  cursor: pointer;
}

.theme-card.active {
  border-color: #e8947d;
  box-shadow: 0 0 0 2px rgba(232, 112, 81, 0.1);
}

.theme-card strong,
.theme-card small {
  align-self: end;
  margin-left: 9px;
}

.theme-card strong {
  font-size: 11px;
}

.theme-card small {
  align-self: start;
  margin-top: 2px;
  color: #999087;
  font-size: 8px;
}

.theme-swatch {
  position: relative;
  grid-row: 1 / span 2;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 9px;
}

.theme-swatch i {
  position: absolute;
  width: 24px;
  height: 24px;
  right: -7px;
  bottom: -6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.theme-swatch.peach { background: linear-gradient(135deg, #f7c8b3, #d86651); }
.theme-swatch.sage { background: linear-gradient(135deg, #d9e2d2, #66876d); }
.theme-swatch.cream { background: linear-gradient(135deg, #f4e6cd, #9d7655); }
.theme-swatch.night { background: linear-gradient(135deg, #34445e, #111728); }

.range-field {
  display: grid;
  gap: 9px;
  margin: 19px 0;
}

.range-field > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.range-field output {
  color: var(--accent-deep);
  font-size: 10px;
  font-weight: 800;
}

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

.music-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.music-field > div {
  display: grid;
  gap: 3px;
  margin-right: auto;
  min-width: 0;
}

.music-field span {
  max-width: 230px;
  overflow: hidden;
  color: #918981;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consent-box {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 20px;
  padding: 17px 18px;
  color: #6f675f;
  border: 1px solid #ddd6cd;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  line-height: 1.65;
  cursor: pointer;
}

.consent-box.invalid {
  border-color: #df7158;
  animation: shake 0.35s;
}

.consent-box input {
  position: absolute;
  opacity: 0;
}

.custom-check {
  display: grid;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1.5px solid #cfc5bb;
  border-radius: 6px;
  background: white;
}

.consent-box input:checked + .custom-check {
  border-color: var(--accent);
  background: var(--accent);
}

.consent-box input:checked + .custom-check::after {
  content: "✓";
  color: white;
  font-size: 13px;
  font-weight: 900;
}

.consent-box strong {
  display: block;
  color: #48433e;
  font-size: 11px;
}

.preview-panel {
  position: sticky;
  top: 74px;
  display: flex;
  height: calc(100vh - 74px);
  min-height: 650px;
  padding: 30px clamp(24px, 4vw, 64px);
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(rgba(245, 240, 234, 0.88), rgba(245, 240, 234, 0.95)),
    repeating-linear-gradient(90deg, transparent 0 35px, rgba(82, 70, 60, 0.035) 35px 36px),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(82, 70, 60, 0.035) 35px 36px);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #807970;
  font-size: 10px;
}

.preview-header > div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4f4943;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #77a27a;
  box-shadow: 0 0 0 4px rgba(119, 162, 122, 0.13);
}

.stage-wrap {
  display: grid;
  min-width: 0;
  min-height: 0;
  flex: 1;
  padding: 22px 0;
  place-items: center;
}

.stage {
  position: relative;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border: 7px solid #2b2a29;
  border-radius: 30px;
  background: #f3d7ca;
  box-shadow: 0 30px 65px rgba(48, 38, 30, 0.25), 0 0 0 1px #111;
  transition: width 0.3s, aspect-ratio 0.3s;
}

.stage.portrait {
  width: min(42vh, 350px);
  aspect-ratio: 9 / 16;
}

.stage.landscape {
  width: 100%;
  max-width: 650px;
  aspect-ratio: 16 / 9;
}

.stage.square {
  width: min(52vh, 500px);
  aspect-ratio: 1 / 1;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #f3d7ca;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  flex-direction: column;
  color: #5c4238;
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.7), transparent 20%),
    linear-gradient(160deg, #f9ded1, #edb9a6);
  text-align: center;
}

.empty-preview.hidden {
  display: none;
}

.empty-preview > strong {
  margin: 25px 0 17px;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.04em;
}

.sparkle {
  position: absolute;
  color: rgba(255,255,255,0.8);
}

.sparkle.s1 { top: 16%; left: 19%; font-size: 20px; }
.sparkle.s2 { top: 26%; right: 18%; font-size: 11px; }

.empty-illustration {
  position: relative;
  width: 120px;
  height: 105px;
}

.photo-card {
  position: absolute;
  width: 82px;
  height: 96px;
  padding: 7px;
  overflow: hidden;
  border: 5px solid #fff8f2;
  border-bottom-width: 18px;
  border-radius: 3px;
  background: #dce6d8;
  box-shadow: 0 10px 24px rgba(104, 68, 52, 0.18);
}

.photo-card.back {
  left: 5px;
  top: 9px;
  background: #f0c3b4;
  transform: rotate(-11deg);
}

.photo-card.front {
  right: 6px;
  top: 2px;
  transform: rotate(8deg);
}

.photo-card .sun {
  position: absolute;
  width: 19px;
  height: 19px;
  top: 17px;
  right: 14px;
  border-radius: 50%;
  background: #f5c56d;
}

.photo-card .hill {
  position: absolute;
  width: 90px;
  height: 65px;
  bottom: -24px;
  border-radius: 50%;
}

.photo-card .hill.one { left: -26px; background: #94b18f; }
.photo-card .hill.two { right: -36px; bottom: -31px; background: #6f916f; }

.preview-add-button {
  padding: 10px 14px;
  color: #6c4336;
  border: 1px solid rgba(126, 76, 60, 0.24);
  background: rgba(255,255,255,0.54);
  font-size: 10px;
}

.local-badge {
  position: absolute;
  right: 10px;
  bottom: 9px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  color: white;
  border-radius: 999px;
  background: rgba(24, 27, 25, 0.46);
  font-family: ui-monospace, monospace;
  font-size: 7px;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}

.local-badge svg {
  width: 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.player-controls {
  display: flex;
  width: min(720px, 100%);
  margin: 0 auto;
  align-items: center;
  gap: 10px;
}

.play-button {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: white;
  border: 0;
  border-radius: 50%;
  background: #2e2b28;
  box-shadow: 0 7px 16px rgba(46, 43, 40, 0.2);
  cursor: pointer;
}

.play-button svg {
  width: 17px;
  fill: currentColor;
}

.play-button .pause-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.playing .pause-icon {
  display: block;
}

.timeline {
  width: 100%;
  min-width: 50px;
}

.timecode {
  min-width: 31px;
  color: #5f5953;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9px;
}

.timecode.muted {
  color: #a39b93;
}

.export-card {
  display: flex;
  width: min(720px, 100%);
  margin: 19px auto 0;
  padding: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid rgba(220, 210, 199, 0.85);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 25px rgba(66, 50, 37, 0.06);
}

.export-card > div,
.export-card > div > span:last-child {
  display: flex;
}

.export-card > div {
  align-items: center;
  gap: 10px;
}

.export-card > div > span:last-child {
  flex-direction: column;
  gap: 2px;
}

.export-card strong {
  font-size: 11px;
}

.export-card small {
  color: #928a82;
  font-size: 8px;
}

.export-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--accent-deep);
  border-radius: 10px;
  background: var(--accent-soft);
}

.export-icon svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.primary-button {
  min-height: 42px;
  padding: 10px 17px;
  color: white;
  border: 0;
  background: linear-gradient(135deg, #ec7b5d, #d85b42);
  box-shadow: 0 8px 20px rgba(218, 91, 66, 0.23);
  font-size: 11px;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(218, 91, 66, 0.3);
}

.primary-button:disabled {
  color: #aca49c;
  background: #e4dfda;
  box-shadow: none;
  cursor: not-allowed;
}

.primary-button svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-button.full {
  width: 100%;
  margin-top: 14px;
}

.privacy-note {
  display: flex;
  width: min(720px, 100%);
  margin: 13px auto 0;
  align-items: flex-start;
  gap: 8px;
  color: #7f7971;
}

.privacy-note svg {
  flex: 0 0 auto;
  width: 16px;
  color: #718b72;
}

.privacy-note p {
  margin: 0;
  font-size: 8px;
  line-height: 1.55;
}

.privacy-note strong {
  color: #5d755f;
}

.modal,
.export-dialog {
  width: min(460px, calc(100% - 30px));
  padding: 0;
  color: var(--ink);
  border: 0;
  border-radius: 25px;
  background: #fffdfb;
  box-shadow: var(--shadow);
}

.modal::backdrop,
.export-dialog::backdrop {
  background: rgba(37, 31, 27, 0.48);
  backdrop-filter: blur(5px);
}

.modal form {
  position: relative;
  padding: 34px;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  color: #918981;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  font-size: 19px;
  cursor: pointer;
}

.modal-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  place-items: center;
  color: var(--accent-deep);
  border-radius: 15px;
  background: var(--accent-soft);
  font-size: 22px;
}

.modal-icon.secure {
  color: #5f7b62;
  background: #edf4ea;
}

.modal-icon svg {
  width: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.modal h2,
.export-dialog h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.modal p,
.modal li {
  color: #756e66;
  font-size: 11px;
  line-height: 1.75;
}

.modal ul {
  margin: 17px 0;
  padding: 15px 18px 15px 32px;
  border-radius: 13px;
  background: #f7f5f1;
}

.help-list {
  display: grid;
  gap: 12px;
  margin: 20px 0;
  padding: 0;
  list-style: none;
}

.help-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.help-list li > span {
  display: grid;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  place-items: center;
  color: white;
  border-radius: 9px;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.help-list p {
  margin: 0;
}

.help-list strong {
  display: block;
  color: #4c4640;
  font-size: 12px;
}

.browser-tip {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f4ef;
  text-align: center;
}

.export-dialog {
  padding: 38px;
  text-align: center;
}

.render-visual {
  position: relative;
  display: grid;
  width: 90px;
  height: 90px;
  margin: 0 auto 23px;
  place-items: center;
}

.render-visual > svg {
  width: 27px;
  fill: none;
  stroke: #657f68;
  stroke-width: 1.5;
}

.render-orbit,
.render-orbit::before,
.render-orbit::after {
  position: absolute;
  inset: 0;
  border: 1px solid #e4ded7;
  border-radius: 50%;
}

.render-orbit {
  animation: spin 6s linear infinite;
}

.render-orbit::before,
.render-orbit::after {
  content: "";
  transform: rotate(60deg) scaleY(0.38);
}

.render-orbit::after {
  transform: rotate(-60deg) scaleY(0.38);
}

.render-orbit span {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.render-orbit span:nth-child(1) { top: 6px; left: 40px; }
.render-orbit span:nth-child(2) { right: 5px; bottom: 24px; background: #78977d; }
.render-orbit span:nth-child(3) { left: 7px; bottom: 20px; background: #d7a457; }

.export-dialog > p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 11px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee9e3;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #eb8668, #d96149);
  transition: width 0.18s linear;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: #9a9289;
  font-size: 9px;
}

.progress-meta span:first-child {
  color: var(--accent-deep);
  font-weight: 800;
}

.export-result {
  display: grid;
  gap: 12px;
  margin-top: -112px;
  padding-top: 115px;
  background: #fffdfb;
}

.export-result > div {
  display: grid;
  gap: 4px;
}

.export-result small {
  color: #8f877f;
  font-size: 9px;
}

.success-check {
  display: grid;
  width: 70px;
  height: 70px;
  margin: 0 auto;
  place-items: center;
  color: white;
  border-radius: 50%;
  background: #76987a;
  box-shadow: 0 10px 24px rgba(93, 132, 98, 0.25);
  font-size: 30px;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 28px;
  max-width: calc(100% - 30px);
  padding: 11px 16px;
  color: white;
  border-radius: 11px;
  background: rgba(37, 35, 31, 0.92);
  box-shadow: 0 10px 30px rgba(30, 25, 21, 0.2);
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    border-right: 0;
  }

  .preview-panel {
    position: relative;
    top: 0;
    height: auto;
    min-height: 820px;
  }

  .stage-wrap {
    min-height: 560px;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    padding: 9px 15px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
  }

  .brand-mark span:nth-child(3) {
    left: 10px;
  }

  .brand small,
  .privacy-chip {
    display: none;
  }

  .editor-panel {
    padding: 30px 15px 55px;
  }

  .welcome-card h1 {
    font-size: 42px;
  }

  .editor-section {
    padding: 19px;
    border-radius: 20px;
  }

  .scene-item {
    grid-template-columns: 14px 55px 1fr;
  }

  .scene-actions {
    grid-column: 2 / -1;
    justify-content: end;
  }

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

  .preview-panel {
    padding: 23px 15px 45px;
    min-height: 740px;
  }

  .stage-wrap {
    min-height: 480px;
  }

  .stage.portrait {
    width: min(74vw, 315px);
  }

  .stage.landscape {
    width: 100%;
  }

  .stage.square {
    width: min(83vw, 390px);
  }

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

  .primary-button {
    width: 100%;
  }

  .modal form,
  .export-dialog {
    padding: 27px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
