:root {
  --bg-dark: #0c1014;
  --panel-bg: #151a22;
  --accent: #eab308;
  --accent-glow: rgba(234, 179, 8, 0.35);
  --erase-red: #ef4444;
  --erase-red-glow: rgba(239, 68, 68, 0.45);
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --border: #2d333f;
  --radius: 12px;
  --editor-block-gap: 28px;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: "Pretendard", sans-serif;
  margin: 0;
}

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

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

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

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

.logo-title-row h1 {
  margin: 0;
}

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

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: #fef9c3;
  margin-bottom: 8px;
}

.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(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
}

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

.header-status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.compute-capability {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  white-space: nowrap;
}

.compute-capability.is-gpu {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(16, 185, 129, 0.12);
}

.compute-capability.is-cpu {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
}

.compute-capability.is-pending {
  color: var(--text-dim);
  font-weight: 600;
}

.compute-capability.is-warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.1);
}

.status-dot {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.bin-readiness {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-dim);
  max-width: min(360px, 48vw);
}

.bin-readiness.is-ok {
  color: #34d399;
}

.bin-readiness.is-warn {
  color: #fbbf24;
}

.bin-readiness.is-err {
  color: #f87171;
}

.logo-area h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
}

.header-tagline {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}

/* AdSense — 이미지 경로 위 · 결과 다운로드 아래 (팝업 블러 제외) */
.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:not(:has(.adsbygoogle)) {
  min-height: var(--itz-ad-height, 90px);
}

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

.editor-ad[data-adsense-empty="1"]::after {
  content: "";
}

#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;
}

/* 콘텐츠 셸 — 팝업(준비·처리)은 여기서만 블러 */
.enhancer-content-shell {
  position: relative;
  min-width: 0;
}

.enhancer-content-shell[aria-busy="true"] .drop-zone,
.enhancer-content-shell[aria-busy="true"] .preview-panel,
.enhancer-content-shell[aria-busy="true"] .options-layout,
.enhancer-content-shell[aria-busy="true"] .action-stack {
  pointer-events: none;
}

.drop-zone,
.options-layout {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.path-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
}

.source-mode-select {
  flex: 0 0 auto;
  min-width: 88px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-control, #0f1318);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
}

.path-row input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-control, #0f1318);
  color: var(--text-main);
}

.folder-meta {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted, #9ca3af);
}

.btn-pick-file,
.btn-new-job,
.btn-primary,
.btn-download {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-primary {
  background: linear-gradient(135deg, #ca8a04, #eab308);
  border-color: transparent;
  color: #0c1014;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-download.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.options-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(168px, 200px);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

@media (max-width: 800px) {
  .options-layout {
    grid-template-columns: 1fr;
  }
}

.options-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 4px 20px 16px;
}

.options-group {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.options-group--last {
  border-bottom: none;
  padding-bottom: 8px;
}

.options-group-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.options-grid {
  display: grid;
  gap: 12px 14px;
  align-items: end;
}

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

@media (max-width: 900px) {
  .options-grid--3 {
    grid-template-columns: 1fr 1fr;
  }

  .option-field--wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .options-grid--3 {
    grid-template-columns: 1fr;
  }
}

.option-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.option-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.option-hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
  margin: 0;
}

.option-select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-control, #0f1318);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
}

.media-summary-panel {
  padding: 16px 18px;
  border-left: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  align-self: stretch;
}

@media (max-width: 800px) {
  .media-summary-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

.media-summary-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.media-summary-list {
  margin: 0;
}

.media-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(45, 51, 63, 0.6);
}

.media-summary-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.media-summary-item dt {
  color: var(--text-dim);
  font-weight: 500;
}

.media-summary-item dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

/* 미리보기 · 영역 편집 · 원본/결과 재생 */
.preview-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

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

.preview-panel-heading {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* 브러시 툴바 */
.brush-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.brush-tool-group {
  display: flex;
  gap: 6px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-control, #0f1318);
}

.brush-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.brush-tool-btn.is-active {
  background: linear-gradient(135deg, #ca8a04, #eab308);
  color: #0c1014;
}

.brush-size-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.brush-size-field label {
  font-weight: 600;
  white-space: nowrap;
}

.brush-size-field input[type="range"] {
  width: 110px;
  accent-color: var(--accent);
}

.brush-size-field output {
  min-width: 3.2em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

.brush-clear-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.brush-clear-btn:hover {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.preview-viewport {
  position: relative;
  width: 100%;
  min-height: min(42vh, 520px);
  max-height: min(56vh, 640px);
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--bg-control, #0a0d10);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

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

.preview-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: min(42vh, 520px);
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  background: var(--bg-control, #0a0d10);
}

.preview-empty.is-error {
  color: #fca5a5;
}

.preview-empty.is-error p {
  max-width: 36em;
  line-height: 1.5;
  word-break: break-word;
}

.preview-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.canvas-stage {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#edit-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  cursor: crosshair;
  touch-action: none;
  background: repeating-conic-gradient(#12161d 0% 25%, #0a0d10 0% 50%) 50% / 20px 20px;
  border-radius: 4px;
}

#edit-canvas.is-move {
  cursor: move;
}

#edit-canvas.is-nw-resize,
#edit-canvas.is-se-resize {
  cursor: nwse-resize;
}

#edit-canvas.is-ne-resize,
#edit-canvas.is-sw-resize {
  cursor: nesw-resize;
}

#edit-canvas.is-n-resize,
#edit-canvas.is-s-resize {
  cursor: ns-resize;
}

#edit-canvas.is-e-resize,
#edit-canvas.is-w-resize {
  cursor: ew-resize;
}

.canvas-hint,
.compare-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* 실행 버튼 — 한 줄씩 */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-action--secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-action--secondary:hover {
  border-color: rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
}

.btn-action--primary {
  background: linear-gradient(135deg, #ca8a04, #eab308);
  border-color: transparent;
  color: #0c1014;
}

.btn-action--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-action--download {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  gap: 8px;
}

.btn-action--download.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-action--primary:not(:disabled):active,
.btn-action--secondary:not(:disabled):active,
.btn-action--download:not(.is-disabled):active {
  transform: scale(0.99);
}

.enhancer-busy-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(8, 10, 14, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  pointer-events: auto;
}

.enhancer-busy-overlay.is-active {
  display: flex !important;
}

.enhancer-busy-overlay[hidden]:not(.is-active) {
  display: none !important;
}

.enhancer-busy-panel,
.loading-card {
  width: min(420px, 92vw);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  outline: none;
}

.enhancer-busy-panel:focus-visible {
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(168, 85, 247, 0.55);
}

.loading-track {
  height: 8px;
  background: var(--bg-control, #0f1318);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
}

.loading-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ca8a04, #eab308);
  transition: width 0.25s ease;
}

.loading-bar.is-determinate {
  transition: width 0.35s ease;
}

.loading-percent {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin: 8px 0 0;
}

.loading-step {
  font-size: 13px;
  color: var(--accent);
  margin: 0;
}

.loading-message {
  font-size: 14px;
  color: var(--text-dim);
}

.video-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  margin-top: 4px;
}

.video-stack[hidden] {
  display: none;
}

.video-stack-item {
  margin: 0;
}

.video-stack-item figcaption {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--bg-control, #0a0d10);
  overflow: hidden;
}

.stack-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* 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;
}
html[data-theme="light"] .preview-viewport,
html[data-theme="light"] .preview-empty,
html[data-theme="light"] .video-frame {
  background: #eef2f7 !important;
  color: #334155 !important;
}

