:root {
  color-scheme: light;
  --widget-bg: #ffffff;
  --widget-surface: #f1f5f9;
  --widget-divider: #e2e8f0;
  --widget-text: #0f172a;
  --widget-muted: #52637a;
  --widget-brand: #0a84ff;
  --widget-positive: #30d158;
  --widget-negative: #ff453a;
  --widget-neutral: #8e8e93;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --widget-bg: #0a0a0a;
  --widget-surface: #1c1c1e;
  --widget-divider: rgba(255, 255, 255, 0.08);
  --widget-text: #ffffff;
  --widget-muted: #aab6c8;
}

:root[data-background="transparent"] { --widget-bg: transparent; }
:root[data-background="black"] {
  color-scheme: dark;
  --widget-bg: #0a0a0a;
  --widget-surface: #1c1c1e;
  --widget-divider: rgba(255, 255, 255, 0.08);
  --widget-text: #ffffff;
  --widget-muted: #aab6c8;
}
:root[data-background="slate"] {
  color-scheme: dark;
  --widget-bg: #0f172a;
  --widget-surface: #1e293b;
  --widget-divider: rgba(255, 255, 255, 0.1);
  --widget-text: #ffffff;
  --widget-muted: #cbd5e1;
}
:root[data-background="white"] {
  color-scheme: light;
  --widget-bg: #ffffff;
  --widget-surface: #f1f5f9;
  --widget-divider: #e2e8f0;
  --widget-text: #0f172a;
  --widget-muted: #52637a;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 0; background: var(--widget-bg); color: var(--widget-text); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
.widget { width: 100%; display: flex; flex-direction: column; background: var(--widget-bg); overflow: hidden; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 7px; border-bottom: 1px solid var(--widget-divider); }
.title { margin: 0; font-size: 16px; line-height: 1.25; font-weight: 700; }
.description { margin: 4px 0 0; color: var(--widget-muted); font-size: 13px; line-height: 1.35; }
.content { padding: 8px 10px; }
.powered { color: var(--widget-brand); font-size: 13px; font-weight: 700; line-height: 1.2; text-align: right; white-space: nowrap; }
.powered span { display: block; }
.rows { display: grid; gap: 6px; }
.row, .card { display: grid; gap: 4px; padding: 8px 9px; border-radius: 10px; background: var(--widget-surface); }
.row { grid-template-columns: minmax(72px, 1fr) auto auto; align-items: center; }
.entity { min-width: 0; display: flex; align-items: center; gap: 9px; }
.circularAvatar { position: relative; width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #fff; }
.avatarFallback { color: #334155; font-size: 10px; font-weight: 800; }
.circularAvatar .entityLogo { position: absolute; inset: 0; }
.entityLogo { width: 30px; height: 30px; flex: 0 0 auto; object-fit: contain; border-radius: 50%; padding: 2px; background: #fff; }
.name { min-width: 0; }
.code { display: block; font-size: 15px; font-weight: 800; }
.sub { display: block; color: var(--widget-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { font-size: 15px; font-weight: 800; text-align: right; }
.change { font-size: 13px; font-weight: 700; text-align: right; }
.positive { color: var(--widget-positive); }
.negative { color: var(--widget-negative); }
.neutral { color: var(--widget-neutral); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.indexCard { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; min-width: 0; }
.indexIdentity { min-width: 0; display: flex; align-items: center; gap: 9px; }
.indexLogo { padding: 0; border: 2px solid #fff; }
.indexQuote { min-width: 0; display: grid; justify-items: end; gap: 4px; }
.indexQuote .price { font-size: 18px; }
.indexChangeRow { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.indexChangeValue { font-size: 12px; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.indexMetrics { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 8px; border-top: 1px solid var(--widget-divider); }
.indexMetric { min-width: 0; display: grid; gap: 2px; }
.indexMetricLabel { color: var(--widget-muted); font-size: 11px; line-height: 1.25; }
.indexMetricValue { overflow: hidden; font-size: 13px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.goldList { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 6px; }
.gold { display: grid; gap: 8px; }
.goldUnavailable { align-content: center; }
.goldUnavailable .empty { margin: 0; }
.goldLine { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.goldLine strong { font-size: 16px; }
.goldValue { display: grid; justify-items: end; gap: 1px; }
.goldValue small { font-size: 11px; font-weight: 700; }
.goldMeta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; border-top: 1px solid var(--widget-divider); }
.miniChart { min-width: 0; }
.chartStockHeader { min-width: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: center; gap: 12px; }
.chartStockIdentity { min-width: 0; display: flex; align-items: center; gap: 9px; }
.chartStockIdentity .circularAvatar, .chartStockLogo { width: 36px; height: 36px; }
.chartStockIdentity .title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chartStockIdentity .sub { font-size: 13px; }
.chartStockQuote { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 2px 6px; }
.stockPrice { font-size: 20px; font-weight: 800; line-height: 1.1; text-align: right; }
.priceChangeBadge { min-width: 50px; display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border: 1px solid currentColor; border-radius: 8px; font-size: 12px; font-weight: 500; line-height: 1.25; white-space: nowrap; }
.priceChangeBadge.priceChangeInline { min-width: 0; padding: 0; border: 0; border-radius: 0; font-size: 13px; font-weight: 700; line-height: 1.35; }
.stockUpdated { grid-column: 1 / -1; color: var(--widget-muted); font-size: 12px; line-height: 1.35; text-align: right; }
.chartToolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.stockChoices, .rangeChoices { display: flex; gap: 2px; width: fit-content; max-width: 100%; padding: 3px; overflow-x: auto; border: 1px solid var(--widget-divider); border-radius: 999px; background: var(--widget-surface); scrollbar-width: none; }
.stockChoices::-webkit-scrollbar { display: none; }
.rangeChoices::-webkit-scrollbar { display: none; }
.stockChoices button, .rangeChoices button { min-width: 44px; min-height: 28px; padding: 4px 9px; border: 0; border-radius: 999px; color: var(--widget-muted); background: transparent; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.stockChoices button[aria-selected="true"] { color: #fff; background: var(--widget-brand); }
.rangeChoices button[aria-pressed="true"] { color: #fff; background: var(--widget-brand); }
.stockChoices button:focus-visible, .rangeChoices button:focus-visible { outline: 2px solid var(--widget-brand); outline-offset: 1px; }
.chartStage { position: relative; min-width: 0; }
.chartHost { width: 100%; height: 300px; }
.chartTooltip { position: absolute; z-index: 5; top: 0; left: 0; width: 116px; padding: 8px 10px; pointer-events: none; contain: layout paint style; visibility: hidden; opacity: 0; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 6px; color: #fff; background: #1c1c1e; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24); transform: translate3d(0, 0, 0); transition: opacity 80ms ease; will-change: transform; }
.chartTooltip.isVisible { visibility: visible; opacity: 1; }
.tooltipDate { margin-bottom: 5px; color: #a1a1aa; font-size: 11px; font-weight: 600; line-height: 1.2; }
.tooltipValue { display: flex; align-items: center; gap: 5px; color: #d4d4d8; font-size: 12px; font-weight: 500; line-height: 1.2; white-space: nowrap; }
.tooltipDot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--widget-brand); }
.tooltipPrice { color: #fff; font-size: 12px; font-weight: 700; }
.chartFallback { display: none; margin: 0; padding: 24px 0; color: var(--widget-muted); text-align: center; }
.miniChart.chartError .chartStage, .miniChart.chartError .stockChoices { display: none; }
.miniChart.chartError .chartFallback { display: block; }
.empty { color: var(--widget-muted); font-size: 14px; line-height: 1.45; padding: 12px 0; }

:root[data-size="compact"] .header { padding: 7px 8px 5px; }
:root[data-size="compact"] .title { font-size: 14px; }
:root[data-size="compact"] .description { margin-top: 2px; font-size: 12px; }
:root[data-size="compact"] .powered { font-size: 12px; }
:root[data-size="compact"] .content { padding: 5px 8px; }
:root[data-size="compact"] .rows,
:root[data-size="compact"] .grid { gap: 5px; }
:root[data-size="compact"] .row,
:root[data-size="compact"] .card { gap: 2px; padding: 5px 7px; border-radius: 8px; }
:root[data-size="compact"] .entity { gap: 7px; }
:root[data-size="compact"] .entityLogo { width: 24px; height: 24px; }
:root[data-size="compact"] .code,
:root[data-size="compact"] .price { font-size: 13px; }
:root[data-size="compact"] .sub { font-size: 10px; }
:root[data-size="compact"] .change { font-size: 11px; }
:root[data-size="compact"] .gold { gap: 5px; }
:root[data-size="compact"] .goldLine { font-size: 12px; }
:root[data-size="compact"] .goldLine strong { font-size: 14px; }
:root[data-size="compact"] .indexQuote .price { font-size: 15px; }
:root[data-size="compact"] .indexChangeRow { gap: 4px; }
:root[data-size="compact"] .indexChangeValue { font-size: 10px; }
:root[data-size="compact"] .indexMetrics { gap: 6px; padding-top: 5px; }
:root[data-size="compact"] .indexMetricLabel { font-size: 10px; }
:root[data-size="compact"] .indexMetricValue { font-size: 11px; }
:root[data-size="compact"] .chartStockIdentity .circularAvatar,
:root[data-size="compact"] .chartStockLogo { width: 30px; height: 30px; }
:root[data-size="compact"] .chartStockIdentity .sub { font-size: 12px; }
:root[data-size="compact"] .stockPrice { font-size: 18px; }
:root[data-size="compact"] .priceChangeBadge { min-width: 50px; padding: 2px 6px; font-size: 12px; }
:root[data-size="compact"] .priceChangeBadge.priceChangeInline { min-width: 0; padding: 0; font-size: 12px; }
:root[data-size="compact"] .chartHost { height: 240px; }

@media (max-width: 420px) {
  .row { grid-template-columns: minmax(64px, 1fr) auto; }
  .change { grid-column: 2; }
  .grid { grid-template-columns: 1fr; }
  .header { flex-wrap: wrap; }
  .chartStockHeader { width: 100%; justify-content: space-between; }
  .chartToolbar { align-items: flex-start; flex-direction: column; }
  .stockChoices, .rangeChoices { width: 100%; justify-content: flex-start; }
  .chartHost { height: 280px; }
  :root[data-size="compact"] .chartHost { height: 230px; }
}
