:root {
  --bg-dark: #0f1115;
  --bg-elevated: #141820;
  --panel-bg: #1a1d23;
  --accent: #f43f5e;
  --accent-soft: #fb7185;
  --accent-glow: rgba(244, 63, 94, 0.28);
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: #2d333f;
  --radius: 14px;
  --radius-sm: 10px;
  --editor-block-gap: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Pretendard", system-ui, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(ellipse 70% 46% at 50% -18%, rgba(244, 63, 94, 0.14), transparent),
    radial-gradient(ellipse 50% 36% at 100% 12%, rgba(244, 63, 94, 0.05), transparent);
}

.app-container {
  min-height: 100vh;
}

.main-content {
  max-width: 1288px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.app-header {
  margin-bottom: 28px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(244, 63, 94, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.logo-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-title-row h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo-title-row .accent {
  color: var(--accent);
}

.header-tagline {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

.btn-to-dashboard {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-to-dashboard:hover {
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
}

.btn-to-dashboard::before {
  content: "←";
  font-size: 12px;
  opacity: 0.85;
}

.editor-ad {
  margin: 0 0 var(--editor-block-gap);
  min-height: var(--itz-ad-height, 90px);
  border-radius: var(--radius);
  background: var(--bg-control, #0a0c10);
  border: 1px dashed var(--border);
  display: block;
  overflow: hidden;
  line-height: 0;
}

.editor-ad.editor-ad-exempt {
  position: relative;
  z-index: 50;
  isolation: isolate;
}

.editor-ad .adsbygoogle {
  display: block;
  width: 100%;
  min-height: var(--itz-ad-height, 90px);
  line-height: normal;
}

.editor-ad[data-adsense-empty="1"] {
  min-height: var(--itz-ad-height, 90px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#editor-ad-above-path {
  margin-top: 0;
  margin-bottom: var(--editor-block-gap);
}

#editor-ad-below-export {
  margin-top: var(--editor-block-gap);
  margin-bottom: 0;
}

.composer,
.stage,
.qualities {
  background: linear-gradient(180deg, var(--panel-bg) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.composer-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.composer-hint {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

.composer-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-row input {
  flex: 1;
  min-width: 220px;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0c0f14;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-row input::placeholder {
  color: var(--text-muted);
}

.composer-row input:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.composer-status {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.composer-status.is-error {
  color: #fda4af;
}

.btn-primary,
.btn-ghost {
  height: 46px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #e11d48, #fb7185);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.btn-ghost:hover {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.1);
}

.btn-primary:disabled,
.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-wide {
  min-width: 160px;
}

.stage {
  min-height: 280px;
}

.stage-empty,
.stage-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 240px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

.stage-frame,
.stage-skeleton,
.hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
}

.stage-frame {
  max-width: 520px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  background:
    linear-gradient(180deg, rgba(244, 63, 94, 0.06), transparent 55%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.015) 10px,
      rgba(255, 255, 255, 0.015) 20px
    );
}

.stage-skeleton {
  background: linear-gradient(90deg, #171b22 0%, #222833 50%, #171b22 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.hero {
  position: relative;
  background: #090b0f;
  border: 1px solid var(--border);
}

.hero-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #090b0f;
}

.hero-meta {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hero-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.78);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
  backdrop-filter: blur(8px);
}

.hero-chip--muted {
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.qualities-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.qualities-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.qualities-head p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.quality-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.7);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.quality-card:hover,
.quality-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: rgba(244, 63, 94, 0.08);
}

.quality-card.is-active {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.quality-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 8px;
  background: #090b0f;
}

.quality-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.quality-title {
  font-size: 13px;
  font-weight: 700;
}

.quality-size {
  font-size: 11px;
  color: var(--text-dim);
}

.quality-download {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.quality-download:hover {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.12);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(20, 24, 32, 0.94);
  color: var(--text-main);
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 720px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  .main-content {
    padding: 20px 14px calc(40px + env(safe-area-inset-bottom, 0px));
  }

  .logo-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .logo-title-row h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .header-tagline {
    font-size: 13.5px;
    line-height: 1.55;
  }

  .btn-to-dashboard {
    min-height: 40px;
  }

  .composer,
  .stage,
  .qualities {
    padding: 16px;
  }

  .composer-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .composer-row input {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  .composer-row .btn-ghost,
  .composer-row .btn-primary {
    width: 100%;
    min-height: 44px;
  }

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

  .hero-actions .btn-primary,
  .hero-actions .btn-ghost,
  .btn-wide {
    width: 100%;
    min-width: 0;
  }

  .qualities-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

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

  .editor-ad,
  .editor-ad .adsbygoogle,
  .editor-ad[data-adsense-empty="1"] {
    min-height: var(--itz-ad-height, 90px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-skeleton {
    animation: none;
  }

  .btn-primary,
  .btn-ghost,
  .quality-card {
    transition: none;
  }
}

/* itz-theme-contrast */
html[data-theme="light"] .option-card label,
html[data-theme="light"] .option-hint,
html[data-theme="light"] .path-hint,
html[data-theme="light"] .range-val,
html[data-theme="light"] .preset-label,
html[data-theme="light"] .chips-label,
html[data-theme="light"] .size-pill {
  color: #0f172a !important;
}
html[data-theme="light"] .chip:not(.active):not(.is-on),
html[data-theme="light"] .preset-btn:not(.active) {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .chip.active {
  background: var(--accent, #3b82f6) !important;
  color: #ffffff !important;
}
html[data-theme="light"] .path-row input,
html[data-theme="light"] .option-card input[type="number"],
html[data-theme="light"] .option-card input[type="text"] {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .btn-pick-file {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .media-summary-panel {
  background: #f1f5f9;
}
html[data-theme="light"] .media-summary-title,
html[data-theme="light"] .media-summary-hint,
html[data-theme="light"] .media-summary-item dt,
html[data-theme="light"] .media-summary-item dd {
  color: #0f172a;
}
html[data-theme="dark"] .chip:not(.active):not(.is-on) {
  color: #e2e8f0;
}
html[data-theme="dark"] .chip.active {
  color: #ffffff;
}
html[data-theme="dark"] .range-val {
  color: #e2e8f0;
}
html[data-theme="dark"] .path-row input,
html[data-theme="dark"] .option-card input[type="number"],
html[data-theme="dark"] .option-card input[type="text"] {
  color: #ffffff;
}

/* itz-theme-controls */
html[data-theme="light"] .toggle-card {
  background: var(--bg-control, #f8fafc) !important;
  border-color: var(--border, #d8dee8);
  color: #0f172a;
}
html[data-theme="light"] .toggle-card-title,
html[data-theme="light"] .option-label,
html[data-theme="light"] .check-label {
  color: #0f172a !important;
}
html[data-theme="light"] .toggle-card-desc,
html[data-theme="light"] .option-hint,
html[data-theme="light"] .choice small,
html[data-theme="light"] .check-line small {
  color: #475569 !important;
}
html[data-theme="light"] .toggle-card:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 12%, #ffffff) !important;
  border-color: color-mix(in srgb, var(--accent) 42%, #d8dee8);
}
html[data-theme="light"] .toggle-card.is-disabled,
html[data-theme="light"] .toggle-card.is-disabled:has(input:checked) {
  opacity: 0.72;
  background: var(--bg-control-muted, #e8eef4) !important;
}
html[data-theme="light"] .toggle-card.is-disabled .toggle-card-title,
html[data-theme="light"] .toggle-card.is-disabled .toggle-card-desc {
  color: #64748b !important;
}
html[data-theme="light"] .option-select,
html[data-theme="light"] .option-field select {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .choice,
html[data-theme="light"] .check-line {
  background: var(--bg-control, #f8fafc) !important;
  color: #0f172a;
}
html[data-theme="light"] .mode-chip:not(.active):not(.is-on) {
  background: var(--bg-control, #f8fafc) !important;
  color: #334155 !important;
}
html[data-theme="light"] .mode-chip.active,
html[data-theme="light"] .mode-chip.is-on {
  background: var(--accent, #3b82f6) !important;
  color: #ffffff !important;
}
html[data-theme="light"] .size-pill:not(:has(input:checked)) {
  background: #f8fafc !important;
  color: #334155 !important;
}
html[data-theme="light"] .size-pill:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 16%, #ffffff) !important;
  color: #0c4a6e !important;
}
html[data-theme="light"] .btn-pick-file:hover:not(:disabled) {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .toast {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .preview-dialog {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .howto code {
  background: #e8eef4 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .btn-action--download:not(.is-disabled) {
  color: #0f766e !important;
}
html[data-theme="dark"] .toggle-card-title,
html[data-theme="dark"] .option-label {
  color: var(--text-main, #e2e8f0);
}
html[data-theme="dark"] .toggle-card-desc,
html[data-theme="dark"] .option-hint,
html[data-theme="dark"] .choice small,
html[data-theme="dark"] .check-line small {
  color: var(--text-subtle, #94a3b8);
}
html[data-theme="dark"] .option-select {
  background: var(--bg-control, #0f1318);
  color: var(--text-main, #e2e8f0);
}
html[data-theme="dark"] .path-row input {
  background: var(--bg-control, #0f1318);
  color: var(--text-main, #ffffff);
}
html[data-theme="dark"] .mode-chip:not(.active):not(.is-on) {
  color: #cbd5e1;
}
html[data-theme="dark"] .size-pill:has(input:checked) {
  color: #e0f2fe;
}
