:root {
  --ai-bg: #070b14;
  --ai-bg-soft: #0f1625;
  --ai-panel: rgba(15, 22, 37, 0.92);
  --ai-panel-strong: rgba(10, 15, 26, 0.98);
  --ai-border: rgba(148, 163, 184, 0.14);
  --ai-text-soft: #94a3b8;
  --ai-text-strong: #e8edf6;
  --ai-accent: #6ea8fe;
  --ai-accent-soft: rgba(110, 168, 254, 0.14);
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.08), transparent 25%),
    linear-gradient(180deg, #020617 0%, var(--ai-bg) 100%);
  color: var(--ai-text-strong);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
}

.app-container {
  width: 100%;
  max-width: none;
  padding: 1rem;
}

.top-grid .btn,
.nav-grid .btn {
  width: 100%;
  min-height: 3.1rem;
  border-radius: 1rem;
}

.top-grid .btn,
.nav-grid .btn,
.action-row .btn {
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.top-grid .btn:hover,
.nav-grid .btn:hover,
.action-row .btn:hover {
  transform: translateY(-1px);
}

.btn-outline-light,
.btn-outline-light.panel-card,
.nav-grid .btn-outline-light.panel-card,
.action-row .btn-outline-light {
  color: #d5dfef;
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 22, 37, 0.86);
}

.btn-outline-light:hover,
.btn-outline-light:focus,
.btn-outline-light.panel-card:hover,
.btn-outline-light.panel-card:focus,
.nav-grid .btn-outline-light.panel-card:hover,
.nav-grid .btn-outline-light.panel-card:focus,
.action-row .btn-outline-light:hover,
.action-row .btn-outline-light:focus {
  color: #eff5ff;
  border-color: rgba(110, 168, 254, 0.28);
  background: rgba(30, 41, 59, 0.88);
}

.btn-light.panel-card,
.nav-grid .btn-light.panel-card {
  color: #eff5ff;
  border-color: rgba(110, 168, 254, 0.24);
  background: rgba(44, 62, 92, 0.92);
}

.btn-light.panel-card:hover,
.btn-light.panel-card:focus,
.nav-grid .btn-light.panel-card:hover,
.nav-grid .btn-light.panel-card:focus {
  color: #f8fbff;
  border-color: rgba(110, 168, 254, 0.34);
  background: rgba(55, 75, 108, 0.96);
}

.btn-outline-warning,
.btn-outline-warning.panel-card,
.top-grid .btn-outline-warning {
  color: #f3c987;
  border-color: rgba(245, 158, 11, 0.22);
  background: rgba(56, 36, 12, 0.42);
}

.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-warning.panel-card:hover,
.btn-outline-warning.panel-card:focus,
.top-grid .btn-outline-warning:hover,
.top-grid .btn-outline-warning:focus {
  color: #ffd79d;
  border-color: rgba(245, 158, 11, 0.34);
  background: rgba(83, 53, 16, 0.56);
}

.btn-outline-danger,
.btn-outline-danger.panel-card,
.action-row .btn-outline-danger {
  color: #f0a8a8;
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(74, 22, 28, 0.36);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-outline-danger.panel-card:hover,
.btn-outline-danger.panel-card:focus,
.action-row .btn-outline-danger:hover,
.action-row .btn-outline-danger:focus {
  color: #ffc2c2;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(98, 28, 36, 0.5);
}

.btn-outline-secondary,
.btn-outline-secondary.panel-card,
.top-grid .btn-outline-secondary {
  color: #bac7d8;
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(26, 34, 50, 0.72);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary.panel-card:hover,
.btn-outline-secondary.panel-card:focus,
.top-grid .btn-outline-secondary:hover,
.top-grid .btn-outline-secondary:focus {
  color: #e6edf8;
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(39, 49, 70, 0.84);
}

.btn-ai-primary {
  color: #ecf4ff;
  border: 1px solid rgba(110, 168, 254, 0.28);
  background: linear-gradient(180deg, rgba(24, 35, 55, 0.96) 0%, rgba(18, 28, 45, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.btn-ai-primary:hover,
.btn-ai-primary:focus {
  color: #ffffff;
  border-color: rgba(110, 168, 254, 0.38);
  background: linear-gradient(180deg, rgba(30, 43, 67, 0.98) 0%, rgba(22, 33, 52, 1) 100%);
}

.panel-card {
  background: var(--ai-panel);
  border: 1px solid var(--ai-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.hero-card {
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(10, 15, 26, 0.96) 100%);
}

.page-title-main {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin-bottom: 0.5rem;
}

.hero-center {
  text-align: center;
  max-width: 980px;
  margin: 0 auto;
}

.text-soft {
  color: var(--ai-text-soft) !important;
}

.status-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--ai-border);
  background: rgba(17, 24, 39, 0.72);
  color: var(--ai-text-soft);
  font-size: 0.82rem;
}

.page-switch .btn.active {
  background: var(--ai-accent-soft);
  border-color: rgba(110, 168, 254, 0.35);
  color: #dbeafe;
}

.chat-shell,
.image-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-feed {
  min-height: 54vh;
  max-height: 70vh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 1.1rem;
  border: 1px solid var(--ai-border);
  background: linear-gradient(180deg, rgba(7, 12, 24, 0.96) 0%, rgba(10, 15, 28, 0.98) 100%);
}

.chat-empty {
  min-height: 46vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ai-text-soft);
  padding: 2rem;
}

.chat-message {
  margin-bottom: 1rem;
}

.chat-bubble {
  border-radius: 1rem;
  border: 1px solid var(--ai-border);
  padding: 0.95rem 1rem;
  background: rgba(12, 18, 31, 0.92);
}

.chat-message.user .chat-bubble {
  background: rgba(21, 31, 52, 0.96);
}

.chat-message-meta {
  font-size: 0.78rem;
  color: var(--ai-text-soft);
  margin-bottom: 0.45rem;
}

.chat-bubble pre {
  background: rgba(6, 10, 20, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.9rem;
  padding: 0.9rem;
  overflow-x: auto;
}

.chat-bubble code:not(pre code) {
  padding: 0.12rem 0.3rem;
  border-radius: 0.3rem;
  background: rgba(148, 163, 184, 0.12);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.action-row .btn {
  border-radius: 0.95rem;
  width: 100%;
  min-height: 3rem;
}

.prompt-box textarea,
.prompt-box input,
.prompt-box select {
  border-radius: 1rem;
}

.image-stage {
  width: 100%;
  min-height: 380px;
  border-radius: 1.25rem;
  border: 1px solid var(--ai-border);
  background: linear-gradient(180deg, rgba(7, 12, 24, 0.98) 0%, rgba(10, 16, 28, 0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.image-stage img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 1rem;
  display: block;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.35);
  margin: 0 auto;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  align-items: stretch;
}

.thumb-card {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--ai-border);
  background: rgba(10, 16, 28, 0.94);
}

.thumb-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.thumb-card-body {
  padding: 0.55rem;
  color: var(--ai-text-soft);
  font-size: 0.72rem;
  line-height: 1.35;
}

.thumb-card.placeholder {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  background: rgba(12, 18, 31, 0.72);
}

.thumb-card.placeholder .thumb-card-body {
  text-align: center;
  padding: 1rem;
}

.image-loading {
  text-align: center;
  color: var(--ai-text-soft);
}

.image-loading .spinner-border {
  width: 3rem;
  height: 3rem;
}

.modal-content {
  background: rgba(11, 16, 28, 0.98);
  border: 1px solid var(--ai-border);
  backdrop-filter: blur(16px);
}

.modal-static-note {
  font-size: 0.9rem;
  color: var(--ai-text-soft);
}

.instruction-copy {
  white-space: pre-wrap;
  line-height: 1.7;
}

@media (max-width: 767.98px) {
  .app-container {
    padding: 0.75rem;
  }

  .chat-feed {
    min-height: 50vh;
    max-height: none;
  }

  .image-stage {
    min-height: 320px;
  }

  .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .thumb-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .action-row {
    grid-template-columns: 1fr;
  }

  .thumb-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
