:root {
  --app-bg: #f4f7fb;
  --ink: #111827;
  --muted: #667085;
  --line: #d8e0ea;
  --panel: #ffffff;
  --brand: #2563eb;
  --accent: #0f766e;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--ink);
}

.app-nav {
  background: #111827;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .18);
}

.page-heading {
  margin-bottom: 1.5rem;
}

.page-heading h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  margin-bottom: .35rem;
  letter-spacing: 0;
}

.page-heading p,
.text-secondary {
  color: var(--muted) !important;
}

.eyebrow {
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .08);
  padding: 1.25rem;
}

.login-shell {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 440px);
}

.prompt-box {
  resize: vertical;
  min-height: 180px;
}

.prompt-helper {
  margin-top: .55rem;
  border-radius: 6px;
  padding: .55rem .7rem;
  font-size: .85rem;
  border: 1px solid var(--line);
}

.prompt-helper--muted {
  color: var(--muted);
  background: #f8fafc;
}

.prompt-helper--success {
  color: #166534;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.prompt-helper--warning {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.prompt-helper--danger {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .85rem;
}

.model-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  background: #fff;
}

.model-card:hover,
.model-card.active {
  border-color: var(--brand);
  box-shadow: 0 12px 26px rgba(37, 99, 235, .12);
  transform: translateY(-1px);
}

.model-card h3 {
  font-size: 1rem;
  margin-bottom: .35rem;
}

.model-card p {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: .75rem;
}

.cost {
  color: var(--brand);
  font-weight: 800;
}

.upload-preview {
  position: relative;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
}

.upload-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.upload-preview button {
  position: absolute;
  top: .75rem;
  right: .75rem;
}

/* Generator result grid (single result after generation) */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.media-thumb {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: #101827;
  cursor: zoom-in;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-meta {
  padding: .85rem;
}

.media-meta p {
  color: var(--muted);
  font-size: .88rem;
  min-height: 2.7rem;
}

/* Gallery grid — compact thumbnails */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .65rem;
}

.gallery-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #101827;
  cursor: pointer;
  border: 1px solid var(--line);
}

.gallery-thumb img,
.gallery-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s ease;
}

.gallery-thumb:hover img,
.gallery-thumb:hover video {
  transform: scale(1.04);
}

.gallery-thumb__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  opacity: 0;
  transition: opacity .18s ease;
}

.gallery-thumb:hover .gallery-thumb__overlay {
  opacity: 1;
}

.gallery-thumb__actions {
  display: flex;
  gap: .4rem;
}

.gallery-thumb__btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform .15s ease;
}

.gallery-thumb__btn:hover {
  transform: scale(1.15);
}

.gallery-thumb__btn--view {
  background: rgba(255,255,255,.9);
  color: #111827;
}

.gallery-thumb__btn--delete {
  background: rgba(239, 68, 68, .9);
  color: #fff;
}

.gallery-thumb__badges {
  position: absolute;
  top: .4rem;
  left: .4rem;
  display: flex;
  gap: .25rem;
}

.gallery-thumb__prompt {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: .35rem .5rem;
  font-size: .72rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-stats {
  font-size: .85rem;
  color: var(--muted);
}

.gallery-thumb--deleting {
  opacity: .4;
  pointer-events: none;
}

/* Cost counter in navbar */
.cost-counter {
  display: flex;
  align-items: center;
  gap: .3rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .82rem;
  white-space: nowrap;
}

.cost-counter__label {
  color: rgba(255,255,255,.5);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cost-counter__value {
  color: #fff;
  font-weight: 700;
  min-width: 4rem;
  text-align: right;
}

.cost-counter__reset {
  background: none;
  border: none;
  color: rgba(255,255,255,.45);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  padding: 0 0 0 .15rem;
  transition: color .15s, transform .3s;
}

.cost-counter__reset:hover {
  color: #fff;
}

.cost-counter__reset.spinning {
  animation: spin .4s linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.gallery-thumb__user {
  position: absolute;
  top: .4rem;
  right: .4rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .65rem;
  padding: .15rem .4rem;
  border-radius: 4px;
  max-width: calc(100% - .8rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  border-radius: 999px;
  padding: .35rem .7rem;
  background: #eef2ff;
  color: #3730a3;
  font-size: .82rem;
  font-weight: 700;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.media-modal {
  background: #0f172a;
  color: #fff;
}

#mediaModalBody img,
#mediaModalBody video {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #050816;
  border-radius: 8px;
}
