:root {
  --bg: #f5f7f2;
  --bg-strong: #eef3ec;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --text: #152217;
  --muted: #607062;
  --border: rgba(24, 50, 30, 0.1);
  --shadow: 0 20px 45px rgba(20, 30, 24, 0.08);
  --shadow-soft: 0 10px 28px rgba(20, 30, 24, 0.06);
  --primary: #1f6b45;
  --primary-strong: #155235;
  --accent: #9fd3a8;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(159, 211, 168, 0.45), transparent 26%),
    radial-gradient(circle at bottom right, rgba(31, 107, 69, 0.09), transparent 26%),
    linear-gradient(180deg, #f8faf7 0%, var(--bg) 100%);
}

body {
  padding: 20px;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.sidebar,
.main-layout {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.panel-soft {
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.brand-card {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 16px;
  align-items: start;
  padding: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(244, 248, 243, 0.82));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.brand-card h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  line-height: 1.15;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.steps {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 146px;
  margin-top: 6px;
  padding: 18px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1.5px dashed rgba(31, 107, 69, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(239, 246, 240, 0.85));
}

.upload-title {
  font-weight: 700;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.upload-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.upload-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.8);
}

.upload-card.is-temp {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(243, 248, 244, 0.92));
}

.upload-card.is-uploading {
  border-color: rgba(31, 107, 69, 0.24);
}

.upload-card.is-processing {
  border-color: rgba(31, 107, 69, 0.28);
}

.upload-card.is-processing .upload-progress span {
  width: 100% !important;
  animation: processingPulse 1.2s ease-in-out infinite;
}

.upload-card.is-failed {
  border-color: rgba(168, 55, 55, 0.22);
  background: rgba(255, 250, 250, 0.92);
}

.upload-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
}

.upload-content {
  min-width: 0;
}

.upload-name {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.upload-progress {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(31, 107, 69, 0.1);
}

.upload-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.16s ease;
}

@keyframes processingPulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scaleX(0.985);
  }

  50% {
    opacity: 1;
    transform: scaleX(1);
  }
}

.upload-badge {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(31, 107, 69, 0.08);
  border: 1px solid rgba(31, 107, 69, 0.12);
  color: var(--primary-strong);
  font-size: 0.82rem;
  font-weight: 600;
}

.remove-upload {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  min-height: 36px;
  padding-inline: 12px;
  border-radius: 999px;
}

.remove-upload:hover {
  background: rgba(21, 34, 23, 0.05);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px;
  align-items: center;
}

.hero h2 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
  line-height: 1.12;
}

.hero-actions,
.button-row,
.row-between {
  display: flex;
  align-items: center;
}

.hero-actions,
.button-row {
  gap: 12px;
  flex-wrap: wrap;
}

.row-between {
  justify-content: space-between;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 20px;
}

.chat-panel,
.preview-panel {
  display: grid;
  min-height: 72vh;
}

.chat-panel {
  grid-template-rows: auto minmax(260px, 1fr) auto;
}

.chat-header,
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 24px 0;
}

.chat-header h3,
.preview-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(31, 107, 69, 0.14);
  background: rgba(159, 211, 168, 0.18);
  color: var(--primary-strong);
  font-size: 0.88rem;
  font-weight: 600;
}

.chat-log {
  padding: 24px;
  display: grid;
  gap: 14px;
  align-content: start;
  overflow: auto;
}

.message {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.message.user {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(31, 107, 69, 0.94), rgba(21, 82, 53, 0.96));
  color: white;
}

.message.user .message-meta {
  color: rgba(255, 255, 255, 0.72);
}

.message-meta {
  margin-bottom: 8px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-body {
  line-height: 1.55;
  white-space: pre-wrap;
}

.composer {
  padding: 0 24px 24px;
}

.composer-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(25, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
}

textarea:focus {
  border-color: rgba(31, 107, 69, 0.42);
  box-shadow: 0 0 0 4px rgba(159, 211, 168, 0.18);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 14px;
}

.composer-note {
  color: var(--muted);
  font-size: 0.95rem;
}

.primary-button,
.ghost-button,
.chip {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 18px;
  border: 1px solid transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 14px 28px rgba(31, 107, 69, 0.22);
}

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

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(25, 44, 30, 0.1);
}

.ghost-button.small {
  min-height: 36px;
  padding-inline: 12px;
  border-radius: 999px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(25, 44, 30, 0.1);
  color: var(--text);
}

.preview-panel {
  grid-template-rows: auto minmax(300px, 1fr) auto;
}

.render-stage {
  margin: 20px 24px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(249, 251, 248, 0.9), rgba(239, 244, 238, 0.94));
  overflow: hidden;
  position: relative;
  min-height: 540px;
  display: grid;
  place-items: center;
}

.render-stage.empty img {
  display: none;
}

.render-placeholder {
  display: grid;
  gap: 12px;
  place-items: center;
  max-width: 280px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.render-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(159, 211, 168, 0.25);
  color: var(--primary-strong);
  font-size: 2rem;
}

.render-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.render-caption {
  padding: 0 24px 24px;
  line-height: 1.5;
}

.empty-state {
  padding: 22px;
  border: 1px dashed rgba(31, 107, 69, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  text-align: center;
}

.gap-sm {
  gap: 12px;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

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

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

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .brand-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

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

  .hero,
  .chat-header,
  .preview-header,
  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-panel,
  .preview-panel {
    min-height: auto;
  }

  .render-stage {
    min-height: 360px;
    margin-inline: 16px;
  }

  .composer,
  .chat-log,
  .render-caption {
    padding-inline: 16px;
  }

  .chat-header,
  .preview-header {
    padding-inline: 16px;
  }

  .message {
    max-width: 100%;
  }
}
