:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f7f7f8;
  --ink: #1f2328;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --user: #ececec;
  --assistant: #ffffff;
  --accent: #111827;
  --accent-soft: #eef2ff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --shadow: 0 20px 40px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #131a23 0%, #18212d 100%);
}

button,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

body.empty-state .chat-stage {
  min-height: 0;
  display: block;
  padding: 0;
}

body.empty-state .intro-card {
  display: none;
}

body.empty-state .message-list {
  display: none;
}

body.empty-state .composer-shell {
  position: fixed;
  left: 0;
  right: 0;
  top: 54%;
  bottom: auto;
  transform: translateY(-50%);
  padding: 0 16px;
  background: transparent;
}

body.empty-state .composer {
  width: min(900px, 100%);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 16px 6px;
  backdrop-filter: blur(14px);
  background: rgba(19, 26, 35, 0.84);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-inner {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand-logo-shell {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.42));
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 8px 20px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(16px);
}

.brand-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(17, 24, 39, 0.12));
}

.brand-copy h1,
.intro-card p,
.message-bubble p {
  margin: 0;
}

.brand-copy h1 {
  font-family: "SF Pro Display", "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: clamp(30px, 4vw, 34px);
  font-weight: 600;
  letter-spacing: -0.05em;
  color: #f4f7fb;
  line-height: 0.94;
  text-wrap: balance;
}

.brand-tagline {
  margin: 6px 0 0;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: #7b8492;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.current-user-label {
  margin: 0;
  font-size: 13px;
  color: rgba(244, 247, 251, 0.72);
}

.ghost-button {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.ghost-button {
  padding: 9px 14px;
  cursor: pointer;
  color: rgba(244, 247, 251, 0.84);
  font-size: 14px;
  transition: background 0.18s ease, transform 0.18s ease;
}

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

.chat-stage {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 48px 16px 184px;
}

.intro-card {
  margin: 0 auto 36px;
  padding: 12px 0 6px;
  max-width: 720px;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: center;
}

.intro-kicker {
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 600;
  letter-spacing: -0.06em;
  color: #161c26;
  line-height: 1.02;
}

.intro-copy {
  margin: 14px auto 0 !important;
  color: var(--muted);
  line-height: 1.65;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.04em;
  color: #161c26;
  max-width: 560px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 820px;
  margin: 0 auto;
}

.message {
  display: flex;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  justify-content: flex-start;
}

.message-bubble {
  width: min(100%, 760px);
  padding: 18px 20px;
  border-radius: 26px;
  border: 1px solid rgba(16, 24, 40, 0.06);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.03);
}

.user-message .message-bubble {
  background: var(--user);
  border-bottom-right-radius: 10px;
}

.assistant-message .message-bubble {
  background: var(--assistant);
  border-bottom-left-radius: 10px;
}

.intro-bubble {
  background: #fafafa;
  max-width: 640px;
  margin: 0 auto;
  display: none;
}

.message-bubble.loading {
  background: #fffdf7;
  border-style: dashed;
}

.message-role {
  margin-bottom: 10px !important;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-text {
  line-height: 1.7;
  white-space: pre-wrap;
}

.message-image {
  width: 100%;
  display: block;
  margin-top: 10px;
  border-radius: 18px;
  border: 1px solid rgba(16, 24, 40, 0.08);
  background: #f8fafc;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

.download-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.error-banner {
  position: fixed;
  left: 50%;
  bottom: 124px;
  z-index: 15;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f9d3cf;
  box-shadow: var(--shadow);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 13, 18, 0.56);
  backdrop-filter: blur(12px);
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.auth-kicker,
.auth-title,
.auth-subtitle {
  margin: 0;
}

.auth-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #667085;
}

.auth-title {
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.05em;
  color: #141a23;
}

.auth-subtitle {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: #667085;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  font-size: 14px;
  color: #344054;
}

.auth-field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #f8fafc;
  font: inherit;
  outline: none;
}

.auth-submit-button {
  width: 100%;
  margin-top: 22px;
}

.auth-toggle-button {
  margin-top: 14px;
}

.composer-shell {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  padding: 18px 16px 22px;
  background:
    linear-gradient(180deg, rgba(19, 26, 35, 0) 0%, rgba(19, 26, 35, 0.82) 24%, rgba(19, 26, 35, 0.96) 100%);
}

.composer {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 16px 16px 14px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.reference-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.generation-mode-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 12px;
}

.mode-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: rgba(17, 24, 39, 0.88);
  text-align: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 8px 18px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.mode-option:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.78);
}

.mode-option.is-selected {
  background: rgba(17, 24, 39, 0.9);
  border-color: rgba(17, 24, 39, 0.88);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 20px rgba(15, 23, 42, 0.14);
}

.mode-option:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.mode-option-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.reference-preview-image {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(16, 24, 40, 0.08);
  background: #f8fafc;
  flex-shrink: 0;
}

.reference-preview-copy {
  min-width: 0;
}

.reference-preview-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.inline-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.composer-input {
  width: 100%;
  resize: none;
  min-height: 60px;
  max-height: 180px;
  padding: 6px 8px 10px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.composer-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.composer-tools-primary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.send-arrow-button {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 720px) {
  body {
    background: linear-gradient(180deg, #131a23 0%, #18212d 100%);
  }

  .topbar {
    background: rgba(19, 26, 35, 0.84);
  }

  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .chat-stage {
    padding: 34px 12px 150px;
  }

  body.empty-state .chat-stage {
    min-height: 0;
    padding: 0;
  }

  body.empty-state .composer-shell {
    top: 52%;
  }

  .intro-card,
  .message-bubble {
    border-radius: 20px;
  }

  .composer-shell {
    padding: 12px;
  }

  .composer {
    border-radius: 24px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-tools {
    align-items: stretch;
  }

  .composer-tools-primary {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-button {
    width: 100%;
    min-height: 44px;
  }

  .composer-hint {
    text-align: center;
  }

  .reference-preview {
    align-items: flex-start;
  }

  .brand-logo-shell {
    width: 72px;
    height: 72px;
    border-radius: 22px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }
}
