/* favorites responsive styles extracted from js/favorites.js
   Moved to a separate file so it's easier to edit. */
#favoritesRoot .favorite-container { padding: 0px; overflow: visible; }
#favoritesRoot .favorite-item { position: relative; display: grid; grid-template-columns: 1fr minmax(150px, 200px) minmax(100px, auto); align-items: center; gap: 12px; padding: 12px 0; box-sizing: border-box; overflow: visible; }
#favoritesRoot .favorite-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#favoritesRoot .favorite-symbol { font-weight: 700; font-size: 1.05rem; }
#favoritesRoot .favorite-name { color: var(--text-secondary); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-wrap: break-word; hyphens: auto; }
#favoritesRoot .favorite-sparkline { width: 100%; height: 48px; flex-shrink: 0; }
#favoritesRoot .favorite-price-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; overflow: visible; }
#favoritesRoot .favorite-price { text-align: right; }

/* Mobile portrait: make sparkline taller and move price/change to top-right */
@media (max-width:480px) {
  #favoritesRoot .favorite-item { grid-template-columns: 1fr; grid-template-rows: auto auto auto; padding-top: 12px; padding-bottom: 12px; }
  #favoritesRoot .favorite-meta { grid-column: 1; grid-row: 1; width: auto; min-width: 0; }
  #favoritesRoot .favorite-sparkline { grid-column: 1; grid-row: 2; height: 88px; min-height: 64px; }
  #favoritesRoot .favorite-price-actions { position: absolute; top: 8px; right: 8px; flex-direction: column; align-items: flex-end; background: transparent; min-width: 0; }
  #favoritesRoot .favorite-price { text-align: right; }
  #favoritesRoot .favorite-name { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
}
/* Favorites panel styles
   Used together with favorites.js to render a mock list of favorite assets.
*/

.favorite-container {
  width: 100%;
  max-width: 1100px;
  margin: 18px auto;
  padding: 0px;
  color: var(--text-primary, #fff);
  box-sizing: border-box;
/* Favorites panel styles
   Used together with favorites.js to render a mock list of favorite assets.
*/
}

/* hide host by default; will be toggled via script */
#favoritesRoot { display: none; }

/* Reuse refresh icon sizing for favorites refresh button */
.favorite-btn.refresh-btn i,
.favorite-actions-toggle i {
  font-size: 16px;
  display: inline-block;
  transform-origin: center center;
}

/* spinning animation (reuse loader-two-phase if present; else provide fallback) */
@keyframes favoriteSpinner {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.favorite-btn.refresh-btn.spinning i,
.favorite-actions-toggle.spinning i {
  animation: favoriteSpinner 2ms linear infinite;
}
/* Support inline SVG refresh icon (added to favorites.js). Match the same
   spinning animation previously applied to <i> elements so the inline SVG
   rotates when the button has the .spinning class. */
.favorite-btn.refresh-btn .refresh-icon,
.favorite-actions-toggle .refresh-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  transform-origin: center center;
  /* for SVG elements, ensure transform-origin affects the SVG content box */
  transform-box: fill-box;
  -webkit-transform-box: fill-box;
}
.favorite-btn.refresh-btn.spinning .refresh-icon,
.favorite-actions-toggle.spinning .refresh-icon {
  animation: favoriteSpinner 360ms linear infinite;
}
.favorites-visible #favoritesRoot { display: block; background: var(--bg-primary); }

.favorite-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.favorite-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.fav-group-selector-wrapper {
  position: relative;
  display: inline-block;
  flex: 1;
  max-width: 320px;
}

.fav-group-selector-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.05) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text-primary, #ffffff);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.fav-group-selector-btn:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.09) 100%);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}

.fav-group-selector-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.fav-group-selector-btn:focus {
  outline: none;
  border-color: var(--gradient-start, #7c3aed);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15), 0 4px 12px rgba(0, 0, 0, 0.18);
}

.fav-group-name {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.3px;
}

.fav-group-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), color 160ms ease;
  color: rgba(255, 255, 255, 0.7);
  stroke-width: 2.5;
}

.fav-group-selector-btn:hover .fav-group-chevron {
  color: var(--text-primary, #ffffff);
}

/* Dropdown menu - iOS style */
.fav-group-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: linear-gradient(135deg, rgba(26, 26, 46, 0.98) 0%, rgba(26, 26, 46, 0.96) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-12px) scale(0.95);
  transition: opacity 200ms ease, visibility 200ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 3000;
  min-width: 200px;
}

.fav-group-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.fav-group-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.fav-group-option {
  padding: 14px 16px;
  color: var(--text-primary, #ffffff);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 140ms ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  font-weight: 500;
}

.fav-group-option:last-of-type:not(.fav-group-action) {
  border-bottom: none;
}

.fav-group-option:hover:not(.fav-group-action) {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.fav-group-option:active:not(.fav-group-action) {
  background: rgba(255, 255, 255, 0.14);
}

.fav-group-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 4px 0;
}

.fav-group-action {
  font-weight: 700;
  color: var(--gradient-end, #38bdf8);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(56, 189, 248, 0.08) 100%);
  border-bottom: none !important;
  border-top: 1px solid rgba(56, 189, 248, 0.15) !important;
  padding: 14px 16px;
  transition: all 140ms ease;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.fav-group-action:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0.14) 100%) !important;
  color: #64e4ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.fav-group-action:active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25) 0%, rgba(56, 189, 248, 0.18) 100%) !important;
  transform: translateY(0);
}

#topbar-group-selector {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: var(--text-primary, #ffffff);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 150ms ease;
  min-width: 120px;
}

#topbar-group-selector:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

#topbar-group-selector:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--gradient-start, #7c3aed);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

#topbar-group-selector option {
  background: #1a1a2e;
  color: #ffffff;
}

.favorite-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Favorites-specific override: prevent global .refresh-btn centering and oversized spacing
   Ensure the refresh button inside the favorites header is a compact icon button
   and does not overlap other controls. */
.favorite-controls .refresh-btn {
  margin: 0;
  padding: 10px;
  min-width: 40px;
  height: 40px;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.favorite-controls .refresh-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}

.favorite-controls .refresh-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.favorite-controls .refresh-btn i {
  font-size: 16px;
  line-height: 1;
}

.favorite-list {
  display: block;
  /* ✅ FIX: Allow dropdown menus to overflow without being clipped */
  overflow: visible !important;
  clip-path: none !important;
  width: 100%;
}

.favorite-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 150px) minmax(100px, auto);
  grid-template-rows: auto;
  align-items: center;
  align-content: center;
  gap: 8px;
  padding: 12px 0;
  border-radius: 5px;
  border-bottom: 1px solid var(--border-underline);
  /* ✅ FIX: Critical - do NOT restrict overflow, let dropdown escape */
  position: relative;
  overflow: visible !important;
  clip-path: none !important;
  /* ✅ FIX: Ensure high z-index context but don't trap children */
  z-index: auto;
}

.favorite-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
}

.favorite-symbol {
  font-weight: 800;
  font-size: 1.05rem;
  width: auto;
}

.favorite-name {
  color: var(--text-secondary, #cfcfcf);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.favorite-sparkline {
  width: 150px;
  height: 48px;
  display: block;
}

.favorite-price-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  /* ✅ FIX: Let dropdown menu escape without clipping */
  overflow: visible !important;
  position: relative;
  z-index: auto;
  min-width: 100px;
}

.favorite-price {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.price-value {
  font-weight: 700;
  display: block;
}

.price-change {
  display: inline-block;
  margin-top: 0px;
  padding: 0px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.price-change.up { background: rgba(34,197,94,0.14); color: #22c55e; }
.price-change.down { background: rgba(239,68,68,0.12); color: #ef4444; }

/* Menu wrapper and toggle button */
.favorite-actions-menu-wrapper {
  position: relative;
  display: inline-block;
}

.favorite-actions-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.04);
  color: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 200ms ease, border-color 200ms ease;
}

.favorite-actions-toggle:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
}

/* Dropdown menu (hidden by default) */
.favorite-actions-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card-bg, #1a1a1a);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  min-width: 120px;
  margin-top: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.favorite-actions-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Menu items */
.favorite-action-item {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: inherit;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 150ms ease;
}

.favorite-action-item:first-child {
  border-radius: 7px 7px 0 0;
}

.favorite-action-item:last-child {
  border-radius: 0 0 7px 7px;
}

.favorite-action-item:hover {
  background: rgba(255,255,255,0.08);
}

.favorite-action-item.remove-btn:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}

.favorite-actions {
  display: inline-block;
  /* ✅ FIX: Very high z-index to break out of stacking contexts */
}

/* Vertical menu button (three dots) */
.favorite-actions-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1;
  transition: all 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
  background: rgba(255, 255, 255, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  pointer-events: auto;
}

.favorite-actions-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

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

/* Dropdown menu (vertical options) */
.favorite-actions-menu {
  position: fixed !important;
  background: linear-gradient(135deg, rgba(26, 26, 46, 0.98) 0%, rgba(26, 26, 46, 0.96) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  min-width: 140px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 160ms ease, visibility 160ms ease, transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  /* ✅ CRITICAL: Position fixed + highest z-index escapes stacking context */
  z-index: 999999 !important;
  /* ✅ FIX: Pointer events only when visible */
  pointer-events: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
  /* Position will be set dynamically via JavaScript */
  top: 0 !important;
  right: 40px !important;
}

.favorite-actions-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  /* ✅ FIX: Re-enable pointer events when menu is open */
  pointer-events: auto;
}

/* ✅ FIX: Prevent menu from closing when hovering over menu items */
.favorite-actions-menu.open:hover {
  pointer-events: auto !important;
}

/* Menu items */
.favorite-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary, #ffffff);
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 140ms ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 500;
}

.favorite-action-item:last-child {
  border-bottom: none;
}

.favorite-action-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

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

.favorite-action-item.move-action:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

/* Icon styling for menu items */
.favorite-action-item::before {
  content: attr(data-icon);
  font-size: 1rem;
  display: inline-block;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.favorite-btn {
  display: none; /* Hide old button style */
}

.favorite-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-secondary, #bdbdbd);
}

/* small touch target tweaks for mobile */
.favorite-item .favorite-btn { padding: 8px; }

/* subtle hover */
.favorite-item:hover { transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.18); }

/* Bottom sheet viewer for favorite details */
.fav-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: -100%;
  height: 95vh;
  max-height: 88vh;
  background: var(--card-bg);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  box-shadow: 0 -20px 50px rgba(0,0,0,0.32);
  transition: bottom 260ms cubic-bezier(.2,.9,.2,1), transform 180ms ease;
  z-index: 2200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fav-sheet.is-open { bottom: 0; }
.fav-sheet .sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(0,0,0,0.18);
  border-radius: 4px;
  margin: 10px auto 6px auto;
}
.fav-sheet .close-left {
  position: absolute;
  left: 10px;
  top: 8px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 2220;
}
.fav-sheet .sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 14px;
  border-bottom: 0px solid var(--border-color);
}
.fav-sheet .sheet-title { font-weight: 700; font-size: 1.1rem; }
.fav-sheet .sheet-body { padding:0px; overflow: auto; flex: 1; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; min-height: 450px; }

/* Sheet chart container - responsive design for Lightweight Charts */
.fav-sheet .sheet-chart {
  width: 100%;
  height: 450px;
  min-height: 450px;
  max-height: none;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.1);
}

/* Ensure chart resizes smoothly */
.fav-sheet .sheet-chart > div {
  width: 100%;
  height: 100%;
}

.fav-sheet .sheet-sparkline { 
  width: 100%; 
  height: 600px; 
  min-height: 450px; 
  margin: 8px 0 6px; 
  position: relative; 
  padding-right: 0px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fav-sheet.is-open .sheet-sparkline { width: 100%; height: 600px; min-height: 450px; overflow: hidden; }

/* LightweightCharts container - keep it simple like TradingView example */
.fav-sheet .sheet-sparkline .tv-lightweight-charts {
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box;
}

.fav-sheet .sheet-sparkline .tv-lightweight-charts-normalized {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* Canvas should fill the container */
.fav-sheet .sheet-sparkline .tv-lightweight-charts canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}

/* LightweightCharts may use internal table layout - don't hide, let it work */
.fav-sheet .sheet-sparkline table {
  width: 100% !important;
  height: 100% !important;
  border-collapse: collapse;
  display: block !important;
}

.fav-sheet .sheet-sparkline table canvas,
.fav-sheet .sheet-sparkline .tv-lightweight-charts table canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* All canvas elements should be visible */
.fav-sheet .sheet-sparkline canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}

/* Ensure any inline SVG inside the sheet sparkline fills its container */
/* DISABLED: This conflicts with LightweightCharts canvas z-index and sizing.
   LightweightCharts manages its own canvas elements - don't override SVG here. */
/* .fav-sheet .sheet-sparkline svg { width: calc(100% - 40px); height: 100%; display: block; position: relative; z-index: 2; } */

/* Subtle grid overlay inside the sparkline area to help gauge the path vertically/horizontally.
   The grid is decorative only (pointer-events: none) and sits under the svg content visually
   (svg is z-index:2). Adjust --grid-rows for different spacing. 
    Background Grid
   */
.fav-sheet .sheet-sparkline::before { 
  content: "";
  position: absolute;
  left: 0;
  right: 0px; /* avoid drawing under the y-axis area */
  top: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
  /* vertical spacing; change 60px to your preferred spacing */
  background-image:
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 1px, transparent 5px, transparent 60px),
    repeating-linear-gradient(to right, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 1px, transparent 5px, transparent 120px);
}

/* Right-side vertical y-axis area reserved for price labels positioned over chart */
.fav-sheet .sheet-sparkline .sheet-yaxis {
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 12px 8px;
  box-sizing: border-box;
  z-index: 10;
  color: var(--text-secondary);
  font-size: 12px;
  pointer-events: none;
  text-align: right;
  line-height: 1.2;
  background: linear-gradient(to left, rgba(11, 11, 11, 0.8), transparent);
  -webkit-mask-image: linear-gradient(to left, black 0%, black 80%, transparent 100%);
  mask-image: linear-gradient(to left, black 0%, black 80%, transparent 100%);
}

.fav-sheet .sheet-sparkline .sheet-yaxis .yaxis-label {
  line-height: 1;
  white-space: nowrap;
  opacity: 0.9;
  font-weight: 500;
  font-size: 11px;
}

/* Themeable sparkline SVG text labels (max/min/last). Configure easily by
   overriding the CSS vari(max-width: 599px)ables below, for example:
   .fav-sheet { --spark-label-font-size: 12px; --spark-label-fill: #fff; }
*/
.fav-sheet {
  --spark-label-font-size: 10px;
  --spark-label-fill: var(--text-secondary, #6b7280);
  --spark-label-weight: 600;
  --spark-label-opacity: 0.92;
}

.fav-sheet.is-open {
  /* slightly larger labels when the sheet is open */
  --spark-label-font-size: 12px;
}

/* Target the SVG text nodes inserted by drawSparkline(): spark-max-label,
   spark-min-label and spark-last-label. Use !important to override inline
   presentation when necessary. */
.fav-sheet .sheet-sparkline svg text.spark-max-label,
.fav-sheet .sheet-sparkline svg text.spark-min-label,
.fav-sheet .sheet-sparkline svg text.spark-last-label {
  font-size: var(--spark-label-font-size) !important;
  fill: var(--spark-label-fill) !important;
  font-weight: var(--spark-label-weight) !important;
  opacity: var(--spark-label-opacity) !important;
  pointer-events: none;
  white-space: nowrap;
}

/* If you want the y-axis labels clickable, remove pointer-events: none and adjust JS accordingly. */
.fav-sheet.is-open .sheet-sparkline svg path.sparkline,
.fav-sheet.is-open .sheet-sparkline svg circle.last-dot {
  /* Use a thinner stroke in the expanded sheet so the line doesn't look oversized.
     Keep non-scaling stroke so device-pixel thickness remains stable. */
  stroke-width: 2px !important;
  vector-effect: non-scaling-stroke;
}

/* Fallback: if the path does not have a class, or JS writes stroke-width as an attribute,
   override any presentation attribute by targeting all paths inside the open sheet sparkline. */
.fav-sheet.is-open .sheet-sparkline svg path,
.fav-sheet.is-open .sheet-sparkline svg g path {
  stroke-width: 2px !important;
  vector-effect: non-scaling-stroke !important;
}

/* Also reduce any explicitly-rendered last-dot radius if present */
.fav-sheet.is-open .sheet-sparkline svg circle {
  r: 3px; /* SVG attribute override via CSS isn't supported for `r` in all browsers, but keep for authoring consistency */
}
.fav-sheet .sheet-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 12px;
  margin-left: 20px;
  margin-top:30px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.fav-sheet .sheet-stats .stat { display:flex; flex-direction:column; gap:4px; }
.fav-sheet .sheet-stats .stat .label { color: var(--text-secondary); font-size:0.82rem; }
.fav-sheet .sheet-stats .stat .value { font-weight:700; }
.fav-sheet .sheet-footer { display:flex; gap:10px; padding:10px 14px; border-top:1px solid var(--border-color); justify-content:space-between; align-items:center; }
.fav-sheet .nav-btn { border: 1px solid var(--border-color); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.fav-sheet .close-btn { background: transparent; border: none; font-size: 18px; cursor: pointer; }

/* Make header-right buttons appear on a circular background */
.fav-sheet .sheet-header-right > button,
.fav-sheet .sheet-header-right button.close-btn,
.fav-sheet .sheet-header-right button.delete-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  cursor: pointer;
  color: inherit;
}
.fav-sheet .sheet-header-right > button:hover {
  background: rgba(255,255,255,0.06);
}

/* Smaller icon size inside circular button for neatness */
.fav-sheet .sheet-header-right > button img,
.fav-sheet .sheet-header-right > button svg,
.fav-sheet .sheet-header-right > button > * {
  max-width: 20px;
  max-height: 20px;
  display: block;
}


/* x-axis label styling inside sparkline SVG (fallback small labels) */
.fav-sheet svg .xaxis-label { font-size: 10px; fill: var(--text-secondary); }

/* sheet-info now inline with sheet-symbol (shows price and change) */
.fav-sheet .sheet-info { 
  color: var(--text-secondary); 
  font-size: 0.85rem; 
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

.fav-sheet .sheet-info div {
  display: flex;
  gap: 6px;
  align-items: center;
}

.fav-sheet .sheet-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* X axis label container under the sparkline: distribute labels evenly */
.fav-sheet .sheet-xaxis { width: 100%; height: 20px; overflow: hidden; }
.fav-sheet .sheet-xaxis .xaxis-wrap { margin-left:25px; margin-right:25px; display:flex; height: 20px; justify-content:space-between; gap:6px; margin-top:6px; }
.fav-sheet .sheet-xaxis .xaxis-label { flex: 1 1 auto; text-align:center; font-size:12px; color:var(--text-secondary); opacity:0.9; }

/* compact volume row displayed under the x-axis labels in the sheet */
.fav-sheet .sheet-volume { height: 30px; margin-top:6px; overflow: hidden; display: none; }
.fav-sheet .sheet-volume .volume-wrap { display:flex; align-items:flex-end; height:100%; gap:2px; }
.fav-sheet .sheet-volume .vol-bar { flex: 1 1 auto; display:block; }
.fav-sheet .sheet-volume .vol-inner { width:100%; background: rgba(0,0,0,0.12); border-radius: 2px; height:100%; transform-origin: bottom; }

/* only show volume row when sheet is open */
.fav-sheet.is-open .sheet-volume { display: block; }


/* Small screens: full height sheet */
@media (max-width: 599px) {
  .fav-sheet { height: 95vh; }
  .fav-sheet .sheet-sparkline { height: 120px; }
  
  /* Mobile: stack layout for favorite items */
  .favorite-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 0;
  }
  
  .favorite-meta {
    width: 100%;
    min-width: auto;
  }
  
  .favorite-sparkline {
    width: 100%;
    height: 40px;
  }
  
  .favorite-price-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;

  }
  
  .favorite-price {
    text-align: left;
    min-width: auto;
  }
}

.sheet-symbol {
  margin-left: 10px;
  font-weight: 800;
  font-size: 1.8rem;
}

/* Container for symbol + info shown inline (horizontally) */
.sheet-symbol-info {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.sheet-name {
  margin-left: 10px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* LLM analyze button and mockup area inside sheet-meta */
.sheet-meta { position: relative; }
.sheet-llm-btn {
  position: absolute;
  top: 50px;
  right: 8px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gradient-start, #7c3aed), var(--gradient-end, #38bdf8));
  color: white;
  border: none;
  box-shadow: 0 10px 30px rgba(124,58,237,0.18), 0 6px 18px rgba(56,189,248,0.08);
  cursor: pointer;
  z-index: 30;
}
.sheet-llm-btn svg { width:22px; height:22px; fill: currentColor; }
.sheet-llm-btn:active { transform: scale(0.98); }
.sheet-llm-btn.active { box-shadow: 0 18px 40px rgba(124,58,237,0.28), 0 8px 22px rgba(56,189,248,0.12); }

.sheet-llm {
  margin-top: 0px;
}
.sheet-llm .llm-mockbox {
    border: 4px solid var(--gradient-end);
    padding: 0px 10px;
    border-radius: 1px;
    background: linear-gradient(180deg, var(--gradient-start), var(--gradient-end));
    box-shadow: 0 6px 18px var(--gradient-start);
}
.sheet-llm .llm-title { font-weight:700; font-size:0.95rem; margin-bottom:6px; margin-top:3px;}
.sheet-llm .llm-content { color: var(--text-primary, inherit); font-size:0.9rem; max-height: 160px; overflow: hidden; transition: max-height 240ms ease, opacity 220ms ease; opacity: 0.95; }
.sheet-llm .llm-content.visible { max-height: 640px; }

/* Pulse glow animation for LLM analyze button */
@keyframes pulseGlow {
  0% {
    box-shadow: rgba(124, 58, 237, 0.10) 0px 8px 20px 0px, rgba(14, 165, 233, 0.08) 0px 4px 12px 0px;
  }
  50% {
    box-shadow: rgba(124, 58, 237, 0.306) 0px 19.7261px 47.1784px 0px, rgba(14, 165, 233, 0.19) 0px 11.7261px 29.0208px 0px;
  }
  100% {
    box-shadow: rgba(124, 58, 237, 0.08) 0px 6px 14px 0px, rgba(14, 165, 233, 0.06) 0px 3px 8px 0px;
  }
}

/* Apply the pulse on hover/active/when explicitly active */
.sheet-llm-btn:hover,
.sheet-llm-btn.active {
  animation: pulseGlow 2.4s ease-in-out infinite;
}

/* Prefer an outlined SVG icon inside the circular button. If JS inserts an SVG
   with filled paths, ensure we render it as an outline by forcing fill:none and
   using stroke=currentColor so the icon matches the button gradient color. */
.sheet-llm-btn svg { width:22px; height:22px; fill: none !important; stroke: currentColor !important; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Gradient border + subtle glow for the LLM result container. Uses border-image
   to draw a 1px gradient border and a complementary glow via box-shadow. */
.sheet-llm {
  margin-top: 1px;
  position: relative;
  padding: 0px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  box-shadow: 0 10px 30px rgba(124,58,237,0.08), 0 6px 18px rgba(14,165,233,0.06);
  /* Prevent flex shrinking to maintain consistent height */
  flex-shrink: 0;
}

/* Pop-up transform for LLM box when active: appears to emerge from background */
.sheet-llm {
  will-change: transform, opacity, filter, box-shadow;
  transform-origin: top center;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  filter: blur(2px) saturate(0.98);
  transition: transform 300ms cubic-bezier(.2,.9,.25,1), opacity 220ms ease, filter 260ms ease, box-shadow 320ms ease;
}

@keyframes llmPop {
  0% { transform: translateY(16px) scale(0.955); opacity: 0; filter: blur(3px) saturate(0.95); }
  55% { transform: translateY(-6px) scale(1.03); opacity: 0.86; filter: blur(0) saturate(1.04); }
  100% { transform: translateY(0) scale(1); opacity: 1; filter: none; }
}

.sheet-llm.active {
  /* play pop animation and strengthen glow/shadow; slightly slower fade-in for pleasant effect */
  animation: llmPop 520ms cubic-bezier(.2,.9,.25,1) both;
  transition: box-shadow 360ms ease, filter 360ms ease;
  box-shadow: 0 22px 70px rgba(124,58,237,0.22), 0 10px 34px rgba(14,165,233,0.10);
  z-index: 40;
}

/* When an active box is collapsed (content-only), override the animation
   and ensure it stays visible and compact. The content is hidden but title shows. */
.sheet-llm.active.content-collapsed {
  animation: none;
  height: 52px; /* fixed height for consistent collapsed appearance */
  overflow: hidden;
  transform: translateY(0) scale(1) !important;
  opacity: 1 !important;
  filter: none !important;
  box-shadow: 0 10px 30px rgba(124,58,237,0.08), 0 6px 18px rgba(14,165,233,0.06);
}

/* reduce pointer events when hidden to avoid accidental interactions */
.sheet-llm:not(.active):not(.collapsed):not(.content-collapsed) {
  /* When the LLM box is not active and not explicitly collapsed (either .collapsed or .content-collapsed),
     disable pointer events to avoid accidental interaction. Collapsed boxes intentionally remain 
     interactive so the user can tap the title to expand them. */
  pointer-events: none;
}

/* Collapsed LLM box: minimal header-only presentation; content hidden but the
   title remains clickable so users can expand it. */
.sheet-llm.collapsed {
  max-height: 52px;
  overflow: hidden;
  transition: max-height 260ms ease, opacity 220ms ease;
  pointer-events: auto; /* allow clicks on header */
  opacity: 0.96;
}
.sheet-llm.collapsed .llm-content {
  max-height: 0 !important;
  opacity: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden;
}

/* New: content-only collapse state. This hides only the content area while
   keeping the title/header visible and interactive so users can re-open it.
   Use !important to ensure this takes precedence over `.llm-content.visible`. */
.sheet-llm.content-collapsed {
  max-height: 52px; /* keep a compact header footprint */
  overflow: hidden;
  transition: max-height 260ms ease, opacity 220ms ease;
  pointer-events: auto; /* allow clicks on header/title */
  opacity: 0.96;
  /* Ensure collapsed boxes are visually present regardless of load order
     and override any base `.sheet-llm` opacity/transform rules. */
  opacity: 1 !important;
  transform: none !important;
  -webkit-transform: none !important;
  filter: none !important;
  -webkit-filter: none !important;
  display: block !important;
}
.sheet-llm.content-collapsed .llm-content {
  max-height: 0 !important;
  opacity: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  display: block; /* keep layout consistent; content collapsed via size/opacity */
}

/* Ensure the title remains a visible, focusable control when content-collapsed */
.sheet-llm.content-collapsed .llm-title {
  pointer-events: auto;
  cursor: pointer;
}

/* Make the title a click target and reserve space for a small collapse icon */
.sheet-llm .llm-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.llm-collapse-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  text-align: center;
  line-height: 18px;
  font-size: 12px;
  transform: rotate(0deg);
  transition: transform 200ms ease, opacity 160ms ease;
  opacity: 0.9;
}
.sheet-llm.collapsed .llm-collapse-icon { transform: rotate(-90deg); opacity: 0.95; }

/* Also apply a faint inner glow by adding a pseudo-element that overlays a
   soft gradient; keeps the content area clear while providing visual depth. */
.sheet-llm::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), inset 0 -8px 24px rgba(124,58,237,0.02);
}


/* Desktop / large tablet split view: show favorites list and sheet side-by-side
   When the body has .favorites-visible and viewport >= 768px (iPad mini portrait
   and up), allocate 30% width to #favoritesRoot on the left and 70% to the
   .fav-sheet on the right. The sheet becomes a right-side panel instead of
   a bottom sheet. */
.favorites-visible .fav-sheet .sheet-handle,
.favorites-visible .fav-sheet .close-btn {
  margin-right: 30px ;
}

@media (min-width: 686px) {
  #favoritesRoot .favorite-name { min-width:90px; text-wrap-mode: nowrap;}

  /* Ensure favorites host is visible when toggled */
  .favorites-visible #favoritesRoot {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40%;
    max-width: none;
    overflow: auto;
    z-index: 1000;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color, rgba(255,255,255,0.04));
    padding: 12px;
  }

  /* Right-side sheet: occupy remaining space */
  .favorites-visible .fav-sheet {
    position: fixed;
    bottom: 0;
    left: 40%;
    right: 0;
    width: 60%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    transition: none;
    z-index: 10;
    /* Use a column flex layout so the inner .sheet-body can grow and scroll
       while .sheet-meta remains sticky relative to that scroll container. */
    display: flex;
    flex-direction: column;
    /* Do not let the outer panel capture scroll; let the inner .sheet-body
       handle vertical scrolling. */
    overflow: hidden;
  }

  /* In split mode the sheet should appear open by default when toggled */
  .favorites-visible .fav-sheet.is-open { bottom: 0; }

  /* Hide the mobile sheet handle and the close button in split mode */
  .favorites-visible .fav-sheet .sheet-handle,
  .favorites-visible .fav-sheet .close-btn {
    display: none;
  }

  /* Adjust sparkline sizing inside the right panel - KEEP height: 600px for consistency */
  .favorites-visible .fav-sheet .sheet-sparkline { min-height: 450px; height: 600px; }
  /* DISABLED: Don't override SVG as it conflicts with LightweightCharts */
  /* .favorites-visible .fav-sheet .sheet-sparkline svg { width: calc(100% - 20px); } */

  /* ensure favorite list container margin doesn't add extra whitespace */
  .favorites-visible .favorite-container { margin: 0; max-width: none; }

  .fav-sheet{
    padding-top: 10px;
  }
  .fav-sheet .sheet-header {
    padding: 12px 20px;
  }
  .fav-sheet .sheet-footer {
    padding: 12px 20px;
  }
  .fav-sheet .sheet-stats {
    margin-left: 20px;
  }
  
}
@media (min-width: 1025px) {
  .favorites-visible #favoritesRoot {
     padding-left: 62px;
     padding-top: 60px;
  }

}

/* Desktop split-view: pin the sheet-meta so the sheet-body scrolls beneath it */
@media (min-width: 686px) {
  .favorites-visible .fav-sheet .sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }

  .favorites-visible .fav-sheet .sheet-meta {
    position: sticky;
    top: 0;
    z-index: 100;
    background: inherit;
    padding-top: 0px;
    padding-bottom: 0px;
  }

  /* subtle underline to separate meta from scrollable content */
  .favorites-visible .fav-sheet .sheet-meta {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: box-shadow 200ms ease, transform 160ms ease, border-color 180ms ease;
  }

  /* small 'lift' animation while dragging */
  .favorites-visible .fav-sheet .sheet-meta.is-dragging {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    border-bottom-color: rgba(255,255,255,0.08);
  }

  .favorites-visible .fav-sheet .sheet-sparkline,
  .favorites-visible .fav-sheet .sheet-xaxis,
  .favorites-visible .fav-sheet .sheet-volume,
  .favorites-visible .fav-sheet .sheet-stats {
    flex: 0 0 auto;
  }
}

/* Vertical draggable splitter between #favoritesRoot and .fav-sheet in split view */
.favorites-splitter {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 14px; /* hit target area */
  left: 40%;
  z-index: 1800;
  display: none !important; /* hidden by default - only show when .favorites-visible is on body */
  touch-action: none; /* we'll handle pointer events */
}
/* Only show splitter when favorites panel is visible AND on wide screens */
.favorites-visible .favorites-splitter { display: block !important; }
@media (max-width: 686px) {
  .favorites-visible .favorites-splitter { display: none !important; }
}
.favorites-splitter .split-handle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 50%;
  width: 4px;
  height: 120px;
  margin-top: -60px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.24);
  transition: background 120ms ease, width 120ms ease;
  pointer-events: none;
}
.favorites-splitter:hover .split-handle,
.favorites-splitter:focus-within .split-handle {
  background: rgba(255,255,255,0.08);
  height: 160px;
}
.favorites-splitter { cursor: col-resize; }

/* Make splitter accessible (focus outline) */
.favorites-splitter:focus { outline: none; }
.favorites-splitter:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,0.18); border-radius: 6px; }

/* tooltip shown near splitter while dragging */
.favorites-splitter .split-tooltip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.76);
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}
.favorites-splitter.dragging .split-tooltip { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.fav-sheet .sheet-header,
.favorites-visible .fav-sheet .sheet-meta{
  background: var(--card-bg);
}


/* Scoped token usage meta for favorites sheet only
   Selector: body > div.fav-sheet.is-open > div.sheet-body > div.sheet-meta > div.sheet-llm.active > div > div.token-usage-meta
   Copied properties from global .token-usage-meta in css/style.css so the token meta styling applies only inside the favorites sheet. */

body > div.fav-sheet.is-open > div.sheet-body > div.sheet-llm.active > div > div.token-usage-meta{
    font-size: 12px;
    color: #323232 !important;
    margin: 0 2px 4px 60px;
    line-height: 1.4;
    text-align: right;
}

/* Controls for technical overlay toggles shown next to the sheet sparkline */
.tech-overlay-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.tech-overlay-controls .tech-toggle-btn {
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15,23,42,0.06);
  color: var(--text-primary, #0f172a);
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.tech-overlay-controls .tech-toggle-btn.active {
  background: linear-gradient(180deg, rgba(99,102,241,0.12), rgba(99,102,241,0.08));
  border-color: rgba(99,102,241,0.28);
  color: #334155;
}
.tech-overlay-controls .tech-toggle-btn.inactive {
  opacity: 0.45;
}

/* compact layout for small screens: stack buttons */
@media (max-width: 480px) {
  .tech-overlay-controls { flex-wrap: wrap; gap:6px; }
  .tech-overlay-controls .tech-toggle-btn { padding: 6px 10px; font-size: 13px; }
}

  /* News panel styles inserted under sheet-stats */
  .fav-sheet .sheet-news {
    margin: 8px 20px 20px 20px;
    display: block;
    gap: 10px;
    color: var(--text-primary, #e6eef8);
    font-size: 0.95rem;
  }
  .fav-sheet .sheet-news .news-summary {
    background: linear-gradient(180deg, rgba(124,58,237,0.06), rgba(56,189,248,0.03));
    border: 1px solid rgba(124,58,237,0.12);
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(12,18,28,0.45);
    margin-bottom: 10px;
  }
  .fav-sheet .sheet-news .news-summary-heading {
    font-weight: 700;
    font-size: 0.98rem;
    margin-bottom: 8px;
    color: var(--text-primary, #fff);
  }
  .fav-sheet .sheet-news .news-summary-body {
    color: var(--text-secondary, #cbd5e1);
    line-height: 1.45;
    max-height: 120px;
    overflow: auto;
  }
  .fav-sheet .sheet-news .news-list { display:flex; flex-direction:column; gap:10px; }
  .fav-sheet .sheet-news .news-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.03);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .fav-sheet .sheet-news .news-item-header { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
  .fav-sheet .sheet-news .news-item-title { font-weight:700; font-size:0.95rem; color: var(--text-primary); }
  .fav-sheet .sheet-news .news-item-title a { color: inherit; text-decoration: none; }
  .fav-sheet .sheet-news .news-item-title a:hover { text-decoration: underline; }
  .fav-sheet .sheet-news .news-item-meta { color: var(--text-secondary); font-size:0.82rem; margin-left:8px; white-space:nowrap; }
  .fav-sheet .sheet-news .news-item-snippet { margin-top:0; color: var(--text-secondary); font-size:0.9rem; line-height:1.45; flex-grow: 1; }
  .fav-sheet .sheet-news .news-item-link { margin-top:0; }
  .fav-sheet .sheet-news .news-item-link a { color: var(--gradient-end, #38bdf8); text-decoration: none; font-weight:600; }
  .fav-sheet .sheet-news .news-item-link a:hover { text-decoration: underline; }
  .fav-sheet .sheet-news .news-empty,
  .fav-sheet .sheet-news .news-error { color: var(--text-secondary); padding: 8px 12px; font-size:0.95rem; }

  /* make news summary and list adapt on small screens */
  @media (max-width: 599px) {
    .fav-sheet .sheet-news { margin: 10px 12px; }
    .fav-sheet .sheet-news .news-summary-body { max-height: 160px; }
  }


body > div.fav-sheet.is-open > div.sheet-body > div.sheet-llm.active > div > div.llm-content.visible > p > strong:first-child  {
    font-size: 1rem;
    display: inline-grid;
    margin-top: 1rem;
}

/* Timeframe buttons (1D/1W/1M) for candlestick type switching */
.fav-timeframe-controls {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  padding: 0 8px;
  align-items: center;
  flex-wrap: wrap;
}

.fav-timeframe-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #ffffff);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 150ms ease;
  min-width: 40px;
  text-align: center;
}

.fav-timeframe-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.fav-timeframe-btn.active {
  background: linear-gradient(135deg, var(--gradient-start, #7c3aed), var(--gradient-end, #38bdf8));
  border-color: rgba(124, 58, 237, 0.6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.fav-timeframe-btn.active:hover {
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

/* Marker toggle button styling */
.fav-marker-toggle {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: var(--text-primary, #ffffff);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 150ms ease;
  white-space: nowrap;
}

.fav-marker-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.fav-marker-toggle.active {
  background: linear-gradient(135deg, var(--gradient-start, #7c3aed), var(--gradient-end, #38bdf8));
  border-color: rgba(124, 58, 237, 0.6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.fav-marker-toggle.active:hover {
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

/* Old checkbox styling - kept for backward compatibility */

/* Responsive layout for small screens */
@media (max-width: 599px) {
  .fav-timeframe-controls {
    gap: 6px;
    margin: 6px 0;
    padding: 0 6px;
  }
  
  .fav-timeframe-btn {
    padding: 5px 10px;
    font-size: 11px;
    min-width: 36px;
  }
  
  .fav-timeframe-controls label {
    font-size: 11px;
  }
}

/* Technical overlay label styling (tweakable from here)
   - Labels and their background rects are inserted with classes:
     .tech-label (text) and .tech-label-bg (rect)
   - Type-specific classes are added too: .tech-level-support, .tech-level-resistance,
     .tech-level-ema, .tech-level-sma, etc. Override CSS variables to change colors.
*/
.fav-sheet svg .tech-label {
  font-size: 11px;
  font-family: sans-serif;
  fill: var(--tech-label-color, #ffffff);
  pointer-events: none;
  dominant-baseline: middle;
}
.fav-sheet svg .tech-label-bg {
  /* default background and rounded corners; color controlled via type-specific rules below */
  fill: var(--tech-label-bg, rgba(0,0,0,0.6));
  opacity: 0.95;
  rx: 6px; /* rounded corners */
  pointer-events: none;
}

/* Type-specific colors (easy to override) */
.fav-sheet svg .tech-level-resistance .tech-label-bg { fill: var(--tech-resistance-bg, #ef4444); }
.fav-sheet svg .tech-level-support .tech-label-bg { fill: var(--tech-support-bg, #10b981); }
.fav-sheet svg .tech-level-ema .tech-label-bg { fill: var(--tech-ema-bg, #f97316); }
.fav-sheet svg .tech-level-sma .tech-label-bg { fill: var(--tech-sma-bg, #3b82f6); }

/* text color per type (if you'd like different contrast) */
.fav-sheet svg .tech-level-ema .tech-label { fill: var(--tech-ema-text, #ffffff); }
.fav-sheet svg .tech-level-sma .tech-label { fill: var(--tech-sma-text, #ffffff); }
.fav-sheet svg .tech-level-support .tech-label { fill: var(--tech-support-text, #ffffff); }
.fav-sheet svg .tech-level-resistance .tech-label { fill: var(--tech-resistance-text, #ffffff); }

/* EMA/SMA placed on the left via JS; ensure left labels don't get clipped on small widths */
.fav-sheet svg .tech-level-ema .tech-label,
.fav-sheet svg .tech-level-sma .tech-label {
  text-anchor: start; /* JS sets x=6 for these, but ensure CSS uses left alignment */
}

/* small padding tweak so the background rect doesn't touch the left edge */
.fav-sheet svg .tech-level-ema .tech-label-bg,
.fav-sheet svg .tech-level-sma .tech-label-bg {
  /* if you want to nudge the rect further right, adjust translateX below */
  transform-origin: 0 0;
}

/* make sure overlay controls and labels remain above decorative grid */
.fav-sheet svg g.tech-overlay { z-index: 4; }

/* 🔄 LAZY LOAD: Loading state for favorite items during price fetch */
#favoritesRoot .favorite-item.loading {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
}

#favoritesRoot .favorite-item.loading .favorite-price {
  animation: pulse-loading 1.5s ease-in-out infinite;
}

@keyframes pulse-loading {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
