@import url('https://cdn.jsdelivr.net/npm/sahel-font@3.4.0/dist/font-face.min.css');

:root, html {
  font-size: 85% !important;
  line-height: 1.35;
  --font-fa: 'Sahel', 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
  --font-en: 'Outfit', -apple-system, sans-serif;

  /* Luxury Dark AMOLED Glassmorphism System */
  --bg-main: #0a0b0e;
  --bg-surface: rgba(22, 23, 29, 0.75);
  --bg-surface-secondary: #1a1b22;
  --bg-gradient-1: #0a0b0e;
  --bg-gradient-2: #16171d;
  --bg-gradient-3: #1a1b22;
  
  --primary-accent: #7c3aed;
  --primary-gradient: #7c3aed;
  --secondary-accent: #7c3aed;
  --action-gradient: #7c3aed;
  --tertiary-accent: #6d28d9;
  --success-accent: #10b981;
  
  --glass-bg: rgba(22, 23, 29, 0.75);
  --glass-card: rgba(22, 23, 29, 0.75);
  --glass-card-hover: rgba(28, 29, 37, 0.85);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-border-glow: rgba(124, 58, 237, 0.25);
  --glass-blur: blur(16px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --text-primary: #e4e4e7;
  --text-secondary: #8e8e9c;
  --text-muted: #71717a;
  
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 14px;
  --border-radius-xl: 16px;
  --border-radius-pill: 9999px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Single Unified AMOLED Glassmorphism Theme */
body,
body.theme-oceanic,
[data-theme="oceanic"],
body.theme-aurora,
body.theme-sunrise,
body.theme-cyber,
body.theme-pearl,
body.theme-deep-focus,
body.theme-pomodoro,
body.theme-zen,
body.theme-cosmic,
body.theme-pacific,
body.theme-golden,
body.theme-autumn,
body.theme-emerald,
body.theme-indigo,
body.theme-pastel,
body.theme-solar,
body.theme-dark-glass {
  --bg-main: #0a0b0e;
  --bg-surface: rgba(22, 23, 29, 0.75);
  --bg-surface-secondary: #1a1b22;
  --primary-accent: #7c3aed;
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-blur: blur(16px);
  background: #0a0b0e;
  color: #e4e4e7;
}

body .glass-panel,
body .modal-card,
.glass-panel,
.modal-card {
  background: rgba(22, 23, 29, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

body .glass-panel-interactive:hover,
.glass-panel-interactive:hover {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(28, 29, 37, 0.85);
}

body .app-header,
body .bottom-nav {
  background: rgba(10, 11, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.07);
}

/* Font Family Overrides */
body.font-vazir {
  --font-fa: 'Vazirmatn', 'Dana', system-ui, sans-serif;
}
body.font-shabnam {
  --font-fa: 'Shabnam', 'Vazirmatn', sans-serif;
}
body.font-sahel {
  --font-fa: 'Sahel', 'Vazirmatn', sans-serif;
}
body.font-samim {
  --font-fa: 'Samim', 'Vazirmatn', sans-serif;
}
body.font-aref {
  --font-fa: 'Aref Ruqaa', 'Amiri', 'Vazirmatn', serif;
}
body.font-nastaliq,
body.font-irannastaliq {
  --font-fa: 'IranNastaliq', 'Noto Nastaliq Urdu', 'Pak Nastaleeq', 'Vazirmatn', serif;
  line-height: 1.8;
}
body.font-lalezar {
  --font-fa: 'Lalezar', 'Vazirmatn', sans-serif;
}
body.font-monospace {
  --font-fa: 'Samim', monospace, 'Courier New', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body, button, input, select, textarea, table, h1, h2, h3, h4, h5, h6, th, td, span, div, p, a {
  font-family: 'Sahel', 'Vazirmatn', system-ui, sans-serif !important;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: var(--font-fa);
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Glass Panels utility */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-lg);
}

.glass-panel-interactive {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  will-change: transform;
}

.glass-panel-interactive:hover {
  transform: translateY(-2px);
  box-shadow: none;
  border-color: rgba(124, 58, 237, 0.2);
}

.glass-panel-interactive:active {
  transform: scale(0.98);
}

/* App Shell */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 90px; /* Space for bottom nav */
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Top Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 6px 14px;
  min-height: 44px;
  background: #0c0d11;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: none;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  width: 26px;
  height: 26px;
  background: #7c3aed;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: none;
}

.header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f4f4f6;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Header Buttons */
.btn-icon-pulse {
  position: relative;
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  will-change: transform;
}

.btn-icon-pulse:hover {
  background: #262730;
  border-color: rgba(255, 255, 255, 0.14);
  transform: scale(1.05);
}

.btn-icon-pulse:active {
  transform: scale(0.95);
}

.btn-telegram {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  padding: 4px 8px;
  border-radius: var(--border-radius-pill);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  box-shadow: none;
  transition: all var(--transition-fast);
  will-change: transform;
}

.btn-telegram:hover {
  background: #262730;
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.btn-telegram:active {
  transform: scale(0.98);
}

.btn-header-action {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  padding: 4px 8px;
  border-radius: 10px;
  font-family: var(--font-fa);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  will-change: transform;
}

.btn-header-action:hover {
  background: #262730;
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.btn-header-action:active {
  transform: scale(0.98);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background: #0c0d11;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px)) 12px;
  box-shadow: none;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 0;
}
.bottom-nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 8px;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex: 1;
  text-align: center;
  will-change: transform;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #ffffff;
  background: #7c3aed;
  box-shadow: none;
}

.nav-item:active {
  transform: scale(0.96);
}

/* Floating Action Button (FAB) in Bottom Navigation */
.nav-fab-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  z-index: 1001;
  top: -12px;
}

.nav-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 3px solid #0c0d11;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.55), 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
  animation: fab-glow-pulse 2.5s infinite ease-in-out;
}

.nav-fab-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 28px rgba(16, 185, 129, 0.8), 0 6px 16px rgba(0, 0, 0, 0.6);
}

.nav-fab-btn:active {
  transform: scale(0.94);
}

.nav-fab-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.2;
}

.nav-fab-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #34d399;
  margin-top: 2px;
  white-space: nowrap;
}

@keyframes fab-glow-pulse {
  0%, 100% {
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 26px rgba(16, 185, 129, 0.75), 0 4px 16px rgba(0, 0, 0, 0.6);
  }
}


/* Content Container */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Day Selector & Pill Tabs Container */
.day-selector, .pill-tabs-container, .segment-control, .tabs-pill-wrap {
  display: flex;
  gap: 6px;
  background: #16171d;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-pill);
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
}

.day-selector::-webkit-scrollbar,
.pill-tabs-container::-webkit-scrollbar,
.segment-control::-webkit-scrollbar {
  display: none;
}

.day-pill, .tab-pill, .segment-btn {
  padding: 8px 18px;
  border-radius: var(--border-radius-pill);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  will-change: transform;
}

.day-pill:hover, .tab-pill:hover, .segment-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.day-pill.active, .tab-pill.active, .segment-btn.active {
  background: #7c3aed;
  color: #ffffff;
  font-weight: 800;
  border-color: transparent;
  box-shadow: none;
}

.day-pill:active, .tab-pill:active, .segment-btn:active {
  transform: scale(0.98);
}

/* 48 Slots Grid */
.slots-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all var(--transition-fast);
  will-change: transform;
}

.slot-row:hover {
  background: #262730;
  border-color: rgba(124, 58, 237, 0.2);
  box-shadow: none;
  transform: translateX(-3px);
}

.slot-time {
  font-family: var(--font-en);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 95px;
  direction: ltr;
  text-align: right;
}

.slot-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: var(--border-radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.slot-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cards & Widgets */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #16171d;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  max-height: 90vh;
  overflow-y: auto;
  will-change: transform;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: #f4f4f6;
  letter-spacing: -0.02em;
}

.btn-close {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e4e4e7;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-close:hover {
  background: #2f303d;
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  transform: scale(1.06);
}

.btn-close:active {
  transform: scale(0.95);
}

/* Category Grid in Picker */
.category-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.cat-pick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #1f2029;
  color: var(--text-primary);
  font-family: var(--font-fa);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  will-change: transform;
}

.cat-pick-btn:hover {
  transform: translateY(-2px);
  background: #262730;
  border-color: rgba(124, 58, 237, 0.25);
  box-shadow: none;
}

.cat-pick-btn:active {
  transform: scale(0.98);
}

/* Inputs & Form Elements */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.input-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: var(--font-fa);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #7c3aed;
  background: #1f2029;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-muted);
}

select option {
  background: #16171d;
  color: var(--text-primary);
}

.btn-primary {
  width: 100%;
  padding: 12px 18px;
  background: #7c3aed;
  border: none;
  border-radius: 14px;
  color: #ffffff;
  font-family: var(--font-fa);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition-fast);
  will-change: transform, box-shadow;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: none;
}

/* Donut & Progress Rings */
.progress-ring-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== 24-Hour Activity Matrix Grid ===== */
.matrix-24h-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #16171d;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

.matrix-24h-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  text-align: center;
}

.matrix-col-activity {
  padding: 10px 12px;
  background: #1f2029;
  color: #a1a1aa;
  font-size: 0.85rem;
  font-weight: bold;
  border-radius: 8px;
  text-align: right;
  min-width: 165px;
  max-width: 195px;
  width: 175px;
  position: sticky;
  right: 0;
  z-index: 5;
  box-shadow: -3px 0 8px rgba(0, 0, 0, 0.4);
}

td.matrix-col-activity {
  background: #1f2029;
  color: #e4e4e7;
}

.matrix-act-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.matrix-act-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  color: #e4e4e7;
}

.matrix-act-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: normal;
  flex-shrink: 0;
}

.matrix-act-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 3px;
  font-size: 0.85rem;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.matrix-act-btn:hover {
  opacity: 1;
}

.matrix-col-slot {
  padding: 8px 4px;
  background: #1f2029;
  color: #71717a;
  font-size: 0.72rem;
  font-family: var(--font-en);
  font-weight: bold;
  border-radius: 6px;
  min-width: 44px;
  width: 44px;
  letter-spacing: 0.5px;
}

td.matrix-slot-cell {
  padding: 3px;
  cursor: pointer;
  position: relative;
  min-width: 44px;
  width: 44px;
}

.matrix-cell-box {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.matrix-test-input {
  width: 100%;
  height: 38px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e4e4e7;
  text-align: center;
  font-weight: bold;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  font-family: var(--font-en);
}

/* 24-Hour Matrix Current Slot Pulse & Focus Highlight */
@keyframes slotHighlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.9), inset 0 0 12px rgba(124, 58, 237, 0.6);
    border-color: #7c3aed !important;
    transform: scale(1.06);
  }
  50% {
    box-shadow: 0 0 20px 4px rgba(124, 58, 237, 0.6), inset 0 0 16px rgba(124, 58, 237, 0.6);
    border-color: #8b5cf6 !important;
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0), inset 0 0 0 rgba(124, 58, 237, 0);
    transform: scale(1);
  }
}

.matrix-slot-highlighted {
  animation: slotHighlightPulse 1.6s ease-in-out 3;
  z-index: 10 !important;
  border: 2px solid #7c3aed !important;
  position: relative;
}

.matrix-col-slot-highlighted {
  background: #7c3aed !important;
  color: #ffffff !important;
  font-weight: 900 !important;
  box-shadow: none !important;
  border: 1.5px solid #7c3aed !important;
}

/* Responsive adjustments for Mobile, Tablet, Laptop, Portrait & Landscape */
@media (max-width: 768px) {
  /* Font Sizes & Spacing Compression for Mobile */
  html {
    font-size: 14.5px;
  }

  .main-container {
    padding: 8px 6px;
    gap: 10px;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Compact Card & Panel Padding */
  .glass-panel {
    padding: 12px 14px !important;
    border-radius: 16px !important;
  }

  /* Titles and Headers (0.95rem to 1rem) */
  .card-title,
  h2,
  h3,
  .modal-title,
  .section-title {
    font-size: 0.95rem !important;
    margin-bottom: 8px !important;
    line-height: 1.45 !important;
  }

  h1 {
    font-size: 1.08rem !important;
  }

  h4 {
    font-size: 0.88rem !important;
  }

  /* Explanatory texts, paragraphs and labels (0.8rem to 0.85rem) */
  p,
  .input-label,
  .card-desc,
  .text-secondary,
  .study-cycle-step p {
    font-size: 0.8rem !important;
    line-height: 1.6 !important;
  }

  .slot-note,
  .slot-time {
    font-size: 0.78rem !important;
  }

  /* Form Controls & Inputs Compact */
  .form-input,
  .form-select,
  .form-textarea {
    padding: 8px 12px !important;
    font-size: 0.84rem !important;
    border-radius: 10px !important;
  }

  .input-group {
    margin-bottom: 10px !important;
    gap: 4px !important;
  }

  /* Compact Buttons */
  .btn-primary {
    padding: 9px 14px !important;
    font-size: 0.85rem !important;
    border-radius: 12px !important;
  }

  .day-pill {
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
    border-radius: 16px !important;
  }

  .study-cycle-step {
    padding: 10px !important;
    border-radius: 14px !important;
  }

  .study-cycle-step button {
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
  }

  .app-header {
    padding: 6px 12px;
    gap: 8px;
    overflow: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  .header-brand {
    flex-shrink: 0;
  }
  .header-title {
    font-size: 0.9rem;
    white-space: nowrap;
  }
  .header-actions-wrapper {
    overflow: hidden !important;
    width: auto !important;
  }
  .header-actions {
    overflow: hidden !important;
    gap: 6px;
  }
  .btn-header-action, .btn-telegram {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .category-picker-grid {
    grid-template-columns: 1fr !important;
  }
  .slot-row {
    flex-wrap: wrap;
    gap: 6px !important;
    padding: 7px 10px !important;
    border-radius: 10px !important;
  }
  .modal-card {
    padding: 16px !important;
    border-radius: 18px !important;
    max-width: 95vw;
  }
  .bottom-nav {
    width: 100%;
    bottom: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 6px)) 8px !important;
  }
  .nav-item {
    padding: 4px 2px !important;
    font-size: 0.7rem !important;
  }
  .nav-item svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* 24-Hour Matrix Mobile UX Optimization */
  .matrix-24h-container {
    padding: 8px 4px !important;
    border-radius: 12px !important;
  }

  .matrix-24h-table {
    border-spacing: 2px !important;
  }

  .matrix-col-activity {
    padding: 6px 6px !important;
    min-width: 110px !important;
    max-width: 125px !important;
    width: 115px !important;
    font-size: 0.76rem !important;
    border-radius: 6px !important;
  }

  .matrix-act-info {
    max-width: 75px !important;
    gap: 4px !important;
  }

  .matrix-act-title {
    max-width: 70px !important;
    font-size: 0.76rem !important;
  }

  .matrix-act-badge {
    display: none !important; /* Hide badge text on mobile to maximize title room */
  }

  .matrix-act-btn {
    padding: 1px 2px !important;
    font-size: 0.72rem !important;
  }

  .matrix-col-slot {
    padding: 6px 1px !important;
    min-width: 38px !important;
    width: 38px !important;
    font-size: 0.64rem !important;
    border-radius: 4px !important;
  }

  td.matrix-slot-cell {
    padding: 1.5px !important;
    min-width: 38px !important;
    width: 38px !important;
  }

  .matrix-cell-box {
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 6px !important;
    font-size: 0.92rem !important;
  }

  .matrix-test-input {
    height: 34px !important;
    font-size: 0.82rem !important;
    border-radius: 6px !important;
    padding: 2px !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (min-width: 1025px) {
  .main-container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .bottom-nav {
    padding: 4px 10px;
  }
  .modal-card {
    max-height: 96vh !important;
  }
}

/* ===== Articles View ===== */
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.12) !important;
}

/* ===== Article Content (High Contrast & High Readability) ===== */
.article-content,
.article-body,
.article-body p,
.article-body li,
.article-body span,
.article-content p,
.article-content li,
.article-content span,
.article-content div:not(.info-box):not(.highlight-box):not(.note-box) {
  color: #e2e8f0 !important; /* Bright & clear matte white font */
  line-height: 1.9 !important;
  font-size: 1.02rem !important;
  font-family: inherit !important;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  color: #ffffff !important;
  font-weight: 800 !important;
  margin-top: 1.5rem !important;
  margin-bottom: 0.8rem !important;
  line-height: 1.6 !important;
}

.article-content h2,
.article-body h2 {
  font-size: 1.15rem !important;
  border-right: 4px solid #38bdf8 !important;
  padding-right: 12px !important;
}

.article-content h3,
.article-body h3 {
  font-size: 1.05rem !important;
  color: #cbd5e1 !important;
}

.article-content strong,
.article-content b,
.article-body strong,
.article-body b {
  color: #38bdf8 !important; /* Soft cyan/blue highlight for keywords */
  font-weight: 800 !important;
}

.article-content ul,
.article-body ul {
  padding-right: 22px !important;
  margin-bottom: 16px !important;
}

.article-content ul li,
.article-body ul li {
  font-size: 1.02rem !important;
  line-height: 1.9 !important;
  color: #e2e8f0 !important;
  margin-bottom: 8px !important;
  list-style-type: disc !important;
}

.article-content table,
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: #16171d !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.92rem;
}

.article-content th,
.article-body th {
  background: #7c3aed !important;
  color: #ffffff !important;
  padding: 12px;
  text-align: right;
  font-weight: bold;
}

.article-content td,
.article-body td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0 !important;
}

.article-content tr:nth-child(even) td,
.article-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03) !important;
}

/* Info / highlight boxes inside articles */
.article-content blockquote,
.article-content .info-box,
.article-content .highlight-box,
.article-content .note-box,
.article-body blockquote,
.article-body .info-box,
.article-body .highlight-box,
.article-body .note-box {
  background: #1f2029 !important;
  color: #f1f5f9 !important;
  border-radius: 14px;
  padding: 16px 18px;
  border-right: 4px solid #7c3aed;
  margin: 16px 0;
}

/* ===== Question Bank & Test Stem Styling ===== */
.question-stem,
.qb-question-text {
  color: #f8fafc !important;
  font-size: 0.98rem !important;
  line-height: 1.85 !important;
}

.question-stem strong,
.question-stem b,
.question-stem .keyword-highlight,
.qb-question-text strong,
.qb-question-text b,
.qb-question-text .keyword-highlight,
.keyword-highlight {
  color: #fbbf24 !important; /* Amber / glowing yellow */
  background: rgba(251, 191, 36, 0.12) !important;
  font-weight: 700 !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(251, 191, 36, 0.25) !important;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.25);
}

/* ===== Mnemonic Box Glowing Phosphor Green Highlights ===== */
.qb-mnemonic-box .keyword-highlight,
.qb-mnemonic-box strong,
.qb-mnemonic-box b,
.qb-mnemonic-box .mnemonic-quote,
.mnemonic-box .keyword-highlight,
.mnemonic-box strong,
.mnemonic-box b,
.mnemonic-box .mnemonic-quote {
  color: #4ade80 !important; /* Glowing phosphor green for memory codes */
  background: rgba(74, 222, 128, 0.14) !important;
  font-weight: 800 !important;
  padding: 1px 6px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(74, 222, 128, 0.3) !important;
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.35);
}

/* ===== Key Note Box Golden Highlights ===== */
.qb-key-note-box .keyword-highlight,
.qb-key-note-box strong,
.qb-key-note-box b,
.key-point-box .keyword-highlight,
.key-point-box strong,
.key-point-box b {
  color: #fde047 !important; /* Soft golden yellow */
  background: rgba(253, 224, 71, 0.12) !important;
  font-weight: 700 !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(253, 224, 71, 0.25) !important;
  text-shadow: 0 0 8px rgba(253, 224, 71, 0.3);
}

/* ===== Faded Brand Watermark Overlay on Test Cards ===== */
.test-card,
.qb-question-card,
.qb-bento-card,
.bento-question-card {
  position: relative !important;
  overflow: hidden !important;
}

.test-card::after,
.qb-question-card::after,
.qb-bento-card::after,
.bento-question-card::after {
  content: "PlanEx • @medicalaa";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.035); /* Subtle & elegant background watermark */
  pointer-events: none;
  user-select: none;
  z-index: 1;
  white-space: nowrap;
  font-family: 'Outfit', system-ui, sans-serif;
}

#btn-back-to-articles:hover {
  background: #1f2029 !important;
  color: white !important;
}

/* User Guide Modal Content Scrollbar */
.user-guide-content::-webkit-scrollbar {
  width: 5px;
}
.user-guide-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}
.user-guide-content::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.4);
  border-radius: 4px;
}

/* 🟢 Live Pomodoro Active Users Tracking Badge & Pulse Animation */
@keyframes neon-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    transform: scale(0.95);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    transform: scale(0.95);
  }
}

.pomodoro-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--border-radius-pill);
  padding: 6px 14px;
  color: #10b981;
  font-weight: 700;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
}

.neon-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: neon-pulse 1.8s infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes livePulseAnim {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.97);
  }
}

.animate-pulse {
  animation: livePulseAnim 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.live-studying-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #10b981;
  padding: 2px 10px;
  border-radius: var(--border-radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: none;
  transition: all var(--transition-fast);
}

/* 🌿 Slim Mini Live Study Bar */
.slim-live-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  max-width: 96%;
  min-height: 28px;
  height: 30px;
  margin: 0 auto 12px auto;
  padding: 0 14px;
  border-radius: var(--border-radius-pill);
  background: #16171d;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: none;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
  will-change: transform;
}

.slim-live-bar:hover {
  border-color: rgba(16, 185, 129, 0.6);
  background: #1f2029;
  transform: translateY(-1px);
}

.slim-live-bar:active {
  transform: scale(0.98);
}

.slim-live-text {
  font-size: 0.76rem;
  font-weight: 700;
  color: #10b981;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.slim-live-count {
  color: #10b981;
  font-family: var(--font-en), var(--font-fa);
  font-weight: 900;
  font-size: 0.82rem;
  margin: 0 2px;
}

.slim-live-separator {
  color: rgba(16, 185, 129, 0.4);
  margin: 0 4px;
}

/* 🏆 Leaderboard & Study Room Neon Avatars */
.studying-avatar-ring,
.user-avatar-active,
.leaderboard-avatar-studying,
.avatar-studying {
  border: 2px solid #10b981 !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35) !important;
  position: relative;
}

.time-badge-pill,
.badge-study-time {
  background: #1f2029;
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* =========================================================================
   🤖 PLANEX FLOATING AI ASSISTANT WIDGET (AMOLED MINIMAL)
   ========================================================================= */

.ai-fab-container {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 1005;
  display: flex;
  align-items: center;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-fab-container.active {
  transform: scale(0.92);
}

.ai-fab-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #7c3aed;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  box-shadow: none;
  font-family: var(--font-fa);
  font-size: 0.88rem;
  font-weight: 800;
  transition: all var(--transition-fast);
  overflow: visible;
  will-change: transform;
}

.ai-fab-button:hover {
  transform: translateY(-2px);
  background: #6d28d9;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.ai-fab-button:active {
  transform: translateY(0) scale(0.97);
}

.ai-fab-glow {
  display: none;
}

.ai-fab-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.ai-fab-sparkle {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 0.85rem;
}

.ai-fab-label {
  white-space: nowrap;
  letter-spacing: -0.2px;
}

/* Floating AI Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: 86px;
  right: 20px;
  width: 400px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100vh - 110px);
  z-index: 1010;
  display: flex;
  flex-direction: column;
  background: #16171d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, visibility 0.25s;
  overflow: hidden;
}

.ai-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Window Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1f2029;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar-badge {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.ai-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0c0d11;
  box-shadow: 0 0 6px #10b981;
}

.ai-header-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-header-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: #e4e4e7;
  letter-spacing: -0.02em;
}

.ai-header-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-badge-free {
  font-size: 0.68rem;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.15);
  padding: 1px 8px;
  border-radius: var(--border-radius-pill);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-ai-header-icon {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  will-change: transform;
}

.btn-ai-header-icon:hover {
  background: #262730;
  color: #ffffff;
  border-color: rgba(124, 58, 237, 0.4);
}

.btn-ai-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

/* Quick Prompts Bar */
.ai-quick-prompts-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: #16171d;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.ai-quick-prompts-bar::-webkit-scrollbar {
  display: none;
}

.btn-quick-prompt {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #a1a1aa;
  padding: 5px 12px;
  border-radius: var(--border-radius-pill);
  font-family: var(--font-fa);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  will-change: transform;
}

.btn-quick-prompt:hover {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Messages Container */
.ai-chat-messages {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Message Rows */
.ai-message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  animation: ai-msg-fade 0.2s ease-out;
}

@keyframes ai-msg-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-message-row.user {
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.ai-msg-avatar.user-avatar {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.ai-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--border-radius-lg);
  font-size: 0.86rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.ai-message-row.bot .ai-msg-bubble {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
  border-top-right-radius: 4px;
  box-shadow: none;
}

.ai-message-row.user .ai-msg-bubble {
  background: #7c3aed;
  border: none;
  color: #ffffff;
  border-top-left-radius: 4px;
  box-shadow: none;
}

.ai-msg-content p {
  margin: 0 0 6px 0;
}
.ai-msg-content p:last-child {
  margin-bottom: 0;
}

.ai-bullet-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0;
  color: #e4e4e7;
}

.ai-bullet-dot {
  color: #7c3aed;
  font-size: 0.75rem;
  margin-top: 1px;
}

.ai-numbered-item {
  margin: 4px 0;
  font-weight: 500;
}

.ai-msg-spacer {
  height: 6px;
}

.ai-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.btn-copy-ai-msg {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 2px;
  transition: color var(--transition-fast);
}

.btn-copy-ai-msg:hover {
  color: #7c3aed;
}

/* Typing Indicator */
#ai-typing-indicator {
  display: none;
}
#ai-typing-indicator.visible {
  display: flex;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

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

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  animation: bounce-dot 1.2s infinite ease-in-out;
}

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

@keyframes bounce-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.typing-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Input Area */
.ai-chat-input-bar {
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
  background: #16171d;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  padding: 4px 8px 4px 6px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-input-wrapper:focus-within {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.ai-chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: var(--font-fa);
  font-size: 0.85rem;
  padding: 6px 4px;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

.ai-chat-input::placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.btn-send-ai {
  background: #7c3aed;
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  box-shadow: none;
  will-change: transform;
}

.btn-send-ai:hover:not(.disabled) {
  transform: scale(1.05);
  background: #6d28d9;
}

.btn-send-ai.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-flashcard-trigger {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  padding: 5px 10px;
  border-radius: var(--border-radius-pill);
  font-family: var(--font-fa);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-flashcard-trigger:hover {
  background: #262730;
  border-color: rgba(124, 58, 237, 0.35);
  color: #ffffff;
}

.btn-quick-prompt.highlight {
  background: rgba(124, 58, 237, 0.18);
  border-color: rgba(124, 58, 237, 0.4);
  color: #c4b5fd;
  font-weight: 700;
}

.ai-status-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: #10b981;
}

/* Flashcard Interactive Display in Chat */
.ai-flashcard-interactive-card {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  padding: 12px 14px;
  margin: 10px 0;
  box-shadow: none;
  text-align: right;
  direction: rtl;
}

.ai-flashcard-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-flashcard-badge {
  font-size: 0.7rem;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.15);
  padding: 2px 8px;
  border-radius: var(--border-radius-pill);
  font-weight: 700;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.btn-save-single-flashcard {
  background: #10b981;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: var(--border-radius-pill);
  font-family: var(--font-fa);
  font-size: 0.72rem;
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: none;
}

.btn-save-single-flashcard:hover:not(:disabled) {
  background: #059669;
}

.btn-save-single-flashcard:disabled {
  opacity: 0.85;
  cursor: default;
}

.ai-flashcard-q {
  color: #c4b5fd;
  font-size: 0.84rem;
  margin-bottom: 6px;
  font-weight: 700;
  line-height: 1.5;
}

.ai-flashcard-a {
  color: #e4e4e7;
  font-size: 0.82rem;
  line-height: 1.5;
}

.ai-fc-label {
  font-weight: 800;
  margin-left: 4px;
}

.ai-flashcards-bulk-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.btn-save-all-flashcards {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-fa);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
  box-shadow: none;
}

.btn-save-all-flashcards:hover:not(:disabled) {
  background: #6d28d9;
}

.btn-save-all-flashcards:disabled {
  opacity: 0.85;
  cursor: default;
}

.ai-input-hint {
  display: flex;
  justify-content: center;
  margin-top: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Leitner Box & Flashcards Section Styles */
.btn-filter-leitner-box:hover {
  transform: translateY(-2px);
  background: #1f2029 !important;
}

.btn-filter-leitner-box.active {
  background: rgba(124, 58, 237, 0.2) !important;
  border-color: #7c3aed !important;
  box-shadow: none;
}

.leitner-card-flip {
  perspective: 1000px;
}

.btn-leitner-review-action:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn-delete-flashcard:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  transform: scale(1.1);
}

/* Mobile Responsiveness for AI Widget */
@media (max-width: 600px) {
  .ai-fab-container {
    bottom: 76px;
    right: 14px;
  }
  
  .ai-fab-button {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .ai-chat-window {
    bottom: 74px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: calc(100vw - 20px);
    height: calc(100vh - 140px);
    border-radius: 18px;
  }
}

/* ==========================================================================
   🏥 Question Bank (AMOLED Minimal Bento Grid & Active Recall UI)
   ========================================================================== */

.qb-bento-card,
.qb-question-card {
  position: relative;
  overflow: hidden;
  background: #16171d;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  box-shadow: none;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  will-change: transform;
}

/* 🌟 Subtle Background Watermark for Bento Cards */
.qb-bento-card::before,
.qb-question-card::before {
  content: "PlanEx • @medicalaa";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-14deg);
  font-family: var(--font-en, 'Outfit'), system-ui, -apple-system, sans-serif;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7c3aed;
  opacity: 0.03;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  z-index: 0;
  line-height: 1;
}

.qb-bento-card > *,
.qb-question-card > * {
  position: relative;
  z-index: 1;
}

/* 🌟 Key Note Callout Box */
.qb-key-note,
.qb-key-note-box {
  position: relative;
  overflow: hidden;
  background: #1f2029;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--border-radius-md);
}

.qb-key-note::before,
.qb-key-note-box::before {
  content: "PlanEx • @medicalaa";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--font-en, 'Outfit'), system-ui, -apple-system, sans-serif;
  font-size: clamp(1.05rem, 2.8vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #10b981;
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  z-index: 0;
  line-height: 1;
}

.qb-key-note > *,
.qb-key-note-box > * {
  position: relative;
  z-index: 1;
}

/* 🌟 Mnemonic Callout Box */
.qb-mnemonic,
.qb-mnemonic-box {
  position: relative;
  overflow: hidden;
  background: #1f2029;
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: var(--border-radius-md);
}

.qb-mnemonic::before,
.qb-mnemonic-box::before {
  content: "PlanEx • @medicalaa";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--font-en, 'Outfit'), system-ui, -apple-system, sans-serif;
  font-size: clamp(1.05rem, 2.8vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7c3aed;
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  z-index: 0;
  line-height: 1;
}

.qb-mnemonic > *,
.qb-mnemonic-box > * {
  position: relative;
  z-index: 1;
}

.qb-bento-card:hover,
.qb-question-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.25) !important;
}

.qb-featured-hero-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.35) !important;
}

.qb-option-item {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-md);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  will-change: transform;
}

.qb-option-item:hover {
  background: #262730 !important;
  border-color: rgba(124, 58, 237, 0.25) !important;
  transform: translateX(-2px);
}

.qb-category-pill {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-pill);
  transition: all var(--transition-fast);
}

.qb-category-pill:hover {
  border-color: rgba(124, 58, 237, 0.3) !important;
  background: #262730 !important;
}

.qb-btn-reveal-answer:hover {
  background: rgba(124, 58, 237, 0.15) !important;
  border-color: #7c3aed !important;
}

.qb-exam-period-btn {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-fast);
}

.qb-exam-period-btn:hover {
  border-color: rgba(124, 58, 237, 0.3) !important;
  background: #262730 !important;
  transform: translateY(-2px);
}

.btn-exam-quick-chip {
  background: #1f2029;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-pill);
  transition: all var(--transition-fast);
}

.btn-exam-quick-chip:hover {
  background: rgba(124, 58, 237, 0.15) !important;
  border-color: #7c3aed !important;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .qb-bento-grid {
    grid-template-columns: 1fr !important;
  }

  .qb-header-card {
    padding: 16px !important;
  }

  .qb-period-switcher-list {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 480px) {
  .qb-period-switcher-list {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   ⏱️ Focus Mode & Timer Capsule Tabs (AMOLED Minimal)
   ========================================================================== */

.btn-focus-tab {
  background: transparent !important;
  color: #a1a1aa !important;
  border-radius: var(--border-radius-pill) !important;
  transition: all var(--transition-fast) !important;
}

.btn-focus-tab:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.04) !important;
}

.btn-focus-tab.active {
  background: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

.btn-focus-preset {
  border-radius: var(--border-radius-pill) !important;
  transition: all var(--transition-fast) !important;
}

.btn-focus-preset.active {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

.btn-activity-mode-switch {
  border-radius: var(--border-radius-pill) !important;
  transition: all var(--transition-fast) !important;
}

.btn-activity-mode-switch.active {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

/* ==========================================================================
   ☁️ Cloud Auto-Sync Indicator & Spin Keyframe
   ========================================================================== */

@keyframes spin-sync {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spin-sync {
  animation: spin-sync 1s linear infinite;
  display: inline-block;
  transform-origin: center center;
}

#cloud-sync-status-indicator {
  transition: all 0.2s ease;
  cursor: pointer;
}

#cloud-sync-status-indicator:hover {
  background: rgba(124, 58, 237, 0.2) !important;
  border-color: rgba(124, 58, 237, 0.4) !important;
}

/* ==========================================================================
   🚨 Critical Touch & Horizontal Scroll Isolation Fixes (Snap-back & Scroll Freeze Fix)
   ========================================================================== */

.leaderboard-view,
.leaderboard-container,
.leaderboard-table-wrapper {
  overflow-y: visible;
  touch-action: manipulation;
}

.group-switcher-wrapper,
.my-rooms-chips-container,
.horizontal-scroll-isolated,
.leaderboard-table-container {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x !important;
  overscroll-behavior-x: auto !important; /* روی contain نباشد تا در RTL موبایل قفل نکند */
  scroll-behavior: smooth;
  scrollbar-width: none; /* مخفی کردن اسکرولبار زمخت */
  scroll-snap-type: none !important;
}

.group-switcher-wrapper::-webkit-scrollbar,
.my-rooms-chips-container::-webkit-scrollbar,
.horizontal-scroll-isolated::-webkit-scrollbar,
.leaderboard-table-container::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.horizontal-scroll-isolated > *,
.group-switcher-wrapper > *,
.my-rooms-chips-container > *,
.leaderboard-table-container > * {
  min-width: max-content !important;
  width: max-content !important;
  flex-shrink: 0 !important;
}

.leaderboard-table-container table {
  min-width: 600px !important; /* تضمین اینکه جدول به زور در صفحه فشرده نشود و عرض واقعی پیدا کند */
  width: 100% !important;
  touch-action: pan-x pan-y manipulation !important;
}

/* ==========================================================================
   📚 Article Content & Syllabus Tables Dark Mode Fix (100% Unified)
   ========================================================================== */

/* ریست کامل پسزمینه‌های پیشفرض جداول در مقالات */
.article-content table,
.article-body table,
.custom-table,
.article-content .custom-table,
.article-body .custom-table {
  width: 100% !important;
  border-collapse: collapse !important;
  background-color: #0b1120 !important; /* پسزمینه تیره هماهنگ با تم */
  color: #f1f5f9 !important;
  margin: 1rem 0 !important;
  border: 1px solid #1e293b !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

/* سطرهای فرد: دودی تیره */
.article-content tr:nth-child(odd),
.article-body tr:nth-child(odd),
.custom-table tr:nth-child(odd),
.article-content .custom-table tr:nth-child(odd) {
  background-color: #1e293b !important;
}

.article-content tr:nth-child(odd) td,
.article-body tr:nth-child(odd) td,
.custom-table tr:nth-child(odd) td {
  background-color: #1e293b !important;
}

/* سطرهای زوج: دودی کمی روشنتر (نه سفید) */
.article-content tr:nth-child(even),
.article-body tr:nth-child(even),
.custom-table tr:nth-child(even),
.article-content .custom-table tr:nth-child(even) {
  background-color: #0f172a !important;
}

.article-content tr:nth-child(even) td,
.article-body tr:nth-child(even) td,
.custom-table tr:nth-child(even) td {
  background-color: #0f172a !important;
}

/* رفع کامل هوور سطرهای سفید */
.article-content tr:hover,
.article-body tr:hover,
.custom-table tr:hover,
.article-content tr:hover td,
.article-body tr:hover td,
.custom-table tr:hover td {
  background-color: #1e293b !important;
}

/* سلولها و بردرها */
.article-content td,
.article-content th,
.article-body td,
.article-body th,
.custom-table td,
.custom-table th {
  padding: 10px 12px !important;
  border: 1px solid #334155 !important;
  color: #e2e8f0 !important; /* متن کاملاً خوانا روی پسزمینه تیره */
  font-size: 0.9rem !important;
  line-height: 1.6 !important;
  text-align: right !important;
}

/* هدرهای جدول */
.article-content th,
.article-body th,
.custom-table th {
  background-color: #1e293b !important;
  color: #38bdf8 !important;
  font-weight: 800 !important;
}

/* هدینگها و عناوین داخل جدول (مانند فیزیولوژی، آناتومی و...) */
.article-content td strong,
.article-body td strong,
.custom-table td strong,
.article-content td b,
.article-body td b,
.custom-table td b {
  color: #38bdf8 !important; /* رنگ فیروزه‌ای روشن برای عناوین دروس */
  display: inline-block;
  margin-bottom: 4px;
}

/* ریست کامل کانتینرها و کارت‌های داخل مقالات */
.article-content .container,
.article-body .container {
  background: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: #1e293b !important;
  box-shadow: none !important;
}

.article-content .stat-card,
.article-body .stat-card,
.stat-card {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  border-radius: 14px !important;
  padding: 14px 18px !important;
  color: #e2e8f0 !important;
}

.stat-number {
  color: #38bdf8 !important;
  font-weight: 800 !important;
  font-size: 1.4rem !important;
  font-family: 'Outfit', sans-serif !important;
}

.stat-label {
  color: #cbd5e1 !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
}

.article-content .section-title,
.article-body .section-title {
  color: #38bdf8 !important;
  border-bottom-color: #334155 !important;
}

.article-content .rule-card,
.article-body .rule-card {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-right-color: #10b981 !important;
}

.article-content .rule-card h3,
.article-body .rule-card h3 {
  color: #34d399 !important;
}

.article-content .rule-card ul,
.article-body .rule-card ul {
  color: #cbd5e1 !important;
}

.article-content .simulation-row,
.article-body .simulation-row,
.custom-table .simulation-row {
  background-color: #064e3b !important;
}
.article-content .simulation-row td,
.article-body .simulation-row td,
.custom-table .simulation-row td {
  color: #6ee7b7 !important;
  background-color: #064e3b !important;
}

.article-content .review-row,
.article-body .review-row,
.custom-table .review-row {
  background-color: #78350f !important;
}
.article-content .review-row td,
.article-body .review-row td,
.custom-table .review-row td {
  color: #fde68a !important;
  background-color: #78350f !important;
}

/* Strategic Value Pill Badges */
.pill,
.pill-major,
.pill-minor,
.pill-floating {
  color: #0f172a !important;
  font-weight: 800 !important;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  display: inline-block;
}

.pill-major {
  background: #f59e0b !important;
}

.pill-minor {
  background: #38bdf8 !important;
}

.pill-floating {
  background: #a855f7 !important;
}

/* 🌟 Study Phase Selection Chips Active Highlights */
.btn-phase-chip.active,
.btn-manual-study-pill.active,
#manual-phase-chips-list .active,
#fab-manual-phase-container .active,
#focus-phase-chips-container .active {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.4) !important;
}

#fab-timer-phase-container .btn-fab-study-pill.active,
[data-section="section-live-timer"] .btn-fab-study-pill.active {
  background: rgba(16, 185, 129, 0.25) !important;
  border-color: #10b981 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35) !important;
}
#fab-timer-phase-container .btn-fab-study-pill.active span[style*="color"],
[data-section="section-live-timer"] .btn-fab-study-pill.active span[style*="color"] {
  color: #a7f3d0 !important;
}
