/* =============================================================================
   AFR Chat Hub — Frontend Styles
   Matches the screenshot design: light blue sidebar, white panel cards,
   grouped model dropdowns, global prompt composer.
   ============================================================================= */

/* ── Google Fonts — Noto Sans Bengali ──────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Bengali:wght@400;500;600;700&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --afr-primary:       #3b82f6;
  --afr-primary-dark:  #1e3a5f;
  --afr-primary-hover: #2563eb;
  --afr-sidebar-bg:    #dce8f5;
  --afr-bg:            #6ba3cb;
  --afr-panel-bg:      #ffffff;
  --afr-text:          #1a1a2e;
  --afr-text-muted:    #6b7280;
  --afr-border:        #e5e7eb;
  --afr-radius:        14px;
  --afr-radius-sm:     8px;
  --afr-shadow:        0 4px 16px rgba(0,0,0,0.06);
  --afr-shadow-lg:     0 8px 30px rgba(0,0,0,0.12);
  --afr-sidebar-width: 270px;
  --afr-sidebar-collapsed-width: 64px;
  --afr-prompt-height: 68px;
  --afr-transition:    0.25s ease;
}

/* ── Global Reset (scoped) ──────────────────────────────────────────────────── */
#afr-app, #afr-app * {
  box-sizing: border-box;
}

/* ── Auth Container ─────────────────────────────────────────────────────────── */
.afr-auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 2rem;
  background: var(--afr-bg);
}

.afr-auth-card {
  background: var(--afr-panel-bg);
  padding: 2.5rem 2rem;
  border-radius: var(--afr-radius);
  box-shadow: var(--afr-shadow-lg);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.afr-auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.afr-auth-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--afr-primary-dark);
}

.afr-auth-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: var(--afr-text);
}

.afr-auth-card p {
  color: var(--afr-text-muted);
  margin-bottom: 2rem;
}

.afr-auth-buttons {
  display: flex;
  gap: 1rem;
}

/* ── Modern Light SaaS Plan Selection Screen ────────────────────────────────── */
.afr-plan-select-wrapper {
  position: relative;
  min-height: 100vh;
  width: 100%;
  padding: 3.5rem 1.5rem 4.5rem;
  background: #f8fafc;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(99, 102, 241, 0.05) 0%, transparent 35%),
    radial-gradient(circle at 90% 85%, rgba(37, 99, 235, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(241, 245, 249, 0.5) 0%, transparent 100%);
  overflow: hidden;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.afr-plan-ambient-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.afr-blob-top-left {
  width: 380px;
  height: 380px;
  background: rgba(147, 197, 253, 0.25);
  top: -120px;
  left: -80px;
}

.afr-blob-bottom-right {
  width: 440px;
  height: 440px;
  background: rgba(199, 210, 254, 0.3);
  bottom: -150px;
  right: -100px;
}

.afr-plan-select-container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
}

/* Header */
.afr-plan-select-header {
  text-align: center;
  margin-bottom: 2.75rem;
}

.afr-brand-logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.afr-brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
}

.afr-brand-logo-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.afr-plan-page-heading {
  font-size: 2.5rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.afr-plan-page-subtext {
  font-size: 1.05rem;
  color: #64748b;
  margin: 0;
  font-weight: 400;
}

/* Empty State */
.afr-plans-empty-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  max-width: 480px;
  margin: 2rem auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
}

.afr-plans-empty-icon {
  font-size: 2rem;
  color: #3b82f6;
  margin-bottom: 0.75rem;
}

/* Grid */
.afr-plans-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-content: center;
  align-items: stretch;
  gap: 2rem;
  width: 100%;
  max-width: 820px;
  margin: 0 auto 2.5rem;
  box-sizing: border-box;
}

/* Plan Card */
.afr-plan-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 2.25rem 2rem 2rem;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.afr-plan-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Popular Plan Card Highlight */
.afr-plan-card--popular {
  border: 2px solid #2563eb !important;
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.08);
}

/* "👑 Most Popular" Floating Badge */
.afr-popular-badge {
  position: absolute;
  top: -14px;
  right: 28px;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.95rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  letter-spacing: 0.01em;
  z-index: 2;
  white-space: nowrap;
}

.afr-popular-badge-crown {
  font-size: 0.85rem;
  line-height: 1;
}

/* Top Row in Card */
.afr-plan-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.afr-plan-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  flex-shrink: 0;
}

.afr-plan-tag-pill {
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.12);
}

/* Plan Title */
.afr-plan-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.01em;
}

/* Price */
.afr-plan-card-price-row {
  margin-bottom: 0.85rem;
}

.afr-plan-price-amount {
  font-size: 2.25rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.afr-plan-price-unit {
  font-size: 1.125rem;
  font-weight: 500;
  color: #64748b;
  margin-left: 2px;
}

.afr-plan-price-subtext {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 0.35rem;
  font-weight: 400;
}

/* Description */
.afr-plan-card-description {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0 0 1.5rem 0;
  min-height: 2.6rem;
}

/* Features List */
.afr-plan-features-list {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 0 2rem 0 !important;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex-grow: 1;
}

.afr-plan-features-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #334155;
  font-weight: 500;
  line-height: 1.35;
}

.afr-circle-check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.afr-circle-check-icon svg {
  display: block;
}

.afr-feature-text {
  color: #334155;
}

/* Action Button Box */
.afr-plan-action-box {
  margin-top: auto;
  padding-top: 0.5rem;
}

.afr-btn-plan-select {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  outline: none;
  box-sizing: border-box;
}

/* Outline Style (Standard Card) */
.afr-btn-plan-select--outline {
  border: 1.5px solid #2563eb;
  color: #2563eb;
  background: #ffffff;
}

.afr-btn-plan-select--outline:hover,
.afr-btn-plan-select--outline:focus {
  background: #eff6ff;
  border-color: #1d4ed8;
  color: #1d4ed8;
}

/* Filled Style (Popular Card) */
.afr-btn-plan-select--filled {
  border: 1.5px solid #2563eb;
  color: #ffffff;
  background: #2563eb;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.afr-btn-plan-select--filled:hover,
.afr-btn-plan-select--filled:focus {
  background: #1d4ed8;
  border-color: #1d4ed8;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.afr-btn-plan-select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Notice Bar */
.afr-plan-select-notice {
  max-width: 480px;
  margin: 1.5rem auto 0;
  padding: 0.75rem 1.25rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  font-weight: 500;
}

/* Spinner Dots */
.afr-spinner-dots {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: afrRotate 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes afrRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .afr-plan-select-wrapper {
    padding: 2rem 1rem 3rem;
  }
  .afr-plan-page-heading {
    font-size: 1.85rem;
  }
  .afr-plans-grid {
    grid-template-columns: 1fr;
    max-width: 380px;
    gap: 1.5rem;
  }
}

/* ── Global Buttons ─────────────────────────────────────────────────────────── */
.afr-btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--afr-radius-sm);
  border: none;
  background: var(--afr-primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--afr-transition);
  text-align: center;
  text-decoration: none;
}

.afr-btn:hover { background: var(--afr-primary-hover); }

.afr-btn-secondary {
  background: transparent;
  color: var(--afr-primary);
  border: 1.5px solid var(--afr-primary);
}

.afr-btn-secondary:hover { background: rgba(59,130,246,0.08); }

/* ── Dashboard Layout: Edge-to-Edge Full Screen SaaS ────────────────────────── */
html:has(#afr-app),
body:has(#afr-app) {
  overflow: hidden !important;
}

#afr-app, .afr-app {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 99998 !important;
  display: flex !important;
  overflow: hidden !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--afr-bg);
}

/* Account for WordPress Admin Bar when logged in on desktop */
body.admin-bar #afr-app,
body.admin-bar .afr-app {
  top: 32px !important;
  height: calc(100vh - 32px) !important;
  max-height: calc(100vh - 32px) !important;
}

@media screen and (max-width: 782px) {
  #wpadminbar,
  div#wpadminbar,
  body.admin-bar #wpadminbar {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }
  html,
  html.html,
  body,
  body.admin-bar {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  body.admin-bar #afr-app,
  body.admin-bar .afr-app {
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.afr-sidebar {
  width: var(--afr-sidebar-width);
  min-width: var(--afr-sidebar-width);
  background: var(--afr-sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0.9rem;
  gap: 0.75rem;
  overflow: hidden;
  transition: width var(--afr-transition), min-width var(--afr-transition);
  border-right: 1px solid rgba(0,0,0,0.06);
}

.afr-sidebar.collapsed {
  width: var(--afr-sidebar-collapsed-width);
  min-width: var(--afr-sidebar-collapsed-width);
}

.afr-sidebar.collapsed .afr-logo-text,
.afr-sidebar.collapsed .afr-workspace-label,
.afr-sidebar.collapsed .afr-history-section,
.afr-sidebar.collapsed .afr-plan-card,
.afr-sidebar.collapsed .afr-plan-metrics,
.afr-sidebar.collapsed .afr-upgrade-btn,
.afr-sidebar.collapsed .afr-layout-btn-label {
  display: none;
}

/* Logo area */
.afr-logo-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.afr-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.afr-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: transparent;
  display: block;
  flex-shrink: 0;
}

.afr-logo-icon {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 30px;
  height: 30px;
}

.afr-logo-sq {
  display: block;
  border-radius: 3px;
}

.afr-logo-sq--blue   { background: var(--afr-primary); }
.afr-logo-sq--yellow { background: #fbbf24; }

.afr-logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--afr-primary-dark);
  line-height: 1.2;
  white-space: nowrap;
}

.afr-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--afr-text-muted);
  font-size: 1.2rem;
  padding: 0.35rem;
  border-radius: 6px;
  line-height: 1;
  transition: color var(--afr-transition);
}

.afr-collapse-btn:hover { color: var(--afr-primary); }

/* Workspace card */
.afr-workspace-card {
  background: #fff;
  border-radius: var(--afr-radius-sm);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--afr-shadow);
  cursor: pointer;
}

.afr-workspace-icon {
  font-size: 1.25rem;
  color: var(--afr-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.afr-workspace-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--afr-text);
  white-space: nowrap;
}

/* Layout selector */
.afr-layout-selector {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
}

.afr-layout-btn {
  flex: 1;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid transparent;
  border-radius: 4px;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--afr-text-muted);
  transition: all var(--afr-transition);
  min-width: 0;
  min-height: 32px;
}

.afr-layout-btn:hover:not(:disabled) {
  border-color: var(--afr-primary);
  color: var(--afr-primary);
  background: rgba(59,130,246,0.06);
}

.afr-layout-btn.active {
  border-color: var(--afr-primary);
  color: var(--afr-primary);
  background: rgba(59,130,246,0.1);
}

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

/* History */
.afr-history-section {
  flex: 1 1 auto;
  min-height: 110px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.afr-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}

.afr-history-toggle {
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.55rem !important;
  text-decoration: none !important;
  color: #0f172a !important;
  font-family: inherit !important;
}

.afr-history-clock-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  background: #dbeafe !important;
  color: #2563eb !important;
  flex-shrink: 0 !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12) !important;
}

.afr-history-clock-badge svg {
  display: block;
}

.afr-history-title-text {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  letter-spacing: -0.01em !important;
  line-height: 1.2 !important;
}

.afr-history-toggle .afr-chevron {
  font-size: 0.85rem !important;
  color: #64748b !important;
  margin-left: 2px !important;
  transition: transform 0.2s ease !important;
  line-height: 1 !important;
}

.afr-history-section.collapsed .afr-history-toggle .afr-chevron {
  transform: rotate(-90deg) !important;
}

.afr-history-see-all {
  font-size: 0.82rem !important;
  color: var(--afr-primary) !important;
  text-decoration: none !important;
  white-space: nowrap !important;
}

.afr-history-see-all:hover { text-decoration: underline !important; }

.afr-history-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 2px 2px 4px 2px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.45rem !important;
  max-height: 250px !important;
  overflow-y: auto !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(0, 0, 0, 0.16) transparent !important;
  flex: 1 1 auto !important;
  min-height: 60px !important;
}

.afr-history-list::-webkit-scrollbar {
  width: 4px;
}

.afr-history-list::-webkit-scrollbar-track {
  background: transparent;
}

.afr-history-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
  border-radius: 4px;
}

.afr-history-item {
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: #1e293b;
  background: #ffffff;
  padding: 0px 10px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.85);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 1.4;
  min-height: 38px;
  box-sizing: border-box;
  position: relative;
  gap: 0.55rem;
}

.afr-history-item:hover {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.afr-history-item.active {
  background: #ffffff;
  color: #0f172a;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
  font-weight: 600;
}

.afr-history-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #2563eb;
}

.afr-history-item-icon svg {
  display: block;
}

.afr-history-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-size: 0.95rem;
  color: #1e293b;
  font-weight: 500;
}

.afr-history-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  opacity: 0.65;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.afr-history-item:hover .afr-history-more-btn,
.afr-history-item.active .afr-history-more-btn,
.afr-history-more-btn.afr-menu-open {
  opacity: 1;
}

.afr-history-more-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

/* History Context Dropdown Menu */
.afr-history-dropdown {
  position: fixed;
  background: #23272f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 999999;
  min-width: 120px;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.afr-history-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: #f1f5f9;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  box-sizing: border-box;
}

.afr-history-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.afr-history-menu-item--delete {
  color: #ef4444;
}

.afr-history-menu-item--delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.afr-history-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 3px 0;
}

/* History inline rename input */
.afr-history-rename-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.afr-history-rename-input {
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 2px 6px;
  font-size: 0.8rem;
  border: 1px solid #3b82f6;
  border-radius: 4px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.afr-history-rename-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  flex-shrink: 0;
}

.afr-history-rename-save {
  background: #22c55e;
  color: #ffffff;
}

.afr-history-rename-cancel {
  background: #e2e8f0;
  color: #475569;
}

/* Sidebar spacer */
.afr-sidebar-spacer {
  flex: 0 1 8px;
  min-height: 4px;
}

/* Plan card in sidebar */
.afr-plan-card {
  flex-shrink: 0 !important;
  background: #ffffff !important;
  border-radius: 14px !important;
  padding: 0.65rem 0.85rem 0.7rem !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  box-sizing: border-box !important;
  line-height: 1.2 !important;
  margin-top: auto !important;
}

.afr-plan-card * {
  box-sizing: border-box !important;
}

.afr-plan-card-top {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.35rem !important;
  margin-bottom: 0.5rem !important;
  line-height: 1.2 !important;
}

.afr-plan-badges-wrap {
  display: flex !important;
  align-items: center !important;
  gap: 0.3rem !important;
}

.afr-plan-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  padding: 0.18rem 0.55rem !important;
  background: #dbeafe !important;
  color: #1e40af !important;
  border-radius: 999px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
  line-height: 1.2 !important;
}

.afr-plan-new-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  padding: 0.14rem 0.45rem !important;
  background: #fef3c7 !important;
  color: #b45309 !important;
  border-radius: 999px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
  line-height: 1.2 !important;
}

.afr-plan-user-wrap {
  display: flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  margin-left: auto !important;
}

.afr-user-avatar {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  border-radius: 50% !important;
  background: #2563eb !important;
  color: #ffffff !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

.afr-plan-arrow {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  color: #2563eb !important;
  padding: 2px !important;
  line-height: 1 !important;
  transition: transform 0.15s ease !important;
}

.afr-plan-arrow:hover {
  transform: translateY(1px) !important;
}

.afr-plan-metrics {
  display: flex !important;
  flex-direction: column !important;
  line-height: 1.2 !important;
}

.afr-metric-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 0.18rem !important;
  line-height: 1.2 !important;
}

.afr-metric-left {
  display: flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  line-height: 1.2 !important;
}

.afr-metric-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0 !important;
  color: #2563eb !important;
}

.afr-metric-icon svg {
  display: block;
}

.afr-metric-label { 
  color: #475569 !important; 
  font-size: 0.8rem !important;
  font-weight: 500 !important; 
  line-height: 1.2 !important;
}

.afr-metric-value { 
  color: #0f172a !important; 
  font-size: 0.8rem !important;
  font-weight: 700 !important; 
  line-height: 1.2 !important;
}

.afr-metric-bar {
  height: 4px !important;
  background: #e2e8f0 !important;
  border-radius: 999px !important;
  margin-bottom: 0.3rem !important;
  overflow: hidden !important;
}

.afr-metric-fill {
  height: 100% !important;
  background: #2563eb !important;
  border-radius: 999px !important;
  transition: width 0.4s ease !important;
}

.afr-upgrade-btn {
  width: 100% !important;
  height: 32px !important;
  min-height: 32px !important;
  margin-top: 0.45rem !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #2563eb !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 9px !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  line-height: 1 !important;
}

.afr-upgrade-btn:hover {
  background: #1d4ed8 !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38) !important;
  transform: translateY(-1px) !important;
}

/* Bottom nav */
.afr-sidebar-bottom {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  gap: 0.4rem;
  justify-content: space-around;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(0,0,0,0.07);
}

.afr-nav-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--afr-text-muted);
  padding: 0.5rem;
  border-radius: 8px;
  transition: all var(--afr-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.afr-nav-icon-btn:hover,
.afr-nav-icon-btn.afr-nav-active {
  color: var(--afr-primary);
  background: rgba(59,130,246,0.1);
}

/* ── Main Area ──────────────────────────────────────────────────────────────── */
.afr-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--afr-bg);
}

/* ── Panel Layouts ──────────────────────────────────────────────────────────── */
.afr-panels-container {
  flex: 1;
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem 0 0.75rem;
  overflow: hidden !important;
  min-height: 0;
}

.afr-layout-1  { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.afr-layout-2  { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.afr-layout-3  { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }
.afr-layout-4  { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.afr-layout-6  { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }

.afr-panels-container.afr-single-mode {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

.afr-panels-container.afr-single-mode .afr-panel:not(.afr-panel--single-focused) {
  display: none !important;
}

.afr-panels-container.afr-single-mode .afr-panel.afr-panel--single-focused {
  display: flex !important;
  grid-column: 1 / -1 !important;
  grid-row: 1 / -1 !important;
  height: 100% !important;
  width: 100% !important;
}

/* ── Panel Card ─────────────────────────────────────────────────────────────── */
.afr-panel {
  background: var(--afr-panel-bg);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  border: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.afr-panel.afr-panel--dropdown-open {
  z-index: 1000 !important;
}

.afr-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  gap: 8px;
}

/* Model selector button (Screenshot 2) */
.afr-model-selector-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
  border-radius: 10px;
  text-align: left;
  flex: 1;
  min-width: 0;
  transition: background var(--afr-transition);
}

.afr-model-selector-btn:hover {
  background: #f8fafc;
}

/* Badge Icon Box (Screenshots 2, 3, 4) */
.afr-model-icon-box {
  width: 25px;
  height: 25px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.afr-model-icon-box svg {
  display: block;
  width: 14px !important;
  height: 14px !important;
  margin: auto;
}

.afr-dropdown-item-icon {
  width: 25px !important;
  height: 25px !important;
  border-radius: 14px !important;
}

.afr-dropdown-item-icon svg {
  width: 14px !important;
  height: 14px !important;
}

.afr-custom-provider-letter {
  font-size: 14px !important;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Model Text Group (Screenshot 2) */
.afr-model-text-group {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.afr-model-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.afr-model-name {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.afr-model-chevron {
  color: #1e293b;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.afr-model-subtitle {
  display: none !important;
}

/* Panel Right Action Buttons (Screenshot 2) */
.afr-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.afr-panel-divider {
  display: none !important;
}

.afr-panel-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--afr-transition), background var(--afr-transition);
}

.afr-panel-action-btn:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.afr-panel-action-arrow {
  color: #ffffff;
  background: #3a3a3a;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
}

.afr-panel-action-arrow svg {
  width: 13px !important;
  height: 13px !important;
}

.afr-panel-action-arrow:hover {
  background: #4a4a4a;
  color: #ffffff;
}

.afr-panel-action-btn:hover { color: var(--afr-primary); }

/* Messages */
.afr-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.afr-message {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-family: 'Noto Sans Bengali', 'Noto Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
  animation: afrFadeIn 0.2s ease;
}

.afr-message-row--user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  align-self: flex-end;
  max-width: 90%;
  animation: afrFadeIn 0.2s ease;
}

.afr-message-row--user .afr-message--user {
  align-self: auto;
  max-width: 100%;
}

.afr-msg-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--afr-text-muted);
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--afr-transition);
  opacity: 0.65;
  flex-shrink: 0;
}

.afr-msg-copy-btn:hover {
  opacity: 1;
  color: var(--afr-primary);
  background: rgba(59, 130, 246, 0.08);
}

.afr-message--user {
  max-width: 85%;
  background: #1a3a6e;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.afr-message--ai {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #f8fafc;
  color: var(--afr-text);
  align-self: stretch;
  border: 1px solid var(--afr-border);
  border-bottom-left-radius: 3px;
}

.afr-message-content {
  font-family: 'Noto Sans Bengali', 'Noto Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
}

.afr-message-footer {
  display: flex;
  align-items: center;
  margin-top: 0.4rem;
  padding-top: 0.25rem;
}

.afr-credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fef08a;
  border-radius: 999px;
  padding: 2px 10px;
  margin-right: auto;
  line-height: 1.4;
  letter-spacing: 0.01em;
  user-select: none;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.08);
  transition: all 0.2s ease;
  cursor: default;
}

.afr-credit-badge:hover {
  background: #fef3c7;
  border-color: #fde68a;
}

.afr-badge-lightning {
  color: #f59e0b;
  font-size: 0.85rem;
  line-height: 1;
}

[data-afr-theme="dark"] .afr-credit-badge,
#afr-app.afr-dark-theme .afr-credit-badge {
  color: #fef08a;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

[data-afr-theme="dark"] .afr-credit-badge:hover,
#afr-app.afr-dark-theme .afr-credit-badge:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
}

.afr-ai-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--afr-text-muted);
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--afr-transition);
  opacity: 0.65;
}

.afr-ai-copy-btn:hover {
  opacity: 1;
  color: var(--afr-primary);
  background: rgba(59, 130, 246, 0.08);
}

.afr-message--error {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  align-self: stretch;
}

/* Typing indicator */
.afr-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: #f8fafc;
  border-radius: 10px;
  align-self: flex-start;
  border: 1px solid var(--afr-border);
}

.afr-typing span {
  width: 6px; height: 6px;
  background: var(--afr-text-muted);
  border-radius: 50%;
  animation: afrBounce 1.2s infinite;
}

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

@keyframes afrBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

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

/* ── Model Dropdown ─────────────────────────────────────────────────────────── */
.afr-model-dropdown {
  position: fixed;
  width: 240px;
  background: #fff;
  border: 1px solid var(--afr-border);
  border-radius: var(--afr-radius-sm);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
  z-index: 999999 !important;
  max-height: 520px;
  overflow-y: auto;
  animation: afrFadeIn 0.15s ease;
}

.afr-dropdown-provider {
  padding: 0.4rem 0.75rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--afr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f9fafb;
  position: sticky;
  top: 0;
}

.afr-dropdown-model {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--afr-text);
  transition: background var(--afr-transition);
}

.afr-dropdown-model:hover { background: #f0f4ff; }

.afr-dropdown-model.selected {
  background: #eff6ff;
  color: var(--afr-primary);
  font-weight: 600;
}

.afr-dropdown-model .afr-model-name {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.afr-model-provider-tag {
  margin-left: auto;
  font-size: 0.7rem;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.2;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.afr-model-credit-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.afr-tier-low {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.afr-tier-med {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.afr-tier-high {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #fed7aa;
}

.afr-model-credit-badge + .afr-model-provider-tag {
  margin-left: 0.35rem;
}

.afr-model-credit-badge + .afr-model-check {
  margin-left: 0.35rem;
}

.afr-dropdown-model.selected .afr-model-provider-tag {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.afr-dropdown-model .afr-model-check {
  margin-left: auto;
  color: var(--afr-primary);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.afr-model-provider-tag + .afr-model-check {
  margin-left: 0.35rem;
}

.afr-model-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  font-weight: 700;
}

/* ── Global Prompt Bar ──────────────────────────────────────────────────────── */
.afr-prompt-bar {
  background: transparent;
  border: none;
  padding: 0.5rem 0.85rem 1rem;
  flex-shrink: 0;
}

.afr-prompt-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ffffff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  min-height: 60px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transition: box-shadow var(--afr-transition);
}

.afr-prompt-inner:focus-within {
  box-shadow: 0 6px 22px rgba(0,0,0,0.18);
}

.afr-prompt-tools-left,
.afr-prompt-tools-right {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.afr-prompt-tool-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--afr-text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--afr-transition), background var(--afr-transition), transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.afr-prompt-tool-btn svg {
  pointer-events: none !important;
  display: block;
}

.afr-prompt-tool-btn:hover {
  color: var(--afr-primary);
  background: rgba(59,130,246,0.08);
}

.afr-prompt-tool-btn:active {
  transform: scale(0.92);
}

#afr-app .afr-prompt-input,
.afr-prompt-input,
#afr-global-prompt {
  flex: 1;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  resize: none;
  font-size: 1.15rem !important;
  font-family: inherit !important;
  color: var(--afr-text) !important;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.5 !important;
  min-width: 0;
  padding: 4px 0 !important;
}

#afr-app .afr-prompt-input:focus,
.afr-prompt-input:focus,
#afr-global-prompt:focus {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.afr-prompt-input::placeholder { color: var(--afr-text-muted); }

#afr-app .afr-send-btn,
.afr-send-btn {
  width: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: #2563eb !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 50% !important;
  aspect-ratio: 1 / 1 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35) !important;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease !important;
  outline: none !important;
  box-sizing: border-box !important;
  position: relative !important;
  line-height: 1 !important;
}

#afr-app .afr-send-btn:hover:not(:disabled),
.afr-send-btn:hover:not(:disabled) {
  background: #1d4ed8 !important;
  transform: scale(1.06) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45) !important;
}

#afr-app .afr-send-btn:active:not(:disabled),
.afr-send-btn:active:not(:disabled) {
  transform: scale(0.95) !important;
}

#afr-app .afr-send-btn:disabled,
.afr-send-btn:disabled {
  background: #64748b !important;
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

#afr-app .afr-send-btn svg,
.afr-send-btn svg {
  width: 18px !important;
  height: 18px !important;
  stroke: #ffffff !important;
  fill: none !important;
  stroke-width: 2.5 !important;
  display: block !important;
  margin: auto !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
}

.afr-prompt-tool-btn.active {
  color: #ffffff !important;
  background: #2563eb !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.afr-prompt-tool-btn.active svg {
  stroke: #ffffff !important;
}

.afr-prompt-tool-btn.active:hover {
  background: #1d4ed8 !important;
  color: #ffffff !important;
}

/* ── Tooltip ────────────────────────────────────────────────────────────────── */
.afr-tooltip-btn {
  position: relative;
}

.afr-tooltip-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  transform: translateY(4px);
  white-space: pre-line;
  background: #1e293b;
  color: #f8fafc;
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.45;
  width: max-content;
  min-width: 260px;
  max-width: 340px;
  text-align: left;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 9999999;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 500;
}

.afr-tooltip-btn:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ── Attached File Chips ────────────────────────────────────────────────────── */
.afr-attached-files-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px 4px;
  width: 100%;
  box-sizing: border-box;
}

.afr-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  max-width: 220px;
  animation: afrFadeIn 0.15s ease;
}

.afr-file-chip-icon {
  font-size: 0.85rem;
  opacity: 0.8;
}

.afr-file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.afr-file-chip-remove {
  background: none;
  border: none;
  padding: 0;
  margin-left: 2px;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  transition: color 0.15s, background 0.15s;
}

.afr-file-chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* ── Image Thumbnail Card (Screenshots 1 & 3) ────────────────────────────────── */
.afr-image-thumb-card {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: #1e293b;
  overflow: visible;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 5px;
  margin-right: 5px;
  animation: afrFadeIn 0.2s ease;
}

.afr-image-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 11px;
  display: block;
}

.afr-thumb-uploading-overlay {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: rgba(30, 41, 59, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(1.5px);
}

.afr-thumb-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: afrSpin 0.75s linear infinite;
}

.afr-thumb-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}

.afr-thumb-remove-btn:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
  transform: scale(1.1);
}

@keyframes afrSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* ── Expanded Composer (matching Screenshot 2) ──────────────────────────────── */
.afr-expanded-composer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 24px;
}

.afr-expanded-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.afr-expanded-card {
  position: relative;
  width: calc(100% - 48px);
  max-width: 880px;
  background: #181b20;
  border: 1px solid #282d37;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  padding: 8px 18px 16px;
  box-sizing: border-box;
  animation: afrSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
}

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

.afr-expanded-handle-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 10px;
  cursor: pointer;
  width: 100%;
}

.afr-expanded-handle-pill {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  transition: background 0.15s;
}

.afr-expanded-handle-bar:hover .afr-expanded-handle-pill {
  background: rgba(255, 255, 255, 0.45);
}

.afr-expanded-textarea-wrap {
  background: #1f232b;
  border: 1px solid #2d333f;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.afr-expanded-textarea {
  width: 100%;
  min-height: 140px;
  max-height: 350px;
  background: transparent;
  border: none;
  outline: none;
  color: #f1f5f9;
  font-size: 0.98rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
}

.afr-expanded-textarea::placeholder {
  color: #64748b;
}

.afr-expanded-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.afr-expanded-tools-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.afr-expanded-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #232731;
  border: 1px solid #2f3543;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.afr-expanded-tool-btn:hover {
  background: #2c323f;
  color: #f1f5f9;
  border-color: #3b4455;
}

.afr-expanded-tool-btn svg {
  pointer-events: none !important;
  display: block;
}

.afr-expanded-tool-btn.active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

.afr-expanded-tool-btn.active svg {
  stroke: #ffffff !important;
}

.afr-expanded-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 8px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.afr-expanded-send-btn:hover:not(:disabled) {
  background: #1d4ed8;
  transform: scale(1.02);
}

.afr-expanded-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Light Theme overrides for expanded composer when not dark */
:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-handle-pill {
  background: #cbd5e1;
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-textarea-wrap {
  background: #f8fafc;
  border-color: #e2e8f0;
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-textarea {
  color: #0f172a;
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-tool-btn {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-tool-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

:root:not([data-afr-theme="dark"]) body:not(.afr-dark-theme) .afr-expanded-tool-btn.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #2563eb;
}

/* Dark theme chip override */
[data-afr-theme="dark"] .afr-file-chip,
body.afr-dark-theme .afr-file-chip,
#afr-app.afr-dark-theme .afr-file-chip {
  background: #232731;
  border-color: #2f3543;
  color: #f1f5f9;
}

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.afr-modal-overlay {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999 !important;
  padding: 1rem;
  animation: afrFadeIn 0.15s ease;
}

.afr-modal {
  background: #fff;
  border-radius: var(--afr-radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 10000000 !important;
}

.afr-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--afr-text-muted);
  line-height: 1;
  padding: 0.25rem;
  border-radius: 4px;
}

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

.afr-modal h2 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  color: var(--afr-text);
}

/* ── Form Controls ──────────────────────────────────────────────────────────── */
.afr-form-group {
  margin-bottom: 1rem;
}

.afr-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--afr-text);
  margin-bottom: 0.35rem;
}

.afr-input, .afr-form-control, .afr-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--afr-border);
  border-radius: var(--afr-radius-sm);
  font-size: 0.875rem;
  color: var(--afr-text);
  background: #fff;
  transition: border-color var(--afr-transition);
  outline: none;
}

.afr-input:focus, .afr-form-control:focus {
  border-color: var(--afr-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* ── Notice ─────────────────────────────────────────────────────────────────── */
.afr-notice {
  padding: 0.75rem 1rem;
  border-radius: var(--afr-radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.afr-notice--warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* ── Settings modal tabs ────────────────────────────────────────────────────── */
.afr-modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--afr-border);
  margin-bottom: 1.25rem;
}

.afr-modal-tab {
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--afr-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--afr-transition);
}

.afr-modal-tab.active {
  color: var(--afr-primary);
  border-bottom-color: var(--afr-primary);
  font-weight: 600;
}

.afr-modal-tab-content { display: none; }
.afr-modal-tab-content.active { display: block; }

/* API key row */
.afr-api-key-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.6rem;
  background: #f8fafc;
  border-radius: var(--afr-radius-sm);
  border: 1px solid var(--afr-border);
}

.afr-api-key-row .afr-api-key-label {
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 80px;
}

.afr-api-key-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  outline: none;
}

.afr-api-key-status {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.afr-api-key-status--set    { background: #dcfce7; color: #15803d; }
.afr-api-key-status--unset  { background: #fee2e2; color: #b91c1c; }

/* ── Scrollbars ─────────────────────────────────────────────────────────────── */
.afr-messages::-webkit-scrollbar,
.afr-history-list::-webkit-scrollbar,
.afr-model-dropdown::-webkit-scrollbar,
.afr-modal::-webkit-scrollbar {
  width: 5px;
}

.afr-messages::-webkit-scrollbar-track,
.afr-history-list::-webkit-scrollbar-track,
.afr-model-dropdown::-webkit-scrollbar-track,
.afr-modal::-webkit-scrollbar-track {
  background: transparent;
}

.afr-messages::-webkit-scrollbar-thumb,
.afr-history-list::-webkit-scrollbar-thumb,
.afr-model-dropdown::-webkit-scrollbar-thumb,
.afr-modal::-webkit-scrollbar-thumb {
  background: var(--afr-border);
  border-radius: 3px;
}

.afr-model-dropdown::-webkit-scrollbar {
  width: 6px;
}
.afr-model-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.afr-model-dropdown::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Loading spinner ────────────────────────────────────────────────────────── */
.afr-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--afr-border);
  border-top-color: var(--afr-primary);
  border-radius: 50%;
  animation: afrSpin 0.7s linear infinite;
  display: inline-block;
}

@keyframes afrSpin { to { transform: rotate(360deg); } }

/* ── Plan modal ─────────────────────────────────────────────────────────────── */
.afr-plan-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--afr-border);
  font-size: 0.875rem;
}

.afr-plan-modal-row:last-child { border-bottom: none; }

.afr-plan-modal-feature {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

/* ── Plan Details Modal ─────────────────────────────────────────────────────── */
.afr-modal-plan-details .afr-modal {
  max-width: 520px;
  width: 95%;
  border-radius: 16px;
  padding: 1.75rem;
}

.afr-plan-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--afr-border);
}

.afr-plan-details-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.afr-plan-details-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--afr-text);
}

.afr-plan-card-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.afr-plan-card-hero-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.afr-plan-hero-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e3a8a;
}

.afr-plan-hero-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: #2563eb;
}

.afr-plan-hero-cycle {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: normal;
}

.afr-plan-hero-sub {
  font-size: 0.8125rem;
  color: #475569;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.afr-plan-metrics-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.afr-plan-metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.afr-plan-metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.afr-plan-metric-label {
  color: var(--afr-text-muted);
  font-weight: 500;
}

.afr-plan-metric-val {
  color: var(--afr-text);
  font-weight: 600;
}

.afr-plan-progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
}

.afr-plan-progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.afr-plan-features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
  padding: 0.85rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--afr-border);
  margin-bottom: 1.25rem;
}

.afr-plan-feat-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8125rem;
  color: #334155;
  font-weight: 500;
}

.afr-plan-feat-icon-ok {
  color: #10b981;
  font-weight: bold;
}

.afr-plan-feat-icon-no {
  color: #94a3b8;
}

/* ── Plan Switcher Modal ────────────────────────────────────────────────────── */
.afr-modal-plan-switcher .afr-modal {
  max-width: 860px !important;
  width: 95% !important;
  border-radius: 16px;
  padding: 2rem !important;
  max-height: 90vh;
}

.afr-plan-switcher-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--afr-border);
}

.afr-plan-switcher-header-left h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--afr-text);
}

.afr-plan-switcher-header-left p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--afr-text-muted);
}

.afr-plan-switcher-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 720px) {
  .afr-plan-switcher-grid {
    grid-template-columns: 1fr;
  }
}

.afr-plan-card--current {
  border: 2px solid #10b981 !important;
  background: #f0fdf4 !important;
}

.afr-current-plan-badge {
  position: absolute;
  top: -13px;
  right: 24px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  z-index: 2;
  white-space: nowrap;
}

.afr-btn-plan-select--current {
  background: #e2e8f0 !important;
  color: #64748b !important;
  border: 1.5px solid #cbd5e1 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

.afr-btn-plan-select--current:hover {
  background: #e2e8f0 !important;
  color: #64748b !important;
}

/* ── Mobile SaaS Header & Layout Bar (Screenshot 2) ─────────────────────────── */
.afr-mobile-top-bar {
  display: none;
}

.afr-mobile-layout-bar-wrap {
  display: none;
}

.afr-gradient-logo {
  width: 38px;
  height: 38px;
  position: relative;
  flex-shrink: 0;
}

.afr-grad-sq {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.afr-grad-sq--back {
  top: 1px;
  left: 1px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  opacity: 0.85;
}

.afr-grad-sq--front {
  bottom: 1px;
  right: 1px;
  background: linear-gradient(135deg, #a855f7, #818cf8);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.25);
}

.afr-mobile-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

.afr-mobile-brand-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.afr-mobile-brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.afr-brand-highlight {
  color: #2563eb;
}

.afr-brand-main {
  color: #0f172a;
}

.afr-mobile-brand-sub {
  font-size: 0.76rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 1px;
}

.afr-mobile-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.afr-mobile-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: all 0.18s ease;
  padding: 0;
}

.afr-mobile-header-btn:hover {
  border-color: #93c5fd;
  color: #2563eb;
  background: #eff6ff;
  transform: translateY(-1px);
}

.afr-mobile-layout-selector {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  border: 1px solid #f1f5f9;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.afr-mobile-layout-selector .afr-layout-btn {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.afr-mobile-layout-selector .afr-layout-btn:hover:not(:disabled) {
  background: #f8fafc;
  color: #475569;
}

.afr-mobile-layout-selector .afr-layout-btn.active {
  background: #eff6ff !important;
  color: #2563eb !important;
}

/* Mobile History Modal */
.afr-mobile-history-overlay {
  z-index: 999999 !important;
}

.afr-mobile-history-card {
  max-width: 420px !important;
  width: 92% !important;
  border-radius: 18px !important;
  padding: 20px !important;
  max-height: 80vh !important;
  display: flex !important;
  flex-direction: column !important;
}

.afr-mobile-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 12px;
}

.afr-mobile-history-body {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
}

.afr-mobile-history-body .afr-history-item-icon {
  display: none !important;
}

.afr-mobile-history-body .afr-history-item {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 8px !important;
  padding: 0.55rem 0.6rem 0.55rem 0.8rem !important;
  min-height: 40px !important;
  color: #0f172a !important;
}

.afr-mobile-history-body .afr-history-item:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

.afr-mobile-history-body .afr-history-item.active {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: transparent !important;
  color: var(--afr-primary) !important;
  box-shadow: none !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .afr-layout-3, .afr-layout-6 {
    grid-template-columns: repeat(2, 1fr);
  }
  .afr-layout-6 { grid-template-rows: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  /* Edge-to-edge container */
  .afr-app, #afr-app {
    flex-direction: column !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    background: linear-gradient(180deg, #f0f6fc 0%, #f7fbfe 40%, #ffffff 100%) !important;
  }

  /* Hide WordPress Admin Bar on mobile as requested */
  #wpadminbar,
  div#wpadminbar,
  body.admin-bar #wpadminbar {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }
  html,
  html.html,
  body,
  body.admin-bar {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  body.admin-bar #afr-app,
  body.admin-bar .afr-app {
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  /* Hide wide desktop sidebar */
  .afr-sidebar, #afr-sidebar {
    display: none !important;
  }

  /* Show sleek top mobile header (Screenshot 2) */
  .afr-mobile-top-bar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 14px 16px 8px 16px !important;
    background: transparent !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
  }

  /* Show floating mobile layout bar (Screenshot 2) */
  .afr-mobile-layout-bar-wrap {
    display: flex !important;
    justify-content: flex-start !important;
    padding: 2px 16px 12px 16px !important;
    background: transparent !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
  }

  .afr-main {
    flex: 1 1 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: transparent !important;
    overflow: hidden !important;
    min-height: 0 !important;
  }

  /* Scrollable panels stack (Screenshot 2) */
  .afr-panels-container {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 16px 8px 16px !important;
    gap: 12px !important;
    overflow-y: auto !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin;
  }

  .afr-panel {
    width: 100% !important;
    min-height: auto !important;
    flex-shrink: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid #f1f5f9 !important;
  }

  .afr-panel:not(.afr-panel--has-messages):not(.afr-panel--single-focused) .afr-messages {
    display: none !important;
  }

  .afr-panel:not(.afr-panel--has-messages):not(.afr-panel--single-focused) .afr-panel-header {
    border-bottom: none !important;
  }

  /* Single focused panel on mobile: take full height with scrollable full messages */
  .afr-panel.afr-panel--single-focused {
    min-height: 100% !important;
    height: 100% !important;
    flex: 1 1 100% !important;
  }

  .afr-panel.afr-panel--single-focused .afr-messages {
    display: flex !important;
    flex: 1 !important;
    overflow-y: auto !important;
  }

  /* Multi-panel preview mode on mobile: 2-line prompt & 2-line response preview */
  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) {
    min-height: auto !important;
    height: auto !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-messages {
    display: flex !important;
    flex-direction: column !important;
    padding: 8px 12px 10px 12px !important;
    gap: 6px !important;
    overflow: hidden !important;
    max-height: none !important;
  }

  /* In multi-panel preview, only show the latest prompt & response if multiple exist */
  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message-row--user:not(:last-of-type),
  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--ai:not(:last-of-type) {
    display: none !important;
  }

  /* 2-line clamp for user prompt */
  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message-row--user {
    margin-bottom: 0 !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message-row--user .afr-msg-copy-btn {
    display: none !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--user {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding: 6px 10px !important;
    font-size: 0.82rem !important;
    line-height: 1.35 !important;
    max-width: 92% !important;
  }

  /* 2-line clamp for AI response */
  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--ai {
    padding: 6px 10px !important;
    border-radius: 8px !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--ai .afr-message-footer {
    display: none !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--ai .afr-message-content {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.82rem !important;
    line-height: 1.35 !important;
    white-space: normal !important;
  }

  .afr-panels-container:not(.afr-single-mode) .afr-panel.afr-panel--has-messages:not(.afr-panel--single-focused) .afr-message--ai .afr-message-content > * {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
    line-height: inherit !important;
  }

  /* Prompt bar fixed at bottom */
  .afr-prompt-bar {
    flex-shrink: 0 !important;
    margin: 6px 14px 14px 14px !important;
    margin-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    padding: 4px 6px 4px 12px !important;
    position: relative !important;
    z-index: 50 !important;
  }

  .afr-prompt-inner {
    padding: 0.5rem 0.75rem !important;
    min-height: 48px !important;
  }

  #afr-global-prompt::placeholder,
  .afr-prompt-input::placeholder {
    color: transparent !important;
    opacity: 0 !important;
    font-size: 0 !important;
  }

  #afr-copy-prompt {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .afr-auth-buttons { flex-direction: column; }
  .afr-modal { padding: 1.25rem; }
  .afr-mobile-brand-title { font-size: 1.05rem; }
  .afr-mobile-top-bar { padding: 10px 14px 6px 14px !important; }
  .afr-mobile-layout-bar-wrap { padding: 2px 14px 10px 14px !important; }
  .afr-panels-container { padding: 0 14px 6px 14px !important; }
  .afr-prompt-bar {
    margin: 4px 10px 10px 10px !important;
    margin-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
}

/* ── Dark Theme ─────────────────────────────────────────────────────────────── */
[data-afr-theme="dark"],
body.afr-dark-theme,
#afr-app.afr-dark-theme {
  --afr-sidebar-bg:    #dce8f5;
  --afr-bg:            #111111;
  --afr-panel-bg:      #1a1a1a;
  --afr-text:          #f1f5f9;
  --afr-text-muted:    #94a3b8;
  --afr-border:        #2a2a2a;
  --afr-shadow:        0 4px 16px rgba(0, 0, 0, 0.5);
  --afr-shadow-lg:     0 8px 30px rgba(0, 0, 0, 0.7);
}

/* ── Sidebar: Always retain light theme design in dark mode ─────────────────── */
[data-afr-theme="dark"] .afr-sidebar,
body.afr-dark-theme .afr-sidebar,
#afr-app.afr-dark-theme .afr-sidebar,
[data-afr-theme="dark"] #afr-sidebar,
body.afr-dark-theme #afr-sidebar,
#afr-app.afr-dark-theme #afr-sidebar {
  background: #dce8f5 !important;
  border-right-color: #cbd5e1 !important;
  color: #1a1a2e !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-logo-text,
#afr-app.afr-dark-theme .afr-sidebar .afr-logo-text {
  color: #1e3a5f !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-collapse-btn,
#afr-app.afr-dark-theme .afr-sidebar .afr-collapse-btn {
  color: #6b7280 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-collapse-btn:hover,
#afr-app.afr-dark-theme .afr-sidebar .afr-collapse-btn:hover {
  color: #3b82f6 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-workspace-card,
#afr-app.afr-dark-theme .afr-sidebar .afr-workspace-card {
  background: #ffffff !important;
  border: 1px solid transparent !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
  color: #1a1a2e !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-workspace-icon,
#afr-app.afr-dark-theme .afr-sidebar .afr-workspace-icon {
  color: #3b82f6 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-workspace-label,
#afr-app.afr-dark-theme .afr-sidebar .afr-workspace-label {
  color: #1a1a2e !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-layout-btn,
#afr-app.afr-dark-theme .afr-sidebar .afr-layout-btn {
  background: #ffffff !important;
  color: #64748b !important;
  border-color: #d0dbe7 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-layout-btn:hover:not(:disabled),
#afr-app.afr-dark-theme .afr-sidebar .afr-layout-btn:hover:not(:disabled) {
  border-color: #93c5fd !important;
  color: #2563eb !important;
  background: #ffffff !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-layout-btn.active,
#afr-app.afr-dark-theme .afr-sidebar .afr-layout-btn.active {
  background: #dbeafe !important;
  color: #2563eb !important;
  border-color: #3b82f6 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-toggle,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-toggle {
  color: #0f172a !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-item,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-item {
  color: #1e293b !important;
  background: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03) !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-item:hover,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-item:hover {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(37, 99, 235, 0.28) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08) !important;
  transform: translateY(-1px);
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-item.active,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-item.active {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #2563eb !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12) !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-title,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-title {
  color: #1e293b !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-more-btn,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-more-btn {
  color: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-more-btn:hover,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-more-btn:hover {
  background: rgba(0, 0, 0, 0.06) !important;
  color: #0f172a !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-plan-card,
#afr-app.afr-dark-theme .afr-sidebar .afr-plan-card {
  background: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05) !important;
  padding: 0.65rem 0.85rem 0.7rem !important;
  line-height: 1.2 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-metric-bar,
#afr-app.afr-dark-theme .afr-sidebar .afr-metric-bar {
  background: #e2e8f0 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-metric-fill,
#afr-app.afr-dark-theme .afr-sidebar .afr-metric-fill {
  background: #2563eb !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-metric-row,
#afr-app.afr-dark-theme .afr-sidebar .afr-metric-row {
  background: transparent !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-metric-label,
#afr-app.afr-dark-theme .afr-sidebar .afr-metric-label {
  color: #475569 !important;
  font-weight: 500 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-metric-value,
#afr-app.afr-dark-theme .afr-sidebar .afr-metric-value {
  color: #0f172a !important;
  font-weight: 700 !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-plan-user-initial,
#afr-app.afr-dark-theme .afr-sidebar .afr-plan-user-initial {
  background: #2563eb !important;
  color: #ffffff !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-upgrade-btn,
#afr-app.afr-dark-theme .afr-sidebar .afr-upgrade-btn {
  background: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3) !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-nav-icon-btn,
#afr-app.afr-dark-theme .afr-sidebar .afr-nav-icon-btn {
  color: #64748b !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-nav-icon-btn:hover,
#afr-app.afr-dark-theme .afr-sidebar .afr-nav-icon-btn:hover {
  color: #2563eb !important;
  background: rgba(0, 0, 0, 0.06) !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-nav-icon-btn.afr-nav-active,
#afr-app.afr-dark-theme .afr-sidebar .afr-nav-icon-btn.afr-nav-active {
  color: #2563eb !important;
  background: #e0edfd !important;
}

[data-afr-theme="dark"] .afr-sidebar .afr-history-list::-webkit-scrollbar-thumb,
#afr-app.afr-dark-theme .afr-sidebar .afr-history-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18) !important;
}

[data-afr-theme="dark"] .afr-panel,
#afr-app.afr-dark-theme .afr-panel {
  background: #1a1a1a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-panel-header,
#afr-app.afr-dark-theme .afr-panel-header {
  border-bottom-color: #2a2a2a;
}

[data-afr-theme="dark"] .afr-model-selector-btn,
#afr-app.afr-dark-theme .afr-model-selector-btn {
  color: #ffffff;
}

[data-afr-theme="dark"] .afr-model-name,
#afr-app.afr-dark-theme .afr-model-name,
[data-afr-theme="dark"] .afr-model-chevron,
#afr-app.afr-dark-theme .afr-model-chevron {
  color: #ffffff !important;
}

[data-afr-theme="dark"] .afr-panel-action-btn,
#afr-app.afr-dark-theme .afr-panel-action-btn {
  color: #cbd5e1;
}

[data-afr-theme="dark"] .afr-panel-action-btn:hover,
#afr-app.afr-dark-theme .afr-panel-action-btn:hover {
  background: #2a2a2a;
  color: #60a5fa;
}

[data-afr-theme="dark"] .afr-model-selector-btn:hover,
#afr-app.afr-dark-theme .afr-model-selector-btn:hover {
  background: #212121;
}

[data-afr-theme="dark"] .afr-message--ai,
#afr-app.afr-dark-theme .afr-message--ai {
  background: #212121;
  border-color: #2a2a2a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-message--ai .afr-message-footer,
#afr-app.afr-dark-theme .afr-message--ai .afr-message-footer {
  border-top-color: #2a2a2a;
}

[data-afr-theme="dark"] .afr-typing,
#afr-app.afr-dark-theme .afr-typing {
  background: #212121;
  border-color: #2a2a2a;
}

[data-afr-theme="dark"] .afr-prompt-bar,
#afr-app.afr-dark-theme .afr-prompt-bar {
  background: transparent;
}

[data-afr-theme="dark"] .afr-prompt-inner,
#afr-app.afr-dark-theme .afr-prompt-inner {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

[data-afr-theme="dark"] .afr-prompt-inner:focus-within,
#afr-app.afr-dark-theme .afr-prompt-inner:focus-within {
  border-color: #3a3a3a;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7);
}

[data-afr-theme="dark"] .afr-prompt-input,
#afr-app.afr-dark-theme .afr-prompt-input {
  color: #f1f5f9 !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

[data-afr-theme="dark"] .afr-prompt-input::placeholder,
#afr-app.afr-dark-theme .afr-prompt-input::placeholder {
  color: #94a3b8;
}

[data-afr-theme="dark"] .afr-prompt-tool-btn,
[data-afr-theme="dark"] .afr-prompt-bar-btn,
#afr-app.afr-dark-theme .afr-prompt-tool-btn,
#afr-app.afr-dark-theme .afr-prompt-bar-btn {
  color: #94a3b8;
}

[data-afr-theme="dark"] .afr-prompt-tool-btn:hover,
[data-afr-theme="dark"] .afr-prompt-bar-btn:hover,
#afr-app.afr-dark-theme .afr-prompt-tool-btn:hover,
#afr-app.afr-dark-theme .afr-prompt-bar-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
}

[data-afr-theme="dark"] .afr-modal,
#afr-app.afr-dark-theme .afr-modal {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-modal-input,
#afr-app.afr-dark-theme .afr-modal-input {
  background: #111111;
  border-color: #2a2a2a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-modal-input:focus,
#afr-app.afr-dark-theme .afr-modal-input:focus {
  border-color: var(--afr-primary);
}

[data-afr-theme="dark"] .afr-modal-tab,
#afr-app.afr-dark-theme .afr-modal-tab {
  color: #94a3b8;
}

[data-afr-theme="dark"] .afr-modal-tab.active,
#afr-app.afr-dark-theme .afr-modal-tab.active {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
}

[data-afr-theme="dark"] .afr-model-dropdown,
#afr-app.afr-dark-theme .afr-model-dropdown {
  background: #1a1a1a;
  border-color: #2a2a2a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-dropdown-group-title,
#afr-app.afr-dark-theme .afr-dropdown-group-title {
  background: #141414;
  color: #94a3b8;
  border-color: #2a2a2a;
}

[data-afr-theme="dark"] .afr-dropdown-model,
#afr-app.afr-dark-theme .afr-dropdown-model,
[data-afr-theme="dark"] .afr-dropdown-model .afr-model-name,
#afr-app.afr-dark-theme .afr-dropdown-model .afr-model-name {
  color: #ffffff !important;
}

[data-afr-theme="dark"] .afr-dropdown-model:hover,
#afr-app.afr-dark-theme .afr-dropdown-model:hover {
  background: #212121;
}

[data-afr-theme="dark"] .afr-dropdown-model.selected,
#afr-app.afr-dark-theme .afr-dropdown-model.selected,
[data-afr-theme="dark"] .afr-dropdown-model.selected .afr-model-name,
#afr-app.afr-dark-theme .afr-dropdown-model.selected .afr-model-name {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa !important;
}

[data-afr-theme="dark"] .afr-model-provider-tag,
#afr-app.afr-dark-theme .afr-model-provider-tag {
  background: #2a2a36 !important;
  color: #94a3b8 !important;
  border-color: #3f3f46 !important;
}

[data-afr-theme="dark"] .afr-dropdown-model.selected .afr-model-provider-tag,
#afr-app.afr-dark-theme .afr-dropdown-model.selected .afr-model-provider-tag {
  background: rgba(37, 99, 235, 0.25) !important;
  color: #93c5fd !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-afr-theme="dark"] .afr-tier-low,
#afr-app.afr-dark-theme .afr-tier-low {
  background: rgba(5, 150, 105, 0.15) !important;
  color: #34d399 !important;
  border-color: rgba(5, 150, 105, 0.3) !important;
}

[data-afr-theme="dark"] .afr-tier-med,
#afr-app.afr-dark-theme .afr-tier-med {
  background: rgba(37, 99, 235, 0.15) !important;
  color: #60a5fa !important;
  border-color: rgba(37, 99, 235, 0.3) !important;
}

[data-afr-theme="dark"] .afr-tier-high,
#afr-app.afr-dark-theme .afr-tier-high {
  background: rgba(234, 88, 12, 0.15) !important;
  color: #fb923c !important;
  border-color: rgba(234, 88, 12, 0.3) !important;
}

/* Theme selector dropdown */
.afr-theme-select {
  width: 100%;
  max-width: 240px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--afr-border);
  border-radius: var(--afr-radius-sm);
  background: var(--afr-panel-bg);
  color: var(--afr-text);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--afr-transition);
}

.afr-theme-select:focus {
  border-color: var(--afr-primary);
}

[data-afr-theme="dark"] .afr-api-key-row,
#afr-app.afr-dark-theme .afr-api-key-row {
  background: #212121;
  border-color: #2a2a2a;
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-api-key-row input,
#afr-app.afr-dark-theme .afr-api-key-row input {
  color: #f1f5f9;
}

[data-afr-theme="dark"] .afr-plan-modal-row,
#afr-app.afr-dark-theme .afr-plan-modal-row {
  border-bottom-color: #2a2a2a;
}

[data-afr-theme="dark"] .afr-plan-card-hero,
#afr-app.afr-dark-theme .afr-plan-card-hero {
  background: linear-gradient(135deg, #1e293b 0%, #143528 100%);
  border-color: rgba(37, 99, 235, 0.3);
}

[data-afr-theme="dark"] .afr-plan-hero-name,
#afr-app.afr-dark-theme .afr-plan-hero-name {
  color: #93c5fd;
}

[data-afr-theme="dark"] .afr-plan-hero-sub,
#afr-app.afr-dark-theme .afr-plan-hero-sub {
  color: #94a3b8;
}

[data-afr-theme="dark"] .afr-plan-features-grid,
#afr-app.afr-dark-theme .afr-plan-features-grid {
  background: #1e1e1e;
  border-color: #333333;
}

[data-afr-theme="dark"] .afr-plan-feat-item,
#afr-app.afr-dark-theme .afr-plan-feat-item {
  color: #cbd5e1;
}

[data-afr-theme="dark"] .afr-plan-card--current,
#afr-app.afr-dark-theme .afr-plan-card--current {
  background: #064e3b !important;
  border-color: #10b981 !important;
}

[data-afr-theme="dark"] .afr-btn-plan-select--current,
#afr-app.afr-dark-theme .afr-btn-plan-select--current {
  background: #2a2a2a !important;
  color: #71717a !important;
  border-color: #3f3f46 !important;
}

[data-afr-theme="dark"] .afr-messages::-webkit-scrollbar-thumb,
[data-afr-theme="dark"] .afr-history-list::-webkit-scrollbar-thumb,
[data-afr-theme="dark"] .afr-model-dropdown::-webkit-scrollbar-thumb,
[data-afr-theme="dark"] .afr-modal::-webkit-scrollbar-thumb,
#afr-app.afr-dark-theme .afr-messages::-webkit-scrollbar-thumb,
#afr-app.afr-dark-theme .afr-history-list::-webkit-scrollbar-thumb,
#afr-app.afr-dark-theme .afr-model-dropdown::-webkit-scrollbar-thumb {
  background: #3a3a3a;
}

/* ── Large Settings Modal ─────────────────────────────────────────────────── */
.afr-modal.afr-modal-large,
.afr-modal-settings .afr-modal {
  max-width: 820px !important;
  width: 95% !important;
  padding: 1.75rem !important;
}

/* ── Provider Cards & Accordions in Frontend Settings (Matching Admin View) ── */
.afr-provider-section {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.afr-provider-section:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.afr-provider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  border-radius: 12px;
  background: #ffffff;
  transition: background 0.15s ease;
}

.afr-provider-header:hover {
  background: #f8fafc;
}

.afr-provider-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.afr-provider-name-col {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 200px;
  min-width: 200px;
  flex-shrink: 0;
}

.afr-provider-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.afr-provider-avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.afr-provider-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-right: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status Pill */
.afr-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 82px;
  min-width: 82px;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  box-sizing: border-box;
}

.afr-status-pill--active {
  background: #ecfdf5;
  color: #15803d;
}

.afr-status-pill--active .afr-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.afr-status-pill--inactive {
  background: #f1f5f9;
  color: #64748b;
}

.afr-status-pill--inactive .afr-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}

/* Type Pill */
.afr-type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  min-width: 76px;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  line-height: 1;
  box-sizing: border-box;
}

/* Original Provider Pill */
.afr-orig-provider-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 110px;
  min-width: 110px;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
  line-height: 1;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Models Count */
.afr-models-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: #64748b;
  flex-shrink: 0;
  margin-left: 0;
}

.afr-models-count svg {
  color: #64748b;
  stroke: #64748b;
}

/* Right Actions */
.afr-provider-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.afr-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.afr-action-btn--edit {
  color: #475569;
}

.afr-action-btn--edit:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.afr-action-btn--edit:hover svg {
  stroke: #2563eb;
}

.afr-action-btn--delete {
  color: #ef4444;
}

.afr-action-btn--delete svg {
  stroke: #ef4444;
}

.afr-action-btn--delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

.afr-action-btn--delete:hover svg {
  stroke: #dc2626;
}

.afr-chevron-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: #94a3b8;
  cursor: pointer;
}

.afr-chevron-svg {
  transition: transform 0.2s ease;
}

.afr-chevron-wrap--expanded .afr-chevron-svg {
  transform: rotate(180deg);
}

/* Dashed Add Custom Provider Card */
.afr-custom-provider-card-dashed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  user-select: none;
  margin-top: 1.25rem;
  transition: all 0.15s ease;
}

.afr-custom-provider-card-dashed:hover {
  border-color: #93c5fd;
  background: #fbfdff;
}

.afr-dashed-card-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.afr-dashed-plus-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eff6ff;
  color: #3b82f6;
}

.afr-dashed-card-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
}

.afr-badge-openai {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: #eff6ff;
  color: #3b82f6;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ── Custom Provider Form (Matching Reference Screenshot 1 & 2) ─────────────────── */
.afr-provider-body {
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
}

.afr-cp-card-inner {
  padding: 1.25rem 1.5rem;
  background: #ffffff;
}

.afr-cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.afr-cp-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.afr-cp-plug-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff6ff;
  flex-shrink: 0;
}

.afr-cp-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem 0;
  line-height: 1.25;
}

.afr-cp-subtitle {
  font-size: 0.8125rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

.afr-cp-header-right {
  display: flex;
  align-items: center;
}

.afr-cp-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #2563eb;
  font-size: 0.75rem;
  font-weight: 500;
}

.afr-cp-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
  .afr-cp-grid-3 {
    grid-template-columns: 1fr;
  }
}

.afr-cp-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
  .afr-cp-grid-2 {
    grid-template-columns: 1fr;
  }
}

.afr-cp-field {
  display: flex;
  flex-direction: column;
}

.afr-cp-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.45rem;
  display: block;
}

.afr-required {
  color: #ef4444;
  margin-left: 2px;
}

.afr-cp-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.afr-cp-input-icon {
  position: absolute;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #64748b;
  z-index: 1;
}

.afr-cp-input {
  width: 100%;
  height: 42px !important;
  padding: 0 12px 0 38px !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  font-size: 0.85rem !important;
  background: #ffffff;
  color: #1e293b;
  outline: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.afr-cp-input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
}

/* Models Box */
.afr-cp-models-box {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.afr-cp-models-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  color: #1e293b;
  font-weight: 600;
}

.afr-cp-models-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.afr-cp-model-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.afr-cp-model-id-wrap {
  flex: 1;
}

.afr-cp-model-name-wrap {
  flex: 1;
}

.afr-cp-remove-model {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: #ffffff;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.afr-cp-remove-model:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
}

.afr-cp-remove-model:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #e2e8f0;
}

.afr-cp-remove-model:disabled svg {
  stroke: #94a3b8;
}

.afr-cp-add-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 14px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #2563eb;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.afr-cp-add-model-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* Bottom Action Buttons */
.afr-cp-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.afr-cp-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 42px;
  padding: 0 20px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
}

.afr-cp-btn-save:hover {
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.35);
}

.afr-cp-btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 42px;
  padding: 0 20px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.afr-cp-btn-cancel:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ── Custom Provider View Mode vs Edit Mode ─────────────────────────────── */
.afr-cp-view-mode .afr-cp-input {
  background-color: #f8fafc !important;
  color: #475569 !important;
  border-color: #e2e8f0 !important;
  cursor: default !important;
  user-select: text;
  box-shadow: none !important;
}

.afr-cp-view-mode .afr-cp-input:focus {
  outline: none !important;
  border-color: #e2e8f0 !important;
  box-shadow: none !important;
}

.afr-cp-view-mode .afr-cp-remove-model {
  display: none !important;
}

.afr-cp-view-mode .afr-cp-add-model-btn {
  display: none !important;
}

.afr-cp-view-mode .afr-cp-actions {
  display: none !important;
}

.afr-cp-edit-mode .afr-cp-input:not([name="provider_key"]):not([data-readonly="true"]) {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
  cursor: text !important;
}

.afr-cp-edit-mode .afr-cp-input:not([name="provider_key"]):not([data-readonly="true"]):focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

.afr-cp-edit-mode .afr-cp-remove-model {
  display: inline-flex !important;
}

.afr-cp-edit-mode .afr-cp-add-model-btn {
  display: inline-flex !important;
}

.afr-cp-edit-mode .afr-cp-actions {
  display: flex !important;
}

/* ── Dark Theme Overrides for Provider Cards ─────────────────────────────── */
[data-afr-theme="dark"] .afr-provider-section,
#afr-app.afr-dark-theme .afr-provider-section {
  background: #1e1e24 !important;
  border-color: #2d2d38 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

[data-afr-theme="dark"] .afr-provider-header,
#afr-app.afr-dark-theme .afr-provider-header {
  background: #1e1e24 !important;
}

[data-afr-theme="dark"] .afr-provider-header:hover,
#afr-app.afr-dark-theme .afr-provider-header:hover {
  background: #252530 !important;
}

[data-afr-theme="dark"] .afr-provider-title,
#afr-app.afr-dark-theme .afr-provider-title {
  color: #f1f5f9 !important;
}

[data-afr-theme="dark"] .afr-provider-avatar-initial,
#afr-app.afr-dark-theme .afr-provider-avatar-initial {
  background: #2a2a36 !important;
  color: #cbd5e1 !important;
}

[data-afr-theme="dark"] .afr-type-pill,
#afr-app.afr-dark-theme .afr-type-pill {
  background: #2a2a36 !important;
  color: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-orig-provider-pill,
#afr-app.afr-dark-theme .afr-orig-provider-pill {
  background: rgba(37, 99, 235, 0.18) !important;
  color: #93c5fd !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-afr-theme="dark"] .afr-models-count,
#afr-app.afr-dark-theme .afr-models-count {
  color: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-models-count svg,
#afr-app.afr-dark-theme .afr-models-count svg {
  color: #94a3b8 !important;
  stroke: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-action-btn--edit,
#afr-app.afr-dark-theme .afr-action-btn--edit {
  color: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-action-btn--edit:hover,
#afr-app.afr-dark-theme .afr-action-btn--edit:hover {
  background: #2a2a36 !important;
  color: #60a5fa !important;
}

[data-afr-theme="dark"] .afr-action-btn--edit:hover svg,
#afr-app.afr-dark-theme .afr-action-btn--edit:hover svg {
  stroke: #60a5fa !important;
}

[data-afr-theme="dark"] .afr-action-btn--delete:hover,
#afr-app.afr-dark-theme .afr-action-btn--delete:hover {
  background: rgba(239, 68, 68, 0.15) !important;
}

[data-afr-theme="dark"] .afr-custom-provider-card-dashed,
#afr-app.afr-dark-theme .afr-custom-provider-card-dashed {
  background: #1e1e24 !important;
  border-color: #383848 !important;
}

[data-afr-theme="dark"] .afr-custom-provider-card-dashed:hover,
#afr-app.afr-dark-theme .afr-custom-provider-card-dashed:hover {
  background: #252532 !important;
  border-color: #3b82f6 !important;
}

[data-afr-theme="dark"] .afr-dashed-card-text,
#afr-app.afr-dark-theme .afr-dashed-card-text {
  color: #f1f5f9 !important;
}

[data-afr-theme="dark"] .afr-dashed-plus-icon,
#afr-app.afr-dark-theme .afr-dashed-plus-icon {
  background: rgba(59, 130, 246, 0.15) !important;
}

[data-afr-theme="dark"] .afr-badge-openai,
#afr-app.afr-dark-theme .afr-badge-openai {
  background: rgba(59, 130, 246, 0.15) !important;
}

[data-afr-theme="dark"] .afr-provider-body,
#afr-app.afr-dark-theme .afr-provider-body {
  border-top-color: #2d2d38 !important;
  background: #18181f !important;
}

[data-afr-theme="dark"] .afr-cp-card-inner,
#afr-app.afr-dark-theme .afr-cp-card-inner {
  background: #18181f !important;
}

[data-afr-theme="dark"] .afr-cp-title,
#afr-app.afr-dark-theme .afr-cp-title {
  color: #f1f5f9 !important;
}

[data-afr-theme="dark"] .afr-cp-subtitle,
#afr-app.afr-dark-theme .afr-cp-subtitle {
  color: #94a3b8 !important;
}

[data-afr-theme="dark"] .afr-cp-plug-icon,
#afr-app.afr-dark-theme .afr-cp-plug-icon {
  background: rgba(59, 130, 246, 0.15) !important;
}

[data-afr-theme="dark"] .afr-cp-info-badge,
#afr-app.afr-dark-theme .afr-cp-info-badge {
  background: rgba(59, 130, 246, 0.12) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: #60a5fa !important;
}

[data-afr-theme="dark"] .afr-cp-label,
#afr-app.afr-dark-theme .afr-cp-label {
  color: #cbd5e1 !important;
}

[data-afr-theme="dark"] .afr-cp-input,
#afr-app.afr-dark-theme .afr-cp-input {
  background: #121216 !important;
  border-color: #2d2d38 !important;
  color: #f1f5f9 !important;
}

[data-afr-theme="dark"] .afr-cp-view-mode .afr-cp-input,
#afr-app.afr-dark-theme .afr-cp-view-mode .afr-cp-input {
  background: #1a1a22 !important;
  color: #94a3b8 !important;
  border-color: #252530 !important;
}

[data-afr-theme="dark"] .afr-cp-models-box,
#afr-app.afr-dark-theme .afr-cp-models-box {
  background: #14141a !important;
  border-color: #252530 !important;
}

[data-afr-theme="dark"] .afr-cp-models-header,
#afr-app.afr-dark-theme .afr-cp-models-header {
  color: #f1f5f9 !important;
}

[data-afr-theme="dark"] .afr-cp-remove-model,
#afr-app.afr-dark-theme .afr-cp-remove-model {
  background: #1e1e26 !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
}

[data-afr-theme="dark"] .afr-cp-remove-model:hover:not(:disabled),
#afr-app.afr-dark-theme .afr-cp-remove-model:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
}

[data-afr-theme="dark"] .afr-cp-add-model-btn,
#afr-app.afr-dark-theme .afr-cp-add-model-btn {
  background: #1e1e26 !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: #60a5fa !important;
}

[data-afr-theme="dark"] .afr-cp-add-model-btn:hover,
#afr-app.afr-dark-theme .afr-cp-add-model-btn:hover {
  background: rgba(59, 130, 246, 0.15) !important;
}

[data-afr-theme="dark"] .afr-cp-actions,
#afr-app.afr-dark-theme .afr-cp-actions {
  border-top-color: #252530 !important;
}

[data-afr-theme="dark"] .afr-cp-btn-cancel,
#afr-app.afr-dark-theme .afr-cp-btn-cancel {
  background: #252530 !important;
  border-color: #383848 !important;
  color: #cbd5e1 !important;
}

[data-afr-theme="dark"] .afr-cp-btn-cancel:hover,
#afr-app.afr-dark-theme .afr-cp-btn-cancel:hover {
  background: #2d2d3a !important;
  color: #ffffff !important;
}

[data-afr-theme="dark"] .afr-logo-openai svg,
[data-afr-theme="dark"] .afr-logo-anthropic svg,
#afr-app.afr-dark-theme .afr-logo-openai svg,
#afr-app.afr-dark-theme .afr-logo-anthropic svg {
  fill: #ffffff !important;
}

/* ── Pending Plan Approval Card ────────────────────────────────────────── */
.afr-pending-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(226, 232, 240, 0.8);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.afr-pending-icon-wrap {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2);
}
.afr-pending-hourglass-svg {
  animation: afr-pulse-slow 2.4s ease-in-out infinite;
}
@keyframes afr-pulse-slow {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.08); opacity: 1; }
}
.afr-pending-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 14px;
  border-radius: 9999px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.afr-pending-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}
.afr-pending-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.afr-pending-message {
  font-size: 0.98rem;
  line-height: 1.6;
  color: #475569;
  margin: 0 0 24px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}
.afr-pending-details-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 26px;
  text-align: left;
}
.afr-pending-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 0.9rem;
}
.afr-pending-detail-row:last-child {
  border-bottom: none;
}
.afr-pending-detail-label {
  color: #64748b;
  font-weight: 500;
}
.afr-pending-detail-value {
  color: #1e293b;
}
.afr-pending-price-tag {
  color: #3b82f6;
  font-size: 0.84rem;
  font-weight: 600;
  margin-left: 4px;
}
.afr-pending-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.afr-btn-refresh-status {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.afr-btn-refresh-status:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.afr-btn-logout-link {
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  transition: all 0.15s ease;
}
.afr-btn-logout-link:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

[data-afr-theme="dark"] .afr-pending-card,
#afr-app.afr-dark-theme .afr-pending-card {
  background: #1e1e2d !important;
  border-color: #2d2d3f !important;
}
[data-afr-theme="dark"] .afr-pending-title,
#afr-app.afr-dark-theme .afr-pending-title {
  color: #ffffff !important;
}
[data-afr-theme="dark"] .afr-pending-message,
#afr-app.afr-dark-theme .afr-pending-message {
  color: #cbd5e1 !important;
}
[data-afr-theme="dark"] .afr-pending-details-box,
#afr-app.afr-dark-theme .afr-pending-details-box {
  background: #151521 !important;
  border-color: #252538 !important;
}
[data-afr-theme="dark"] .afr-pending-detail-row,
#afr-app.afr-dark-theme .afr-pending-detail-row {
  border-bottom-color: #222232 !important;
}
[data-afr-theme="dark"] .afr-pending-detail-value,
#afr-app.afr-dark-theme .afr-pending-detail-value {
  color: #ffffff !important;
}

/* ── Plan Header Top Row & Guest Login Prompt ───────────────────────────────── */
.afr-plan-header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.75rem;
}
.afr-header-login-prompt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
  color: #64748b;
}
.afr-btn-header-login {
  background: #ffffff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.06);
}
.afr-btn-header-login:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* ── Integrated Auth Modal ─────────────────────────────────────────────────── */
.afr-auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.afr-auth-modal-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 430px;
  width: 100%;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.25);
  animation: afrModalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes afrModalPop {
  0% { opacity: 0; transform: scale(0.95) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.afr-auth-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.afr-auth-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.afr-auth-modal-header {
  margin-bottom: 1.25rem;
}
.afr-auth-modal-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.afr-auth-tabs-nav {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}
.afr-auth-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}
.afr-auth-tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.afr-auth-subtext {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 1rem 0;
}
.afr-form-group {
  margin-bottom: 1rem;
}
.afr-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}
.afr-form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.875rem;
  outline: none;
  background: #ffffff;
  color: #0f172a;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
.afr-form-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.afr-form-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.afr-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #64748b;
  cursor: pointer;
}
.afr-btn-auth-submit {
  width: 100%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.afr-btn-auth-submit:hover {
  background: #1d4ed8;
}
.afr-modal-alert {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.825rem;
  margin-bottom: 1rem;
}

/* Dark theme overrides */
[data-afr-theme="dark"] .afr-auth-modal-card,
#afr-app.afr-dark-theme .afr-auth-modal-card {
  background: #1e1e2d;
  color: #ffffff;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.5);
}
[data-afr-theme="dark"] .afr-auth-tabs-nav,
#afr-app.afr-dark-theme .afr-auth-tabs-nav {
  background: #151521;
}
[data-afr-theme="dark"] .afr-auth-tab-btn,
#afr-app.afr-dark-theme .afr-auth-tab-btn {
  color: #94a3b8;
}
[data-afr-theme="dark"] .afr-auth-tab-btn.active,
#afr-app.afr-dark-theme .afr-auth-tab-btn.active {
  background: #28283c;
  color: #ffffff;
}
[data-afr-theme="dark"] .afr-form-label,
#afr-app.afr-dark-theme .afr-form-label {
  color: #e2e8f0;
}
[data-afr-theme="dark"] .afr-form-input,
#afr-app.afr-dark-theme .afr-form-input {
  background: #151521;
  border-color: #323248;
  color: #ffffff;
}
[data-afr-theme="dark"] .afr-btn-header-login,
#afr-app.afr-dark-theme .afr-btn-header-login {
  background: #1e1e2d;
  border-color: #3b82f6;
  color: #60a5fa;
}



