:root {
  color-scheme: dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0f172a;
  color: #f8fafc;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 16px;
}

.page {
  width: min(920px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page__header {
  text-align: center;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.page__header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 4px 0 0;
  opacity: 0.7;
  font-size: 0.95rem;
}

.page__main {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: clamp(320px, 60vh, 600px);
}

.message {
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.45;
  word-wrap: break-word;
  font-size: 0.95rem;
  position: relative;
}

.message--user {
  margin-left: auto;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.message--assistant {
  margin-right: auto;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.message figure {
  margin: 0;
}

.image-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-card__thumb {
  border-radius: 12px;
  max-width: min(320px, 100%);
  cursor: zoom-in;
}

.image-card figcaption {
  font-size: 0.85rem;
  opacity: 0.8;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.actions__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action {
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid transparent;
  color: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s ease, border 0.2s ease;
}

.action:hover {
  background: rgba(148, 163, 184, 0.25);
}

.action--active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.form {
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 10px;
}

.form--secondary {
  opacity: 0.85;
}

.form input {
  flex: 1;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  outline: none;
}

.submit {
  padding: 8px 18px;
  border-radius: 12px;
  background: #38bdf8;
  border: none;
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.submit:hover {
  transform: translateY(-1px);
}

.placeholder {
  opacity: 0.7;
  font-size: 0.9rem;
}

.page__footer {
  min-height: 24px;
}

.toast {
  min-height: 24px;
  font-size: 0.9rem;
  opacity: 0.85;
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .page {
    gap: 12px;
  }

  .actions__quick {
    gap: 6px;
  }

  .submit {
    padding: 8px 14px;
  }
}
.message--pending {
  opacity: 0.65;
  display: flex;
  align-items: center;
}

.message--pending .loader {
  margin: 0 auto;
}

.loader {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.3);
  border-top-color: #38bdf8;
  animation: spin 1s linear infinite;
  display: inline-block;
}

.error {
  color: #fca5a5;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
}

.lightbox[aria-hidden="false"] {
  display: flex;
}

.lightbox__content {
  position: relative;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 20px;
  max-width: min(90vw, 720px);
  max-height: min(90vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lightbox__image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
}

.lightbox__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.lightbox__download {
  padding: 8px 16px;
  border-radius: 12px;
  background: #38bdf8;
  border: none;
  color: #0f172a;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: rgba(248, 250, 252, 0.85);
  font-size: 1.4rem;
  cursor: pointer;
}

.lightbox__caption {
  opacity: 0.85;
  font-size: 0.95rem;
}
