#ai-reader-fab {
  position: fixed;
  right: 0;
  top: 150px;
  z-index: 2147483000;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  min-width: 84px;
  padding: 8px 10px 8px 8px;
  border: 1px solid #a855f7;
  border-right: 0;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  background: linear-gradient(135deg, #4c1d95, #9333ea 60%, #c084fc);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22) inset, 0 12px 30px rgba(147, 51, 234, 0.45);
}

#ai-reader-fab .ai-reader-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: 0 0 auto;
}

#ai-reader-fab .ai-reader-label {
  line-height: 1.05;
  text-align: center;
  white-space: normal;
}

#ai-reader-fab:hover {
  filter: brightness(1.08);
}

#ai-reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 100060;
  background: transparent;
}

#ai-reader-panel {
  position: fixed;
  right: 96px;
  top: 150px;
  z-index: 100070;
  width: min(500px, calc(100vw - 120px));
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(196, 132, 252, 0.6);
  border-right: 0;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  background: linear-gradient(180deg, rgba(34, 16, 64, 0.96), rgba(23, 10, 45, 0.96));
  color: #f5f3ff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(216, 180, 254, 0.2) inset;
  overflow: hidden;
}

.ai-reader-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(216, 180, 254, 0.3);
}

.ai-reader-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ai-reader-minimize,
.ai-reader-close {
  border: 0;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  color: #f5f3ff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.ai-reader-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: #f3e8ff;
}

.ai-reader-minimize:hover,
.ai-reader-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

#ai-reader-cache {
  position: fixed;
  right: 0;
  top: 240px;
  z-index: 2147482999;
  border: 1px solid rgba(168, 85, 247, 0.9);
  border-radius: 10px 0 0 10px;
  border-right: 0;
  background: linear-gradient(135deg, #3b136f, #7c2fd1);
  color: #f5f3ff;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124, 47, 209, 0.4);
}

#ai-reader-cache:hover {
  filter: brightness(1.08);
}

@media (max-width: 1100px) {
  #ai-reader-panel {
    right: 72px;
    width: min(470px, calc(100vw - 88px));
  }
}

.ai-reader-status {
  padding: 10px 14px;
  font-size: 12px;
  color: #ddd6fe;
  border-bottom: 1px solid rgba(216, 180, 254, 0.2);
}

.ai-reader-lock-note {
  padding: 10px 14px;
  font-size: 12px;
  color: #f5d0fe;
  background: rgba(168, 85, 247, 0.14);
  border-bottom: 1px solid rgba(216, 180, 254, 0.18);
}

.ai-reader-body {
  padding: 14px;
  overflow: auto;
  line-height: 1.5;
  font-size: 13px;
  color: #f5f3ff;
}

.ai-reader-entry {
  padding: 10px 12px;
  border: 1px solid rgba(216, 180, 254, 0.22);
  border-radius: 10px;
  background: rgba(73, 27, 126, 0.28);
}

.ai-reader-entry-tone-1 { background: rgba(73, 27, 126, 0.28); }
.ai-reader-entry-tone-2 { background: rgba(42, 68, 128, 0.30); }
.ai-reader-entry-tone-3 { background: rgba(31, 92, 110, 0.30); }
.ai-reader-entry-tone-4 { background: rgba(104, 54, 99, 0.30); }

.ai-reader-entry + .ai-reader-entry {
  margin-top: 10px;
}

.ai-reader-entry-head {
  font-size: 12px;
  font-weight: 700;
  color: #e9d5ff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-reader-entry-body {
  font-size: 13px;
  color: #f5f3ff;
  line-height: 1.45;
}

.ai-reader-entry-delete {
  border: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #f5f3ff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.ai-reader-entry-delete:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ai-reader-dots::after {
  content: "";
  display: inline-block;
  width: 20px;
  text-align: left;
  animation: ai-reader-dots 1.2s steps(4, end) infinite;
}

@keyframes ai-reader-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

html.ai-reader-active,
html.ai-reader-active body {
  overflow: hidden !important;
}

#ai-reader-focus {
  position: fixed;
  z-index: 100065;
  pointer-events: none;
  border: 3px solid transparent;
  border-radius: 12px;
  border-image: linear-gradient(130deg, #c084fc, #7e22ce, #e9d5ff) 1;
  box-shadow:
    0 0 10px rgba(192, 132, 252, 0.9),
    0 0 24px rgba(147, 51, 234, 0.75),
    inset 0 0 14px rgba(196, 132, 252, 0.42);
  animation: ai-reader-glow 1.6s ease-in-out infinite alternate;
}

#ai-reader-focus::after {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: 100066;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(233, 213, 255, 0.45) 0 2px, transparent 3px),
    radial-gradient(circle at 84% 16%, rgba(216, 180, 254, 0.45) 0 2px, transparent 3px),
    radial-gradient(circle at 20% 85%, rgba(196, 132, 252, 0.42) 0 2px, transparent 3px),
    radial-gradient(circle at 90% 76%, rgba(233, 213, 255, 0.48) 0 2px, transparent 3px);
  animation: ai-reader-sparkle 2.2s linear infinite;
}

@keyframes ai-reader-glow {
  from { opacity: 0.68; }
  to { opacity: 1; }
}

@keyframes ai-reader-sparkle {
  0% { transform: translateY(0); opacity: 0.65; }
  50% { transform: translateY(-3px); opacity: 1; }
  100% { transform: translateY(0); opacity: 0.65; }
}

/* Dashboard responsive fix: prevent horizontal overflow when native filter panel is open */
@media (max-width: 1200px) {
  html.ai-dashboard-route,
  body.ai-dashboard-route {
    overflow-x: hidden !important;
  }

  body.ai-dashboard-route #app,
  body.ai-dashboard-route .app,
  body.ai-dashboard-route [data-test="dashboard-content"],
  body.ai-dashboard-route .dashboard-content,
  body.ai-dashboard-route .dashboard .dragdroppable-row,
  body.ai-dashboard-route .dashboard .dragdroppable-column {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.ai-dashboard-route .dashboard .grid-container,
  body.ai-dashboard-route .dashboard .chart-slice,
  body.ai-dashboard-route .dashboard .slice_container {
    max-width: 100% !important;
  }

  html.ai-dashboard-route.ai-native-filter-open,
  body.ai-dashboard-route.ai-native-filter-open {
    overflow-x: hidden !important;
  }

  body.ai-dashboard-route.ai-native-filter-open #app,
  body.ai-dashboard-route.ai-native-filter-open .app,
  body.ai-dashboard-route.ai-native-filter-open [role="main"],
  body.ai-dashboard-route.ai-native-filter-open .dashboard,
  body.ai-dashboard-route.ai-native-filter-open [data-test="dashboard-content"],
  body.ai-dashboard-route.ai-native-filter-open .dashboard-content,
  body.ai-dashboard-route.ai-native-filter-open .dashboard .dragdroppable,
  body.ai-dashboard-route.ai-native-filter-open .dashboard .dragdroppable-row,
  body.ai-dashboard-route.ai-native-filter-open .dashboard .dragdroppable-column {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    left: 0 !important;
    transform: none !important;
  }

  body.ai-dashboard-route.ai-native-filter-open .dashboard .chart-slice,
  body.ai-dashboard-route.ai-native-filter-open .dashboard .slice_container,
  body.ai-dashboard-route.ai-native-filter-open .dashboard .grid-container {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Force native filter sidebar to overlay instead of pushing dashboard width */
  body.ai-dashboard-route.ai-native-filter-open [data-test="filter-bar"],
  body.ai-dashboard-route.ai-native-filter-open [data-test="native-filter-bar"],
  body.ai-dashboard-route.ai-native-filter-open [data-test="dashboard-native-filters"],
  body.ai-dashboard-route.ai-native-filter-open [class*="filterBar"],
  body.ai-dashboard-route.ai-native-filter-open [class*="FilterBar"] {
    position: fixed !important;
    top: 58px !important;
    left: 0 !important;
    bottom: 0 !important;
    z-index: 1002 !important;
    width: min(82vw, 320px) !important;
    max-width: 82vw !important;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.16) !important;
  }

  body.ai-dashboard-route.ai-native-filter-open [data-test="dashboard-content"],
  body.ai-dashboard-route.ai-native-filter-open .dashboard-content {
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
}

@media (max-width: 900px) {
  html.ai-mobile-filter-open,
  body.ai-mobile-filter-open {
    overflow-x: hidden !important;
  }

  body.ai-mobile-filter-open .ai-mobile-filter-panel {
    position: fixed !important;
    top: 58px !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(82vw, 320px) !important;
    max-width: 82vw !important;
    z-index: 1002 !important;
    overflow-y: auto !important;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.16) !important;
  }

  body.ai-mobile-filter-open .ai-mobile-dashboard-content,
  body.ai-mobile-filter-open [data-test="dashboard-content"],
  body.ai-mobile-filter-open .dashboard-content {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    overflow-x: hidden !important;
  }
}
