:root {
  color-scheme: light;
  --bg-top: #fff7ed;
  --bg-bottom: #ffedd5;
  --panel: rgba(255, 252, 247, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --line: rgba(194, 65, 12, 0.16);
  --text: #1c1917;
  --muted: #6b625b;
  --accent: #f97316;
  --accent-deep: #c2410c;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --shadow: 0 22px 70px rgba(124, 45, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", "Pretendard", "SUIT", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(249, 115, 22, 0.18), transparent 25%),
    radial-gradient(circle at bottom right, rgba(251, 191, 36, 0.14), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

a {
  color: inherit;
}

.app-shell {
  width: min(1400px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.conversation-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border-radius: 32px;
}

.conversation-panel {
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header,
.preview-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid rgba(120, 113, 108, 0.1);
}

body.chat-started .chat-header,
body.chat-started .preview-header {
  display: flex;
}

.chat-label {
  margin: 0 0 6px;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chat-header h1,
.preview-header h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.chat-header h1,
.preview-header h2 {
  font-size: 1.35rem;
}

.chat-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-window {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
  flex-direction: column;
  gap: 14px;
}

body.chat-started .chat-window {
  display: flex;
}

.chat-bubble {
  max-width: 88%;
  padding: 16px 18px;
  border-radius: 24px;
  line-height: 1.65;
  box-shadow: 0 10px 30px rgba(124, 45, 18, 0.08);
  word-break: break-word;
}

.chat-bubble p:first-child {
  margin-top: 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: white;
  border-bottom-right-radius: 8px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-bottom-left-radius: 8px;
}

.chat-bubble.assistant.loading {
  animation: blink 1s infinite ease-in-out;
  opacity: 0.6;
}

.chat-bubble.assistant.loading .progress-title {
  margin: 0 0 6px;
  font-weight: 700;
}

.chat-bubble.assistant.loading .progress-current {
  margin: 0;
  color: var(--accent-deep);
  font-size: 0.92rem;
}

.progress-steps {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.progress-steps li {
  font-size: 0.9rem;
  color: var(--muted);
}

.progress-steps li.is-current {
  color: var(--text);
  font-weight: 700;
}

.progress-steps li.is-completed {
  color: var(--accent-deep);
}

@keyframes blink {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

.drop-zone,
.pending-files,
.saved-files {
  display: none;
}

body.show-dropzone .drop-zone,
body.chat-started .saved-files:not(:empty),
body.chat-started .pending-files:not(:empty) {
  display: flex;
}

.drop-zone {
  margin: 0 24px 14px;
  padding: 18px 20px;
  border-radius: 24px;
  border: 1px dashed rgba(194, 65, 12, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 247, 237, 0.92)),
    var(--accent-soft);
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.12);
}

.drop-zone strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1rem;
}

.drop-zone p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.pending-files,
.saved-files {
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 24px 14px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.file-chip.pending {
  background: rgba(249, 115, 22, 0.1);
}

.file-chip button {
  border: none;
  background: transparent;
  color: var(--accent-deep);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.chat-form {
  margin-top: auto;
  padding: 16px 24px 24px;
}

body:not(.chat-started) .chat-form {
  padding-top: 0;
  width: min(760px, calc(100% - 48px));
  margin: auto auto 40px;
}

.composer-shell {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 12px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(120, 113, 108, 0.16);
  box-shadow: 0 18px 50px rgba(124, 45, 18, 0.1);
}

.chat-form textarea {
  width: 100%;
  min-height: 30px;
  max-height: 220px;
  padding: 16px 18px;
  resize: none;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  outline: none;
}

.composer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}

.status-text {
  margin: 10px 8px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

body:not(.chat-started) .status-text {
  text-align: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: none;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.primary-button,
.secondary-button,
.link-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  min-width: 110px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
}

.secondary-button,
.link-button,
.ghost-button,
.icon-button {
  padding: 11px 16px;
  background: var(--panel-strong);
  color: var(--accent-deep);
  border: 1px solid rgba(194, 65, 12, 0.18);
}

.icon-button {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 1.35rem;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.preview-panel {
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-height: calc(100vh - 48px);
}

body.chat-started .preview-panel {
  display: flex;
}

.preview-frame {
  flex: 1;
  width: calc(100% - 24px);
  margin: 12px;
  border: 0;
  border-radius: 24px;
  background: white;
  min-height: 620px;
  box-shadow: inset 0 0 0 1px rgba(120, 113, 108, 0.1);
}

code,
pre {
  font-family: "IBM Plex Mono", monospace;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 540px;
  }

  .preview-frame {
    min-height: 520px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    padding: 8px 0 16px;
  }

  .conversation-panel,
  .preview-panel {
    border-radius: 24px;
  }

  .chat-header,
  .preview-header,
  .chat-window,
  .drop-zone,
  .pending-files,
  .saved-files,
  .chat-form {
    padding-left: 16px;
    padding-right: 16px;
  }

  body:not(.chat-started) .chat-form {
    width: calc(100% - 16px);
    margin-bottom: 24px;
  }

  .chat-header,
  .preview-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-header-actions,
  .composer-actions,
  .drop-zone {
    width: 100%;
  }

  .composer-shell,
  .drop-zone {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-button,
  .icon-button,
  .ghost-button {
    width: 100%;
  }

  .preview-frame {
    width: calc(100% - 16px);
    margin: 8px;
    border-radius: 18px;
    min-height: 420px;
  }
}
