/* ==========================================================================
   Saraiki Text Assistant - Ultra-Premium Modern Stylesheet
   Pure CSS3 - Modern Typography - Glassmorphism - Ambient Lighting - Dark/Light
   ========================================================================== */

/* --- Custom Properties & Theme Design System --- */
:root {
  /* Core Colors - Light Theme (Default) */
  --bg-app: #f8fafc;
  --bg-app-gradient: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.06) 0%, rgba(248, 250, 252, 0.95) 75%), #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-modal-backdrop: rgba(15, 23, 42, 0.45);

  --bg-bubble-user: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --bg-bubble-user-text: #ffffff;
  --bg-bubble-assistant: #ffffff;
  --bg-pill: #f1f5f9;
  --bg-pill-hover: #e2e8f0;
  --bg-pill-active: #ecfdf5;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --text-accent: #059669;
  --text-accent-hover: #047857;

  --border-subtle: #f1f5f9;
  --border-default: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-accent: #10b981;
  --border-accent-subtle: #a7f3d0;
  --border-card-hover: rgba(16, 185, 129, 0.35);

  /* Brand Emerald Gradients & Glows */
  --brand-primary: #059669;
  --brand-primary-hover: #047857;
  --brand-teal: #0d9488;
  --brand-gradient: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --brand-gradient-hover: linear-gradient(135deg, #047857 0%, #0f766e 100%);
  --brand-gradient-subtle: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
  --brand-shadow: 0 4px 16px -1px rgba(5, 150, 105, 0.3);
  --brand-glow: 0 0 35px -5px rgba(16, 185, 129, 0.25);

  /* Auth Tokens - Default Light */
  --auth-bg: #f8fafc;
  --auth-surface: #ffffff;
  --auth-card: #ffffff;
  --auth-card-border: #e2e8f0;
  --auth-input-bg: #f8fafc;
  --auth-input-border: #cbd5e1;
  --auth-input-border-focus: #059669;
  --auth-input-border-error: #ef4444;
  --auth-input-border-success: #059669;
  --auth-text-primary: #0f172a;
  --auth-text-secondary: #475569;
  --auth-text-muted: #64748b;
  --auth-text-accent: #059669;
  --auth-text-error: #dc2626;
  --auth-text-success: #059669;
  --orb-emerald: rgba(16, 185, 129, 0.08);
  --orb-teal: rgba(13, 148, 136, 0.06);
  --orb-blue: rgba(14, 165, 233, 0.04);
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 0 1px #e2e8f0;
  --shadow-input: 0 1px 2px rgba(0, 0, 0, 0.04) inset;
  --shadow-btn: 0 4px 16px -2px rgba(5, 150, 105, 0.45);
  --shadow-btn-hover: 0 6px 22px -2px rgba(5, 150, 105, 0.6);
  --input-height: 48px;
  --btn-height: 48px;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 20px -3px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.1), 0 10px 12px -6px rgba(0, 0, 0, 0.08);

  /* Typography */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-arabic: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", "Arabic Typesetting", "Tahoma", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --base-font-size: 14px;
  --line-height-normal: 1.5;
  --line-height-arabic: 2.1;

  /* Sizing & Transitions */
  --sidebar-width: 290px;
  --header-height: 66px;
  --composer-max-width: 860px;
  /* Radii match live computed values (auth section previously overwrote these) */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: var(--transition-fast);
  --t-normal: var(--transition-normal);
  --t-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --bg-app: #080c14;
  --bg-app-gradient: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.09) 0%, rgba(8, 12, 20, 0.98) 75%), #080c14;
  --bg-surface: #0f1626;
  --bg-surface-glass: rgba(15, 22, 38, 0.85);
  --bg-surface-elevated: #162035;
  --bg-sidebar: #0b101d;
  --bg-card: #0f1626;
  --bg-card-hover: #162238;
  --bg-input: #121a2c;
  --bg-modal-backdrop: rgba(0, 0, 0, 0.75);

  --bg-bubble-user: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --bg-bubble-user-text: #ffffff;
  --bg-bubble-assistant: #0f1626;
  --bg-pill: #162035;
  --bg-pill-hover: #1f2d4a;
  --bg-pill-active: rgba(16, 185, 129, 0.18);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-accent: #34d399;
  --text-accent-hover: #10b981;

  --border-subtle: #162035;
  --border-default: #1e2c45;
  --border-strong: #2c3e60;
  --border-accent: #10b981;
  --border-accent-subtle: #065f46;
  --border-card-hover: rgba(52, 211, 153, 0.4);

  --brand-gradient-subtle: linear-gradient(135deg, rgba(5, 150, 105, 0.18) 0%, rgba(13, 148, 136, 0.12) 100%);
  --brand-shadow: 0 4px 20px -1px rgba(5, 150, 105, 0.45);
  --brand-glow: 0 0 40px -5px rgba(16, 185, 129, 0.35);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 20px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.65);

  /* Auth Dark Tokens */
  --auth-bg: #070b12;
  --auth-surface: #0f1726;
  --auth-card: #111a2d;
  --auth-card-border: rgba(36, 52, 82, 0.85);
  --auth-input-bg: #0b1220;
  --auth-input-border: #1e2c45;
  --auth-input-border-focus: #10b981;
  --auth-input-border-error: #ef4444;
  --auth-input-border-success: #10b981;
  --auth-text-primary: #f1f5f9;
  --auth-text-secondary: #94a3b8;
  --auth-text-muted: #64748b;
  --auth-text-accent: #34d399;
  --auth-text-error: #f87171;
  --auth-text-success: #34d399;
  --orb-emerald: rgba(5, 150, 105, 0.16);
  --orb-teal: rgba(13, 148, 136, 0.12);
  --orb-blue: rgba(14, 165, 233, 0.08);
  --shadow-card: 0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(36, 52, 82, 0.5);
  --shadow-input: 0 1px 3px rgba(0, 0, 0, 0.4) inset;
}

/* High Contrast Accessibility Mode */
body.high-contrast {
  --border-default: #64748b;
  --border-strong: #94a3b8;
  --text-muted: #475569;
}

body.high-contrast[data-theme="dark"] {
  --border-default: #64748b;
  --border-strong: #cbd5e1;
  --text-muted: #cbd5e1;
}

/* Font Size Modifiers */
body.font-sm {
  --base-font-size: 13px;
}

body.font-md {
  --base-font-size: 14px;
}

body.font-lg {
  --base-font-size: 16px;
}

/* Reduced Motion Mode */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--base-font-size);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background: var(--bg-app-gradient);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Ultra-Sleek Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* RTL Helpers */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
  line-height: var(--line-height-arabic);
}

.font-arabic {
  font-family: var(--font-arabic);
}

/* --- Standardized Button System --- */
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

button:focus-visible {
  outline: 2px solid var(--border-accent);
  outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-gradient-hover);
  box-shadow: var(--brand-shadow);
  transform: translateY(-1.5px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Secondary / Outline Button */
.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.8125rem;
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  border-color: var(--border-accent);
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Ghost Icon Button */
.btn-ghost-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.btn-ghost-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-ghost-icon.active {
  color: var(--text-accent);
  background-color: var(--bg-pill-active);
}

/* Nav Item Button */
.btn-nav {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  justify-content: flex-start;
  position: relative;
}

.btn-nav:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-nav.active {
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  font-weight: 600;
}

.btn-nav.active::after {
  content: '';
  position: absolute;
  right: 0.5rem;
  width: 5px;
  height: 18px;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
}

/* --- Layout Grid: Sidebar + Main Area --- */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* --- Sidebar Styling --- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.125rem 1.125rem 1rem 1.125rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background: var(--brand-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 700;
  font-family: var(--font-arabic);
  box-shadow: var(--brand-shadow);
  user-select: none;
  position: relative;
}

.brand-logo::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--brand-gradient);
  opacity: 0.3;
  filter: blur(6px);
  z-index: -1;
}

.brand-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.version-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-pill-active);
  color: var(--text-accent);
  border: 1px solid var(--border-accent-subtle);
}

/* Sidebar Actions */
.sidebar-actions {
  padding: 0.875rem 0.875rem 0.35rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.875rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.btn-new-chat:hover {
  border-color: var(--border-accent);
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  transform: translateY(-1px);
}

.kbd-shortcut {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  background: var(--bg-pill);
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border-default);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 0.75rem;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Sidebar History List */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.history-group-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0 0.5rem 0.35rem 0.5rem;
  text-transform: uppercase;
}

.history-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  user-select: none;
}

.history-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.history-item.active {
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  font-weight: 600;
}

.history-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  flex: 1;
}

.history-item-left svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}

.history-item.active .history-item-left svg,
.history-item.pinned .history-item-left svg {
  color: var(--text-accent);
}

.history-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-actions {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

.history-item:hover .history-item-actions {
  display: flex;
}

.history-action-btn {
  padding: 0.25rem;
  border-radius: 4px;
  color: var(--text-dim);
}

.history-action-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-pill);
}

.history-action-btn.delete:hover {
  color: #ef4444;
}

/* Sidebar Nav Landmarks */
.sidebar-nav {
  padding: 0.625rem 0.875rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-user {
  padding: 0.875rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-status {
  font-size: 0.625rem;
  color: var(--text-accent);
  font-weight: 600;
}

/* --- App Main Container --- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-app-gradient);
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-default);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-toggle-btn {
  display: none;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.header-app-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.header-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.header-pill-btn:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.header-pill-btn svg {
  color: var(--text-accent);
}

/* Dropdown Menu Container */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 0.375rem;
  z-index: 50;
  display: none;
}

.dropdown-menu.open {
  display: block;
  animation: dropdownIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-header {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem 0.25rem 0.75rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.dropdown-item.active {
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  font-weight: 600;
}

.dropdown-item-desc {
  font-size: 0.625rem;
  color: var(--text-dim);
}

/* Content Container Views */
.content-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
  flex: 1;
  height: 100%;
  overflow: hidden;
  flex-direction: column;
}

.view-panel.active {
  display: flex;
}

/* ==========================================================================
   VIEW 1: CHAT ASSISTANT
   ========================================================================== */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.25rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Welcome Screen */
.welcome-container {
  max-width: 840px;
  width: 100%;
  margin: auto;
  padding: 1.5rem 1rem 2.5rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.welcome-badge-glow {
  position: relative;
  margin-bottom: 1.5rem;
}

.welcome-logo {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--brand-gradient);
  color: #ffffff;
  font-size: 2.5rem;
  font-family: var(--font-arabic);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--brand-shadow);
  position: relative;
  z-index: 2;
}

.welcome-badge-glow::before {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 32px;
  background: var(--brand-gradient);
  opacity: 0.25;
  filter: blur(20px);
  z-index: 1;
  animation: glowPulse 4s infinite alternate ease-in-out;
}

@keyframes glowPulse {
  0% {
    transform: scale(0.9);
    opacity: 0.2;
  }

  100% {
    transform: scale(1.15);
    opacity: 0.35;
  }
}

/* Unique Single H1 */
.welcome-h1 {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.welcome-calligraphy {
  font-family: var(--font-arabic);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-accent);
  line-height: 2.3;
  margin-bottom: 0.6rem;
  text-shadow: 0 2px 10px rgba(16, 185, 129, 0.15);
}

.welcome-description {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 620px;
  line-height: 1.65;
  margin-bottom: 2.25rem;
}

/* Suggestion Prompt Grid - 2x3 Grid with Rich Glass Hover */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.125rem;
  width: 100%;
}

.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.prompt-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.prompt-card:hover {
  border-color: var(--border-accent);
  box-shadow: 0 12px 28px -6px rgba(16, 185, 129, 0.14), var(--shadow-md);
  transform: translateY(-3px);
}

.prompt-card:hover::before {
  opacity: 1;
}

.prompt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.prompt-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-pill-active);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.prompt-card:hover .prompt-card-icon {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: var(--brand-shadow);
}

.prompt-card-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-pill);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  letter-spacing: 0.02em;
}

.prompt-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.prompt-card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Prominent 'Try Prompt' Button */
.prompt-card-footer {
  margin-top: 1.125rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prompt-tag {
  font-size: 0.6875rem;
  color: var(--text-dim);
  font-weight: 600;
}

.btn-try-prompt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  border: 1px solid var(--border-accent-subtle);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.prompt-card:hover .btn-try-prompt {
  background: var(--brand-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--brand-shadow);
}

.btn-try-prompt span:last-child {
  transition: transform var(--transition-fast);
}

.prompt-card:hover .btn-try-prompt span:last-child {
  transform: translateX(3px);
}

/* Quick Action Chips Bar (Above Composer) */
.quick-action-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  overflow-x: auto;
  padding: 0.125rem 0.25rem;
  scrollbar-width: none;
}

.quick-action-chips::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.quick-chip:hover {
  border-color: var(--border-accent);
  color: var(--text-accent);
  background-color: var(--bg-pill-active);
  transform: translateY(-1px);
}

/* Conversation Stream Messages */
.messages-container {
  width: 100%;
  max-width: var(--composer-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding-bottom: 2.5rem;
}

.message-row {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.message-row.user-row {
  justify-content: flex-end;
}

.message-row.assistant-row {
  justify-content: flex-start;
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  user-select: none;
}

.assistant-avatar {
  background: var(--brand-gradient);
  color: #ffffff;
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  box-shadow: var(--brand-shadow);
}

.user-avatar-circle {
  background-color: var(--text-primary);
  color: var(--bg-surface);
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
}

.message-bubble {
  max-width: 82%;
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  box-shadow: var(--shadow-xs);
  position: relative;
}

.user-bubble {
  background: var(--bg-bubble-user);
  color: var(--bg-bubble-user-text);
  border-top-right-radius: 4px;
  box-shadow: var(--brand-shadow);
}

.user-timestamp {
  font-size: 0.6875rem;
  opacity: 0.85;
  margin-top: 0.4rem;
  text-align: right;
}

.assistant-bubble {
  background: var(--bg-bubble-assistant);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-top-left-radius: 4px;
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.assistant-model-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.assistant-title-text {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Rich Message Body Text Formatting */
.message-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-body p {
  margin-bottom: 0.85rem;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body blockquote {
  border-left: 3px solid var(--text-accent);
  padding: 0.6rem 1rem;
  margin: 0.85rem 0;
  color: var(--text-secondary);
  background: var(--bg-pill);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

[dir="rtl"] .message-body blockquote {
  border-left: none;
  border-right: 3px solid var(--text-accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.message-body pre {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  padding: 0.875rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-x: auto;
  margin: 0.85rem 0;
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.8125rem;
}

.message-body th,
.message-body td {
  border: 1px solid var(--border-default);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

[dir="rtl"] .message-body th,
[dir="rtl"] .message-body td {
  text-align: right;
}

.message-body th {
  background-color: var(--bg-input);
  font-weight: 700;
}

/* Assistant Message Action Toolbar */
.assistant-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
}

.action-btn {
  padding: 0.375rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.action-btn:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.action-btn.active {
  color: var(--text-accent);
}

.action-btn.active.dislike {
  color: #ef4444;
}

.action-btn-right {
  margin-left: auto;
}

[dir="rtl"] .action-btn-right {
  margin-left: 0;
  margin-right: auto;
}

/* Typing Indicator with Bouncing Dots */
.typing-indicator-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  max-width: var(--composer-max-width);
  margin: 0 auto;
}

.typing-indicator-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-sm);
}

.bouncing-dots {
  display: flex;
  gap: 5px;
}

.bouncing-dot {
  width: 7px;
  height: 7px;
  background: var(--brand-gradient);
  border-radius: 50%;
  animation: bounceDot 1.4s infinite ease-in-out both;
}

.bouncing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.bouncing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounceDot {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

.typing-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Floating Studio Composer Card */
.composer-wrapper {
  width: 100%;
  max-width: var(--composer-max-width);
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem 1.25rem;
}

.composer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 0.875rem 1.125rem;
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.09), var(--shadow-md);
  transition: all var(--transition-normal);
  position: relative;
}

.composer-card:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15), 0 20px 40px -8px rgba(16, 185, 129, 0.18);
}

.composer-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  min-height: 46px;
  max-height: 180px;
  line-height: 1.55;
}

.composer-textarea::placeholder {
  color: var(--text-dim);
}

.composer-textarea[dir="rtl"] {
  font-family: var(--font-arabic);
  line-height: var(--line-height-arabic);
}

/* Bottom Toolbar */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-subtle);
  gap: 0.75rem;
}

.composer-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.composer-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}

.composer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.char-counter {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background-color: var(--border-default);
  margin: 0 0.2rem;
}

/* Pulsing Recording State for Microphone */
.btn-ghost-icon.recording {
  background-color: #fee2e2;
  color: #ef4444;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  70% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: #ffffff;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
  background: var(--brand-gradient-hover);
  box-shadow: var(--brand-shadow);
  transform: scale(1.04);
}

.btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* Legible 12px Disclaimer */
.composer-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.75rem;
  user-select: none;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* ==========================================================================
   VIEW 2: TRANSLATION STUDIO
   ========================================================================== */
.studio-view {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.view-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.view-heading {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.view-subheading {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.translation-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.125rem;
  align-items: stretch;
}

.translation-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
  transition: all var(--transition-fast);
}

.translation-box:focus-within {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}

.translation-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.select-custom {
  background: var(--bg-pill);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select-custom:focus {
  border-color: var(--border-accent);
}

.translation-textarea {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.65;
}

.translation-textarea[dir="rtl"] {
  font-family: var(--font-arabic);
  line-height: var(--line-height-arabic);
}

.translation-swap-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-swap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.btn-swap:hover {
  border-color: var(--border-accent);
  color: var(--text-accent);
  transform: rotate(180deg) scale(1.06);
}

.translation-box-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.translation-presets {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
}

.presets-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-chip {
  background: var(--bg-pill);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-chip:hover {
  border-color: var(--border-accent);
  color: var(--text-accent);
  background-color: var(--bg-pill-active);
  transform: translateY(-1px);
}

/* ==========================================================================
   VIEW 3: WRITING ASSISTANT
   ========================================================================== */
.writing-options-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.writing-mode-btn {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-pill);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.writing-mode-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.writing-mode-btn.active {
  background: var(--bg-pill-active);
  color: var(--text-accent);
  border-color: var(--border-accent);
}

.writing-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.125rem;
}

/* ==========================================================================
   VIEW 4: SETTINGS VIEW
   ========================================================================== */
.settings-container {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem 1rem 3.5rem 1rem;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-xs);
}

.settings-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.settings-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.125rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* Modern Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-default);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

input:checked+.slider {
  background-color: var(--text-accent);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

/* Theme Option Cards */
.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
  margin-top: 0.5rem;
}

.theme-option-card {
  padding: 0.85rem;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.theme-option-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-1px);
}

.theme-option-card.active {
  border-color: var(--border-accent);
  background-color: var(--bg-pill-active);
  color: var(--text-accent);
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   VIEW 5: ABOUT & ALPHABET
   ========================================================================== */
.about-hero {
  background: var(--brand-gradient-subtle);
  border: 1px solid var(--border-accent-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.about-hero-logo {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  background: var(--brand-gradient);
  color: #ffffff;
  font-size: 2.25rem;
  font-family: var(--font-arabic);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--brand-shadow);
}

.alphabet-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.alphabet-table {
  width: 100%;
  border-collapse: collapse;
}

.alphabet-table th {
  background: var(--bg-input);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 0.85rem 1.125rem;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}

.alphabet-table td {
  padding: 0.95rem 1.125rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.alphabet-table tr:hover td {
  background-color: var(--bg-card-hover);
}

.alphabet-table tr:last-child td {
  border-bottom: none;
}

.alphabet-char-cell {
  font-family: var(--font-arabic);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-accent);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  animation: toastIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Backdrop Overlay for Mobile Drawer */
.backdrop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-modal-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 35;
}

.backdrop-overlay.open {
  display: block;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.75rem;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle-btn {
    display: inline-flex;
  }

  .prompt-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .translation-grid {
    grid-template-columns: 1fr;
  }

  .translation-swap-container {
    transform: rotate(90deg);
    margin: -0.5rem 0;
  }

  .writing-editor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 1rem;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .welcome-h1 {
    font-size: 1.85rem;
  }

  .welcome-calligraphy {
    font-size: 1.55rem;
  }

  .header-app-title {
    display: none;
  }

  .composer-wrapper {
    padding: 0 0.5rem 0.85rem 0.5rem;
  }

  .composer-hint {
    display: none;
  }

  .message-bubble {
    max-width: 94%;
  }

  .theme-selector-grid {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   AUTHENTICATION PAGES (Login / Signup)
   ========================================================================== */

/* Light auth component overrides (tokens live in :root / [data-theme=dark]) */
[data-theme="light"] .auth-bg::before {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 65%);
}

[data-theme="light"] .auth-bg::after {
  background: radial-gradient(circle, rgba(13, 148, 136, 0.06) 0%, transparent 65%);
}

[data-theme="light"] .auth-bg-orb3 {
  background: radial-gradient(circle, rgba(14, 165, 233, 0.04) 0%, transparent 65%);
}

[data-theme="light"] .auth-bg-grid {
  background-image:
    linear-gradient(rgba(16, 185, 129, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.05) 1px, transparent 1px);
}

[data-theme="light"] .auth-brand-name {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .auth-brand-name span {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .auth-card::after {
  background: linear-gradient(180deg, rgba(5, 150, 105, 0.02) 0%, transparent 100%);
}

[data-theme="light"] .form-input:hover {
  border-color: #94a3b8;
  background: #ffffff;
}

[data-theme="light"] .form-input:focus {
  background: #ffffff;
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15), var(--shadow-input);
}

[data-theme="light"] .btn-social {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

[data-theme="light"] .btn-social:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .btn-demo-badge {
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed rgba(16, 185, 129, 0.6);
  color: #047857;
}

[data-theme="light"] .btn-demo-badge:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #059669;
}

[data-theme="light"] .lang-badge {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .lang-badge:hover {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
}

[data-theme="light"] .modal-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal-close {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .auth-toast.info {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* --- Floating Theme Switcher Button --- */
.auth-top-actions {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  background: var(--auth-card);
  border: 1px solid var(--auth-card-border);
  border-radius: var(--radius-full);
  color: var(--auth-text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--t-fast);
}

.theme-toggle-btn:hover {
  border-color: rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.theme-toggle-btn:active {
  transform: translateY(0) scale(0.97);
}

.theme-toggle-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

[data-theme="dark"] .theme-toggle-btn svg {
  color: #f59e0b;
}

[data-theme="light"] .theme-toggle-btn svg {
  color: #059669;
}

@media (max-width: 600px) {
  .auth-top-actions {
    top: 0.75rem;
    right: 0.75rem;
  }

  .theme-toggle-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.76rem;
  }

  .theme-toggle-btn .theme-label {
    display: none;
    /* Icon-only on very compact screens */
  }
}

body[data-page="login"],
body[data-page="signup"] {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  background-color: var(--auth-bg);
  color: var(--auth-text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  overflow-y: auto;
  /* Always allow vertical scrolling */
  -webkit-overflow-scrolling: touch;
}

/* --- Animated Ambient Background --- */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-bg::before {
  content: '';
  position: absolute;
  top: -25%;
  left: -20%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, var(--orb-emerald) 0%, transparent 65%);
  animation: orbFloat 18s ease-in-out infinite alternate;
  border-radius: 50%;
}

.auth-bg::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: -15%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, var(--orb-teal) 0%, transparent 65%);
  animation: orbFloat 22s ease-in-out infinite alternate-reverse;
  border-radius: 50%;
}

.auth-bg-orb3 {
  position: absolute;
  top: 35%;
  right: 25%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--orb-blue) 0%, transparent 65%);
  animation: orbFloat 26s ease-in-out infinite alternate;
  border-radius: 50%;
}

.auth-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

@keyframes orbFloat {
  0% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(3%, 2%) scale(1.04);
  }

  66% {
    transform: translate(-2%, 4%) scale(0.98);
  }

  100% {
    transform: translate(2%, -3%) scale(1.02);
  }
}

/* --- Page Layout with Guaranteed Natural Scroll --- */
.auth-page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* Natural flow allows full scrolling without top cutoffs */
  min-height: 100vh;
  min-height: 100dvh;
  padding: 3rem 1.25rem 4rem;
  box-sizing: border-box;
  width: 100%;
}

/* --- Brand Header --- */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  text-align: center;
}

.auth-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-logo-img {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3), 0 8px 24px -4px rgba(0, 0, 0, 0.6), var(--brand-glow);
  transition: transform var(--t-spring), box-shadow var(--t-normal);
}

.auth-logo-img:hover {
  transform: scale(1.06) rotate(-2deg);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5), 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 50px -5px rgba(16, 185, 129, 0.6);
}

.auth-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 25px;
  border: 1.5px solid rgba(16, 185, 129, 0.25);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

  0%,
  100% {
    opacity: 0.35;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(1.04);
  }
}

.auth-brand-name {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.auth-brand-name span {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-brand-subtitle {
  font-family: var(--font-arabic);
  font-size: 1.05rem;
  color: var(--auth-text-secondary);
  direction: rtl;
  unicode-bidi: bidi-override;
  line-height: 1.8;
  margin-top: -0.1rem;
}

/* --- Language Support Badges --- */
.lang-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.lang-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--auth-card-border);
  color: var(--auth-text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: all var(--t-fast);
}

.lang-badge:hover {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--auth-text-accent);
}

.lang-badge.rtl {
  font-family: var(--font-arabic);
  text-transform: none;
  font-size: 0.78rem;
  direction: rtl;
}

/* --- Auth Card with Auto Margins for Perfect Centering & Scrolling --- */
.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0 0 auto 0;
  /* Flows naturally on small screens */
  background: var(--auth-card);
  border: 1px solid var(--auth-card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 2.25rem 2.25rem 2rem;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  animation: cardEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.7), transparent);
}

.auth-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(180deg, rgba(5, 150, 105, 0.05) 0%, transparent 100%);
  pointer-events: none;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Card Header --- */
.auth-card-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-card-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--auth-text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.auth-card-desc {
  font-size: 0.88rem;
  color: var(--auth-text-secondary);
  line-height: 1.5;
}

/* --- Quick Demo Badge / Instant Fill --- */
.demo-banner-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.btn-demo-badge {
  background: rgba(16, 185, 129, 0.1);
  border: 1px dashed rgba(16, 185, 129, 0.45);
  color: #34d399;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--t-fast);
}

.btn-demo-badge:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-demo-badge:active {
  transform: translateY(0) scale(0.98);
}

.btn-demo-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* --- Realistic Social Logins (Google / GitHub) --- */
.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.btn-social {
  width: 100%;
  height: var(--btn-height);
  background: #0d1525;
  border: 1.5px solid var(--auth-input-border);
  border-radius: var(--radius-sm);
  color: var(--auth-text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
  box-sizing: border-box;
}

.btn-social:hover {
  background: #131e33;
  border-color: rgba(52, 211, 153, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.btn-social:active {
  transform: translateY(0) scale(0.99);
}

.btn-social:focus-visible {
  outline: 2px solid var(--auth-input-border-focus);
  outline-offset: 2px;
}

.btn-social svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Divider --- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.15rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--auth-card-border);
}

.divider-text {
  font-size: 0.76rem;
  color: var(--auth-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* --- Form Elements --- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: relative;
  z-index: 1;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--auth-text-secondary);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.form-label .required-mark {
  color: var(--brand-primary);
  font-size: 0.75rem;
}

/* --- Input Wrap & Fields --- */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--auth-text-muted);
  pointer-events: none;
  transition: color var(--t-fast);
  flex-shrink: 0;
}

.input-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.form-input {
  width: 100%;
  height: var(--input-height);
  padding: 0 44px 0 44px;
  background: var(--auth-input-bg);
  border: 1.5px solid var(--auth-input-border);
  border-radius: var(--radius-sm);
  color: var(--auth-text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 400;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.form-input::placeholder {
  color: var(--auth-text-muted);
  font-weight: 400;
}

.form-input:hover {
  border-color: rgba(52, 75, 115, 1);
  background: #0e172a;
}

.form-input:focus {
  border-color: var(--auth-input-border-focus);
  background: #0b1526;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14), var(--shadow-input);
}

.form-group:focus-within .input-icon {
  color: var(--auth-text-accent);
}

.form-input.no-icon-left {
  padding-left: 14px;
}

.form-input.is-error {
  border-color: var(--auth-input-border-error) !important;
  background: rgba(239, 68, 68, 0.05) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
  animation: fieldShake 0.35s ease;
}

.form-input.is-success {
  border-color: var(--auth-input-border-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

@keyframes fieldShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-5px);
  }

  40%,
  80% {
    transform: translateX(5px);
  }
}

.input-action-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--auth-text-muted);
  padding: 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast), background var(--t-fast);
  line-height: 0;
}

.input-action-btn:hover {
  color: var(--auth-text-secondary);
  background: rgba(255, 255, 255, 0.06);
}

.input-action-btn:focus-visible {
  outline: 2px solid var(--auth-input-border-focus);
  outline-offset: 2px;
  color: var(--auth-text-accent);
}

.input-action-btn svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* --- Field Error / Success Validation Message --- */
.field-message {
  font-size: 0.77rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.1rem;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.field-message.show {
  opacity: 1;
  transform: translateY(0);
}

.field-message.error {
  color: var(--auth-text-error);
}

.field-message.success {
  color: var(--auth-text-success);
}

.field-message svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* --- Password Strength Meter --- */
.password-strength {
  margin-top: 0.25rem;
  display: none;
}

.password-strength.visible {
  display: block;
}

.strength-bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.375rem;
}

.strength-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.35s ease;
  width: 0%;
  background: #ef4444;
}

.strength-bar-fill[data-level="1"] {
  width: 25%;
  background: #ef4444;
}

.strength-bar-fill[data-level="2"] {
  width: 50%;
  background: #f97316;
}

.strength-bar-fill[data-level="3"] {
  width: 75%;
  background: #eab308;
}

.strength-bar-fill[data-level="4"] {
  width: 100%;
  background: #10b981;
}

.strength-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--auth-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.strength-label[data-level="1"] {
  color: #f87171;
}

.strength-label[data-level="2"] {
  color: #fb923c;
}

.strength-label[data-level="3"] {
  color: #facc15;
}

.strength-label[data-level="4"] {
  color: #34d399;
}

/* --- Custom Checkbox --- */
.form-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.125rem 0;
}

.form-check-row.between {
  justify-content: space-between;
  align-items: center;
}

.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  border: 1.5px solid var(--auth-input-border);
  border-radius: 6px;
  background: var(--auth-input-bg);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}

.custom-checkbox:checked {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.custom-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5.5px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.custom-checkbox:focus-visible {
  outline: 2px solid var(--auth-input-border-focus);
  outline-offset: 2px;
}

.custom-checkbox:hover:not(:checked) {
  border-color: var(--auth-text-muted);
}

.check-label {
  font-size: 0.84rem;
  color: var(--auth-text-secondary);
  cursor: pointer;
  line-height: 1.5;
  user-select: none;
}

.check-label a,
.check-label .text-link {
  color: var(--auth-text-accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast);
}

.check-label a:hover,
.check-label .text-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* --- Text Links --- */
.text-link {
  background: none;
  border: none;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline;
  padding: 0;
}

.link-forgot {
  font-size: 0.82rem;
  color: var(--auth-text-accent);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--t-fast);
  white-space: nowrap;
}

.link-forgot:hover {
  color: #fff;
  text-decoration: underline;
}

.link-forgot:focus-visible {
  outline: 2px solid var(--auth-input-border-focus);
  outline-offset: 3px;
  border-radius: 3px;
}

/* --- Primary Action Button --- */
.btn-primary {
  width: 100%;
  height: var(--btn-height);
  background: var(--brand-gradient);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  letter-spacing: 0.01em;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  box-shadow: var(--shadow-btn);
  position: relative;
  overflow: hidden;
  margin-top: 0.25rem;
  box-sizing: border-box;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.btn-primary:not(:disabled):hover::before {
  left: 150%;
}

.btn-primary:not(:disabled):hover {
  background: var(--brand-gradient-hover);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-1px);
}

.btn-primary:not(:disabled):active {
  transform: translateY(0) scale(0.99);
  box-shadow: var(--shadow-btn);
}

.btn-primary:focus-visible {
  outline: 2px solid rgba(16, 185, 129, 0.7);
  outline-offset: 3px;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.is-loading .btn-text {
  display: none;
}

.btn-primary:not(.is-loading) .btn-spinner {
  display: none;
}

.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Switch Auth Link --- */
.auth-switch {
  text-align: center;
  font-size: 0.85rem;
  color: var(--auth-text-secondary);
  margin-top: 0.35rem;
}

.auth-switch a,
.auth-switch .text-link {
  color: var(--auth-text-accent);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--t-fast);
  font-size: 0.85rem;
}

.auth-switch a:hover,
.auth-switch .text-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* --- Toast Notification --- */
.auth-toast {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(-15px);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 1.35rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: calc(100vw - 2rem);
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.auth-toast.success {
  background: rgba(5, 150, 105, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.6);
  color: #fff;
}

.auth-toast.error {
  background: rgba(185, 28, 28, 0.95);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fff;
}

.auth-toast.info {
  background: rgba(15, 23, 38, 0.95);
  border: 1px solid rgba(36, 52, 82, 0.9);
  color: var(--auth-text-primary);
}

.toast-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

/* --- Forgot Password Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--auth-card);
  border: 1px solid var(--auth-card-border);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem 2rem;
  width: 100%;
  max-width: 410px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.8);
  transform: scale(0.94) translateY(16px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  box-sizing: border-box;
  margin: auto;
}

.modal-overlay.show .modal-card {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--auth-card-border);
  border-radius: var(--radius-sm);
  color: var(--auth-text-secondary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--auth-text-primary);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-icon {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.2) 0%, rgba(13, 148, 136, 0.12) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.modal-icon svg {
  width: 26px;
  height: 26px;
  color: var(--auth-text-accent);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--auth-text-primary);
  text-align: center;
  margin-bottom: 0.375rem;
}

.modal-desc {
  font-size: 0.86rem;
  color: var(--auth-text-secondary);
  text-align: center;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-success-state {
  display: none;
  text-align: center;
  padding: 0.5rem 0;
}

.modal-success-state.show {
  display: block;
}

.modal-main-state.hidden {
  display: none;
}

.success-anim {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.22) 0%, rgba(13, 148, 136, 0.12) 100%);
  border: 2px solid rgba(16, 185, 129, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-anim svg {
  width: 30px;
  height: 30px;
  color: var(--auth-text-accent);
}

@keyframes successPop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-success-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--auth-text-primary);
  margin-bottom: 0.375rem;
}

.modal-success-desc {
  font-size: 0.85rem;
  color: var(--auth-text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* --- Footer --- */
.auth-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.77rem;
  color: var(--auth-text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.auth-footer a {
  color: var(--auth-text-muted);
  text-decoration: none;
  transition: color var(--t-fast);
}

.auth-footer a:hover {
  color: var(--auth-text-secondary);
}

.auth-footer .footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-dot {
  width: 3px;
  height: 3px;
  background: var(--auth-text-muted);
  border-radius: 50%;
  opacity: 0.5;
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0.5rem;
  background: var(--brand-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 999;
  transition: top var(--t-fast);
}

.skip-link:focus {
  top: 0;
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */

/* --- Tablet (<= 768px) --- */
@media (max-width: 768px) {
  .auth-page {
    padding: 2.5rem 1.25rem 3.5rem;
  }

  .auth-card {
    max-width: 440px;
    padding: 2rem 1.75rem 1.75rem;
  }
}

/* --- Mobile (<= 600px) --- */
@media (max-width: 600px) {
  .auth-page {
    padding: 1.5rem 1rem 3rem;
  }

  .auth-card {
    padding: 1.75rem 1.35rem 1.5rem;
    border-radius: var(--radius-lg);
    max-width: 100%;
  }

  .auth-brand {
    margin-bottom: 1.25rem;
  }

  .auth-brand-name {
    font-size: 1.35rem;
  }

  .auth-brand-subtitle {
    font-size: 0.95rem;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
    /* Stack into single column */
    gap: 1.1rem;
  }

  .auth-card-title {
    font-size: 1.35rem;
  }

  /* Prevent iOS zoom on input focus */
  .form-input {
    font-size: 16px;
  }
}

/* --- Small Mobile (<= 380px) --- */
@media (max-width: 380px) {
  .auth-page {
    padding: 1.25rem 0.75rem 2.5rem;
  }

  .auth-card {
    padding: 1.35rem 1rem 1.25rem;
    border-radius: var(--radius-md);
  }

  .auth-logo-img {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .auth-brand-name {
    font-size: 1.2rem;
  }

  .auth-card-title {
    font-size: 1.2rem;
  }

  .form-input,
  .btn-primary,
  .btn-social {
    height: 46px;
  }

  .btn-social {
    font-size: 0.84rem;
    gap: 0.5rem;
  }

  .btn-primary {
    font-size: 0.88rem;
  }

  .auth-form {
    gap: 0.95rem;
  }

  .link-forgot {
    font-size: 0.78rem;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .auth-bg::before,
  .auth-bg::after,
  .auth-bg-orb3 {
    display: none;
  }
}

/* --- Forced Colors --- */
@media (forced-colors: active) {
  .btn-primary {
    forced-color-adjust: none;
  }

  .custom-checkbox {
    forced-color-adjust: none;
  }
}