:root {
  color-scheme: light;
  --ink: #273036;
  --muted: #75818a;
  --paper: #fffdf9;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(102, 119, 128, 0.18);
  --mint: #8fd6c8;
  --mint-deep: #259184;
  --peach: #ffb8a5;
  --rose: #f5a6c5;
  --lemon: #f7dd8c;
  --sky: #a8d8f0;
  --lilac: #cfc2f4;
  --shadow: 0 24px 70px rgba(94, 118, 122, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    "Microsoft YaHei", "PingFang SC", Inter, ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 184, 165, 0.38), transparent 32%),
    radial-gradient(circle at 80% 4%, rgba(168, 216, 240, 0.42), transparent 34%),
    radial-gradient(circle at 70% 88%, rgba(143, 214, 200, 0.35), transparent 36%),
    linear-gradient(135deg, rgba(255, 253, 249, 0.92), rgba(246, 251, 248, 0.96)),
    var(--paper);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sprite {
  display: none;
}

.ambient-canvas,
.fireworks-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.result-backdrop-stack {
  position: fixed;
  inset: -48px;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1200ms ease;
}

.result-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: var(--result-bg-image);
  background-size: cover;
  background-position: center;
  filter: blur(22px) saturate(1.18) brightness(1.03);
  transform: scale(1.06);
  transition: opacity 1400ms ease, filter 1400ms ease;
}

.result-backdrop.is-active {
  opacity: 1;
}

.result-backdrop-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 253, 249, 0.44), rgba(255, 255, 255, 0.22) 42%, rgba(143, 214, 200, 0.18)),
    radial-gradient(circle at 18% 18%, rgba(255, 184, 165, 0.24), transparent 32%),
    radial-gradient(circle at 82% 76%, rgba(207, 194, 244, 0.2), transparent 34%);
}

body.has-result-bg .result-backdrop-stack {
  opacity: 1;
}

.ambient-canvas {
  z-index: 8;
  opacity: 0.96;
}

.fireworks-canvas {
  z-index: 60;
  opacity: 0;
  transition: opacity 300ms ease;
}

.fireworks-canvas.show {
  opacity: 1;
}

.mouse-trail,
.snow-trail {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  z-index: 80;
  transform: translate(-50%, -50%);
}

.mouse-trail {
  width: 12px;
  height: 12px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.92), rgba(168, 216, 240, 0));
  animation: trailFade 720ms ease-out forwards;
}

.snow-trail {
  width: 24px;
  height: 18px;
  display: grid;
  place-items: center;
  color: rgba(255, 182, 203, 0.94);
  font-size: 18px;
  line-height: 1;
  text-shadow:
    0 0 8px rgba(255, 204, 220, 0.95),
    0 0 16px rgba(245, 166, 197, 0.55);
  animation: petalTrailFade 1080ms ease-out forwards;
}

.snow-trail::before {
  content: "";
  width: 16px;
  height: 11px;
  display: block;
  border-radius: 80% 20% 75% 28%;
  background:
    radial-gradient(circle at 34% 35%, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(135deg, rgba(255, 238, 244, 0.96), currentColor);
  box-shadow: 0 0 10px rgba(245, 166, 197, 0.5);
  transform: rotate(var(--petal-rotate, 18deg));
}

.click-ripple {
  position: fixed;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 81;
  border: 2px solid rgba(245, 128, 168, 0.62);
  box-shadow:
    0 0 16px rgba(245, 166, 197, 0.3),
    inset 0 0 10px rgba(255, 255, 255, 0.52);
  transform: translate(-50%, -50%) scale(0.4);
  animation: ripple 860ms ease-out forwards;
}

.app {
  position: relative;
  z-index: 2;
  width: min(1280px, calc(100vw - 34px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 20px;
}

.eyebrow,
.subtitle,
.section-kicker,
.label,
.field span,
small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 46px;
  line-height: 1.04;
  font-weight: 820;
}

.subtitle {
  margin-top: 10px;
  font-size: 15px;
}

.status-card {
  min-width: 184px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 14px 40px rgba(121, 143, 150, 0.12);
  backdrop-filter: blur(16px);
}

.status-card span {
  display: block;
  font-size: 15px;
  font-weight: 800;
}

.status-card small {
  display: block;
  max-width: 280px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--lemon);
  box-shadow: 0 0 0 7px rgba(247, 221, 140, 0.28);
}

.status-card.running .status-dot {
  background: var(--mint-deep);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-card.done .status-dot {
  background: #5bbd8d;
  box-shadow: 0 0 0 7px rgba(91, 189, 141, 0.22);
}

.status-card.failed .status-dot {
  background: #e9788d;
  box-shadow: 0 0 0 7px rgba(233, 120, 141, 0.22);
}

.studio {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

body.has-result-bg .panel {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.36);
  box-shadow: 0 24px 72px rgba(55, 74, 78, 0.2);
}

body.has-result-bg .status-card {
  background: rgba(255, 255, 255, 0.42);
}

.input-panel {
  padding: 20px;
}

.section-title,
.preview-head,
.run-row,
.drop-actions,
.toggle-row {
  display: flex;
  align-items: center;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 820;
}

.ghost-icon {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 14px;
  color: #7b6a72;
  background: rgba(245, 166, 197, 0.16);
}

.ghost-icon:hover {
  transform: translateY(-1px);
  background: rgba(245, 166, 197, 0.25);
}

.drop-zone {
  position: relative;
  min-height: 238px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  border: 2px dashed rgba(37, 145, 132, 0.35);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(143, 214, 200, 0.24), rgba(255, 255, 255, 0.5)),
    linear-gradient(315deg, rgba(255, 184, 165, 0.18), transparent);
  overflow: hidden;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.drop-zone::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  pointer-events: none;
}

.drop-zone:hover,
.drop-zone.dragging {
  transform: translateY(-2px);
  border-color: rgba(37, 145, 132, 0.8);
  box-shadow: 0 18px 44px rgba(37, 145, 132, 0.18);
}

.drop-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 22px;
  color: var(--mint-deep);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(37, 145, 132, 0.12);
}

.drop-icon svg {
  width: 30px;
  height: 30px;
}

.drop-zone h2 {
  font-size: 21px;
  font-weight: 830;
}

.drop-zone p {
  max-width: 312px;
  margin: 8px auto 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.drop-actions {
  justify-content: center;
  gap: 10px;
}

.drop-copy {
  position: relative;
  z-index: 1;
}

.input-preview {
  position: relative;
  z-index: 2;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  animation: riseIn 260ms ease both;
}

.input-preview[hidden] {
  display: none;
}

.input-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(102, 119, 128, 0.15),
    0 12px 28px rgba(86, 112, 118, 0.12);
}

.source-preview-open {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--image-ratio, 4 / 3);
  max-height: 260px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: transparent;
  cursor: zoom-in;
}

.source-preview-open span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #6b4f5a;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(86, 112, 118, 0.12);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 820;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.source-preview-open:hover span {
  opacity: 1;
  transform: translateY(0);
}

.input-preview-main {
  display: grid;
  gap: 9px;
}

.input-preview .preview-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 820;
}

.input-preview .preview-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.input-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.input-thumb {
  position: relative;
  min-height: 58px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 0 0 1px rgba(102, 119, 128, 0.18),
    0 8px 18px rgba(86, 112, 118, 0.1);
}

.input-thumb.active {
  box-shadow:
    inset 0 0 0 2px rgba(245, 128, 168, 0.74),
    0 10px 22px rgba(245, 128, 168, 0.18);
}

.input-thumb img {
  width: 100%;
  height: 58px;
  max-height: none;
  display: block;
  object-fit: cover;
  border-radius: 0;
  box-shadow: none;
}

.input-thumb-more {
  min-height: 58px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #6b5961;
  background: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 820;
  box-shadow: inset 0 0 0 1px rgba(102, 119, 128, 0.18);
}

.input-file-list {
  max-height: 84px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.54);
  color: #53636b;
  font-size: 12px;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(102, 119, 128, 0.14);
}

.input-file-list div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-file-list div + div {
  margin-top: 4px;
}

.drop-zone.has-preview .drop-copy {
  display: none;
}

.drop-actions button,
.run-row button,
.segments button {
  border: 0;
  border-radius: 999px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.drop-actions button {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  color: #35545a;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(102, 119, 128, 0.13);
}

.drop-actions button:hover,
.run-row button:hover:not(:disabled),
.segments button:hover {
  transform: translateY(-1px);
}

.source-strip {
  min-height: 46px;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  color: #58676c;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 1px var(--line);
}

.field {
  display: block;
  margin: 14px 0;
}

.field span,
.label {
  display: block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 820;
}

input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 0 15px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

input[type="text"]:focus {
  box-shadow:
    inset 0 0 0 1px rgba(37, 145, 132, 0.5),
    0 0 0 5px rgba(143, 214, 200, 0.18);
}

.controls-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segments.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segments button {
  min-height: 39px;
  padding: 0 10px;
  color: #506169;
  background: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 780;
  box-shadow: inset 0 0 0 1px var(--line);
}

.segments button.active {
  color: #174f4c;
  background: linear-gradient(135deg, rgba(143, 214, 200, 0.72), rgba(247, 221, 140, 0.58));
  box-shadow:
    inset 0 0 0 1px rgba(37, 145, 132, 0.24),
    0 10px 24px rgba(37, 145, 132, 0.12);
}

.model-fixed {
  min-height: 62px;
  display: grid;
  gap: 5px;
  padding: 13px 15px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(143, 214, 200, 0.28), rgba(245, 166, 197, 0.22)),
    rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 0 0 1px rgba(37, 145, 132, 0.16),
    0 10px 24px rgba(86, 112, 118, 0.1);
}

.model-fixed strong {
  color: #244447;
  font-size: 15px;
  font-weight: 860;
}

.model-fixed span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.toggle-row {
  gap: 10px;
  margin-top: 14px;
}

.toggle-row label {
  flex: 1;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  color: #53636b;
  font-size: 13px;
  font-weight: 720;
  box-shadow: inset 0 0 0 1px var(--line);
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--mint-deep);
}

.run-row {
  gap: 12px;
  margin-top: 18px;
}

.run-row button {
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  font-weight: 840;
}

.run-button {
  flex: 1.3;
  color: #123f3d;
  background: linear-gradient(135deg, var(--mint), var(--lemon));
  box-shadow: 0 16px 34px rgba(37, 145, 132, 0.2);
}

.run-button.running {
  animation: breathe 1.4s ease-in-out infinite;
}

.soft-button {
  flex: 1;
  color: #674b54;
  background: rgba(245, 166, 197, 0.32);
}

.preview-panel {
  min-height: 720px;
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr) auto;
  overflow: hidden;
}

.preview-head {
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.section-kicker {
  font-size: 12px;
  font-weight: 820;
}

.preview-head h2 {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 830;
}

.progress-shell {
  width: min(230px, 38vw);
  height: 12px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px var(--line);
}

.progress-shell span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--peach), var(--lemon));
  transition: width 220ms ease;
}

.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(143, 214, 200, 0.13), rgba(245, 166, 197, 0.1)),
    rgba(255, 255, 255, 0.42);
}

.output-current {
  min-width: 0;
}

.output-current span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.output-current strong {
  display: block;
  max-width: 360px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #34434a;
  font-size: 13px;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.output-actions button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  color: #486168;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 820;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.output-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(143, 214, 200, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(37, 145, 132, 0.2),
    0 8px 18px rgba(86, 112, 118, 0.12);
}

.output-actions svg {
  width: 15px;
  height: 15px;
}

.preview-stage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-content: start;
  padding: 20px;
  overflow: auto;
}

.empty-preview {
  grid-column: 1 / -1;
  min-height: 330px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(207, 194, 244, 0.2), transparent),
    rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 0 0 1px var(--line);
}

.empty-preview svg {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  color: #94a2a8;
}

.empty-preview p {
  font-weight: 820;
}

.preview-card {
  display: grid;
  grid-template-rows: auto auto;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 14px 34px rgba(86, 112, 118, 0.12);
  animation: riseIn 360ms ease both;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.preview-card.selected {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.76);
  box-shadow:
    inset 0 0 0 2px rgba(37, 145, 132, 0.38),
    0 18px 42px rgba(37, 145, 132, 0.16);
}

.preview-select {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--image-ratio, 1);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(250, 250, 247, 0.9);
  cursor: pointer;
  overflow: hidden;
}

.preview-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transition: transform 220ms ease;
}

.preview-card:hover img {
  transform: scale(1.018);
}

.selected-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(37, 145, 132, 0.88);
  box-shadow: 0 8px 18px rgba(37, 145, 132, 0.22);
  font-size: 12px;
  font-weight: 840;
}

.preview-card.selected .selected-mark {
  display: block;
}

.preview-info {
  padding: 12px 14px 14px;
}

.preview-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.preview-info span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.preview-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.preview-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  color: #476067;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  font-size: 12px;
  font-weight: 780;
  box-shadow: inset 0 0 0 1px var(--line);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.preview-actions button:hover {
  transform: translateY(-1px);
  background: rgba(143, 214, 200, 0.25);
  box-shadow:
    inset 0 0 0 1px rgba(37, 145, 132, 0.18),
    0 8px 18px rgba(86, 112, 118, 0.12);
}

.preview-actions svg {
  width: 15px;
  height: 15px;
}

.preview-actions button span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.log-drawer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.46);
}

.log-drawer summary {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 22px;
  color: #4d5c63;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

pre {
  max-height: 210px;
  margin: 0;
  padding: 16px 20px 20px;
  overflow: auto;
  color: #244447;
  background: rgba(241, 251, 248, 0.62);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 26px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.preview-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(39, 48, 54, 0.42);
  backdrop-filter: blur(16px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 52px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-radius: 30px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 32px 90px rgba(28, 42, 45, 0.32);
  transform: translateY(14px) scale(0.98);
  transition: transform 200ms ease;
}

.preview-modal.open .modal-panel {
  transform: translateY(0) scale(1);
}

.modal-panel img {
  width: 100%;
  max-height: calc(100vh - 132px);
  display: block;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(168, 216, 240, 0.16), transparent),
    rgba(255, 253, 249, 0.92);
}

.modal-caption {
  padding: 13px 18px 16px;
  color: #53636b;
  font-size: 13px;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #624b55;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 24px rgba(39, 48, 54, 0.16);
}

.compare-panel {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100vw - 38px));
  height: min(860px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 32px 90px rgba(28, 42, 45, 0.34);
  transform: translateY(14px) scale(0.98);
  transition: transform 200ms ease;
}

.compare-modal.open .compare-panel {
  transform: translateY(0) scale(1);
}

.compare-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px 12px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(245, 166, 197, 0.16), transparent),
    rgba(255, 255, 255, 0.62);
}

.compare-head strong {
  display: block;
  font-size: 16px;
  font-weight: 840;
}

.compare-head span {
  display: block;
  max-width: 560px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.compare-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-tools button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  color: #624b55;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 840;
}

.compare-tools .modal-close {
  position: static;
  width: 38px;
  height: 38px;
}

.compare-tools input[type="range"] {
  width: 150px;
  accent-color: var(--rose);
}

.compare-tools #compareZoomLabel {
  width: 48px;
  margin: 0;
  text-align: center;
  color: #53636b;
  font-size: 12px;
  font-weight: 820;
}

.compare-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(102, 119, 128, 0.14);
}

.compare-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(45deg, rgba(168, 216, 240, 0.14), transparent),
    rgba(255, 253, 249, 0.94);
}

.compare-label {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  padding: 7px 11px;
  border-radius: 999px;
  color: #5d4b54;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 22px rgba(86, 112, 118, 0.12);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 840;
}

.compare-viewport {
  width: 100%;
  height: 100%;
  overflow: auto;
  cursor: grab;
  scrollbar-color: rgba(245, 166, 197, 0.72) rgba(255, 255, 255, 0.46);
}

.compare-viewport.dragging {
  cursor: grabbing;
  user-select: none;
}

.compare-viewport img {
  max-width: none;
  display: block;
  margin: 52px auto 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    0 0 0 1px rgba(102, 119, 128, 0.18),
    0 16px 40px rgba(86, 112, 118, 0.14);
}

.mobile-actionbar {
  display: none;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(143, 214, 200, 0.22);
  }
  50% {
    transform: scale(1.12);
    box-shadow: 0 0 0 12px rgba(143, 214, 200, 0.08);
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 16px 34px rgba(37, 145, 132, 0.18);
  }
  50% {
    box-shadow: 0 22px 44px rgba(37, 145, 132, 0.32);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes trailFade {
  from {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.2);
  }
}

@keyframes petalTrailFade {
  from {
    opacity: 0.92;
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(-34%, -94%) scale(1.48) rotate(120deg);
  }
}

@keyframes ripple {
  from {
    opacity: 0.78;
    transform: translate(-50%, -50%) scale(0.4);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(5.8);
  }
}

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

  .ambient-canvas,
  .fireworks-canvas,
  .mouse-trail,
  .click-ripple {
    display: none;
  }
}

@media (max-width: 980px) {
  h1 {
    font-size: 40px;
  }

  .masthead {
    align-items: start;
    flex-direction: column;
  }

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

  .preview-panel {
    min-height: 560px;
  }

  .compare-panel {
    height: calc(100vh - 28px);
  }

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

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

@media (max-width: 620px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    background:
      radial-gradient(circle at 18% 4%, rgba(255, 184, 165, 0.24), transparent 34%),
      radial-gradient(circle at 86% 8%, rgba(168, 216, 240, 0.26), transparent 36%),
      linear-gradient(180deg, rgba(255, 253, 249, 0.96), rgba(246, 251, 248, 0.98)),
      var(--paper);
  }

  .app {
    width: 100%;
    padding: 12px 10px calc(94px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 28px;
    line-height: 1.12;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .subtitle {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
  }

  .masthead {
    gap: 10px;
    margin-bottom: 12px;
    padding: 4px 2px 0;
  }

  .status-card {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .status-card span {
    font-size: 14px;
  }

  .status-card small {
    max-width: none;
    font-size: 12px;
  }

  .studio {
    gap: 14px;
  }

  .panel {
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: 0 16px 46px rgba(94, 118, 122, 0.16);
  }

  .input-panel {
    padding: 14px;
  }

  .section-title {
    margin-bottom: 10px;
  }

  .ghost-icon {
    width: 42px;
    height: 42px;
  }

  .drop-zone {
    min-height: 188px;
    padding: 18px 14px;
    border-radius: 22px;
  }

  .drop-zone::before {
    inset: 10px;
    border-radius: 17px;
  }

  .drop-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border-radius: 20px;
  }

  .drop-zone h2 {
    font-size: 19px;
  }

  .drop-zone p {
    max-width: 280px;
    margin: 7px auto 14px;
    font-size: 12px;
    line-height: 1.5;
  }

  .drop-actions button {
    width: min(100%, 250px);
    height: 48px;
    justify-content: center;
    font-size: 15px;
  }

  .source-preview-open {
    max-height: 230px;
    border-radius: 16px;
  }

  .source-preview-open span {
    opacity: 1;
    transform: none;
  }

  .input-thumbs {
    grid-auto-flow: column;
    grid-auto-columns: 72px;
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .input-thumbs::-webkit-scrollbar {
    display: none;
  }

  .input-thumb,
  .input-thumb-more {
    min-height: 62px;
  }

  .input-thumb img {
    height: 62px;
  }

  .input-file-list {
    max-height: 70px;
  }

  .source-strip {
    min-height: 40px;
    margin: 10px 0;
    padding: 10px 12px;
    font-size: 12px;
  }

  .controls-grid {
    gap: 11px;
    margin-top: 12px;
  }

  .model-fixed {
    min-height: auto;
    padding: 12px 13px;
  }

  .drop-actions,
  .toggle-row,
  .run-row,
  .mini-grid,
  .preview-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .segments {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segments button {
    min-height: 46px;
    padding: 0 8px;
    font-size: 13px;
  }

  .run-row {
    margin-top: 14px;
  }

  .run-row button {
    width: 100%;
    height: 52px;
    font-size: 15px;
  }

  .preview-panel {
    min-height: 0;
    grid-template-rows: auto auto auto auto;
  }

  .preview-head {
    gap: 10px;
    padding: 15px 14px;
  }

  .preview-head h2 {
    font-size: 17px;
    line-height: 1.35;
  }

  .progress-shell {
    width: 100%;
  }

  .output-toolbar {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .output-current strong {
    max-width: none;
  }

  .output-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .output-actions button {
    min-height: 48px;
    display: grid;
    gap: 4px;
    padding: 6px 4px;
    border-radius: 16px;
    font-size: 11px;
  }

  .output-actions svg {
    width: 17px;
    height: 17px;
    margin: 0 auto;
  }

  .preview-stage {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    overflow: visible;
  }

  .empty-preview {
    min-height: 190px;
    border-radius: 18px;
  }

  .empty-preview svg {
    width: 42px;
    height: 42px;
  }

  .preview-card {
    border-radius: 18px;
  }

  .preview-info {
    padding: 11px 12px 12px;
  }

  .preview-select {
    min-height: 180px;
  }

  .log-drawer summary {
    height: 44px;
    padding: 0 14px;
  }

  pre {
    max-height: 150px;
    padding: 12px 14px 14px;
    font-size: 11px;
  }

  .preview-actions {
    grid-template-columns: 1fr;
  }

  .preview-modal {
    padding: 0;
  }

  .modal-panel {
    width: 100vw;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
  }

  .modal-panel img {
    max-height: calc(100dvh - 74px);
  }

  .modal-caption {
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  }

  .modal-close {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    width: 44px;
    height: 44px;
  }

  .compare-panel {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  .compare-head {
    padding: calc(12px + env(safe-area-inset-top)) 12px 10px;
    gap: 10px;
  }

  .compare-head span {
    max-width: 100%;
  }

  .compare-tools {
    flex-wrap: wrap;
  }

  .compare-tools input[type="range"] {
    flex: 1;
    width: min(150px, 42vw);
  }

  .compare-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .compare-label {
    top: 10px;
    left: 10px;
  }

  .compare-viewport img {
    margin: 44px auto 24px;
    border-radius: 10px;
  }

  .ambient-canvas {
    opacity: 0.42;
  }

  .snow-trail {
    display: none;
  }

  .mobile-actionbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 70;
    display: grid;
    grid-template-columns: 0.92fr 1.18fr 0.92fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.66);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 18px 46px rgba(39, 48, 54, 0.22);
    backdrop-filter: blur(20px);
  }

  .mobile-actionbar button {
    min-width: 0;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 18px;
    color: #4c6067;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: inset 0 0 0 1px rgba(102, 119, 128, 0.12);
    font-size: 13px;
    font-weight: 840;
  }

  .mobile-actionbar button:disabled {
    opacity: 0.42;
  }

  .mobile-actionbar .mobile-primary {
    color: #123f3d;
    background: linear-gradient(135deg, var(--mint), var(--lemon));
    box-shadow: 0 10px 24px rgba(37, 145, 132, 0.18);
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 25px;
  }

  .output-actions {
    grid-template-columns: 1fr;
  }

  .mobile-actionbar button {
    font-size: 12px;
  }
}
