:root {
  color-scheme: dark;
  --bg: #070914;
  --panel: rgba(16, 21, 39, 0.82);
  --panel-strong: rgba(24, 30, 54, 0.96);
  --text: #f6f7fb;
  --muted: #9ea7bd;
  --line: rgba(255, 255, 255, 0.12);
  --primary: #8b5cf6;
  --primary-2: #06b6d4;
  --danger: #fb7185;
  --success: #34d399;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 20%, rgba(139, 92, 246, 0.28), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(6, 182, 212, 0.18), transparent 32%),
    linear-gradient(135deg, #070914 0%, #0d1222 52%, #0a0f1e 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.shell {
  min-height: 100vh;
  padding: 28px;
}

.login-card {
  width: min(440px, calc(100vw - 36px));
  margin: 10vh auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.brand-pill,
.eyebrow,
.model-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid rgba(139, 92, 246, 0.38);
  border-radius: 999px;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
}

.brand-pill,
.model-badge {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-card h1,
.topbar h1 {
  margin: 16px 0 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.login-card p,
.empty-state p,
.tips p,
.preview-meta p {
  color: var(--muted);
  line-height: 1.65;
}

.login-form,
.settings-panel,
.composer {
  display: grid;
  gap: 14px;
}

.login-form label,
.settings-panel label {
  display: grid;
  gap: 8px;
  color: #d7dcf0;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 118px;
  padding: 14px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(139, 92, 246, 0.72);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.16);
}

.login-form button,
.composer button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 40px rgba(139, 92, 246, 0.24);
}

.form-error,
.error-text {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
}

.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar,
.layout,
.composer-footer,
.progress-head,
.preview-meta {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.layout {
  align-items: stretch;
  gap: 22px;
}

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

.conversation-panel {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto;
  flex: 1;
  min-height: calc(100vh - 152px);
  overflow: hidden;
}

.settings-panel {
  width: 320px;
  padding: 24px;
}

.settings-panel h2 {
  margin: 0 0 8px;
}

.messages {
  overflow-y: auto;
  padding: 24px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  text-align: center;
}

.empty-state span {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 26px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.empty-state h2 {
  margin: 22px 0 6px;
}

.message {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.user-message {
  justify-items: end;
}

.assistant-message {
  justify-items: start;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.bubble {
  max-width: min(760px, 86%);
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.user-message .bubble {
  color: white;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.92), rgba(6, 182, 212, 0.82));
}

.assistant-message .bubble {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
}

.result-card {
  width: min(850px, 96%);
}

.result-card.is-error {
  border-color: rgba(251, 113, 133, 0.35);
}

.progress-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.progress-head span {
  color: #c4b5fd;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

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

.success-text {
  color: var(--success);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.image-tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #111827;
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.image-tile:hover img {
  transform: scale(1.04);
}

.image-tile span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(10px);
}

.composer {
  padding: 18px;
  border-top: 1px solid var(--line);
  background: rgba(6, 9, 20, 0.72);
}

.composer-footer {
  justify-content: space-between;
  gap: 12px;
}

.composer-footer span {
  color: var(--muted);
  font-size: 14px;
}

.tips {
  margin-top: 6px;
  padding: 14px;
  border: 1px solid rgba(6, 182, 212, 0.22);
  border-radius: 18px;
  background: rgba(6, 182, 212, 0.08);
}

.tips strong {
  color: #67e8f9;
}

.preview-dialog {
  width: min(96vw, 1280px);
  max-width: none;
  height: min(94vh, 920px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  color: var(--text);
  background: rgba(4, 6, 14, 0.96);
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
}

.close-preview {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  background: rgba(0, 0, 0, 0.5);
}

.preview-dialog img {
  width: 100%;
  height: calc(100% - 92px);
  object-fit: contain;
  display: block;
  padding: 20px;
}

.preview-meta {
  justify-content: space-between;
  gap: 14px;
  min-height: 92px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}

.preview-meta p {
  margin: 0;
  max-width: 76%;
}

.preview-meta a {
  flex: none;
  padding: 10px 14px;
  border-radius: 999px;
  color: white;
  font-weight: 800;
  text-decoration: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

[hidden] {
  display: none !important;
}

@media (max-width: 960px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .layout,
  .composer-footer,
  .preview-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .settings-panel {
    width: 100%;
  }

  .conversation-panel {
    min-height: 680px;
  }

  .bubble,
  .result-card {
    max-width: 100%;
    width: 100%;
  }

  .preview-meta p {
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .login-card,
  .settings-panel,
  .messages,
  .composer {
    padding: 16px;
  }

  .conversation-panel,
  .settings-panel,
  .login-card {
    border-radius: 22px;
  }

  .composer-footer button {
    width: 100%;
  }
}