:root {
  color-scheme: light;
  --bg: #fff1f5;
  --paper: rgba(255, 253, 250, 0.93);
  --ink: #35202f;
  --muted: #806e78;
  --line: #ead1dc;
  --accent: #c84678;
  --accent-strong: #9e2d5c;
  --blue: #3d8fa1;
  --mint: #6fb69b;
  --butter: #f3bd4f;
  --danger: #b84c43;
  --shadow: 0 20px 54px rgba(139, 67, 107, 0.16);
  font-family: Inter, Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 213, 228, 0.95), transparent 30%),
    radial-gradient(circle at 86% 9%, rgba(222, 235, 189, 0.85), transparent 26%),
    linear-gradient(135deg, #fff6ee 0%, #fff1f5 42%, #f4fbf4 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button,
a.primary {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(49, 111, 163, 0.35);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.page {
  min-height: 100vh;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 36%, #ffe2ed, transparent 34%),
    linear-gradient(135deg, #fffaf4, #fff1f7);
  transition: opacity 280ms ease, visibility 280ms ease;
}

.splash.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-mark,
.app-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 20%, rgba(224, 245, 226, 0.88), transparent 38%),
    linear-gradient(145deg, #fff8f4, #ffe1ed);
  box-shadow: 0 14px 30px rgba(139, 67, 107, 0.16);
  color: transparent;
  font-size: 0;
}

.splash-mark::before,
.app-mark::before {
  content: "";
  position: absolute;
  inset: 9px;
  background:
    radial-gradient(ellipse at 28% 30%, #cf497e 0 22%, transparent 23%),
    radial-gradient(ellipse at 72% 30%, #cf497e 0 22%, transparent 23%),
    radial-gradient(ellipse at 31% 72%, #e66fa0 0 18%, transparent 19%),
    radial-gradient(ellipse at 70% 72%, #58a8ba 0 18%, transparent 19%),
    radial-gradient(ellipse at 50% 50%, #5c2d52 0 8%, transparent 9%),
    linear-gradient(72deg, transparent 0 44%, #5c2d52 45% 50%, transparent 51%),
    linear-gradient(108deg, transparent 0 44%, #5c2d52 45% 50%, transparent 51%);
  filter: drop-shadow(0 5px 8px rgba(107, 49, 92, 0.14));
}

.splash-name {
  margin-top: 112px;
  font-size: 24px;
  font-weight: 800;
}

.splash-studio {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 14px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  margin: 18px 0 22px;
  font-size: 28px;
}

.stack {
  display: grid;
  gap: 14px;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
}

label span,
legend {
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
}

textarea {
  resize: vertical;
  min-height: 156px;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #e6819f);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  padding: 0 18px;
}

.primary:hover {
  background: linear-gradient(135deg, var(--accent-strong), #d76088);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.app-view {
  padding: 14px 18px 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1280px;
  min-height: 28px;
  margin: 0 auto 2px;
}

.kicker {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
}

.floral-ribbon {
  max-width: 1280px;
  height: 88px;
  margin: 0 auto 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.floral-ribbon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ribbon-vine {
  fill: none;
  stroke: #6fb69b;
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.72;
}

.ribbon-vine.soft {
  stroke: #b9d9a8;
  stroke-width: 5;
  opacity: 0.44;
}

.ribbon-leaf {
  fill: #9fcb91;
  opacity: 0.92;
}

.ribbon-flower {
  filter: drop-shadow(0 8px 12px rgba(200, 70, 120, 0.2));
}

.ribbon-flower.pink {
  fill: #ef6f9e;
}

.ribbon-flower.peach {
  fill: #f0a15f;
}

.ribbon-flower.blue {
  fill: #68b8c6;
}

.ribbon-flower.lilac {
  fill: #b897e8;
}

.ribbon-core {
  fill: #f3bd4f;
}

.ribbon-butterfly {
  filter: drop-shadow(0 8px 10px rgba(107, 49, 92, 0.18));
}

.ribbon-butterfly.rose {
  fill: rgba(200, 70, 120, 0.84);
}

.ribbon-butterfly.teal {
  fill: rgba(61, 143, 161, 0.82);
}

.ribbon-body {
  fill: none;
  stroke: #6b315c;
  stroke-width: 4;
  stroke-linecap: round;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--accent-strong);
}

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

.icon-button:hover {
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

.main-column,
.side-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(12px);
}

.panel::before {
  content: "";
  position: absolute;
  top: 8px;
  right: 12px;
  width: 72px;
  height: 72px;
  pointer-events: none;
  opacity: 0.22;
  background:
    radial-gradient(circle at 50% 20%, #ef6f9e 0 12px, transparent 13px),
    radial-gradient(circle at 76% 42%, #ef6f9e 0 12px, transparent 13px),
    radial-gradient(circle at 66% 72%, #ef6f9e 0 12px, transparent 13px),
    radial-gradient(circle at 34% 72%, #ef6f9e 0 12px, transparent 13px),
    radial-gradient(circle at 24% 42%, #ef6f9e 0 12px, transparent 13px),
    radial-gradient(circle at 50% 50%, #f3bd4f 0 8px, transparent 9px);
}

.panel:nth-of-type(2)::before {
  background:
    radial-gradient(circle at 50% 20%, #68b8c6 0 12px, transparent 13px),
    radial-gradient(circle at 76% 42%, #68b8c6 0 12px, transparent 13px),
    radial-gradient(circle at 66% 72%, #68b8c6 0 12px, transparent 13px),
    radial-gradient(circle at 34% 72%, #68b8c6 0 12px, transparent 13px),
    radial-gradient(circle at 24% 42%, #68b8c6 0 12px, transparent 13px),
    radial-gradient(circle at 50% 50%, #f3bd4f 0 8px, transparent 9px);
}

.panel > * {
  position: relative;
  z-index: 1;
}

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

.panel h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 18px;
}

.panel h2::before {
  content: "";
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 17%, #ef6f9e 0 5px, transparent 6px),
    radial-gradient(circle at 80% 42%, #ef6f9e 0 5px, transparent 6px),
    radial-gradient(circle at 68% 78%, #ef6f9e 0 5px, transparent 6px),
    radial-gradient(circle at 32% 78%, #ef6f9e 0 5px, transparent 6px),
    radial-gradient(circle at 20% 42%, #ef6f9e 0 5px, transparent 6px),
    radial-gradient(circle at 50% 52%, #f3bd4f 0 4px, transparent 5px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe5ef, #e6f5ed);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

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

.file-drop {
  position: relative;
  min-height: 126px;
  border: 1px dashed #a7aaa2;
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #fffaf8, #fff1f6);
  cursor: pointer;
}

.file-drop::before {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 54px;
  height: 38px;
  pointer-events: none;
  opacity: 0.32;
  background:
    radial-gradient(ellipse at 26% 32%, #c84678 0 14px, transparent 15px),
    radial-gradient(ellipse at 76% 32%, #3d8fa1 0 14px, transparent 15px),
    radial-gradient(ellipse at 28% 76%, #d76088 0 11px, transparent 12px),
    radial-gradient(ellipse at 74% 76%, #68b8c6 0 11px, transparent 12px),
    linear-gradient(#6b315c, #6b315c);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 4px 34px;
  background-position: center, center, center, center, center;
  background-repeat: no-repeat;
}

.file-drop strong {
  display: block;
  margin-top: 12px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.file-drop small {
  color: var(--muted);
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.text-field {
  margin-top: 14px;
}

fieldset {
  border: 0;
  padding: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9e9f0;
}

.segmented button {
  min-height: 38px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.segmented button.active {
  background: var(--paper);
  color: var(--accent-strong);
  box-shadow: 0 5px 16px rgba(200, 70, 120, 0.16);
}

.range-field {
  grid-column: 1 / -1;
}

.range-field span {
  display: flex;
  justify-content: space-between;
}

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

.wide {
  width: 100%;
  margin-top: 16px;
}

.narration-list,
.music-list {
  display: grid;
  gap: 10px;
}

.narration-item,
.music-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(135deg, #fffaf8, #fff2f7);
}

.narration-item.selected,
.music-item.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.narration-item p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  max-height: 76px;
  overflow: hidden;
}

.narration-item audio,
.active-audio audio {
  width: 100%;
}

.select-inline {
  width: 100%;
}

.active-audio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, #fffaf8, #fff1f6);
}

.active-audio strong {
  display: block;
  margin-bottom: 4px;
}

.controls-grid.compact {
  align-items: end;
  margin-top: 14px;
}

.action-button {
  min-height: 48px;
}

.mode-field {
  margin-top: 14px;
}

.music-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.music-title strong {
  overflow-wrap: anywhere;
}

.music-meta {
  color: var(--muted);
  font-size: 13px;
}

.player-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.player-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.player-actions .danger {
  color: var(--danger);
}

.result-panel video {
  width: 100%;
  max-height: 520px;
  background: #111;
  border-radius: 18px;
}

.download-link {
  width: 100%;
  margin-top: 12px;
}

dialog {
  width: min(420px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(65, 35, 55, 0.42);
  backdrop-filter: blur(4px);
}

.modal-form {
  padding: 20px;
}

.modal-form h2 {
  margin: 0 0 4px;
}

#settingsDialog {
  width: min(340px, calc(100vw - 32px));
  max-height: min(430px, calc(100dvh - 32px));
  overflow: hidden;
}

#settingsDialog .modal-form {
  gap: 10px;
  padding: 16px;
}

#settingsDialog .modal-form h2 {
  font-size: 18px;
  line-height: 1.15;
}

#settingsDialog input {
  min-height: 42px;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 16px;
}

#settingsDialog .message {
  min-height: 18px;
  font-size: 13px;
}

#settingsDialog .modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#settingsDialog button {
  min-height: 40px;
  border-radius: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#settingsDialog .modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.garden-decor {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  opacity: 0.72;
  filter: drop-shadow(0 18px 24px rgba(139, 67, 107, 0.12));
}

.garden-decor svg {
  width: 220px;
  height: 390px;
}

.garden-decor-left {
  left: -34px;
  bottom: -38px;
}

.garden-decor-right {
  right: -28px;
  top: 74px;
}

.stem {
  fill: none;
  stroke: var(--mint);
  stroke-width: 5;
  stroke-linecap: round;
}

.leaf {
  fill: #b9ddbd;
  opacity: 0.9;
}

.flower {
  fill: #ec7aa0;
}

.flower.peach {
  fill: #f3a76f;
}

.flower.lavender {
  fill: #b79ce6;
}

.flower .core {
  fill: var(--butter);
}

.butterfly {
  fill: rgba(190, 86, 156, 0.78);
}

.butterfly.small {
  fill: rgba(61, 143, 161, 0.78);
}

.butterfly .body {
  fill: none;
  stroke: #6b315c;
  stroke-width: 4;
  stroke-linecap: round;
}

.app-view,
.login-view {
  position: relative;
  z-index: 1;
}

.progress-dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  overflow: hidden;
}

.progress-dialog[open] {
  display: grid;
}

.progress-scene {
  position: relative;
  min-height: 220px;
  background:
    radial-gradient(circle at 26% 24%, #ffe0ec, transparent 24%),
    radial-gradient(circle at 78% 20%, #e4f6e4, transparent 24%),
    linear-gradient(135deg, #fffaf4, #fff0f7);
}

.progress-butterfly {
  position: absolute;
  z-index: 2;
  width: 104px;
  left: 32px;
  top: 42px;
  fill: #c84678;
  animation: butterfly-flight 2.8s ease-in-out infinite;
}

.progress-butterfly .body,
.progress-butterfly .antenna {
  fill: none;
  stroke: #6b315c;
  stroke-width: 4;
  stroke-linecap: round;
}

.bloom {
  position: absolute;
  z-index: 1;
  width: 176px;
  right: 34px;
  bottom: -4px;
}

.bloom-stem {
  fill: none;
  stroke: var(--mint);
  stroke-width: 7;
  stroke-linecap: round;
}

.bloom-petals {
  fill: #ef6f9e;
  filter: drop-shadow(0 8px 12px rgba(200, 70, 120, 0.2));
  transform-box: fill-box;
  transform-origin: center;
  animation: bloom-open 2.4s ease-in-out infinite;
}

.bloom-core {
  fill: var(--butter);
}

.progress-copy {
  display: grid;
  gap: 10px;
  padding: 20px;
  text-align: center;
}

.progress-copy h2,
.progress-copy p {
  margin: 0;
}

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

.progress-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c84678, #f3bd4f, #6fb69b);
  transition: width 360ms ease;
}

#progressPercent {
  color: var(--accent-strong);
}

@keyframes butterfly-flight {
  0%, 100% {
    transform: translate(0, 0) rotate(-8deg) scale(1);
  }
  35% {
    transform: translate(76px, -18px) rotate(9deg) scale(0.96);
  }
  70% {
    transform: translate(126px, 26px) rotate(-2deg) scale(1.04);
  }
}

@keyframes bloom-open {
  0%, 100% {
    transform: translate(80px, 66px) scale(0.72) rotate(-4deg);
    opacity: 0.76;
  }
  55% {
    transform: translate(80px, 66px) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@media (max-width: 920px) {
  .workspace,
  .grid.two,
  .controls-grid,
  .active-audio {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .app-view {
    padding: 12px;
  }

  .topbar {
    min-height: 26px;
    margin-bottom: 4px;
  }

  .panel {
    padding: 14px;
  }

  .floral-ribbon {
    height: 72px;
    margin: 0 auto 10px;
  }

  .floral-ribbon svg {
    width: 170%;
    transform: translateX(-24%) translateY(-2px);
  }

  .garden-decor {
    opacity: 0.5;
  }

  .garden-decor svg {
    width: 160px;
  }

  .garden-decor-right {
    top: 160px;
  }

  #settingsDialog {
    width: min(320px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
  }

  #settingsDialog .modal-form {
    padding: 14px;
  }
}
