:root {
  --bg-dark: #0f1115;
  --bg-elevated: #141820;
  --panel-bg: #1a1d23;
  --accent: #10b981;
  --accent-soft: #6ee7b7;
  --accent-glow: rgba(16, 185, 129, 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(16, 185, 129, 0.14), transparent),
    radial-gradient(ellipse 50% 36% at 100% 12%, rgba(16, 185, 129, 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(16, 185, 129, 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(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
}

.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: 48px;
  margin-bottom: 0;
}

.composer,
.stage {
  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;
}

.stage {
  margin-bottom: 0;
}

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

.composer-label:first-child,
.composer > .composer-label:first-of-type {
  margin-top: 0;
}

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

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

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

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 148px;
  padding: 24px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--border));
  background:
    linear-gradient(180deg, rgba(16, 185, 129, 0.06), transparent 70%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.015) 10px,
      rgba(255, 255, 255, 0.015) 20px
    );
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.1);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.dropzone-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}

.list-head .composer-label {
  margin: 0;
}

.list-meta {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.list-head #btn-clear {
  margin-left: auto;
  height: 40px;
  padding: 0 12px;
  flex-shrink: 0;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.thumb-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  grid-template-areas: "img meta toolbar";
  align-items: center;
  gap: 10px 12px;
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.7);
  touch-action: pan-y;
  user-select: none;
}

.thumb-card.is-dragging {
  opacity: 0.72;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.thumb-shot {
  grid-area: img;
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px;
}

.thumb-img {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #11151b;
}

.thumb-num {
  position: absolute;
  left: 4px;
  bottom: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(4, 7, 12, 0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.thumb-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.thumb-name {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-size {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.thumb-toolbar {
  grid-area: toolbar;
  display: flex;
  gap: 6px;
}

.thumb-handle,
.thumb-move,
.thumb-remove {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  cursor: grab;
}

.thumb-handle {
  touch-action: none;
}

.thumb-move,
.thumb-remove {
  cursor: pointer;
  touch-action: manipulation;
}

.thumb-handle:active {
  cursor: grabbing;
}

.thumb-remove {
  color: #fb7185;
}

.thumb-remove:hover,
.thumb-move:hover,
.thumb-handle:hover {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.1);
}

.thumb-remove:hover {
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(251, 113, 133, 0.12);
}

.thumb-move:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.opt-select {
  width: 100%;
  max-width: none;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-control, #0c0f14);
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.vis-hide {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.opts-panel {
  padding: 22px 22px 18px;
}

.opts-head {
  margin-bottom: 16px;
}

.opts-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.opts-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.opts-sub {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

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

.opt-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 70%, var(--panel-bg));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.opt-card--wide {
  grid-column: 1 / -1;
}

.opt-card.is-disabled {
  opacity: 0.48;
  pointer-events: none;
}

.opt-card.is-disabled .opt-label,
.opt-card.is-disabled .range-val {
  color: var(--text-muted);
}

.opt-card.is-disabled input[type="range"] {
  accent-color: var(--text-muted);
}

.opt-label,
.opt-label-row .opt-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-dim);
}

.opt-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: none;
}

.range-row input[type="range"] {
  flex: 1;
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent);
}

.range-val {
  min-width: 48px;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.bg-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bg-row .opt-select {
  flex: 1;
}

#bg-custom {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.fmt-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-control, #0c0f14);
  border: 1px solid var(--border);
}

.fmt-chip {
  height: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}

.fmt-chip.is-on {
  background: linear-gradient(135deg, #059669, #34d399);
  color: #042f24;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.22);
}

.estimate-line {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.estimate-line:empty {
  display: none;
}

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

.btn-primary {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #059669, #34d399);
  color: #042f24;
}

.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(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.1);
}

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

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

.stage {
  min-height: 240px;
}

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

.stage-frame {
  width: 88px;
  height: 168px;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  background:
    linear-gradient(180deg, rgba(16, 185, 129, 0.08), transparent 55%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.015) 10px,
      rgba(255, 255, 255, 0.015) 20px
    );
}

.preview-caption {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

.preview-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: min(56vh, 640px);
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #090b0f;
}

.preview-stack.is-checker {
  background-color: #11151b;
  background-image:
    linear-gradient(45deg, #1a1f27 25%, transparent 25%),
    linear-gradient(-45deg, #1a1f27 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1f27 75%),
    linear-gradient(-45deg, transparent 75%, #1a1f27 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.preview-stack img {
  display: block;
  width: min(100%, 420px);
  height: auto;
}

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

.download-note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

.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);
}

.toast.is-warn {
  border-color: rgba(251, 191, 36, 0.45);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 7, 12, 0.72);
}

.preview-dialog {
  width: min(92vw, 560px);
  max-height: 92vh;
  overflow: auto;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
}

.preview-dialog h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.preview-modal-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.preview-dialog img {
  display: block;
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  background: #090b0f;
  border-radius: 10px;
}

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

@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 {
    padding: 16px;
  }

  .dropzone {
    min-height: 132px;
    padding: 20px 12px;
  }

  .dropzone-title {
    font-size: 15px;
  }

  .opt-select {
    max-width: none;
    font-size: 16px;
  }

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

  .list-head {
    gap: 8px;
  }

  .list-head .composer-label {
    font-size: 13px;
    flex-shrink: 0;
  }

  .list-head #btn-clear {
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .thumb-card {
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas:
      "img meta"
      "bar bar";
    gap: 8px 10px;
    padding: 10px;
  }

  .thumb-shot,
  .thumb-img {
    width: 56px;
    height: 56px;
  }

  .thumb-name {
    font-size: 13px;
  }

  .thumb-toolbar {
    grid-area: bar;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .thumb-handle,
  .thumb-move,
  .thumb-remove {
    width: 100%;
    min-width: 0;
  }

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

  .hero-actions .btn-primary,
  .hero-actions .btn-ghost,
  .btn-wide,
  .preview-modal-actions .btn-primary,
  .preview-modal-actions .btn-ghost {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .card-list {
    max-height: min(46vh, 420px);
  }

  .preview-stack {
    max-height: min(48vh, 480px);
  }

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

@media (prefers-reduced-motion: reduce) {
  .btn-primary,
  .btn-ghost,
  .dropzone {
    transition: none;
  }
}

html[data-theme="light"] .range-val,
html[data-theme="light"] .thumb-name,
html[data-theme="light"] .composer-label,
html[data-theme="light"] .opts-title {
  color: #0f172a !important;
}

html[data-theme="light"] .opts-sub,
html[data-theme="light"] .opt-label {
  color: #475569 !important;
}

html[data-theme="light"] .opt-card {
  background: #f8fafc;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

html[data-theme="light"] .fmt-seg {
  background: #eef2f7;
}

html[data-theme="light"] .fmt-chip {
  color: #475569;
}

html[data-theme="light"] .fmt-chip.is-on {
  color: #042f24;
}

html[data-theme="light"] .estimate-line {
  background: color-mix(in srgb, var(--accent) 8%, #ffffff);
  color: #334155;
}

html[data-theme="light"] .opt-select {
  background-color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475569' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: #0f172a !important;
}

html[data-theme="light"] .thumb-card,
html[data-theme="light"] .thumb-handle,
html[data-theme="light"] .thumb-move,
html[data-theme="light"] .thumb-remove {
  background: #f8fafc;
  color: #0f172a;
}

html[data-theme="light"] .thumb-remove {
  color: #e11d48;
}

html[data-theme="light"] .preview-stack {
  background: #f1f5f9;
}

html[data-theme="light"] .preview-stack.is-checker {
  background-color: #e2e8f0;
  background-image:
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
    linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
}

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="dark"] .range-val {
  color: #e2e8f0;
}

html[data-theme="dark"] .opt-select {
  background: var(--bg-control, #0f1318);
  color: var(--text-main, #e2e8f0);
}
