:root {
  --bg: #f4efe6;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: rgba(255, 251, 245, 0.98);
  --ink: #1f1b18;
  --muted: #5b534e;
  --line: rgba(62, 44, 27, 0.16);
  --line-strong: rgba(62, 44, 27, 0.28);
  --accent: #bd5b2f;
  --accent-strong: #923d19;
  --accent-tint: rgba(189, 91, 47, 0.08);
  --accent-tint-strong: rgba(189, 91, 47, 0.16);
  --shadow: 0 24px 80px rgba(72, 45, 16, 0.14);
  --shadow-sm: 0 2px 6px rgba(72, 45, 16, 0.06);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

/* HTML5 hidden attribute 가 class/element selector 의 display 선언에 가려지지
   않도록 전역 강제. iframe/placeholder 스왑이 정상 동작하기 위해 필수. */
[hidden] {
  display: none !important;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Pretendard Variable", "Pretendard", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 30%),
    linear-gradient(135deg, #efe1ca 0%, #f6f0e8 45%, #e7d3b2 100%);
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  gap: 20px;
}

/* ─── HERO (compact) ─────────────────────────────────────── */

.hero {
  padding: 4px 0 0;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.01em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede {
  margin: 0 0 14px;
  color: var(--muted);
  /*max-width: 720px;*/
  line-height: 1.6;
}

.hero-meta {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink);
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4b5a4;
  transition: background 200ms ease;
}

.chip-dot.ready { background: #6bbf6b; }
.chip-dot.busy { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.chip-dot.error { background: #d04848; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chip-sep { opacity: 0.4; }
.chip-label { opacity: 0.7; }

/* ─── WORKBENCH (two-column) ──────────────────────────────── */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 920px) {
  .workbench {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* ─── DROP ZONE ───────────────────────────────────────────── */

.dropzone {
  display: block;
  position: relative;
  padding: 32px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.dropzone:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--accent);
}

.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone.is-drag-over {
  background: var(--accent-tint-strong);
  border-color: var(--accent);
  border-style: solid;
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-tint);
  padding: 18px 18px;
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-all;
}

.dropzone-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.dropzone-browse {
  color: var(--accent-strong);
  text-decoration: underline;
  font-weight: 700;
}

.dropzone-clear {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dropzone-clear:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ─── PRIMARY CTA ─────────────────────────────────────────── */

.primary-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  background: var(--accent);
  color: #fffdf9;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(146, 61, 25, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-cta:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-strong);
  box-shadow: 0 10px 22px rgba(146, 61, 25, 0.28);
}

.primary-cta:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.cta-arrow {
  font-size: 12px;
}

/* ─── STEPPER ─────────────────────────────────────────────── */

.stepper {
  list-style: none;
  margin: 6px 0 0;
  padding: 12px 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  position: relative;
}

.stepper::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--line);
  z-index: 0;
}

.stepper li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel-strong);
  border: 2px solid var(--line-strong);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.stepper li.is-active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.stepper li.is-active .step-label {
  color: var(--accent-strong);
}

.stepper li.is-done .step-dot {
  background: #6bbf6b;
  border-color: #6bbf6b;
}

.stepper li.is-done .step-label {
  color: var(--ink);
}

/* ─── ANALYSIS ────────────────────────────────────────────── */

.analysis {
  margin: 0;
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.analysis div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: baseline;
}

.analysis dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.analysis dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  word-break: keep-all;
}

/* ─── DOWNLOAD ────────────────────────────────────────────── */

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.download:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.download.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── PREVIEW ─────────────────────────────────────────────── */

.preview {
  overflow: hidden;
}

.preview-frame-wrap {
  position: relative;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: white;
  height: 75vh;
  max-height: 75vh;
}

iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--muted);
  background: repeating-linear-gradient(
    45deg,
    #fbfaf7 0,
    #fbfaf7 12px,
    #f6f3ed 12px,
    #f6f3ed 24px
  );
}

.preview-placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.preview-placeholder-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.preview-placeholder-sub {
  margin: 0;
  font-size: 13px;
  max-width: 280px;
}

@media (max-width: 920px) {
  .preview-frame-wrap {
    height: 60vh;
    max-height: 60vh;
  }
}

/* ─── LOG (collapsible) ───────────────────────────────────── */

.log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.log-panel summary {
  cursor: pointer;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-panel summary::-webkit-details-marker { display: none; }

.log-panel summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 160ms ease;
  color: var(--accent);
}

.log-panel[open] summary::before {
  transform: rotate(90deg);
}

.log-panel summary:hover {
  color: var(--ink);
}

pre#log {
  margin: 0;
  padding: 16px 20px 20px;
  max-height: 280px;
  overflow: auto;
  background: #1e1b18;
  color: #f7f0e5;
  border-radius: 0 0 20px 20px;
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
