:root {
  --bg: #f8f7f2;
  --surface: #fffdfa;
  --text: #172033;
  --muted: #697386;
  --accent: #1769aa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);
  --border: 0.5px solid rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --surface: #182233;
    --text: #eef2f8;
    --muted: #a8b3c7;
    --accent: #78bff2;
    --border: 0.5px solid rgba(255, 255, 255, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", sans-serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 20%), rgba(23, 105, 170, 0.14), transparent 42%);
  z-index: -1;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.aurora {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(23, 105, 170, 0.28), transparent 66%);
  filter: blur(80px);
  opacity: 0.7;
  pointer-events: none;
  z-index: -2;
  animation: float 12s ease-in-out infinite alternate;
}

.aurora-one {
  top: 40px;
  left: -120px;
}

.aurora-two {
  right: -96px;
  bottom: 120px;
  animation-duration: 15s;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px;
  background: rgba(255, 253, 250, 0.74);
  border-bottom: var(--border);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

.brand,
.header-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-family: Montserrat, "Pretendard Variable", sans-serif;
  font-weight: 600;
  letter-spacing: 0;
}

.header-actions {
  gap: 16px;
}

.header-actions a {
  color: var(--muted);
  font-family: Montserrat, "Pretendard Variable", sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page-shell {
  width: min(1184px, 100%);
  margin: 0 auto;
  padding: 48px 16px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 32px;
  align-items: end;
  min-height: 360px;
}

.hero-copy {
  max-width: 720px;
}

.hero-title {
  margin: 0 0 24px;
  font-size: clamp(40px, 7vw, 88px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hero-title .word {
  display: inline-block;
  white-space: nowrap;
}

.hero-title .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(16px);
  animation: titleIn 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--i) * 42ms);
}

.gradient-text {
  color: transparent;
  background: linear-gradient(115deg, var(--accent), var(--text));
  background-clip: text;
  -webkit-background-clip: text;
}

.gradient-text .char {
  color: transparent;
  background: linear-gradient(115deg, var(--accent), var(--text));
  background-clip: text;
  -webkit-background-clip: text;
}

.hero p {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  letter-spacing: -0.01em;
}

.stats-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 253, 250, 0.82);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.stat-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(248, 247, 242, 0.72);
  border: var(--border);
  border-radius: 8px;
}

.stat-item strong {
  font-family: Montserrat, "Pretendard Variable", sans-serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0;
}

.stat-item span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  margin-top: 48px;
  align-items: start;
}

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

.span-two {
  grid-column: 1 / -1;
}

.source-panel {
  display: none;
}

.source-panel.active {
  display: block;
}

.panel {
  padding: 24px;
  background: rgba(255, 253, 250, 0.88);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transform-style: preserve-3d;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

.section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
}

.section-head.compact {
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-box {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.icon-box i {
  font-size: 18px;
}

.icon-accent {
  background: rgba(23, 105, 170, 0.12);
  color: var(--accent);
}

.icon-structure {
  background: rgba(105, 115, 134, 0.12);
  color: var(--text);
}

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

.span-field {
  grid-column: 1 / -1;
}

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

.source-tab {
  display: grid;
  justify-items: start;
  gap: 12px;
  min-height: 160px;
  padding: 16px;
  border: var(--border);
  border-radius: 12px;
  background: rgba(255, 253, 250, 0.72);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.source-tab:hover,
.source-tab.active {
  transform: translateY(-2px);
  background: rgba(23, 105, 170, 0.08);
  box-shadow: var(--shadow-md);
}

.source-tab strong {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.source-tab small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.paste-surface {
  width: 100%;
  border: var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.82);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input {
  min-height: 48px;
  padding: 0 16px;
}

.field textarea {
  min-height: 192px;
  padding: 16px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.paste-surface:focus {
  border-color: rgba(23, 105, 170, 0.44);
  box-shadow: 0 0 0 4px rgba(23, 105, 170, 0.1);
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-button,
.ghost-button,
.primary-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.mode-button i,
.ghost-button i,
.primary-button i,
.remove-image i,
.tree-line i {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(23, 105, 170, 0.12);
  color: var(--accent);
  font-size: 14px;
}

.primary-button i {
  background: rgba(255, 253, 250, 0.18);
  color: #fffdfa;
}

.mode-button,
.ghost-button {
  background: rgba(255, 253, 250, 0.72);
  color: var(--text);
}

.mode-button.active {
  background: rgba(23, 105, 170, 0.12);
  color: var(--accent);
}

.paste-surface {
  min-height: 280px;
  max-height: 520px;
  padding: 16px;
  overflow: auto;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.action-row .primary-button {
  width: min(100%, 280px);
}

.preview-panel {
  margin-top: 24px;
  border: var(--border);
  border-radius: 12px;
  background: rgba(248, 247, 242, 0.62);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: var(--border);
}

.preview-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.preview-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#previewFrame {
  display: block;
  width: 100%;
  height: 640px;
  border: 0;
  background: #ffffff;
}

.paste-surface:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.paste-surface img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 168px;
  padding: 24px;
  border: var(--border);
  border-radius: 12px;
  background: rgba(248, 247, 242, 0.62);
  color: var(--muted);
  text-align: center;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.drop-zone i {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(23, 105, 170, 0.12);
  color: var(--accent);
  font-size: 18px;
}

.drop-zone input {
  display: none;
}

.drop-zone.dragging {
  transform: translateY(-2px);
  border-color: rgba(23, 105, 170, 0.52);
  background: rgba(23, 105, 170, 0.08);
}

.image-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.image-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.72);
}

.image-row img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
}

.image-row strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-row span {
  color: var(--muted);
  font-family: Montserrat, "Pretendard Variable", sans-serif;
  font-size: 12px;
}

.remove-image {
  width: 40px;
  height: 40px;
  padding: 0;
  border: var(--border);
  border-radius: 12px;
  background: rgba(105, 115, 134, 0.1);
  color: var(--muted);
}

.export-panel {
  position: sticky;
  top: 96px;
}

.export-card {
  display: grid;
  gap: 16px;
}

.package-preview {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: var(--border);
  border-radius: 8px;
  background: rgba(248, 247, 242, 0.7);
}

.tree-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: Montserrat, "Pretendard Variable", sans-serif;
  font-size: 13px;
  font-weight: 500;
}

.tree-line i {
  flex: 0 0 auto;
}

.tree-line.muted {
  color: var(--muted);
  padding-left: 24px;
}

.export-status {
  display: none;
  gap: 8px;
}

.export-status.loading {
  display: grid;
}

.skeleton-line {
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(105, 115, 134, 0.12), rgba(105, 115, 134, 0.24), rgba(105, 115, 134, 0.12));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-line.short {
  width: 64%;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  border-color: transparent;
  background: var(--accent);
  color: #fffdfa;
  box-shadow: var(--shadow-lg);
}

.side-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border: var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.9);
  color: var(--text);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ripple {
  position: absolute;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.38);
  transform: scale(0);
  animation: ripple 540ms ease-out;
  pointer-events: none;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 620ms ease, transform 620ms ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes titleIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(48px, 32px, 0) rotate(10deg);
  }
}

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

@keyframes ripple {
  to {
    opacity: 0;
    transform: scale(4);
  }
}

@media (min-width: 768px) {
  .app-header {
    padding: 16px 24px;
  }

  .page-shell {
    padding: 48px 24px;
  }
}

@media (min-width: 1024px) {
  .app-header {
    padding: 16px 32px;
  }

  .page-shell {
    padding: 48px 32px;
  }
}

@media (max-width: 960px) {
  .hero,
  .workspace-grid,
  .archive-form,
  .flow-grid {
    grid-template-columns: 1fr;
  }

  .export-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .header-actions {
    display: none;
  }

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

  .hero {
    min-height: auto;
  }

  .hero-title {
    font-size: 42px;
  }

  .action-row,
  .preview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row .primary-button,
  .action-row .ghost-button,
  .preview-head .ghost-button {
    width: 100%;
  }

  #previewFrame {
    height: 520px;
  }
}

@media (hover: none) {
  body::before,
  .aurora {
    animation: none;
  }

  .panel,
  .stats-panel {
    transform: none !important;
  }
}

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