/* ── Login Page ─────────────────────────────────────────────────────── */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.login-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a1628 100%);
}
.login-bg-ambient {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(99,102,241,.12) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(139,92,246,.08) 0%, transparent 50%);
}

.login-card {
  position: relative;
  width: 380px; max-width: 90vw;
  padding: 40px 32px;
  text-align: center;
  border-radius: 20px;
}

.login-logo-area {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.login-title {
  font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, #e0e7ff, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin: 0;
}
.login-subtitle {
  font-size: 0.85rem; color: var(--color-text-secondary);
  margin: 0;
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  margin: 24px 0;
}

.login-cta {
  font-size: 0.9rem; color: var(--color-text-primary);
  margin: 0 0 20px;
}

.login-google-btn-wrap {
  display: flex; justify-content: center;
  min-height: 44px;
}

.login-or-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.login-or-divider::before,
.login-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}

.login-ms-btn-wrap {
  display: flex; justify-content: center;
  min-height: 44px;
}
.login-ms-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 300px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  background: rgba(255,255,255,.04);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.login-ms-btn:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.2);
}
.login-ms-btn:active {
  background: rgba(255,255,255,.06);
}

.login-error {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #ef4444;
  padding: 8px 12px;
  background: rgba(239,68,68,.08);
  border-radius: 8px;
}

.login-footer {
  margin-top: 20px;
  font-size: 0.7rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  line-height: 1.4;
}
.login-footer a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
  cursor: pointer;
}
.login-footer a:hover {
  text-decoration: underline;
}
.login-contact {
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.3));
}
.login-contact a {
  color: var(--color-text-tertiary, rgba(255,255,255,.4));
  text-decoration: none;
}
.login-contact a:hover {
  color: var(--color-accent, #a78bfa);
  text-decoration: underline;
}

/* ── API Key Modal ─────────────────────────────────────────────────── */
.apikey-overlay {
  z-index: 200;
}
.apikey-modal {
  width: 420px; max-width: 90vw;
  padding: 32px;
  text-align: center;
  border-radius: 16px;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.apikey-icon {
  color: var(--color-accent, #a78bfa);
  margin-bottom: 12px;
}
.apikey-title {
  font-size: 1.15rem; font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 8px;
}
.apikey-desc {
  font-size: 0.8rem; color: var(--color-text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}
.apikey-input-wrap {
  position: relative;
}
.apikey-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 40px 10px 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: border-color .15s;
}
.apikey-input:focus {
  border-color: var(--color-accent, #a78bfa);
}
.apikey-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px;
}
.apikey-error {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #ef4444;
  padding: 8px 12px;
  background: rgba(239,68,68,.08);
  border-radius: 8px;
  text-align: left;
}
.apikey-actions {
  margin-top: 16px;
}
.apikey-submit {
  width: 100%;
  padding: 10px 20px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #6C3BEE, #a78bfa);
  color: #fff;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.apikey-submit:disabled {
  opacity: .4; cursor: not-allowed;
}
.apikey-submit:not(:disabled):hover {
  opacity: .9;
}
.apikey-help {
  margin-top: 14px;
  font-size: 0.72rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
}
.apikey-help a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
}
.apikey-help a:hover { text-decoration: underline; }

/* ── Legal Modals ─────────────────────────────────────────────────── */
.legal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: legalFadeIn .15s ease;
}
@keyframes legalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.legal-modal {
  width: 600px; max-width: 92vw;
  max-height: 80vh;
  border-radius: 16px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.legal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.legal-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}
.legal-close-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.legal-close-btn:hover {
  background: rgba(255,255,255,.12);
  color: var(--color-text-primary);
}
.legal-content {
  padding: 16px 24px 24px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}
.legal-content::-webkit-scrollbar { width: 4px; }
.legal-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
.legal-content h3 {
  font-size: 0.88rem; font-weight: 600;
  color: var(--color-text-primary);
  margin: 20px 0 6px;
}
.legal-content h3:first-of-type {
  margin-top: 8px;
}
.legal-content p {
  margin: 0 0 10px;
}
.legal-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}
.legal-content li {
  margin-bottom: 4px;
}
.legal-content a {
  color: var(--color-accent, #a78bfa);
  text-decoration: none;
}
.legal-content a:hover {
  text-decoration: underline;
}
.legal-updated {
  font-size: 0.75rem;
  color: var(--color-text-tertiary, rgba(255,255,255,.35));
  margin: 0 0 8px;
  font-style: italic;
}

/* ── User Menu ─────────────────────────────────────────────────────── */
.user-menu {
  position: relative;
  margin-left: 12px;
}
.user-menu-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  cursor: pointer;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-primary);
  font-weight: 600; font-size: 0.85rem;
  transition: border-color .15s;
}
.user-menu-btn:hover { border-color: var(--color-accent, #a78bfa); }
.user-menu-avatar {
  width: 100%; height: 100%;
  object-fit: cover;
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 220px;
  padding: 12px 0;
  border-radius: 12px;
  z-index: 300;
}
.user-menu-name {
  padding: 4px 16px 0;
  font-size: 0.85rem; font-weight: 600;
  color: var(--color-text-primary);
}
.user-menu-email {
  padding: 2px 16px 8px;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 4px 0;
}
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: none; background: none;
  color: var(--color-text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.user-menu-item:hover {
  background: rgba(255,255,255,.04);
}
.user-menu-item--danger {
  color: #ef4444;
}
.user-menu-item--danger:hover {
  background: rgba(239,68,68,.08);
}
