﻿/* ═══════════════════════════════════════════
   DESIGN TOKENS — GovGPT v4
   Palette: ChatGPT-style Black/Grey · TN accent green
   Theme: Near-black sidebar + grey content area
═══════════════════════════════════════════ */
:root {
  /* Chrome — ChatGPT-style dark sidebar + topbar */
  --chrome:        #202123;   /* Sidebar + Topbar background */
  --chrome-dark:   #171717;   /* Deeper shade for header within sidebar */
  --chrome-mid:    #2A2B32;   /* Hover/secondary chrome states */
  --chrome-border: rgba(255,255,255,0.10); /* Subtle border on dark chrome */
  --chrome-text:   rgba(255,255,255,0.95); /* Primary text on chrome */
  --chrome-text-2: rgba(255,255,255,0.62); /* Secondary text on chrome */
  --chrome-text-3: rgba(255,255,255,0.35); /* Muted text on chrome */

  /* Accent — TN Government green (kept for identity) */
  --accent:      #10A37F;
  --accent-dark: #0D8C6D;
  --accent-light:rgba(16,163,127,0.14);
  --accent-mid:  #16B894;
  --gold:        #C9A84C;
  --gold-bg:     rgba(201,168,76,0.12);

  /* Active nav highlight on dark chrome */
  --nav-active-bg:   linear-gradient(135deg, rgba(16,163,127,0.28) 0%, rgba(16,163,127,0.12) 60%, rgba(16,163,127,0.06) 100%);
  --nav-active-text: #ffffff;
  --nav-active-glow: 0 0 0 1px rgba(16,163,127,0.35), 0 2px 10px rgba(16,163,127,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
  --nav-hover-bg:    rgba(255,255,255,0.07);
  --nav-accent-bar:  #17D9A6;   /* Brighter TN green left border on active items */

  /* Content area surfaces — dark grey like ChatGPT */
  --bg:          #343541;
  --card:        #444654;

  /* Borders (content area) — dark theme */
  --border:      rgba(255,255,255,0.12);
  --border-light:rgba(255,255,255,0.07);

  /* Text (content area) — light on dark */
  --text:        #ECECF1;
  --text-2:      #C5C5D2;
  --text-3:      #8E8EA0;

  /* Semantic — adjusted for dark theme */
  --green:       #4ade80;
  --green-bg:    rgba(74,222,128,0.15);
  --amber:       #fbbf24;
  --amber-bg:    rgba(251,191,36,0.15);
  --red:         #f87171;
  --red-bg:      rgba(248,113,113,0.15);
  --blue:        #7daafc;

  /* Keep legacy vars pointing to chrome for backward-compat references */
  --navy-dark:   var(--chrome-dark);
  --navy:        var(--chrome);
  --navy-mid:    var(--chrome-mid);
  --sidebar-bg:  var(--chrome);
  --topbar-bg:   var(--chrome);
  --sb-border:   var(--chrome-border);

  /* Radii */
  --r-card:      12px;
  --r-btn:       8px;
  --r-badge:     20px;

  /* Shadows */
  --shadow:      0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.20);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.35);

  /* Layout */
  --sidebar-w:   264px;
  --topbar-h:    56px;
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden; /* screens with position:fixed manage their own scroll */
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; outline-color: #10A37F; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

/* ═══════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════ */
#login-screen {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(145deg, #0D0D0F 0%, #171717 55%, #1A1A1D 100%);
  display: none; align-items: center; justify-content: center;
  opacity: 1; transition: opacity 0.4s ease;
}

#login-screen.visible { display: flex; }

#login-screen.hiding { opacity: 0; pointer-events: none; }

.login-glow {
  position: fixed;
  width: 520px; height: 520px;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
}

.login-glow-1 {
  top: -160px; left: -120px;
  background: radial-gradient(circle, rgba(16,163,127,0.28) 0%, transparent 70%);
}

.login-glow-2 {
  bottom: -180px; right: -140px;
  background: radial-gradient(circle, rgba(201,168,76,0.14) 0%, transparent 70%);
}

.login-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, rgba(48,49,58,0.68) 0%, rgba(34,35,41,0.72) 100%);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.10);
  width: 436px;
  border-radius: 26px;
  padding: 44px 40px 34px;
  box-shadow:
    0 32px 80px rgba(0,0,0,0.50),
    0 8px 24px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.09),
    inset 0 0 0 1px rgba(255,255,255,0.02);
  animation: loginCardIn 0.55s cubic-bezier(.22,.61,.36,1) both;
}

.login-card::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: 26px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(23,217,166,0.55), rgba(255,255,255,0.06) 30%, transparent 55%, rgba(201,168,76,0.30) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@keyframes loginCardIn {
  from { opacity:0; transform: translateY(24px) scale(0.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.login-logo-row {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 26px;
}

.login-emblem {
  width: 76px; height: 76px;
  flex-shrink: 0;
  object-fit: contain;
  padding: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  filter: drop-shadow(0 3px 12px rgba(0,0,0,0.45));
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.login-wordmark {
  display: flex; flex-direction: column; gap: 5px;
}

.login-title {
  font-size: 19px; font-weight: 700;
  color: #ffffff; letter-spacing: -0.015em;
  line-height: 1.28;
}

.login-sub {
  font-size: 10.5px; color: var(--accent-mid);
  letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 600;
  margin-top: 0;
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.10) 15%, rgba(255,255,255,0.10) 85%, transparent);
  margin-bottom: 26px;
}

.login-secure-badge {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin: 22px auto 0;
  padding: 8px 14px;
  width: fit-content;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.03em;
}

.login-secure-badge i { color: var(--accent-mid); font-size: 13px; }

@media (max-width: 480px) {
  .login-glow { width: 340px; height: 340px; filter: blur(80px); }
  .login-card { width: calc(100vw - 32px); padding: 32px 22px 24px; }
  .login-emblem { width: 62px; height: 62px; }
  .login-title { font-size: 16px; }
  .login-logo-row { gap: 14px; margin-bottom: 22px; }
}

/* Topbar branding block — logo + two-line text */
.topbar-brand {
  display: flex; align-items: center; gap: 12px;
}
.topbar-brand-emblem {
  width: 44px; height: 44px; flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.topbar-brand-text {
  display: flex; flex-direction: column; gap: 2px;
}
.topbar-brand-title {
  font-size: 14px; font-weight: 700;
  color: var(--chrome-text); letter-spacing: -0.01em;
  line-height: 1.2;
}
.topbar-brand-sub {
  font-size: 10px; color: var(--chrome-text-2);
  letter-spacing: 0.1em; text-transform: uppercase;
  line-height: 1;
}

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  font-size: 14.5px;
  color: #ECECF1;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-input::placeholder { color: rgba(255,255,255,0.30); }
.form-input:hover { border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.055); }
.form-input:focus {
  border-color: rgba(23,217,166,0.65);
  outline: none;
  background: rgba(255,255,255,0.065);
  box-shadow: 0 0 0 3.5px rgba(23,217,166,0.14), 0 4px 16px rgba(0,0,0,0.20);
}

.pw-wrap { position: relative; }

.pw-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-3);
  font-size: 16px; padding: 4px;
  cursor: pointer; transition: color 0.15s;
  display: flex; align-items: center;
}

.pw-toggle:hover { color: var(--text-2); }

.btn-login {
  width: 100%; padding: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-mid) 0%, var(--accent) 100%);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 6px 18px rgba(16,163,127,0.32), inset 0 1px 0 rgba(255,255,255,0.20);
  transition: box-shadow 0.15s ease, transform 0.1s ease, filter 0.15s ease;
  margin-top: 10px;
}

.btn-login i { font-size: 15px; transition: transform 0.15s ease; }
.btn-login:hover { filter: brightness(1.06); box-shadow: 0 8px 22px rgba(16,163,127,0.40); }
.btn-login:hover i { transform: translateX(2px); }
.btn-login:active { transform: scale(0.99); }

.login-error {
  background: var(--red-bg); color: var(--red);
  font-size: 13px; font-weight: 500;
  padding: 10px 12px; border-radius: 9px;
  margin-top: 14px;
  display: none;
  align-items: center; gap: 7px;
  border: 1px solid rgba(248,113,113,0.20);
}

.login-error.show { display: flex; }

/* ═══════════════════════════════════════════
   SIGN UP SCREEN
═══════════════════════════════════════════ */
#signup-screen {
  position: fixed; inset: 0; z-index: 1001;
  background: linear-gradient(145deg, #0D0D0F 0%, #171717 55%, #1A1A1D 100%);
  display: none; align-items: center; justify-content: center;
  opacity: 1; transition: opacity 0.4s ease;
  overflow-y: auto;
  padding: 20px 16px;
}

#signup-screen.visible { display: flex; }
#signup-screen.hiding { opacity: 0; pointer-events: none; }

.signup-card {
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.10);
  width: 500px; max-width: 100%;
  border-radius: 20px;
  padding: 32px 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  animation: loginCardIn 0.5s cubic-bezier(.22,.61,.36,1) both;
  position: relative;
  margin: auto 0;
  flex-shrink: 0;
}

.signup-back-btn {
  position: absolute; top: 18px; left: 18px;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-2); font-size: 16px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}

.signup-back-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.signup-header {
  text-align: center; margin-bottom: 10px;
}

.signup-emblem-wrap {
  display: flex; justify-content: center; margin-bottom: 6px;
}

.signup-title {
  font-size: 17px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
  margin-bottom: 2px; line-height: 1.2;
}

.signup-sub {
  font-size: 11px; color: var(--text-3); line-height: 1.3;
}

.signup-form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.signup-form-full {
  grid-column: 1 / -1;
}

.signup-divider {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0;
}

.signup-divider::before, .signup-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.signup-divider span {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap;
}

.btn-signup {
  width: 100%; padding: 11px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-btn);
  font-size: 15px; font-weight: 600;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
  cursor: pointer; font-family: inherit;
}

.btn-signup:hover { background: var(--accent-dark); }
.btn-signup:active { transform: scale(0.99); }

.signup-success {
  text-align: center; padding: 20px 0;
  display: none;
}

.signup-success.show { display: flex !important; }

.signup-success-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(74,222,128,0.18); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: 0 auto 14px;
}

.signup-success-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}

.signup-success-sub {
  font-size: 13px; color: var(--text-3); line-height: 1.6;
}

.signup-error {
  background: var(--red-bg); color: var(--red);
  font-size: 13px; font-weight: 500;
  padding: 9px 12px; border-radius: 8px;
  margin-top: 12px;
  display: none;
  grid-column: 1 / -1;
}

.signup-error.show { display: block; }

/* Signup profile photo upload */
.su-photo-wrap {
  position: relative; width: 80px; height: 80px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  border: 2px dashed var(--border);
  transition: border-color 0.2s;
}
.su-photo-wrap:hover { border-color: var(--accent); }
.su-photo-preview {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.su-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.su-photo-icon { font-size: 28px; color: var(--text-3); }
.su-photo-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.18s;
  font-size: 18px; color: #fff;
}
.su-photo-wrap:hover .su-photo-overlay { opacity: 1; }
.su-photo-wrap.has-photo { border-style: solid; border-color: var(--accent); }

/* Profile page — photo upload widget */
.profile-photo-wrap {
  position: relative; width: 64px; height: 64px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  border: 2px solid var(--border-light);
  transition: border-color 0.2s;
}
.profile-photo-wrap:hover { border-color: var(--accent); }
.profile-photo-preview {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.profile-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-initials { font-size: 22px; font-weight: 700; color: #fff; }
.profile-photo-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; opacity: 0; transition: opacity 0.18s;
  font-size: 13px; color: #fff; font-weight: 500;
}
.profile-photo-overlay i { font-size: 16px; }
.profile-photo-wrap:hover .profile-photo-overlay { opacity: 1; }
.btn-remove-photo {
  background: none; border: none; color: var(--red, #e05252);
  font-size: 12px; cursor: pointer; padding: 0;
  display: flex; align-items: center; gap: 4px;
  font-family: inherit; opacity: 0.75;
}
.btn-remove-photo:hover { opacity: 1; }

/* ═══════════════════════════════════════════
   PROFILE PAGE — REDESIGNED v2
═══════════════════════════════════════════ */

/* Identity banner — full-width top strip */
.profile-identity-banner {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 22px 18px;
  background: linear-gradient(135deg, var(--chrome-dark) 0%, var(--chrome) 60%, #2A2B32 100%);
  position: relative; overflow: hidden;
}

/* Subtle diagonal grid watermark on banner */
.profile-identity-banner::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.03) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  pointer-events: none;
}

/* Large avatar on profile banner */
.profile-photo-wrap-lg {
  position: relative; width: 80px; height: 80px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  border: 3px solid rgba(255,255,255,0.30);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 0 0 4px rgba(16,163,127,0.25);
  z-index: 1;
}
.profile-photo-wrap-lg:hover {
  border-color: rgba(255,255,255,0.65);
  box-shadow: 0 0 0 4px rgba(126,200,122,0.40);
}
.profile-photo-preview-lg {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.profile-photo-preview-lg img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-initials-lg { font-size: 28px; font-weight: 700; color: #fff; letter-spacing: -0.02em; }
.profile-photo-overlay-lg {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.52);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; opacity: 0; transition: opacity 0.18s;
  font-size: 11px; color: #fff; font-weight: 600; letter-spacing: 0.02em;
}
.profile-photo-overlay-lg i { font-size: 18px; }
.profile-photo-wrap-lg:hover .profile-photo-overlay-lg { opacity: 1; }

.profile-banner-info { flex: 1; min-width: 0; z-index: 1; }
.profile-banner-name {
  font-size: 20px; font-weight: 700; color: #fff;
  letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 3px;
}
.profile-banner-role {
  font-size: 12px; color: rgba(255,255,255,0.65);
  line-height: 1.4; margin-bottom: 10px;
}
.profile-banner-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.profile-banner-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.80);
  letter-spacing: 0.02em;
}
.profile-banner-chip i { font-size: 12px; color: var(--nav-accent-bar); }

/* Section heading inside card — with left-bar accent */
.profile-section-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px 0;
  margin-bottom: 14px;
}
.profile-section-hdr-bar {
  width: 3px; height: 18px; border-radius: 2px;
  background: var(--accent); flex-shrink: 0;
}
.profile-section-hdr-label {
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3);
}
.profile-section-hdr-icon {
  font-size: 15px; color: var(--text-3); margin-left: auto;
}

/* Profile form body */
.profile-form-body {
  padding: 0 22px 20px;
  display: flex; flex-direction: column; gap: 14px;
}

/* Profile action row */
.profile-action-row {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

/* Security card within profile */
.profile-security-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px; color: var(--text-2);
  line-height: 1.55;
}
.profile-security-notice i { font-size: 15px; color: var(--text-3); flex-shrink: 0; margin-top: 1px; }

/* Improved form input — dark theme */
.form-input-v2 {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--r-btn);
  font-size: 13.5px;
  color: #ECECF1;
  background: rgba(255,255,255,0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.4;
}
.form-input-v2::placeholder { color: rgba(255,255,255,0.30); }
.form-input-v2:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.18);
  background: rgba(255,255,255,0.08);
}

/* Profile page — two-column layout */
.profile-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 860px) {
  .profile-two-col { grid-template-columns: 1fr; }
}

/* Account info rows inside Security card */
.profile-account-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.profile-account-info-row:last-child { border-bottom: none; }
.profile-account-info-label {
  color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
}
.profile-account-info-label i { font-size: 14px; }
.profile-account-info-value { color: var(--text-1); font-weight: 600; font-size: 13px; }
.profile-status-active {
  color: var(--accent);
  background: rgba(16,163,127,0.12);
  padding: 2px 10px; border-radius: 20px; font-size: 11px;
}

/* ═══════════════════════════════════════════
   SIGNUP SCREEN — REDESIGNED v3 (split layout)
═══════════════════════════════════════════ */

/* Wide card: left branding panel + right form panel */
.signup-card-v2 {
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.09);
  width: 900px; max-width: calc(100vw - 32px);
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 64px rgba(0,0,0,0.60);
  animation: loginCardIn 0.5s cubic-bezier(.22,.61,.36,1) both;
  position: relative;
  margin: auto 0;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

/* LEFT PANEL — dark branding column */
.signup-left-panel {
  width: 260px; flex-shrink: 0;
  background: linear-gradient(160deg, #171717 0%, #1E1E22 55%, #202123 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 28px;
  position: relative; overflow: hidden;
  gap: 0;
}
.signup-left-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.025) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.025) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0px;
  pointer-events: none;
}
/* Decorative ring behind emblem */
.signup-left-panel::after {
  content: '';
  position: absolute;
  width: 220px; height: 220px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.07);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.signup-left-emblem {
  width: 90px; height: 90px;
  object-fit: contain; z-index: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.45));
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  margin-bottom: 20px;
}
.signup-left-title {
  font-size: 17px; font-weight: 800; color: #fff;
  letter-spacing: -0.02em; line-height: 1.25;
  text-align: center; z-index: 1;
  margin-bottom: 6px;
}
.signup-left-sub {
  font-size: 11px; color: rgba(255,255,255,0.52);
  letter-spacing: 0.08em; text-transform: uppercase;
  text-align: center; z-index: 1;
  margin-bottom: 28px;
}
.signup-left-divider {
  width: 36px; height: 2px; border-radius: 1px;
  background: rgba(255,255,255,0.18);
  margin-bottom: 28px; z-index: 1;
}
.signup-left-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 20px; z-index: 1;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.72);
  letter-spacing: 0.03em;
}
.signup-left-badge i { font-size: 13px; color: var(--nav-accent-bar, #7EC87A); }

/* Back button — top-right of LEFT panel */
.signup-back-btn-v2 {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.80); font-size: 15px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.signup-back-btn-v2:hover { background: rgba(255,255,255,0.22); color: #fff; }

/* RIGHT PANEL — form content */
.signup-card-header {
  display: none; /* header is now replaced by left panel */
}
.signup-card-body {
  flex: 1; min-width: 0;
  padding: 28px 32px 28px;
  overflow-y: auto;
  max-height: min(92vh, 680px);
}

/* Compact section divider */
.signup-section-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px;
}
.signup-section-divider-bar {
  width: 3px; height: 14px; border-radius: 2px;
  background: var(--accent); flex-shrink: 0;
}
.signup-section-divider-label {
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3);
}
.signup-section-divider-line {
  flex: 1; height: 1px; background: var(--border-light);
}

/* Photo zone — horizontal row inside right panel */
.su-photo-zone {
  display: flex; flex-direction: row; align-items: center;
  gap: 16px; margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-light);
}
.su-photo-wrap-v2 {
  position: relative; width: 72px; height: 72px; border-radius: 50%;
  cursor: pointer; flex-shrink: 0;
  border: 2px dashed var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.su-photo-wrap-v2:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16,163,127,0.12);
}
.su-photo-wrap-v2.has-photo {
  border-style: solid; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16,163,127,0.15);
}
.su-photo-preview-v2 {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.su-photo-preview-v2 img { width: 100%; height: 100%; object-fit: cover; }
.su-photo-icon-v2 { font-size: 28px; color: var(--border); }
.su-photo-overlay-v2 {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(30,45,39,0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; opacity: 0; transition: opacity 0.18s;
  font-size: 10px; color: #fff; font-weight: 600; letter-spacing: 0.02em;
}
.su-photo-overlay-v2 i { font-size: 18px; }
.su-photo-wrap-v2:hover .su-photo-overlay-v2 { opacity: 1; }
.su-photo-label {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
}
.su-photo-label strong { display: block; font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.su-photo-label span { color: var(--accent); font-weight: 600; }

/* 3-column form grid: maximise horizontal use */
.signup-form-grid-v2 {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px 14px;
}
.signup-form-full-v2 { grid-column: 1 / -1; }
/* email spans 2 cols to avoid being too narrow */
.signup-span2 { grid-column: span 2; }

/* Compact form inputs — dark theme */
.form-input-v2 {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--r-btn);
  font-size: 13px;
  color: #ECECF1;
  background: rgba(255,255,255,0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.4;
  box-sizing: border-box;
}
.form-input-v2::placeholder { color: rgba(255,255,255,0.30); }
.form-input-v2:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.18);
  background: rgba(255,255,255,0.09);
}

/* Signup submit button */
.btn-signup-v2 {
  width: 100%; padding: 12px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-btn);
  font-size: 14.5px; font-weight: 700;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  margin-top: 4px;
  cursor: pointer; font-family: inherit;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(16,163,127,0.28);
}
.btn-signup-v2:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 18px rgba(16,163,127,0.38);
}
.btn-signup-v2:active { transform: scale(0.99); }

/* Signup error */
.signup-error-v2 {
  display: none; align-items: flex-start; gap: 10px;
  background: var(--red-bg); color: var(--red);
  border: 1px solid rgba(220,38,38,0.20);
  font-size: 12.5px; font-weight: 500;
  padding: 9px 12px; border-radius: 8px;
  margin-top: 4px;
  grid-column: 1 / -1;
  line-height: 1.5;
}
.signup-error-v2.show { display: flex; }
.signup-error-v2 i { font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* Responsive: stack on narrow screens */
@media (max-width: 700px) {
  .signup-card-v2 { flex-direction: column; width: 100%; max-width: 100%; border-radius: 0; }
  .signup-left-panel { width: 100%; padding: 28px 24px 22px; flex-direction: row; justify-content: flex-start; gap: 16px; }
  .signup-left-panel::after { display: none; }
  .signup-left-emblem { width: 52px; height: 52px; margin-bottom: 0; }
  .signup-left-title { font-size: 14px; text-align: left; margin-bottom: 2px; }
  .signup-left-sub { text-align: left; margin-bottom: 0; }
  .signup-left-divider, .signup-left-badge { display: none; }
  .signup-card-body { max-height: none; padding: 20px 18px 24px; }
  .signup-form-grid-v2 { grid-template-columns: 1fr 1fr; }
  .signup-span2 { grid-column: 1 / -1; }
  .signup-back-btn-v2 { top: 12px; right: 12px; }
}

/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#app.visible { display: flex; }

/* ═══════════════════════════════════════════
   SIDEBAR — Premium Dark Slate Green theme
═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--chrome);
  border-right: none;
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  transform: translateX(-100%);
  animation: sidebarSlideIn 0.4s ease-out 0.1s forwards;
  position: relative; z-index: 10;
  box-shadow: 2px 0 16px rgba(0,0,0,0.22);
}
.sb-scroll-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
}

@keyframes sidebarSlideIn {
  to { transform: translateX(0); }
}

/* Sidebar header — matches topbar height exactly */
.sb-header {
  height: var(--topbar-h);
  padding: 0;
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-dark);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.sb-brand-card {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 10px 0 14px;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: linear-gradient(135deg, rgba(16,163,127,0.08) 0%, rgba(255,255,255,0.02) 100%);
  border: none;
  box-shadow: none;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
  cursor: default;
}

.sb-brand-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0;
}

.sb-brand-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.35), 0 0 16px rgba(16,163,127,0.12);
}

/* Logo + wordmark: horizontal, logo left, text right */
.sb-logo-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.sb-emblem {
  width: 44px; height: 44px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35));
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.sb-wordmark {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  flex: 1;
}

.sb-name {
  font-size: 11px; font-weight: 700; color: var(--chrome-text);
  letter-spacing: -0.01em; line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sb-sub {
  font-size: 8.5px; color: var(--chrome-text-3);
  letter-spacing: 0.13em; text-transform: uppercase;
  margin-top: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* New Chat button */
.sb-new-chat-wrap {
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.btn-new-chat {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  background: rgba(255,255,255,0.12);
  color: var(--chrome-text);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--r-btn);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  justify-content: center;
}

.btn-new-chat:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.28);
}
.btn-new-chat:active { transform: scale(0.98); }

/* Sidebar nav sections */
.sb-section {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--chrome-text-3);
  padding: 16px 18px 5px;
  opacity: 0;
  animation: navItemIn 0.35s ease-out forwards;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 16px;
  margin: 1px 8px 1px 6px;
  color: var(--chrome-text-2);
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  border-left: 2.5px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  position: relative;
  opacity: 0;
  animation: navItemIn 0.35s ease-out forwards;
  user-select: none;
  border-radius: 8px;
}

@keyframes navItemIn {
  from { opacity:0; transform: translateX(-10px); }
  to   { opacity:1; transform: translateX(0); }
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--chrome-text);
  transform: translateX(1px);
}

.nav-item:hover .nav-icon { transform: translateX(2px); color: var(--accent-mid); }

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
  font-weight: 600;
  border-left-color: var(--nav-accent-bar);
  box-shadow: var(--nav-active-glow);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -6px; top: 3px; bottom: 3px;
  width: 3px;
  background: var(--nav-accent-bar);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(23,217,166,0.65);
}

.nav-item.active .nav-icon { color: var(--accent-mid); }

.nav-item.active:hover {
  background: var(--nav-active-bg);
  transform: translateX(1px);
}

.nav-item .nav-arrow {
  margin-left: auto;
  font-size: 12px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s, transform 0.15s;
  color: var(--chrome-text-3);
}

.nav-item:hover .nav-arrow {
  opacity: 1;
  transform: translateX(0);
}

.nav-icon {
  font-size: 16px; flex-shrink: 0;
  transition: transform 0.2s, color 0.18s ease;
  color: inherit;
}

/* NEW badge */
.sb-badge-new {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: 8.5px; font-weight: 800;
  padding: 1px 6px; border-radius: 10px;
  letter-spacing: 0.04em; text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Sidebar Search Bar ── */
.sb-search-wrap {
  padding: 8px 12px 6px;
  flex-shrink: 0;
}
.sb-search-inner {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 7px 10px;
  transition: background 0.15s, border-color 0.15s;
}
.sb-search-inner:focus-within {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.20);
}
.sb-search-icon {
  font-size: 14px; color: var(--chrome-text-3); flex-shrink: 0;
}
.sb-search-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: 12.5px;
  color: var(--chrome-text); caret-color: var(--accent);
}
.sb-search-input::placeholder { color: var(--chrome-text-3); }
.sb-search-clear {
  background: none; border: none; color: var(--chrome-text-3);
  font-size: 13px; cursor: pointer; padding: 0; line-height: 1;
  flex-shrink: 0;
  transition: color 0.12s;
}
.sb-search-clear:hover { color: var(--chrome-text-2); }

/* ── Chat history group labels ── */
.sb-history-group-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--chrome-text-3);
  padding: 14px 18px 6px;
}
.sb-history-group-label:first-child {
  padding-top: 6px;
}

/* ── Collapsible Categories ── */
.sb-cat-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 16px;
  margin: 1px 8px 1px 6px;
  color: var(--chrome-text-2);
  font-size: 13px;
  cursor: pointer;
  border-left: 2.5px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
  user-select: none;
  border-radius: 8px;
  opacity: 0;
  animation: navItemIn 0.35s ease-out forwards;
}

.sb-cat-toggle:hover {
  background: var(--nav-hover-bg);
  color: var(--chrome-text);
  transform: translateX(1px);
}

.sb-cat-toggle:hover .sb-cat-toggle-icon { color: var(--accent-mid); }

.sb-cat-toggle.open {
  color: var(--chrome-text); font-weight: 600;
  background: var(--nav-hover-bg);
  border-left-color: rgba(23,217,166,0.45);
}

.sb-cat-toggle .sb-cat-toggle-icon {
  font-size: 16px; flex-shrink: 0;
  transition: color 0.18s ease;
}

.sb-cat-toggle .sb-cat-caret {
  margin-left: auto;
  font-size: 13px;
  color: var(--chrome-text-3);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
  flex-shrink: 0;
}

.sb-cat-toggle.open .sb-cat-caret { transform: rotate(90deg); }

.sb-cat-toggle .sb-cat-count {
  font-size: 10.5px; font-weight: 700;
  background: linear-gradient(135deg, rgba(16,163,127,0.32) 0%, rgba(16,163,127,0.16) 100%);
  color: #E8FFF6;
  border: 1px solid rgba(23,217,166,0.35);
  padding: 2px 9px; border-radius: var(--r-badge);
  margin-left: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.08);
  letter-spacing: 0.01em;
}

/* ── Tree-view submenu (Applications / Categories children) ── */
.sb-tree-list {
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
  max-height: 0;
  opacity: 0;
}

#sb-cat-list.open { max-height: 600px; opacity: 1; }
#sb-apps-list.open { max-height: 200px; opacity: 1; }

/* Vertical guide line running down the left edge of the child stack, broken only by
   each item's own horizontal tick (drawn via .sb-tree-connector) — the two together
   read as a single continuous "└─" branch per row instead of a plain indent. */
.sb-tree-list::before {
  content: '';
  position: absolute;
  left: 27px; top: 0; bottom: 14px;
  width: 1px;
  background: var(--border);
}

.sb-tree-item {
  position: relative;
  display: flex;
  align-items: center;
  opacity: 1;
  margin: 1px 8px 1px 6px;
  border-radius: 8px;
  border-left: 2.5px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.3s;
}

.sb-tree-item.sb-reordering {
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.3s, transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

.sb-tree-item:hover {
  background: var(--nav-hover-bg);
}

.sb-tree-item.active {
  background: var(--nav-active-bg);
  border-left-color: var(--nav-accent-bar);
  box-shadow: var(--nav-active-glow);
}

.sb-tree-item.active:hover {
  background: var(--nav-active-bg);
}

.sb-tree-connector {
  position: absolute;
  left: 21px; top: 50%;
  width: 17px; height: 1px;
  background: var(--border);
  pointer-events: none;
}

.sb-tree-list .nav-item.sb-tree-link {
  flex: 1;
  padding: 9px 14px 9px 38px;
  margin: 0;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--chrome-text-3);
  opacity: 1;
  animation: none;
  border-left: none;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
}

.sb-tree-list .nav-item.sb-tree-link:hover {
  color: var(--chrome-text);
}

.sb-tree-list .nav-item.sb-tree-link.active {
  color: var(--nav-active-text);
  font-weight: 600;
}

.sb-tree-list .nav-item.sb-tree-link.active::before {
  display: none;
}

.sb-tree-list .nav-item.sb-tree-link .nav-icon {
  font-size: 14px;
}

/* ── Chat History section ──────────────────────────────────────────────────
   Single uniform row pattern for every item regardless of source
   (Application / Category / AI Chat) — only the icon chip's accent color
   varies, so the list reads as one consistent system. */
.sb-chat-history {
  flex-shrink: 0;
}

.sb-history-list {
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 2px 0 8px;
}

.sb-history-item {
  position: relative;
  display: flex; align-items: stretch; gap: 0;
  padding: 0 6px 0 12px;
  font-size: 12.5px; color: var(--chrome-text-2);
  cursor: pointer; border-radius: 9px;
  margin: 0 8px 0 6px;
  border-left: 2.5px solid transparent;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
  overflow: hidden;
}

.sb-history-item:hover {
  background: var(--nav-hover-bg);
  color: var(--chrome-text);
  transform: translateX(1px);
}

.sb-history-item:active {
  transform: translateX(1px) scale(0.99);
}

.sb-history-link {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  padding: 8px 0;
}

/* Source icon chip — same size, shape, and color for every row, so the
   list reads as one consistent system regardless of conversation source. */
.sb-history-source-icon {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 7px;
  font-size: 12.5px;
  background: hsla(168, 70%, 60%, 0.16);
  color: hsl(168, 85%, 72%);
  transition: background 0.16s ease, color 0.16s ease;
}

.sb-history-body {
  display: flex; flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 2px;
  justify-content: center;
}

.sb-history-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.3;
  font-weight: 500;
}

.sb-history-source-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--chrome-text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.2;
}

/* Active/selected state — one definitive treatment for the current conversation */
.sb-history-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
  border-left-color: var(--nav-accent-bar);
}

.sb-history-item.active .sb-history-text {
  font-weight: 600;
}

.sb-history-item.active .sb-history-source-icon {
  background: rgba(255,255,255,0.14);
  color: #ffffff;
}

.sb-history-item.active .sb-history-source-label {
  color: rgba(255,255,255,0.60);
}

/* Empty chat history placeholder */
.sb-history-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 8px;
  font-size: 11.5px; color: var(--chrome-text-3);
}
.sb-history-empty i { font-size: 14px; flex-shrink: 0; }

/* ── Sidebar top action items (New Chat, Search) ── */
.sb-top-actions {
  padding-top: 4px;
}

/* ── Sidebar extra nav (Library, Projects) ── */
.sb-extra-nav {
  padding: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}

/* Sidebar bottom profile — ChatGPT-style user bar */
.sb-bottom-profile {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--chrome-border);
  background: var(--chrome-dark);
  flex-shrink: 0;
  color: var(--chrome-text);
  font-size: 13px; font-weight: 500;
  position: relative;
}
.sb-profile-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden; user-select: none;
}
.sb-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sb-profile-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
}
.sb-profile-name {
  font-size: 13px; font-weight: 600; color: var(--chrome-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.2;
}
.sb-profile-dept {
  font-size: 10.5px; color: var(--chrome-text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.2;
}
.sb-bottom-profile-arrow {
  font-size: 15px; color: var(--chrome-text-3); flex-shrink: 0;
  cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.sb-bottom-profile-arrow:hover,
.sb-bottom-profile.menu-open .sb-bottom-profile-arrow {
  background: var(--nav-hover-bg);
  color: var(--chrome-text);
}

/* Sidebar profile pop-up menu */
.sb-profile-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 10px; right: 10px;
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 -8px 28px rgba(0,0,0,0.45);
  overflow: hidden;
  z-index: 200;
  animation: dropdownIn 0.15s ease-out;
}
.sb-bottom-profile.menu-open .sb-profile-menu { display: block; }

.sb-profile-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--chrome-text-2);
  background: none; border: none;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.sb-profile-menu-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--chrome-text);
}
.sb-profile-menu-item i { font-size: 15px; flex-shrink: 0; color: var(--chrome-text-3); }
.sb-profile-menu-item:hover i { color: var(--chrome-text-2); }
.sb-profile-menu-item.danger { color: var(--red); }
.sb-profile-menu-item.danger i { color: var(--red); opacity: 0.7; }
.sb-profile-menu-item.danger:hover { background: var(--red-bg); color: var(--red); }
.sb-profile-menu-divider {
  height: 1px; background: rgba(255,255,255,0.08); margin: 4px 0;
}

/* Search chats overlay */
.sb-search-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.55);
  align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.sb-search-overlay.open { display: flex; }
.sb-search-modal {
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  width: 520px; max-width: calc(100vw - 32px);
  overflow: hidden;
  animation: loginCardIn 0.2s cubic-bezier(.22,.61,.36,1) both;
}
.sb-search-modal-header {
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sb-search-modal-icon { font-size: 16px; color: var(--chrome-text-3); flex-shrink: 0; }
.sb-search-modal-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: 14px;
  color: var(--chrome-text); caret-color: var(--accent);
}
.sb-search-modal-input::placeholder { color: var(--chrome-text-3); }
.sb-search-modal-close {
  background: none; border: none; color: var(--chrome-text-3);
  font-size: 18px; cursor: pointer; padding: 0; line-height: 1;
  transition: color 0.12s;
}
.sb-search-modal-close:hover { color: var(--chrome-text-2); }
.sb-search-results {
  max-height: 340px; overflow-y: auto;
  padding: 8px 0;
}
.sb-search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: 13px; color: var(--chrome-text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sb-search-result-item:hover { background: rgba(255,255,255,0.07); color: var(--chrome-text); }
.sb-search-result-item i { font-size: 14px; color: var(--chrome-text-3); flex-shrink: 0; }
.sb-search-empty {
  padding: 28px 16px; text-align: center;
  font-size: 13px; color: var(--chrome-text-3);
}

/* ═══════════════════════════════════════════
   CONFIRM DIALOG (Delete / Clear chat, etc.)
═══════════════════════════════════════════ */
.confirm-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.55);
  align-items: center; justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-modal {
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  width: 400px; max-width: calc(100vw - 32px);
  padding: 20px 22px;
}
.confirm-modal-title {
  font-size: 15px; font-weight: 700; color: var(--chrome-text);
  margin-bottom: 8px;
}
.confirm-modal-body {
  font-size: 13px; color: var(--chrome-text-2);
  line-height: 1.5; margin-bottom: 20px;
}
.confirm-modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Chat history item hover action (kebab menu) ── */
.sb-history-item-action {
  flex-shrink: 0;
  align-self: center;
  display: none;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: none; border: none;
  color: var(--chrome-text-3);
  font-size: 14px; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.sb-history-item:hover .sb-history-item-action,
.sb-history-item-action.open {
  display: flex;
}
.sb-history-item-action:hover,
.sb-history-item-action.open {
  background: rgba(255,255,255,0.14); color: var(--chrome-text);
}
.sb-history-item.active .sb-history-item-action {
  color: rgba(255,255,255,0.65);
}
.sb-history-item.active .sb-history-item-action:hover,
.sb-history-item.active .sb-history-item-action.open {
  background: rgba(255,255,255,0.18); color: #ffffff;
}
.sb-history-item-menu {
  display: none;
  position: fixed; top: 0; left: 0;
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  min-width: 150px;
  z-index: 900;
  overflow: hidden;
  padding: 4px;
}
.sb-history-item-menu.open { display: block; }
.sb-history-item-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  font-size: 12.5px; color: var(--chrome-text-2);
  cursor: pointer; background: none; border: none;
  width: 100%; text-align: left; font-family: inherit;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.sb-history-item-menu-item:hover { background: rgba(255,255,255,0.08); color: var(--chrome-text); }
.sb-history-item-menu-item.danger { color: #f87171; }
.sb-history-item-menu-item.danger:hover { background: rgba(248,113,113,0.14); color: #fca5a5; }
.sb-history-item-menu-item i { font-size: 13px; flex-shrink: 0; }

/* Category Chat Mode — banner in chat page */
.chat-category-banner {
  display: none;
  align-items: center; gap: 10px;
  padding: 8px 16px 0;
  flex-shrink: 0;
}
.chat-category-banner.visible { display: flex; }
.chat-category-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-light);
  border: 1px solid rgba(16,163,127,0.30);
  border-radius: 20px;
  padding: 4px 12px 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--accent-mid);
}
.chat-category-badge i { font-size: 13px; }
.chat-category-clear {
  background: none; border: none;
  font-size: 11.5px; color: var(--text-3); cursor: pointer;
  padding: 0 4px; font-family: inherit;
  transition: color 0.12s;
}
.chat-category-clear:hover { color: var(--text-2); }

/* Sidebar footer */
.sb-footer {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--chrome-border);
  flex-shrink: 0;
  background: var(--chrome-dark);
}

.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 8px;
}

.user-info:hover { background: var(--nav-hover-bg); }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--nav-accent-bar);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--chrome-dark);
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: var(--chrome-text); line-height: 1.2; }
.user-role { font-size: 11px; color: var(--chrome-text-2); }

.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: transparent; color: var(--chrome-text-2);
  border: 1px solid rgba(255,255,255,0.14); border-radius: var(--r-btn);
  font-size: 13px; font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
  background: rgba(220,38,38,0.18); color: #fca5a5;
  border-color: rgba(220,38,38,0.4);
}

/* ═══════════════════════════════════════════
   MAIN AREA
═══════════════════════════════════════════ */
.main {
  flex: 1; display: flex; flex-direction: column;
  height: 100vh; min-width: 0; overflow: hidden;
}

/* TOPBAR — Premium Dark Slate Green */
.topbar {
  height: var(--topbar-h);
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--chrome-text-2);
}

.topbar-breadcrumb span { color: var(--chrome-text-2); }
.topbar-breadcrumb strong { color: var(--chrome-text); font-weight: 600; font-size: 15px; }

.topbar-sep { color: var(--chrome-text-3); font-size: 16px; }

.topbar-breadcrumb-nav {
  display: flex; align-items: center; gap: 0;
  font-size: 13px;
}
.topbar-bc-home {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 7px;
  background: none; border: none;
  color: var(--chrome-text-2); font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.topbar-bc-home:hover { background: var(--nav-hover-bg); color: var(--chrome-text); }
.topbar-bc-home i { font-size: 15px; flex-shrink: 0; }
.topbar-bc-sep {
  color: var(--chrome-text-3); font-size: 14px;
  margin: 0 2px; user-select: none; line-height: 1;
}
.topbar-bc-page {
  padding: 5px 8px;
  color: var(--chrome-text); font-size: 13px; font-weight: 700;
  letter-spacing: -0.01em; white-space: nowrap;
}

.topbar-spacer { flex: 1; }

/* TOPBAR USER PROFILE — premium pill badge */
.topbar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 40px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  user-select: none;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.06);
}
.topbar-user:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.20);
  box-shadow: 0 2px 8px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Department logo area in topbar */
.topbar-dept-logo {
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent;
  border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}

.topbar-dept-logo svg { width: 30px; height: 30px; }

/* Dynamic user avatar — shows photo or initials */
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--nav-accent-bar, #3a9e5c);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  overflow: hidden; user-select: none; flex-shrink: 0;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar-avatar-lg {
  width: 40px; height: 40px;
  font-size: 16px;
}

/* Avatar ring — distinct from the flat sidebar avatar */
.topbar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border: 2px solid rgba(16,163,127,0.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.12), 0 2px 6px rgba(0,0,0,0.35);
  letter-spacing: -0.02em;
}
.topbar-user-info { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-user-name {
  font-size: 12.5px; font-weight: 700; color: var(--chrome-text);
  letter-spacing: -0.01em; white-space: nowrap;
}
.topbar-user-role {
  font-size: 10px; color: var(--accent-mid);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; white-space: nowrap;
}
.topbar-user-chevron {
  font-size: 13px; color: rgba(255,255,255,0.35);
  transition: transform 0.2s, color 0.2s;
  margin-left: 1px;
}
.topbar-user:hover .topbar-user-chevron { color: rgba(255,255,255,0.55); }
.topbar-user.open .topbar-user-chevron { transform: rotate(180deg); color: var(--chrome-text-2); }

/* Static topbar user (user layout — no dropdown) */
.topbar-user-static {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 40px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.06);
}
.topbar-user-static .topbar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border: 2px solid rgba(16,163,127,0.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.12), 0 2px 6px rgba(0,0,0,0.35);
}
.topbar-user-static .topbar-user-name {
  font-size: 12.5px; font-weight: 700; color: var(--chrome-text); letter-spacing: -0.01em;
}
.topbar-user-static .topbar-user-role {
  font-size: 10px; color: var(--accent-mid); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* TOPBAR USER DROPDOWN — ChatGPT-style minimal menu */
.topbar-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: #2A2B32;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.40);
  z-index: 100;
  overflow: hidden;
  animation: dropdownIn 0.15s ease-out;
}
.topbar-user.open .topbar-user-dropdown { display: block; }

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dropdown user identity header */
.topbar-user-dropdown-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; gap: 12px; align-items: center;
  background: rgba(255,255,255,0.03);
}

.dropdown-dept-logo {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border: 2px solid rgba(16,163,127,0.50);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.10), 0 2px 6px rgba(0,0,0,0.35);
}

.dropdown-dept-logo svg { width: 32px; height: 32px; }

.dropdown-profile-info { flex: 1; min-width: 0; }

.topbar-user-dropdown-name {
  font-size: 13.5px; font-weight: 700; color: var(--chrome-text);
  line-height: 1.2; margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar-user-dropdown-role {
  font-size: 10.5px; color: var(--accent-mid); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Dropdown menu items */
.dropdown-menu-section {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.dropdown-menu-section:last-child { border-bottom: none; }

.dropdown-menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 16px;
  font-size: 13px; font-weight: 500; color: var(--chrome-text-2);
  cursor: pointer; background: none; border: none;
  width: 100%; text-align: left; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.dropdown-menu-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--chrome-text);
}
.dropdown-menu-item i {
  font-size: 16px; flex-shrink: 0; color: var(--chrome-text-3);
}
.dropdown-menu-item:hover i { color: var(--chrome-text-2); }

.dropdown-menu-item.danger { color: var(--red); }
.dropdown-menu-item.danger i { color: var(--red); opacity: 0.7; }
.dropdown-menu-item.danger:hover { background: var(--red-bg); color: var(--red); }

/* Profile detail rows (kept for compatibility) */
.dropdown-details { display: none; }
.dropdown-detail-row { display: none; }
.dropdown-detail-icon { display: none; }
.dropdown-detail-label { display: none; }
.dropdown-detail-value { display: none; }

.topbar-signout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 11px 18px;
  background: none; border: none;
  font-size: 13px; font-weight: 500;
  color: var(--red);
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}
.topbar-signout-btn:hover { background: var(--red-bg); }

.topbar-signin-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 16px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--chrome-text);
  cursor: pointer; transition: background 0.15s;
  white-space: nowrap;
}
.topbar-signin-btn:hover { background: rgba(255,255,255,0.22); }

/* Topbar "Sign up for free" button (pre-login only) */
.topbar-signup-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 16px;
  background: var(--accent); border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px; font-weight: 600; color: #fff;
  cursor: pointer; transition: background 0.15s;
  white-space: nowrap;
}
.topbar-signup-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ── Pre-login landing state ── */
/* When #app has .pre-login: hide authenticated UI, show landing UI */
#app.pre-login .topbar-breadcrumb-nav { display: none; }
#app.pre-login #topbar-new-chat-btn   { display: none !important; }
#app.pre-login #topbar-signin-btn     { display: flex !important; }
#app.pre-login #topbar-user           { display: none !important; }

/* Sidebar in pre-login: hide all nav, categories, history, profile footer */
#app.pre-login .sb-section,
#app.pre-login #nav-upload,
#app.pre-login #nav-chat,
#app.pre-login #nav-mail-draft,
#app.pre-login #sb-cat-toggle,
#app.pre-login #sb-cat-list,
#app.pre-login #sb-apps-toggle,
#app.pre-login #sb-apps-list,
#app.pre-login .sb-chat-history,
#app.pre-login #sb-bottom-profile-btn { display: none; }
#app.pre-login .sb-extra-nav { display: none; }
#app.pre-login .sb-top-actions { display: none; }

/* Landing welcome page */
#page-landing {
  display: none; position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#page-landing.active { display: flex; }

/* Single centered block that holds all landing content */
.landing-center {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 720px;
  padding: 40px 24px 48px;
  gap: 0;
  /* Slight upward offset matches the visual weight of the sidebar chrome above */
  margin-top: -40px;
}

.landing-welcome {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px;
  width: 100%;
  padding: 0 0 28px;
}

.landing-welcome-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
  margin-bottom: 10px;
  box-shadow: 0 4px 24px rgba(16,163,127,0.40);
}

.landing-welcome-title {
  font-size: 28px; font-weight: 700; color: var(--text);
  letter-spacing: -0.025em; line-height: 1.2;
}

.landing-welcome-sub {
  font-size: 14px; color: var(--text-3); line-height: 1.6;
  max-width: 500px;
}

/* Landing input bar — functional input + login redirect button */
.landing-input-wrap {
  width: 100%; margin-top: 0;
  display: flex; justify-content: center;
}

.landing-input-inner {
  width: 100%;
  background: #40414F;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  display: flex; align-items: center;
  padding: 8px 8px 8px 10px;
  gap: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.landing-input-inner:focus-within {
  border-color: rgba(16,163,127,0.55);
  box-shadow: 0 0 0 3px rgba(16,163,127,0.12);
}

/* Attach icon button */
.landing-input-attach {
  width: 32px; height: 32px; border-radius: 7px;
  background: none; border: none; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  margin-right: 4px;
}
.landing-input-attach:hover { color: var(--text); background: rgba(255,255,255,0.08); }

.landing-input-field {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px; font-family: inherit;
  padding: 6px 8px; min-width: 0;
}
.landing-input-field::placeholder { color: rgba(255,255,255,0.32); }

/* Model selector pill */
.landing-input-model {
  padding: 5px 22px 5px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer; flex-shrink: 0;
  font-family: inherit;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24'%3E%3Cpath fill='%238E8EA0' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-color: rgba(255,255,255,0.06);
  max-width: 140px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  margin-left: 6px; margin-right: 8px;
}
.landing-input-model:hover {
  background-color: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.18);
  color: var(--text);
}
.landing-input-model option { background: #2A2B32; color: var(--text); }

.landing-input-send {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.landing-input-send:hover { background: var(--accent-dark); transform: scale(1.05); }

/* Landing suggestion chips (pill style) */
.landing-chips-row {
  padding: 8px 16px 20px;
  display: flex; gap: 8px;
  justify-content: center; flex-wrap: wrap;
  max-width: 768px; margin: 0 auto; width: 100%;
}

@media (max-width: 600px) {
  .landing-center { margin-top: 0; padding: 28px 16px 40px; }
  .landing-welcome-title { font-size: 22px; }
  .landing-welcome-sub { font-size: 13px; }
  .landing-input-model { max-width: 100px; font-size: 11px; padding: 4px 18px 4px 8px; margin-right: 6px; }
  .landing-input-inner { padding: 6px 6px 6px 8px; }
}

/* Landing suggestion cards — now pill style matching chat welcome chips */
.landing-suggest-cards {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  width: 100%; margin: 14px 0 0;
  padding: 0;
}
.landing-suggest-card {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  color: rgba(255,255,255,0.62);
  font-size: 13px; font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.landing-suggest-card:hover {
  background: var(--accent-light);
  border-color: rgba(16,163,127,0.35);
  color: var(--accent-mid);
  transform: translateY(-1px);
}
.landing-suggest-icon {
  font-size: 14px; color: rgba(255,255,255,0.35); flex-shrink: 0;
}
.landing-suggest-card:hover .landing-suggest-icon { color: var(--accent); }

/* CONTENT AREA */
.content-area {
  flex: 1; overflow: hidden;
  position: relative;
}

/* PAGE PANELS */
.page {
  display: none; position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg);
}

.page.active {
  display: block;
  animation: pageIn 0.25s ease-out both;
}

@keyframes pageIn {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: translateY(0); }
}

.page-inner { padding: 24px; }

/* Page header */
.page-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}

.page-hdr-left { display: flex; align-items: center; gap: 12px; }
.page-hdr-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.page-hdr-title { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.page-hdr-count {
  display: inline-flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-2); font-size: 12px; font-weight: 600;
  padding: 2px 10px; border-radius: var(--r-badge);
}

.page-hdr-right { display: flex; align-items: center; gap: 10px; }

.btn-signout-header {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-btn);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-signout-header:hover {
  background: rgba(220,38,38,0.08); color: #dc2626;
  border-color: rgba(220,38,38,0.35);
}

/* ═══════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 8px;
}

.stat-num {
  font-size: 30px; font-weight: 700;
  color: var(--accent); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-icon {
  font-size: 22px; float: right; margin-top: -4px;
  color: var(--border);
}

.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
}

.activity-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg); }

.activity-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(248,113,113,0.18); color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.activity-icon.doc { background: rgba(125,170,252,0.18); color: var(--blue); }
.activity-icon.rules { background: rgba(74,222,128,0.18); color: var(--green); }

.activity-name { font-size: 13px; font-weight: 500; color: var(--text); }
.activity-meta { font-size: 11px; color: var(--text-3); }

.bar-chart { padding: 10px 18px 14px; }

.bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 9px;
}

.bar-label { font-size: 11.5px; color: var(--text-2); width: 90px; flex-shrink: 0; }

.bar-track {
  flex: 1; height: 8px; background: var(--border-light);
  border-radius: 4px; overflow: hidden;
}

.bar-fill {
  height: 100%; border-radius: 4px;
  background: var(--accent);
  animation: barGrow 0.8s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes barGrow { from { width: 0 !important; } }

.bar-count {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); width: 36px; text-align: right;
  flex-shrink: 0;
}

.quick-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 20px;
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-btn);
  padding: 9px 18px; font-size: 13.5px; font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 9px 18px; font-size: 13.5px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: var(--accent-light); border-color: var(--accent);
}

/* btn-orange is now btn-accent for upload category pages */
.btn-orange {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-btn);
  padding: 9px 18px; font-size: 13.5px; font-weight: 600;
  transition: background 0.15s;
}

.btn-orange:hover { background: var(--accent-dark); }

/* ═══════════════════════════════════════════
   UPLOAD PAGE
═══════════════════════════════════════════ */
.cat-select-wrap {
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}

.cat-select {
  flex: 1; max-width: 380px;
  padding: 10px 36px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-btn);
  font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--card);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cat-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,163,127,0.18);
  outline: none;
}

.cat-select.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.10);
}

.cat-select-error {
  font-size: 12px; color: var(--red); font-weight: 500;
  display: none; margin-top: 4px;
}

.cat-select-error.show { display: block; }

.section-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 12px;
}

.upload-box {
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--r-card);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 20px;
}

.upload-box:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16,163,127,0.12);
}

.upload-box.dragover {
  border-color: var(--accent);
  background: rgba(16,163,127,0.08);
}

.upload-icon { font-size: 40px; color: var(--accent); margin-bottom: 10px; }
.upload-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-sub { font-size: 13px; color: var(--text-3); }

.fmt-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }

.fmt-badge {
  background: rgba(125,170,252,0.15); color: var(--blue);
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-badge);
  border: 1px solid rgba(125,170,252,0.25);
}

.file-preview-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 12px 16px;
  margin-bottom: 12px;
}

.file-preview-icon { font-size: 24px; color: var(--red); flex-shrink: 0; }
.file-preview-icon.doc { color: var(--blue); }
.file-preview-name { font-size: 13px; font-weight: 500; flex: 1; }
.file-preview-size { font-size: 12px; color: var(--text-3); }

.progress-bar-wrap {
  width: 100%; height: 5px;
  background: var(--border-light); border-radius: 3px;
  overflow: hidden; margin-top: 6px;
}

.progress-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; width: 0%;
  transition: width 1.5s cubic-bezier(.22,.61,.36,1);
}

.templates-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); overflow: hidden;
  box-shadow: var(--shadow);
}

.template-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.template-row:last-child { border-bottom: none; }
.template-row:hover { background: var(--bg); }

.tpl-icon { font-size: 20px; color: var(--red); flex-shrink: 0; }
.tpl-icon.doc { color: var(--blue); }
.tpl-info { flex: 1; }
.tpl-name { font-size: 13px; font-weight: 500; }
.tpl-size { font-size: 11px; color: var(--text-3); }

.btn-dl {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--r-btn);
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
}

.btn-dl:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════
   CATEGORY / FILE TABLE PAGES
═══════════════════════════════════════════ */
.file-table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); overflow: hidden;
  box-shadow: var(--shadow);
}

.file-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

.file-table thead tr {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.file-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.file-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.file-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.file-table tbody tr:hover { background: rgba(255,255,255,0.06); }
.file-table tbody tr:last-child { border-bottom: none; }

.file-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.file-name-cell { display: flex; align-items: center; gap: 9px; }

.file-type-icon {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.file-type-icon.pdf { background: rgba(220,38,38,0.20); color: #f87171; }
.file-type-icon.doc { background: rgba(37,99,235,0.20); color: #7daafc; }
.file-type-icon.txt { background: rgba(22,163,74,0.20); color: #6ee7a0; }

.file-fname { font-size: 13px; font-weight: 500; color: var(--text); }
.file-meta { font-size: 11px; color: var(--text-3); }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: var(--r-badge);
  white-space: nowrap;
}

.status-badge.indexed { background: var(--green-bg); color: var(--green); }
.status-badge.processing { background: var(--amber-bg); color: var(--amber); }

.action-btns { display: flex; gap: 6px; }

.btn-icon {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-icon:hover { background: var(--bg); }
.btn-icon.del:hover { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-icon.view:hover { background: #dbeafe; color: var(--blue); border-color: #93c5fd; }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; color: var(--border); }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ═══════════════════════════════════════════
   AI CHAT — ChatGPT-style layout
═══════════════════════════════════════════ */
#page-chat {
  display: none; flex-direction: column;
  position: absolute; inset: 0;
  background: var(--bg);
}

#page-chat.active {
  display: flex;
  animation: pageIn 0.25s ease-out both;
}

/* ── Scrollable message area ── */
.chat-msgs {
  flex: 1; overflow-y: auto;
  padding: 24px 16px 16px;
  display: flex; flex-direction: column; gap: 0;
  min-height: 0;
  /* hidden in welcome state — no content yet */
  visibility: hidden;
}
#page-chat.chatting .chat-msgs {
  visibility: visible;
}

.chat-msgs-inner {
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 100%;
}

/* ── Welcome overlay — full-area, vertically centered ── */
.chat-welcome-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 40px;
  gap: 0;
  pointer-events: none; /* children re-enable */
  z-index: 2;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#page-chat.chatting .chat-welcome-overlay {
  opacity: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

.chat-welcome-body {
  pointer-events: auto;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  width: 100%; max-width: 680px;
  gap: 0;
}

/* ── Input inside welcome: centered on page, PRIMARY focus ── */
.chat-welcome-input-wrap {
  pointer-events: auto;
  width: 100%; max-width: 680px;
  margin-top: 0;
}

/* ── Quick action pills below input ── */
.chat-welcome-chips {
  pointer-events: auto;
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  width: 100%; max-width: 680px;
  margin-top: 14px;
}

.chat-welcome-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; pointer-events: auto;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
  white-space: nowrap;
  line-height: 1.4;
}
.chat-welcome-chip i { font-size: 14px; color: var(--text-3); flex-shrink: 0; }
.chat-welcome-chip:hover {
  background: var(--accent-light);
  border-color: rgba(16,163,127,0.35);
  color: var(--accent-mid);
  transform: translateY(-1px);
}
.chat-welcome-chip:hover i { color: var(--accent); }

/* ── Bottom input area: hidden in welcome state ── */
.chat-input-area {
  padding: 12px 16px 20px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
  display: none; /* hidden until chatting */
  justify-content: center;
  flex-shrink: 0;
  position: sticky; bottom: 0;
}
#page-chat.chatting .chat-input-area {
  display: flex;
}

/* ── Shared input box styling ── */
.chat-input-inner {
  max-width: 640px; width: 100%;
  background: #40414F;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  display: flex; flex-direction: row; align-items: center; gap: 0;
  padding: 10px 10px 10px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.30);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-inner:focus-within {
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 2px 20px rgba(0,0,0,0.40);
}

/* Single-row layout: attach | textarea | model-select | send */
.chat-input-row-ta {
  display: contents; /* children participate directly in parent flex */
}

/* Tools row is now part of the main flex row — no separator needed */
.chat-input-row-tools {
  display: contents;
}

.chat-ta {
  flex: 1; border: none;
  background: transparent; resize: none; outline: none;
  font-family: inherit; font-size: 14px;
  color: #ECECF1;
  min-height: 24px; max-height: 160px; line-height: 1.6;
  padding: 2px 10px;
  align-self: center;
}

.chat-ta::placeholder { color: rgba(255,255,255,0.38); }

/* Hidden file input for attach */
.chat-file-input { display: none; }

.btn-attach {
  width: 32px; height: 32px; border-radius: 7px;
  background: none; border: none; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  margin-right: 4px;
}

.btn-attach:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* Model selector pill */
.chat-model-select {
  padding: 5px 22px 5px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  margin-left: 6px;
  font-family: inherit;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24'%3E%3Cpath fill='%238E8EA0' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-color: rgba(255,255,255,0.06);
  max-width: 140px;
}
.chat-model-select:hover {
  background-color: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.18);
  color: var(--text);
}
.chat-model-select option {
  background: #2A2B32; color: var(--text);
}

/* Spacer — not needed in single-row layout but kept for safety */
.chat-input-spacer { display: none; }

.btn-send {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
  margin-left: 8px;
}

.btn-send:hover { background: var(--accent-dark); }
.btn-send:disabled { opacity: 0.4; cursor: default; }

.msg-row {
  display: flex; gap: 0; align-items: flex-start;
  padding: 18px 0;
  border-bottom: none;
}
.msg-row.user {
  flex-direction: row;
  justify-content: flex-end;
}

.msg-av {
  width: 30px; height: 30px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
  margin-right: 14px;
}

.msg-av.ai {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
}
.msg-av.user { display: none; }

.msg-body {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  max-width: 100%;
}
.msg-row.user .msg-body { align-items: flex-end; flex: 0 1 auto; max-width: 80%; }

.msg-bubble {
  background: transparent; border: none;
  padding: 0;
  font-size: 14.5px; line-height: 1.72; color: var(--text);
}

.msg-row.user .msg-bubble {
  background: #40414F;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 10px 16px;
  color: #ECECF1;
  font-size: 14px;
}

.msg-cite {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-3);
  margin-top: 4px;
}

.msg-cite .ti { color: var(--accent); font-size: 12px; }

.typing-row {
  display: flex; gap: 0; align-items: flex-start;
  padding: 18px 0;
}

.typing-row .msg-av {
  margin-right: 14px;
}

.typing-dots {
  display: flex; gap: 4px; align-items: center; padding: 4px 0;
}

.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: dotBlink 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBlink {
  0%,60%,100% { opacity: 0.25; transform: scale(0.9); }
  30% { opacity: 1; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .typing-dot { animation: none; opacity: 0.5; }
}

/* Welcome title */
.chat-welcome-title {
  font-size: 28px; font-weight: 700; color: var(--text);
  letter-spacing: -0.025em; line-height: 1.2;
  margin-bottom: 28px;
}
@media (max-width: 600px) {
  .chat-welcome-title { font-size: 22px; margin-bottom: 20px; }
  .chat-model-select { max-width: 100px; font-size: 11px; padding: 4px 18px 4px 8px; }
  .chat-input-inner { padding: 8px 8px 8px 10px; border-radius: 12px; }
  .btn-send { width: 30px; height: 30px; }
  .btn-attach { width: 28px; height: 28px; font-size: 15px; }
}

/* Category suggestion cards — pill style matching chat-welcome-chip */
.chat-welcome-cards {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  width: 100%; max-width: 680px;
  margin-top: 0;
}
.chat-welcome-card {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; pointer-events: auto;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
  white-space: nowrap; line-height: 1.4;
}
.chat-welcome-card:hover {
  background: var(--accent-light);
  border-color: rgba(16,163,127,0.35);
  color: var(--accent-mid);
  transform: translateY(-1px);
}
.chat-welcome-card-icon {
  font-size: 14px; color: var(--text-3); flex-shrink: 0;
}
.chat-welcome-card:hover .chat-welcome-card-icon { color: var(--accent); }

/* ═══════════════════════════════════════════
   MODAL
═══════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.open {
  opacity: 1; pointer-events: all;
}

.modal {
  background: var(--card); border-radius: 16px;
  width: 520px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  transform: scale(0.95);
  transition: transform 0.2s;
  overflow: hidden;
}

.modal-backdrop.open .modal { transform: scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: none; border: none; color: var(--text-3);
  cursor: pointer; transition: background 0.12s, color 0.12s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 18px 20px; }

.modal-field { margin-bottom: 14px; }
.modal-field-label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 4px;
}

.modal-field-value { font-size: 13.5px; color: var(--text); }

.modal-content-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
  font-size: 12.5px; color: var(--text-2);
  line-height: 1.7; max-height: 180px; overflow-y: auto;
  font-family: "Courier New", monospace;
  white-space: pre-wrap; word-break: break-word;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* ═══════════════════════════════════════════
   NEW CHAT BUTTON IN TOPBAR
═══════════════════════════════════════════ */
.btn-topbar-new-chat {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 15px;
  background: rgba(255,255,255,0.10);
  color: var(--chrome-text);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r-btn);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-topbar-new-chat:hover {
  background: rgba(255,255,255,0.16);
}
.btn-topbar-new-chat:active { transform: scale(0.97); }

/* ═══════════════════════════════════════════
   SIDEBAR PROFILE SECTION
═══════════════════════════════════════════ */
.sb-profile-section {
  border-top: 1px solid var(--chrome-border);
  flex-shrink: 0;
}

.sb-profile-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 16px;
  color: var(--chrome-text-2);
  font-size: 13px;
  cursor: pointer;
  border-left: 2.5px solid transparent;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  border-radius: 0 6px 6px 0;
  margin-right: 8px;
}
.sb-profile-toggle:hover {
  background: var(--nav-hover-bg); color: var(--chrome-text);
}
.sb-profile-toggle.open {
  background: var(--nav-hover-bg); color: var(--chrome-text); font-weight: 600;
}
.sb-profile-toggle .sb-profile-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--nav-accent-bar);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--chrome-dark);
  flex-shrink: 0;
}
.sb-profile-toggle .sb-profile-caret {
  margin-left: auto; font-size: 13px; color: var(--chrome-text-3);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1); flex-shrink: 0;
}
.sb-profile-toggle.open .sb-profile-caret { transform: rotate(90deg); }

.sb-profile-panel {
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
  max-height: 0; opacity: 0;
}
.sb-profile-panel.open { max-height: 420px; opacity: 1; }

.sb-profile-info {
  padding: 10px 14px 6px 18px;
  display: flex; flex-direction: column; gap: 7px;
}

.sb-profile-row {
  display: flex; align-items: flex-start; gap: 9px;
}
.sb-profile-icon {
  font-size: 13px; color: var(--chrome-text-3); flex-shrink: 0; margin-top: 1px;
}
.sb-profile-label {
  font-size: 9px; font-weight: 700; color: var(--chrome-text-3);
  text-transform: uppercase; letter-spacing: 0.07em; line-height: 1; margin-bottom: 1px;
}
.sb-profile-value {
  font-size: 11.5px; color: var(--chrome-text-2); line-height: 1.3;
}

.btn-profile-settings {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 14px 10px 16px;
  padding: 7px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-btn);
  color: var(--chrome-text-2); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.btn-profile-settings:hover {
  background: rgba(255,255,255,0.14); color: var(--chrome-text);
}

/* ═══════════════════════════════════════════
   MAIL DRAFT SIDEBAR NAV ITEM STYLES
═══════════════════════════════════════════ */
.sb-badge-mail {
  margin-left: auto;
  background: rgba(201,168,76,0.2); color: var(--gold);
  font-size: 8px; font-weight: 800;
  padding: 1px 6px; border-radius: 10px;
  letter-spacing: 0.04em; text-transform: uppercase; flex-shrink: 0;
  border: 1px solid rgba(201,168,76,0.35);
}

/* ═══════════════════════════════════════════
   MAIL DRAFT PAGE
═══════════════════════════════════════════ */
.mail-draft-wrap {
  display: flex; flex-direction: column; gap: 18px;
  padding-bottom: 12px;
}

.mail-draft-source-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow);
}

.mail-source-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
  background: var(--gold-bg);
}
.mail-source-header-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--gold); color: var(--chrome-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.mail-source-title {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.mail-source-sub {
  font-size: 11px; color: var(--text-3);
}

.mail-context-area {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}

.mail-context-label {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.07em;
}

.mail-context-ta {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: var(--r-btn); padding: 10px 13px;
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); resize: vertical; outline: none;
  min-height: 80px; line-height: 1.6;
  transition: border-color 0.15s;
}
.mail-context-ta:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,163,127,0.12); }
.mail-context-ta::placeholder { color: var(--text-3); }

.mail-type-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.mail-type-chip {
  padding: 5px 14px; border-radius: var(--r-badge);
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--card); color: var(--text-2);
  cursor: pointer; transition: all 0.13s;
  user-select: none;
}
.mail-type-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.mail-type-chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-generate-mail {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-btn);
  font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  align-self: flex-start;
}
.btn-generate-mail:hover { background: var(--accent-dark); }
.btn-generate-mail:active { transform: scale(0.98); }
.btn-generate-mail:disabled { opacity: 0.55; cursor: not-allowed; }

/* Output area */
.mail-output-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow);
  display: none;
}
.mail-output-card.visible { display: block; }

.mail-output-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--chrome-dark) 0%, var(--chrome) 100%);
}
.mail-output-header-title {
  font-size: 13px; font-weight: 700; color: var(--chrome-text);
  display: flex; align-items: center; gap: 8px;
}
.mail-output-actions { display: flex; gap: 8px; }

.btn-copy-mail {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.15); color: var(--chrome-text);
  border: 1px solid rgba(255,255,255,0.22); border-radius: var(--r-btn);
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-copy-mail:hover { background: rgba(255,255,255,0.25); }

.btn-new-draft {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: transparent; color: var(--chrome-text-2);
  border: 1px solid rgba(255,255,255,0.14); border-radius: var(--r-btn);
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-new-draft:hover { background: rgba(255,255,255,0.10); color: var(--chrome-text); }

.mail-output-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.mail-field-group { display: flex; flex-direction: column; gap: 5px; }

.mail-field-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.mail-field-input {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border); border-radius: var(--r-btn);
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none;
  transition: border-color 0.15s;
}
.mail-field-input:focus { border-color: var(--accent); }

.mail-field-ta {
  width: 100%; padding: 12px 13px;
  border: 1.5px solid var(--border); border-radius: var(--r-btn);
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); resize: vertical; outline: none;
  min-height: 260px; line-height: 1.75;
  transition: border-color 0.15s;
}
.mail-field-ta:focus { border-color: var(--accent); }

.mail-disclaimer {
  font-size: 11px; color: var(--text-3);
  background: rgba(201,168,76,0.10); border: 1px solid rgba(201,168,76,0.22);
  padding: 8px 12px; border-radius: 7px;
  display: flex; gap: 8px; align-items: flex-start;
}

/* Generating state — now uses the shared .ai-generating-row (THINKING INDICATOR
   section) so this form matches AI Chat/Projects/Applications' loading language. */

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
#toast {
  position: fixed; top: 20px; right: 24px;
  transform: translateX(12px);
  background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 500;
  padding: 11px 20px 11px 16px; border-radius: 8px;
  pointer-events: none; opacity: 0; z-index: 2000;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap; max-width: 360px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

#toast.show {
  opacity: 1;
  transform: translateX(0);
}

#toast.success { background: var(--green); }
#toast.error   { background: #e05252; }
#toast.info    { background: var(--chrome-mid); }
#toast.warning { background: #d97706; }

/* ═══════════════════════════════════════════
   DOCUMENT FILTER SECTION
═══════════════════════════════════════════ */
.doc-filter-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.doc-filter-toprow {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.doc-filter-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-3); letter-spacing: 0.06em;
  text-transform: uppercase; flex-shrink: 0;
}

.doc-filter-search-wrap {
  position: relative; flex: 1; min-width: 180px;
}

.doc-filter-search-wrap .ti {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 15px; pointer-events: none;
}

.doc-filter-search {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border); border-radius: var(--r-btn);
  font-size: 13px; color: var(--text); background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.doc-filter-search:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.15);
}

.doc-filter-search::placeholder { color: var(--text-3); }

.doc-filter-wizard-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-btn);
  border: 1px solid var(--accent); background: var(--accent-light);
  color: var(--accent); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.doc-filter-wizard-btn:hover {
  background: var(--accent); color: #fff;
}

.doc-filter-clear-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 12px; border-radius: var(--r-btn);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-3); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: all 0.15s;
}

.doc-filter-clear-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

.doc-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.doc-filter-field { display: flex; flex-direction: column; gap: 4px; }

.doc-filter-label {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.doc-filter-select, .doc-filter-input {
  padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-btn);
  font-size: 13px; color: var(--text); background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.doc-filter-select:focus, .doc-filter-input:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.18);
}

.doc-filter-select { cursor: pointer; }

.doc-filter-chips {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; margin-top: 10px;
}

.doc-filter-chip-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  flex-shrink: 0;
}

.filter-active-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 10px;
  background: var(--accent-light); color: var(--accent);
  border: 1px solid rgba(16,163,127,0.22);
  border-radius: 20px; font-size: 12px; font-weight: 600;
}

.filter-active-chip button {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: 14px; line-height: 1;
  cursor: pointer; display: flex; align-items: center;
  opacity: 0.7; transition: opacity 0.1s;
}

.filter-active-chip button:hover { opacity: 1; }

.doc-filter-result-count {
  font-size: 12px; color: var(--text-3); margin-left: auto;
  flex-shrink: 0;
}

.doc-filter-result-count strong { color: var(--accent); }

/* ═══════════════════════════════════════════
   SEARCH WIZARD MODAL
═══════════════════════════════════════════ */
#wizard-backdrop {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}

#wizard-backdrop.open { display: flex; }

.wizard-modal {
  background: var(--card);
  width: 560px; max-width: calc(100vw - 32px);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  overflow: hidden;
  animation: wizardIn 0.28s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes wizardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.wizard-header {
  background: var(--chrome);
  padding: 18px 22px 16px;
  display: flex; align-items: center; gap: 12px;
}

.wizard-header-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}

.wizard-header-text { flex: 1; }
.wizard-header-title {
  font-size: 15px; font-weight: 700; color: #fff;
  line-height: 1.2;
}
.wizard-header-sub {
  font-size: 12px; color: rgba(255,255,255,0.6);
  margin-top: 2px;
}

.wizard-close-btn {
  background: rgba(255,255,255,0.1); border: none;
  color: rgba(255,255,255,0.8); width: 30px; height: 30px;
  border-radius: 7px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.wizard-close-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ═══════════════════════════════════════════
   AI ANSWER CARDS — formatted RAG/General-knowledge sections
═══════════════════════════════════════════ */
.ai-answer { display: flex; flex-direction: column; gap: 4px; }

.ai-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.ai-section-tnfd    { border-left-color: var(--accent-mid); }
.ai-section-general { border-left-color: var(--gold); }
.ai-section-default { border-left-color: var(--text-3); }

.ai-section-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.ai-section-icon { font-size: 16px; line-height: 1; }
.ai-section-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  letter-spacing: 0.01em;
}

.ai-section-body { font-size: 13.5px; line-height: 1.7; color: var(--text-2); }

.ai-answer-para { margin: 0 0 10px 0; }
.ai-answer-para:last-child { margin-bottom: 0; }
.ai-section-body strong { color: var(--text); font-weight: 700; }

.ai-answer-list { margin: 0 0 10px 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.ai-answer-list:last-child { margin-bottom: 0; }
.ai-answer-list li {
  padding-left: 26px;
  position: relative;
}
.ai-answer-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 16px;
  height: 16px;
  background-color: var(--accent-mid);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8.5 12.5l2.4 2.4L15.5 9.5'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8.5 12.5l2.4 2.4L15.5 9.5'/%3E%3C/svg%3E") no-repeat center / contain;
}

.ai-section-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 4px;
}

/* ═══════════════════════════════════════════
   AI RESULT CARDS — Official Knowledge / General Knowledge / Sources
═══════════════════════════════════════════ */
.ai-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  overflow: hidden;
}
.ai-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.ai-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.ai-card-icon svg { width: 20px; height: 20px; }
.ai-card-icon--official { color: var(--gold, #c9974d); }
.ai-card-icon--general  { color: var(--accent-mid, #4d9bc9); }
.ai-card-icon--sources  { color: var(--text-3); }
.ai-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.ai-card-body { padding: 20px 22px; font-size: 14px; }

/* Source badges — inline pills appended under an answer card, replacing the old
   standalone "Sources" card. Kept compact/clickable rather than a grid of tiles. */
.ai-source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}
.ai-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
a.ai-source-badge:hover {
  background: var(--accent-light, rgba(16,163,127,0.10));
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}
.ai-source-badge-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }
.ai-source-badge-name {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-source-badge-arrow { font-size: 11px; flex-shrink: 0; color: var(--text-3); }
a.ai-source-badge:hover .ai-source-badge-arrow { color: var(--accent); }

.ai-source-badge--disabled {
  cursor: not-allowed;
  color: var(--text-3);
  opacity: 0.7;
}

/* Inline citation badges — rendered immediately after the paragraph/list item
   they support, instead of collecting all sources in a footer row. Sized
   small enough to sit in the text flow like a ChatGPT/Gemini citation chip. */
.ai-inline-source-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.ai-inline-source-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 180px;
  height: 24px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
a.ai-inline-source-badge:hover {
  background: var(--accent-light, rgba(16,163,127,0.10));
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.ai-inline-source-badge-icon { font-size: 11px; line-height: 1; flex-shrink: 0; }
.ai-inline-source-badge-name {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px;
}
.ai-inline-source-badge--disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Tooltip: full document name on hover, via data-tooltip attribute so long,
   truncated filenames stay readable without a JS tooltip library. */
.ai-inline-source-badge[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 9px;
  border-radius: 6px;
  background: #1a1a1f;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.ai-inline-source-badge[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  .ai-card-header { padding: 12px 16px; }
  .ai-card-body { padding: 16px; }
  .ai-source-badge { max-width: 100%; }
  .ai-inline-source-badge { max-width: 140px; }
}

/* ═══════════════════════════════════════════
   MODEL SELECTOR — chat composer dropdown, populated dynamically from
   GET /models (see components/model-selector.blade.php + model-selector-script.blade.php)
═══════════════════════════════════════════ */
.model-selector-wrap { position: relative; flex-shrink: 0; margin-left: 8px; }

.model-selector-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  max-width: 180px;
  transition: background 0.15s;
}
.model-selector-btn:hover { background: rgba(255,255,255,0.13); }
.model-selector-btn .ti-chevron-down { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.model-selector-btn span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.model-dropdown {
  display: none;
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 220px;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  overflow: hidden;
  z-index: 200;
}
.model-selector-wrap.open .model-dropdown { display: block; }

.model-dropdown-search-wrap {
  position: relative;
  border-bottom: 1px solid var(--border-light);
}
.model-dropdown-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--text-3); pointer-events: none;
}
.model-dropdown-search {
  width: 100%;
  background: none; border: none; outline: none;
  font-family: inherit; font-size: 12.5px; color: var(--text);
  padding: 9px 10px 9px 30px;
}
.model-dropdown-search::placeholder { color: var(--text-3); }

.model-dropdown-list {
  max-height: 240px;
  overflow-y: auto;
}

.model-option {
  padding: 10px 14px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.model-option:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.model-option.active { color: var(--accent); font-weight: 600; background: var(--accent-light); }

.model-dropdown-status {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  font-size: 12.5px; color: var(--text-3);
}
.model-dropdown-status--error { color: var(--red, #e05252); }
.model-dropdown-spinner {
  animation: model-dropdown-spin 0.8s linear infinite;
}
@keyframes model-dropdown-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   THINKING INDICATOR — canonical "AI is generating a response" state.
   Used by every AI-generation surface (AI Chat new/existing conversation,
   category "Ask about X" pages, Projects chat tab, Applications TN-FD,
   AI Mail Draft) via components/thinking-indicator.blade.php, so the
   shimmer look and the show-until-response behavior stay identical
   everywhere instead of being copy-pasted per page.
   ═══════════════════════════════════════════ */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.ai-skeleton-line {
  height: 12px;
  border-radius: 6px;
  margin-bottom: 9px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.14) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 300% 100%;
  animation: ai-shimmer 1.4s infinite linear;
}
.ai-skeleton-line:last-child { margin-bottom: 0; }
@keyframes ai-shimmer { 0% { background-position: 300% 0; } 100% { background-position: -300% 0; } }

.ai-skeleton-status {
  font-size: 12px; color: var(--text-3);
  margin-top: 10px;
  display: flex; align-items: center; gap: 6px;
}
.ai-skeleton-status .ti-dots { animation: pulse 1s infinite; }

.ai-response-fade-in { animation: ai-fade-in 0.25s ease-out; }
@keyframes ai-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Non-chat "generating" surfaces (e.g. AI Mail Draft form) that show a status
   row rather than a chat bubble — same icon/dots language as ai-skeleton-status. */
.ai-generating-row {
  display: none;
  align-items: center; gap: 12px;
  padding: 20px 18px;
  font-size: 13px; color: var(--text-3);
}
.ai-generating-row.visible { display: flex; }
.ai-generating-row .ti-dots { animation: pulse 1s infinite; }

/* ═══════════════════════════════════════════
   COMPOSER SHELL — the single bordered/rounded outer container that now
   wraps BOTH the attachment row and the controls row (attach icon,
   textarea, model selector, send button) for every chat composer, so an
   attachment reads as part of one unified input box (ChatGPT/Claude
   pattern) instead of two separate floating cards. Page-specific styles
   (.chat-input-bar / .proj-chat-input-inner) keep their own sizing
   rules but no longer own the border/background/radius — those moved
   here so every composer shares one visual container regardless of
   which page it's on.
═══════════════════════════════════════════ */
.composer-shell {
  width: calc(100% - 32px); max-width: 928px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-left: 32px;
  box-sizing: border-box;
}
.composer-shell:focus-within {
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 0 0 3px rgba(16,163,127,0.10);
}

/* ── UPLOAD FILE CHIP — shared pre-send attachment preview, used by
   components/upload-file-chip.blade.php across every chat composer
   (AI Chat new/existing conversation, Projects chat tab, category
   "Ask about X" pages). Rendered as the shell's own top row, separated
   from the controls row below it by a thin divider, so it visually
   belongs to the same input box instead of floating above it. Hidden
   (and its padding collapses away) when no file is attached, so the
   composer's height is unaffected until an attachment is present. ── */
.upload-chip-row {
  display: none;
  width: 100%;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-light);
  box-sizing: border-box;
}
.upload-chip-row.visible { display: flex; }

.upload-chip {
  display: flex;
  align-items: center; gap: 8px;
  width: fit-content; max-width: min(320px, 100%);
  padding: 6px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card, 12px);
  font-size: 13px; color: var(--text-2);
  transition: border-color 0.18s, background 0.18s;
  box-sizing: border-box;
}
.upload-chip:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.04); }
.upload-chip .upload-chip-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.upload-chip .upload-chip-info { min-width: 0; max-width: 220px; }
.upload-chip .upload-chip-name {
  display: block;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-chip .upload-chip-meta {
  display: block;
  font-size: 11px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-chip .upload-chip-remove {
  width: 22px; height: 22px; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 13px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.upload-chip .upload-chip-remove:hover { color: var(--red); background: rgba(255,255,255,0.06); }

/* Small tablet / large phone */
@media (max-width: 600px) {
  .upload-chip-row { padding: 8px 8px 7px; }
  .upload-chip {
    max-width: min(260px, 100%);
    gap: 8px;
    padding: 7px 9px;
  }
  .upload-chip .upload-chip-info { max-width: 160px; }
  .upload-chip .upload-chip-icon { font-size: 16px; }
  .upload-chip .upload-chip-name { font-size: 12px; }
  .upload-chip .upload-chip-meta { font-size: 10.5px; }
}

/* Phone */
@media (max-width: 480px) {
  .upload-chip-row { padding: 7px 4px 6px; }
  .upload-chip {
    max-width: 100%;
    padding: 7px 8px;
  }
  .upload-chip .upload-chip-info { max-width: 120px; }
  .upload-chip .upload-chip-remove { width: 24px; height: 24px; }
}

/* ═══════════════════════════════════════════
   CATEGORY MULTI-SELECT — Projects "Create New Project" modal.
   Reuses .model-selector-wrap/.model-selector-btn/.model-dropdown/
   .model-dropdown-search*/.model-dropdown-list/.model-dropdown-status/
   .model-dropdown-spinner as-is; only new rules below.
═══════════════════════════════════════════ */
.category-ms-wrap { width: 100%; margin-left: 0; }
.category-ms-btn { width: 100%; max-width: none; justify-content: space-between; }

/* position:fixed (not absolute) so this dropdown is never clipped by an
   ancestor's overflow:auto — e.g. the "Create New Project" modal body scrolls
   when its content is tall, which would otherwise clip an absolutely-positioned
   dropdown anchored to a field near the bottom of that scroll area. Exact
   top/left/width are set by JS on open, reading the toggle button's real
   screen position (see category-multiselect-script.blade.php positionDropdown()).

   It's reparented to a direct child of <body> while open (a portal): the
   "Create New Project" modal has a permanent transform from its entrance
   animation's animation-fill-mode, and any transformed ancestor becomes the
   containing block for position:fixed descendants instead of the viewport —
   which silently breaks the JS's viewport-relative getBoundingClientRect() math.
   Because of the reparenting, visibility can't rely on a ".wrap.open .dropdown"
   descendant selector (it stops being a descendant once moved) — the script
   toggles a class on the dropdown itself instead. */
.category-ms-dropdown {
  display: none;
  position: fixed; left: auto; right: auto; bottom: auto; top: auto;
  max-width: none;
  max-height: min(260px, 40vh);
  z-index: 500; /* above .new-proj-backdrop (400), so it renders over the modal */
}
.category-ms-dropdown.open { display: flex; flex-direction: column; }
.category-ms-list { max-height: none; flex: 1; overflow-y: auto; }

.category-option {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: background 0.12s;
}
.category-option:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.category-option.active { color: var(--accent); font-weight: 600; background: var(--accent-light); }
.category-option-check {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid var(--border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: transparent;
  transition: all 0.12s;
}
.category-option.active .category-option-check {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.category-ms-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.category-ms-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 10px;
  background: var(--accent-light); color: var(--accent);
  border-radius: 14px; font-size: 12px; font-weight: 600;
}
.category-ms-chip-remove {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 13px; padding: 1px;
  display: flex; align-items: center;
}
.category-ms-chip-remove:hover { color: var(--red); }

/* Step progress indicator */
.wizard-steps-bar {
  display: flex; align-items: center;
  padding: 16px 22px 0;
  gap: 0;
}

.wizard-step-item {
  display: flex; align-items: center; flex: 1; min-width: 0;
}

.wizard-step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  flex-shrink: 0; transition: all 0.2s;
  position: relative; z-index: 1;
}

.wizard-step-dot.active {
  border-color: var(--accent); background: var(--accent);
  color: #fff;
}
.wizard-step-dot.done {
  border-color: var(--green); background: var(--green);
  color: #fff;
}

.wizard-step-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  margin-left: 6px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.wizard-step-item.active .wizard-step-label { color: var(--accent); }
.wizard-step-item.done .wizard-step-label { color: var(--green); }

.wizard-step-line {
  flex: 1; height: 2px; background: var(--border);
  margin: 0 6px; transition: background 0.2s;
}
.wizard-step-line.done { background: var(--green); }

/* Wizard body / step panels */
.wizard-body {
  padding: 20px 22px 10px;
}

.wizard-step-panel { display: none; }
.wizard-step-panel.active { display: block; }

.wizard-step-heading {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.wizard-step-desc {
  font-size: 13px; color: var(--text-3); margin-bottom: 16px;
}

.wizard-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.wizard-form-group { display: flex; flex-direction: column; gap: 5px; }
.wizard-form-group.full { grid-column: 1 / -1; }

.wizard-label {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.wizard-select, .wizard-input {
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--r-btn);
  font-size: 13px; color: var(--text); background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.wizard-select:focus, .wizard-input:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.18);
}
.wizard-select { cursor: pointer; }

/* Summary step */
.wizard-summary-list { display: flex; flex-direction: column; gap: 8px; }

.wizard-summary-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
}
.wizard-summary-row.has-value { border-color: rgba(16,163,127,0.25); background: var(--accent-light); }

.wizard-summary-icon {
  font-size: 15px; color: var(--text-3); flex-shrink: 0; margin-top: 1px;
}
.wizard-summary-row.has-value .wizard-summary-icon { color: var(--accent); }

.wizard-summary-key {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  line-height: 1.2;
}
.wizard-summary-val {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-top: 1px;
}
.wizard-summary-row.has-value .wizard-summary-key { color: var(--accent-dark); }
.wizard-summary-row.has-value .wizard-summary-val { color: var(--accent-dark); }

/* Wizard footer */
.wizard-footer {
  display: flex; align-items: center;
  padding: 12px 22px 18px;
  gap: 10px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.wizard-btn-back {
  display: flex; align-items: center; gap: 5px;
  padding: 9px 16px; border-radius: var(--r-btn);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.wizard-btn-back:hover { border-color: var(--text-3); background: var(--bg); }

.wizard-btn-next {
  display: flex; align-items: center; gap: 5px;
  padding: 9px 18px; border-radius: var(--r-btn);
  border: none; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
  margin-left: auto;
}
.wizard-btn-next:hover { background: var(--accent-dark); }

.wizard-btn-apply {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--r-btn);
  border: none; background: var(--gold); color: #1C1E1A;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
  margin-left: auto;
}
.wizard-btn-apply:hover { background: #b8942e; }

.wizard-step-counter {
  font-size: 12px; color: var(--text-3); margin-left: 0;
}

/* ═══════════════════════════════════════════
   SHARED MODAL & FORM UTILITIES
   (used by Projects modals and RAG citations)
═══════════════════════════════════════════ */
.lib-upload-modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.lib-upload-modal-backdrop.visible { display: flex; }
.lib-upload-modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; width: 540px; max-width: 100%;
  box-shadow: var(--shadow-md);
  animation: loginCardIn .3s ease both;
}
.lib-upload-modal-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.lib-upload-modal-title { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.lib-upload-modal-close {
  background: none; border: none; color: var(--text-3); font-size: 18px;
  cursor: pointer; padding: 2px; transition: color .12s;
}
.lib-upload-modal-close:hover { color: var(--text); }
.lib-upload-modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.lib-upload-drop-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 28px 20px; text-align: center;
  color: var(--text-3); font-size: 13px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.lib-upload-drop-zone:hover, .lib-upload-drop-zone.drag-over {
  border-color: var(--accent); background: var(--accent-light); color: var(--accent);
}
.lib-upload-drop-zone i { font-size: 32px; margin-bottom: 8px; display: block; opacity: .7; }
.lib-upload-drop-zone strong { color: var(--accent); cursor: pointer; }
.lib-upload-drop-zone input[type="file"] { display: none; }
.lib-upload-form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.lib-upload-form-row.full { grid-template-columns: 1fr; }
.lib-upload-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin-bottom: 5px; display: block;
}
.lib-upload-input {
  width: 100%; padding: 8px 12px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.12);
  border-radius: 7px; color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color .15s;
}
.lib-upload-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16,163,127,.15); }
.lib-upload-input::placeholder { color: rgba(255,255,255,.25); }
.lib-upload-modal-ftr {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border-light);
  justify-content: flex-end;
}
.lib-selected-file {
  font-size: 12px; color: var(--accent); margin-right: auto;
  display: flex; align-items: center; gap: 5px; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-doc-tag {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
}
.lib-doc-btn {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: none; color: var(--text-2);
  cursor: pointer; transition: background .12s, color .12s; font-family: inherit;
  display: flex; align-items: center; gap: 4px;
}
.lib-doc-btn:hover { background: var(--nav-hover-bg); color: var(--text); }
.lib-doc-btn.danger:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.lib-rag-cite {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-light); border-radius: 6px;
  padding: 2px 8px; margin-top: 6px; cursor: pointer;
  transition: background .12s;
}
.lib-rag-cite:hover { background: rgba(16,163,127,.25); }

/* ═══════════════════════════════════════════
   PROJECTS PAGE
═══════════════════════════════════════════ */
#page-projects { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#page-projects.active { display: flex; }

/* Projects list view */
.proj-list-view, .proj-detail-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.proj-detail-view { display: none; }
#page-projects.proj-open .proj-list-view { display: none; }
#page-projects.proj-open .proj-detail-view { display: flex; }

.proj-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 24px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
}
.proj-topbar-title { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }
.proj-topbar-back {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
  font-family: inherit; transition: color .12s;
}
.proj-topbar-back:hover { color: var(--accent); }
.proj-topbar-back i { font-size: 16px; }

.proj-grid {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; align-content: start;
}
.proj-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px; cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.proj-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.proj-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.proj-card-name { font-size: 15px; font-weight: 700; color: var(--text); }
.proj-card-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.proj-card-meta {
  display: flex; gap: 10px; font-size: 11px; color: var(--text-3);
  align-items: center; flex-wrap: wrap;
}
.proj-card-meta span { display: flex; align-items: center; gap: 4px; }
.proj-card-meta i { font-size: 13px; }

.proj-new-card {
  background: none; border: 2px dashed var(--border);
  border-radius: 12px; padding: 18px 20px; cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 140px; color: var(--text-3); font-family: inherit;
  text-align: center;
}
.proj-new-card:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.proj-new-card i { font-size: 30px; }
.proj-new-card-label { font-size: 13px; font-weight: 600; }

/* Project detail view — tabs */
.proj-detail-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border-light);
  padding: 0 20px; flex-shrink: 0;
}
.proj-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px; background: none; border-top: none;
  border-left: none; border-right: none; font-family: inherit;
}
.proj-tab:hover { color: var(--text-2); }
.proj-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.proj-tab i { font-size: 15px; }

.proj-tab-panel { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.proj-tab-panel.active { display: flex; }

/* Project chat tab */
.proj-chat-wrap {
  display: flex; flex-direction: column; height: 100%;
}
.proj-chat-msgs { flex: 1; overflow-y: auto; padding: 16px 20px; }
.proj-chat-input-area {
  padding: 10px 16px 14px; border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.proj-chat-input-inner {
  display: flex; align-items: flex-end; gap: 8px;
  background: #40414F; border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px;
}
.proj-chat-ta {
  flex: 1; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14px; font-family: inherit;
  min-height: 22px; max-height: 150px; line-height: 1.5;
}
.proj-chat-ta::placeholder { color: var(--text-3); }
.proj-chat-send {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; transition: background .12s;
}
.proj-chat-send:hover { background: var(--accent-dark); }
.proj-chat-no-docs {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 8px; color: var(--text-3); text-align: center; padding: 30px;
}
.proj-chat-no-docs i { font-size: 40px; opacity: .4; }

/* Project docs tab */
.proj-docs-wrap { flex: 1; overflow-y: auto; padding: 16px 20px; }
.proj-docs-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.proj-docs-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.proj-doc-list { display: flex; flex-direction: column; gap: 8px; }
.proj-doc-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 10px 14px;
}
.proj-doc-row-icon { font-size: 18px; flex-shrink: 0; color: var(--text-3); }
.proj-doc-row-info { flex: 1; min-width: 0; }
.proj-doc-row-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-doc-row-meta { font-size: 11px; color: var(--text-3); }

/* Project overview tab */
.proj-overview-wrap { flex: 1; overflow-y: auto; padding: 16px 20px; }
.proj-overview-section { margin-bottom: 20px; }
.proj-overview-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-3); margin-bottom: 8px;
}
.proj-overview-value { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.proj-stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.proj-stat-box {
  background: var(--bg); border: 1px solid var(--border-light); border-radius: 8px;
  padding: 12px 16px; min-width: 100px; text-align: center;
}
.proj-stat-box-val { font-size: 22px; font-weight: 800; color: var(--accent); }
.proj-stat-box-lbl { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* New Project Modal */
.new-proj-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.new-proj-backdrop.visible { display: flex; }
.new-proj-modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; width: 500px; max-width: 100%;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
  animation: loginCardIn .3s ease both;
}
.new-proj-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.new-proj-title { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.new-proj-body {
  padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}
.new-proj-ftr {
  display: flex; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--border-light); justify-content: flex-end;
}

/* Shared btn-secondary for these pages */
.btn-outline {
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border);
  background: none; color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s, color .12s;
  display: flex; align-items: center; gap: 5px;
}
.btn-outline:hover { background: var(--nav-hover-bg); color: var(--text); }
.btn-primary-sm {
  padding: 7px 16px; border-radius: 7px; border: none;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s;
  display: flex; align-items: center; gap: 5px;
}
.btn-primary-sm:hover { background: var(--accent-dark); }

/* ══════════════════════════════════════════════════════════════════════════
   TN-FD Applications — module selector cards, SQL query card, records DataTable
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Module selector cards ── */
.apps-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto 28px;
}

.apps-module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.apps-module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
}
.apps-module-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(16,163,127,0.14);
}

.apps-module-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  background: rgba(255,255,255,0.08);
}
.apps-module-card.selected .apps-module-icon { background: var(--accent); }

.apps-module-title { font-size: 15px; font-weight: 700; color: var(--text); }
.apps-module-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }

.apps-module-check {
  display: none;
  align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; color: var(--accent-mid);
  margin-top: 2px;
}
.apps-module-card.selected .apps-module-check { display: flex; }

.apps-module-hint {
  font-size: 12px; color: var(--text-3);
  text-align: center; margin-bottom: 24px;
}
.apps-module-hint.warn { color: var(--red); font-weight: 600; }

/* ── SQL query card ── */
.sql-query-card {
  margin-top: 12px;
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.sql-query-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border-light);
}
.sql-query-card.collapsed .sql-query-card-header { border-bottom: none; }
.sql-query-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
}
.sql-query-card-icon { color: var(--accent-mid); font-size: 15px; }
.sql-query-card-actions { display: flex; align-items: center; gap: 10px; }
.sql-query-copy-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-2);
  font-size: 11.5px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sql-query-copy-btn:hover { background: rgba(255,255,255,0.13); color: var(--text); }
.sql-query-copy-btn.copied { background: var(--accent-light); color: var(--accent-mid); border-color: var(--accent); }
.sql-query-card-chevron { color: var(--text-3); font-size: 14px; transition: transform 0.2s; }
.sql-query-card.collapsed .sql-query-card-chevron { transform: rotate(-90deg); }
.sql-query-card-body {
  max-height: 400px;
  overflow: auto;
  transition: max-height 0.2s ease, padding 0.2s ease;
}
.sql-query-card.collapsed .sql-query-card-body { max-height: 0; }
.sql-query-pre {
  margin: 0; padding: 14px 16px;
  font-family: 'SF Mono', 'Fira Code', Consolas, Menlo, monospace;
  font-size: 12.5px; line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
}
.sql-tok-keyword { color: #c586c0; font-weight: 700; }
.sql-tok-string { color: #ce9178; }
.sql-tok-number { color: #b5cea8; }

/* ── Records DataTable ── */
.rdt-wrap {
  margin-top: 12px;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rdt-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}
.rdt-search-wrap {
  position: relative;
  flex: 1; min-width: 160px; max-width: 280px;
}
.rdt-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--text-3); pointer-events: none;
}
.rdt-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-size: 12.5px; font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.rdt-search-input:focus { border-color: var(--accent); }
.rdt-search-input::placeholder { color: var(--text-3); }
.rdt-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rdt-row-count { font-size: 11.5px; color: var(--text-3); margin-right: 4px; white-space: nowrap; }
.rdt-export-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 11px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-2);
  font-size: 11.5px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.rdt-export-btn:hover { background: var(--accent-light); color: var(--accent-mid); }

.rdt-table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.rdt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rdt-th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 14px; text-align: left;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3);
  background: #3a3b45;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.rdt-th span { display: inline-flex; align-items: center; gap: 6px; }
.rdt-sort-icon { font-size: 12px; color: var(--text-3); margin-left: 5px; vertical-align: middle; }
.rdt-th-active, .rdt-th-active .rdt-sort-icon { color: var(--accent-mid); }
.rdt-table td {
  padding: 9px 14px; color: var(--text-2);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.rdt-table tr:last-child td { border-bottom: none; }
.rdt-table tr:hover td { background: rgba(255,255,255,0.04); }
.rdt-td-id { color: var(--accent-mid); font-weight: 600; }
.rdt-no-match { text-align: center; color: var(--text-3); padding: 24px !important; white-space: normal !important; }

.rdt-pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
}
.rdt-page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s;
}
.rdt-page-btn:hover:not(:disabled) { background: rgba(255,255,255,0.14); color: var(--text); }
.rdt-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.rdt-page-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.rdt-empty {
  margin-top: 12px;
  padding: 32px 20px;
  text-align: center;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rdt-empty-icon { font-size: 32px; color: var(--text-3); margin-bottom: 10px; display: block; }
.rdt-empty-title { font-size: 13.5px; color: var(--text-2); font-weight: 600; }

/* ── Generating SQL loading indicator (mirrors chat's ai-skeleton pattern) ── */
.apps-generating-sql {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--accent-mid);
  margin-top: 8px;
}
.apps-generating-sql .ti-loader-2 { animation: apps-spin 0.8s linear infinite; }
@keyframes apps-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .apps-module-grid { grid-template-columns: 1fr; }
  .rdt-toolbar { flex-direction: column; align-items: stretch; }
  .rdt-search-wrap { max-width: none; }
}
