@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --base: #0f0f14;
  --surface: #16161e;
  --card: #1c1c26;
  --muted: #2a2a3a;
  --text: #e8eaf4;
  --text-dim: #9399b2;
  --accent: #7c9cff;
  --accent-glow: rgba(124, 156, 255, 0.35);
  --ok: #7ee8a8;
  --err: #ff7b9c;
}

body {
  font-family: "Outfit", system-ui, sans-serif;
  background: var(--base);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 156, 255, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 123, 156, 0.06), transparent);
}

.glass {
  background: rgba(22, 22, 30, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Mode switch */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  user-select: none;
}

.mode-switch__labels {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 5.5rem;
}

.mode-switch__label {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  transition: color 0.25s ease, opacity 0.25s ease;
  line-height: 1.2;
}

.mode-switch__label.is-active {
  color: var(--accent);
  opacity: 1;
  font-weight: 600;
}

.mode-switch__label:not(.is-active) {
  opacity: 0.45;
}

.mode-switch__track {
  position: relative;
  width: 3.25rem;
  height: 1.75rem;
  flex-shrink: 0;
  background: var(--muted);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.mode-switch__track:hover {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.mode-switch__track:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.75rem - 6px);
  height: calc(1.75rem - 6px);
  background: linear-gradient(145deg, #a8c0ff, var(--accent));
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.mode-switch[data-mode="no_watermark"] .mode-switch__thumb {
  transform: translateX(1.5rem);
}

.mode-switch[data-mode="no_watermark"] .mode-switch__track {
  background: rgba(124, 156, 255, 0.2);
}

/* History sidebar */
.history-panel {
  width: 17rem;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.history-section {
  flex: 1 1 50%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.5rem;
  flex-shrink: 0;
}

.history-section__action {
  font-size: 0.65rem;
  color: var(--text-dim);
  transition: color 0.2s;
}

.history-section__action:hover {
  color: var(--err);
}

.history-section__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.25rem 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.history-section__empty {
  font-size: 0.7rem;
  color: rgba(147, 153, 178, 0.45);
  text-align: center;
  padding: 1.5rem 1rem;
}

.history-section__empty:not(.hidden) + .history-section__list,
.history-section__list:not(:empty) ~ .history-section__empty {
  /* handled in JS */
}

.history-divider {
  flex-shrink: 0;
  height: 1px;
  margin: 0 0.75rem;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(124, 156, 255, 0.35),
    transparent
  );
}

.history-item.is-session.is-active {
  border-color: rgba(126, 232, 168, 0.4);
  background: rgba(126, 232, 168, 0.08);
}

.history-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.history-item:hover {
  background: rgba(124, 156, 255, 0.08);
  border-color: rgba(124, 156, 255, 0.15);
}

.history-item.is-active {
  background: rgba(124, 156, 255, 0.12);
  border-color: rgba(124, 156, 255, 0.35);
}

.history-item__query {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item__meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.gallery-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  border-color: rgba(124, 156, 255, 0.25);
}

.btn-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.btn-pill:hover:not(:disabled) {
  background: rgba(124, 156, 255, 0.15);
  border-color: rgba(124, 156, 255, 0.3);
}

.btn-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #8fadff, var(--accent));
  color: #0f0f14;
  font-weight: 600;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

@media (max-width: 768px) {
  .history-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }

  .history-panel.is-open {
    transform: translateX(0);
  }

  .history-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 44;
  }

  .history-backdrop.is-open {
    display: block;
  }
}
