/* Altrady Charts preview page (charts.altrady.com/chart/:symbol).
 *
 * Colours come from Superchart's design tokens (--color-*, superchart-ui.css),
 * which are the app's V3 tokens: dark on :root, light under [data-theme="light"].
 * The layout sets data-theme on <html> before first paint, so the page and the
 * chart switch together. Nothing here is hard-coded to one theme.
 *
 * Served from public/ (see ChartsHelper#charts_asset_path), not app/assets: the
 * marketing layout links every stylesheet on the asset load path.
 *
 * Type scale: 10 / 12 / 14 / 16 / 18 px only.
 */

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--color-surface-global);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 16px;
}
:root[data-theme="light"] { color-scheme: light; }
:root:not([data-theme="light"]) { color-scheme: dark; }

.cp *, .cp *::before, .cp *::after, .cp-pop, .cp-pop * { box-sizing: border-box; }
.cp button, .cp input, .cp-pop button, .cp-pop input { font: inherit; color: inherit; }
/* Our own controls only: Superchart draws its own focus states inside the chart
   (an extra ring doubled up on its search fields), and text inputs show focus
   with their border. */
.cp :focus-visible:not(.cp-chart-mount *, input), .cp-pop :focus-visible:not(input) { outline: 2px solid var(--color-border-brand); outline-offset: 2px; }
.cp-chart-mount input:focus-visible { outline: none; }
[hidden] { display: none !important; }

.cp-muted { color: var(--color-text-tertiary); }
.cp-strong { color: var(--color-text-primary); font-weight: 500; }
.cp-small { font-size: 10px; line-height: 16px; }
.cp-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cp-link { color: var(--color-text-brand); }
.is-positive { color: var(--color-text-positive); }
.is-negative { color: var(--color-text-negative); }
.is-neutral { color: var(--color-text-tertiary); }

/* --- page frame: market row, then chart + side ------------------------------ */

.cp { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--color-surface-global); }

.cp-head {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; min-height: 57px;
  border-bottom: 1px solid var(--color-border-primary);
  background: var(--color-surface-global);
}
.cp-logo { display: inline-flex; align-items: center; flex: none; color: var(--color-text-primary); }
.cp-logo svg { display: block; }
.cp-head-sep { width: 1px; height: 24px; flex: none; background: var(--color-border-primary); }
.cp-pick {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 8px;
  border: 1px solid var(--color-border-primary); border-radius: 8px; background: transparent; cursor: pointer; white-space: nowrap;
}
.cp-pick-pair { font-size: 14px; line-height: 24px; font-weight: 600; }
.cp-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 8px;
  background: var(--color-surface-elevated); color: var(--color-text-secondary); font-size: 12px; font-weight: 500;
}
/* A disc behind an inset logo, as the desktop app's CoinLogo: coin artwork
   comes in any aspect ratio and with transparent corners. The letter under
   the image shows only when the logo fails to load (the img removes itself). */
.cp-coin {
  position: relative; width: 20px; height: 20px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-surface-elevated); color: var(--color-text-secondary); font-size: 10px; font-weight: 500; text-transform: none; overflow: hidden;
}
.cp-coin img {
  position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px);
  object-fit: contain; border-radius: 50%; background: var(--color-surface-elevated);
}
.cp-coin-lg { width: 24px; height: 24px; border-radius: 12px; }
.cp-coin-lg img { inset: 3px; width: 18px; height: 18px; }
.cp-exchange { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
.cp-exchange img { width: 12px; height: 12px; flex: none; border-radius: 3px; object-fit: contain; }
.cp-stat { display: flex; flex-direction: column; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-stat-label { color: var(--color-text-tertiary); }
.cp-price { font-family: var(--font-heading); font-size: 18px; line-height: 32px; font-weight: 600; }
.cp-spacer { flex: 1; }
.cp-live { display: inline-flex; align-items: center; gap: 8px; color: var(--color-text-tertiary); white-space: nowrap; }
.cp-live-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--color-text-positive); }
.cp-live-dot.is-off { background: var(--color-text-warning); }

.cp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.cp-btn-primary { background: var(--color-button-primary-default); color: var(--color-text-white); }
.cp-btn-default { background: var(--color-button-default-default); border-color: var(--color-button-default-border); color: var(--color-text-secondary); }
.cp-btn-subtle { background: transparent; color: var(--color-text-secondary); }
.cp-icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-secondary);
}
.cp-icon-btn > span { display: inline-flex; }
@media (hover: hover) {
  .cp-pick:hover { background: var(--color-surface-hover); }
  .cp-btn-primary:hover { background: var(--color-button-primary-hover); }
  .cp-btn-default:hover, .cp-btn-subtle:hover, .cp-icon-btn:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
}


.cp-body { flex: 1; min-height: 0; display: flex; }
.cp-chart { position: relative; flex: 1; min-width: 0; display: flex; }
.cp-chart-mount { flex: 1; min-width: 0; min-height: 0; }
.cp-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--color-surface-global); }

/* --- states ------------------------------------------------------------------ */

.cp-state { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.cp-state-title { margin: 0; font-family: var(--font-heading); font-size: 16px; line-height: 24px; font-weight: 600; }
.cp-state-text { margin: 0; color: var(--color-text-secondary); line-height: 18px; }
.cp-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cp-chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--color-border-primary); color: var(--color-text-secondary); text-decoration: none; white-space: nowrap;
}
@media (hover: hover) { .cp-chip:hover { background: var(--color-surface-hover); color: var(--color-text-primary); } }
.cp-skeleton { position: absolute; inset: 16px; display: flex; flex-direction: column; gap: 8px; }
.cp-skel {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--color-surface-elevated) 0%, var(--color-surface-hover) 50%, var(--color-surface-elevated) 100%);
  background-size: 200% 100%; animation: cp-shimmer 1.2s infinite;
}
.cp-skel-fill { flex: 1; }
@keyframes cp-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- side: panel + icon rail -------------------------------------------------- */

.cp-side { display: flex; flex: none; min-height: 0; border-left: 1px solid var(--color-border-primary); }
.cp-panel { width: 320px; display: flex; flex-direction: column; min-height: 0; background: var(--color-surface-global); }
.cp-panel > section { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cp-panel-head {
  /* 41px, border included: level with Superchart's top bar so the line runs straight. */
  box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 41px; padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--color-border-primary); white-space: nowrap;
}
.cp-panel-head .cp-muted { padding-right: 8px; }
.cp-panel-title { margin: 0; font-family: var(--font-heading); font-size: 16px; line-height: 24px; font-weight: 600; }
.cp-panel-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.cp-panel-note { margin: 0; padding: 16px; color: var(--color-text-tertiary); line-height: 18px; }
.cp-panel-skeleton { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.cp-panel-foot {
  display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--color-border-primary);
  color: var(--color-text-tertiary); text-decoration: none; line-height: 18px;
}
.cp-panel-foot svg { flex: none; margin-top: 1px; }
.cp-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 24px 16px; }
.cp-empty p { margin: 0; line-height: 18px; }

.cp-wl-cols, .cp-wl-link { display: grid; grid-template-columns: 1fr 88px 64px; gap: 8px; align-items: center; }
.cp-wl-cols { padding: 8px 48px 4px 16px; color: var(--color-text-tertiary); }
.cp-wl-cols span:nth-child(2), .cp-wl-cols span:nth-child(3) { text-align: right; }
.cp-wl-row { position: relative; display: flex; align-items: center; border-left: 2px solid transparent; }
.cp-wl-row.is-current { background: var(--color-surface-selected); border-left-color: var(--color-border-brand); }
.cp-wl-link { flex: 1; min-width: 0; height: 48px; padding-left: 14px; color: inherit; text-decoration: none; grid-template-columns: 20px 1fr 88px 64px; }
.cp-wl-name { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; overflow: hidden; }
.cp-wl-price, .cp-wl-change { text-align: right; }
.cp-wl-price { border-radius: 4px; padding: 0 4px; }
.cp-wl-remove { width: 24px; height: 24px; margin: 0 8px 0 4px; font-size: 16px; line-height: 16px; opacity: 0; }
.cp-wl-row:focus-within .cp-wl-remove { opacity: 1; }
@media (hover: hover) {
  .cp-wl-row:not(.is-current):hover { background: var(--color-surface-hover); }
  .cp-wl-row:hover .cp-wl-remove { opacity: 1; }
}
@media (hover: none) { .cp-wl-remove { opacity: 1; } }
.flash-up { animation: cp-flash-up .6s; }
.flash-down { animation: cp-flash-down .6s; }
@keyframes cp-flash-up { from { background: var(--color-positive-subtle); } }
@keyframes cp-flash-down { from { background: var(--color-negative-subtle); } }

.cp-ob { font-variant-numeric: tabular-nums; }
.cp-ob-cols, .cp-ob-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 0 16px; }
.cp-tr-cols, .cp-tr-row { grid-template-columns: 64px 1fr 1fr; }
.cp-ob-cols { padding-top: 8px; padding-bottom: 4px; color: var(--color-text-tertiary); }
.cp-ob-cols > :not(:first-child), .cp-ob-row > :not(:first-child) { text-align: right; }
.cp-ob-row { position: relative; height: 20px; align-items: center; white-space: nowrap; }
.cp-ob-row > span:not(.cp-ob-bar) { position: relative; }
.cp-ob-bar { position: absolute; right: 0; top: 1px; bottom: 1px; opacity: .14; pointer-events: none; }
.cp-ob-bar.is-ask { background: var(--color-text-negative); }
.cp-ob-bar.is-bid { background: var(--color-text-positive); }
.cp-ob-spread {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 16px; margin: 4px 0;
  border-top: 1px solid var(--color-border-primary); border-bottom: 1px solid var(--color-border-primary); white-space: nowrap;
}
.cp-ob-last { font-family: var(--font-heading); font-size: 16px; line-height: 24px; font-weight: 600; }

.cp-rail { width: 48px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-left: 1px solid var(--color-border-primary); }
.cp-rail-item {
  position: relative; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--color-text-secondary); text-decoration: none;
}
.cp-rail-item.is-active { background: var(--color-surface-brand-subtle); color: var(--color-text-brand); }
.cp-rail-label { display: none; white-space: nowrap; }
.cp-rail-lock {
  position: absolute; right: 3px; bottom: 3px; width: 12px; height: 12px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--color-surface-global); color: var(--color-text-tertiary);
}
/* Hover tooltips, as the app's TooltipBubble: to the left of the rail with an
   arrow at the button. CSS only; the hover media query keeps taps clean. */
.cp-tip {
  position: absolute; right: calc(100% + 10px); top: 50%; z-index: 30; transform: translate(4px, -50%);
  display: flex; flex-direction: column; gap: 4px; width: max-content; max-width: 240px; padding: 8px 12px; border-radius: 8px;
  background: var(--color-menu-background); border: 1px solid var(--color-border-primary); box-shadow: var(--shadow-overlay);
  color: var(--color-text-primary); text-align: left; white-space: normal; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 0s 120ms;
}
.cp-tip::after {
  content: ""; position: absolute; left: 100%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; transform: rotate(45deg);
  background: var(--color-menu-background); border: solid var(--color-border-primary); border-width: 1px 1px 0 0;
}
.cp-tip-title { font-size: 12px; line-height: 16px; font-weight: 500; }
.cp-tip-body { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); }
.cp-tip-lock { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--color-text-brand); }
.cp-tip:has(.cp-tip-body) { width: 240px; padding: 12px 14px; }
.cp-tip:has(.cp-tip-body) .cp-tip-title { font-size: 14px; line-height: 20px; font-weight: 600; }
@media (hover: hover) {
  .cp-rail-item:hover .cp-tip, .cp-rail-item:focus-visible .cp-tip {
    opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: 150ms, 150ms, 0s;
  }
}
.cp-rail-sep { width: 24px; height: 1px; margin: 4px 0; background: var(--color-border-primary); flex: none; }
@media (hover: hover) { .cp-rail-item:not(.is-active):hover { background: var(--color-surface-hover); color: var(--color-text-primary); } }

/* --- coin info (Market Explorer data) ------------------------------------------ */

.cp-btn-sm { height: 24px; padding: 0 8px; gap: 6px; font-size: 12px; }
.cp-faint { color: var(--color-text-tertiary); opacity: .6; }
.cp-link-btn { padding: 0; border: 0; background: none; color: var(--color-text-brand); font: inherit; cursor: pointer; }
.cp-ci-section { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-bottom: 1px solid var(--color-border-primary); }
.cp-ci-section:last-child { border-bottom: 0; }
.cp-ci-title { margin: 0; font-family: var(--font-heading); font-size: 14px; line-height: 20px; font-weight: 600; }
.cp-ci-hint { margin: 0; color: var(--color-text-tertiary); line-height: 16px; }
.cp-ci-coin { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cp-ci-coin .cp-coin { width: 32px; height: 32px; border-radius: 16px; font-size: 14px; }
.cp-ci-coin .cp-coin img { inset: 4px; width: 24px; height: 24px; }
.cp-ci-name { font-family: var(--font-heading); font-size: 18px; line-height: 24px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-ci-price { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.cp-ci-usd { font-family: var(--font-heading); font-size: 24px; line-height: 32px; font-weight: 600; }
.cp-ci-change { font-weight: 500; }
.cp-ci-crosses { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.cp-ci-range-head { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.cp-ci-range { position: relative; height: 4px; border-radius: 2px; background: var(--color-border-primary); margin: 2px 0 6px; }
.cp-ci-range-fill { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.cp-ci-range-fill.is-up { background: var(--color-text-positive); }
.cp-ci-range-fill.is-down { background: var(--color-text-negative); }
.cp-ci-range-mark {
  position: absolute; top: 8px; width: 0; height: 0; transform: translateX(-5px);
  border: 5px solid transparent; border-top: 0; border-bottom: 6px solid var(--color-text-primary);
}
.cp-ci-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.cp-ci-stats div { display: flex; flex-direction: column; min-width: 0; }
.cp-ci-stats dt { color: var(--color-text-tertiary); }
.cp-ci-stats dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-ci-ta { display: flex; flex-direction: column; gap: 16px; padding: 16px 12px 12px; border: 1px solid var(--color-border-primary); border-radius: 16px; }
.cp-ci-gauge { position: relative; align-self: center; display: flex; flex-direction: column; align-items: center; width: 144px; height: 76px; justify-content: flex-end; }
.cp-ci-gauge svg { position: absolute; inset: 0; }
.cp-ci-signal { font-family: var(--font-heading); font-size: 16px; line-height: 20px; font-weight: 600; }
.cp-ci-signal.is-neutral { color: var(--color-text-secondary); }
.cp-ci-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; }
.cp-ci-score { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.cp-ci-score > span:last-child { font-family: var(--font-heading); font-size: 16px; line-height: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cp-ci-score .is-neutral { color: var(--color-text-secondary); }
.cp-ci-frames { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 4px; }
.cp-ci-frame {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; text-align: center;
  font-size: 10px; line-height: 14px; font-weight: 500; border: 1px solid transparent;
}
.cp-ci-frame .cp-muted { font-size: 12px; line-height: 16px; font-weight: 400; }
.cp-ci-frame.is-positive { background: var(--color-positive-subtlest, var(--color-positive-subtle)); }
.cp-ci-frame.is-negative { background: var(--color-negative-subtlest, var(--color-negative-subtle)); }
.cp-ci-frame.is-neutral { border-color: var(--color-border-primary); color: var(--color-text-secondary); }
.cp-ci-perf { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cp-ci-perf th, .cp-ci-perf td { padding: 6px 0; text-align: right; font-weight: 400; white-space: nowrap; }
.cp-ci-perf thead th { color: var(--color-text-tertiary); }
.cp-ci-perf tbody th { text-align: left; color: var(--color-text-secondary); }
.cp-ci-perf tbody tr + tr { border-top: 1px solid var(--color-border-primary); }
.cp-ci-perf td.is-neutral { color: var(--color-text-secondary); }
.cp-ci-links { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 -8px; }
.cp-ci-about { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cp-ci-about p { margin: 0; line-height: 18px; color: var(--color-text-secondary); }
.cp-ci-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cp-ci-chip { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 8px; background: var(--color-surface-elevated); color: var(--color-text-secondary); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* --- market search popover ---------------------------------------------------- */

.cp-pop {
  position: absolute; z-index: 1000; padding: 8px 0; border-radius: 16px; border: 1px solid var(--color-border-primary);
  background: var(--color-menu-background); box-shadow: var(--shadow-overlay); color: var(--color-text-primary);
  font-family: var(--font-sans); font-size: 12px; line-height: 16px;
}
.cp-search-bar { display: flex; gap: 8px; padding: 4px 12px 8px; }
.cp-search-bar .cp-input { flex: 1; min-width: 0; }
.cp-ex-select {
  display: inline-flex; align-items: center; gap: 6px; flex: none; max-width: 45%; height: 40px; padding: 0 8px 0 10px;
  border: 1px solid var(--color-border-primary); border-radius: 8px; background: transparent; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.cp-ex-select .cp-exchange { overflow: hidden; }
.cp-ex-select .cp-exchange img { width: 14px; height: 14px; }
.cp-ex-select.is-open { border-color: var(--color-border-brand); }
.cp-ex-select.is-open svg { transform: rotate(180deg); }
.cp-groups { display: flex; gap: 4px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.cp-groups::-webkit-scrollbar { display: none; }
.cp-group {
  flex: none; height: 28px; padding: 0 12px; border: 1px solid var(--color-border-primary); border-radius: 8px;
  background: transparent; color: var(--color-text-secondary); cursor: pointer; white-space: nowrap;
}
.cp-group.is-active { background: var(--color-surface-brand-subtle); border-color: transparent; color: var(--color-text-brand); font-weight: 500; }
.cp-tag {
  display: inline-flex; align-items: center; height: 16px; padding: 0 4px; border-radius: 4px; flex: none;
  background: var(--color-surface-elevated); color: var(--color-text-secondary); font-size: 10px; font-weight: 500; vertical-align: 1px;
}
@media (hover: hover) {
  .cp-ex-select:hover, .cp-group:not(.is-active):hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
}
.cp-input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--color-border-primary);
  background: var(--color-surface-global); font-size: 14px; line-height: 20px; outline: none;
}
.cp-input:focus { border-color: var(--color-border-brand); }
.cp-pop-heading { padding: 4px 16px 8px; color: var(--color-text-tertiary); }
.cp-search-results { max-height: 340px; overflow-y: auto; }
.cp-pop-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 4px 16px;
  border: 0; background: transparent; cursor: pointer; text-align: left;
}
.cp-pop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; white-space: nowrap; }
.cp-check { width: 16px; color: var(--color-text-brand); }
@media (hover: hover) { .cp-pop-item:hover { background: var(--color-menu-item-bg-hover); } }

/* --- phone width: Chart / panel tabs, horizontal rail ------------------------- */

/* --- sign-up dialog ------------------------------------------------------------- */

.cp-dialog {
  /* Centred again: the page's base styles zero the margins <dialog> centres with. */
  position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100dvh - 32px);
  width: min(400px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--color-border-primary); border-radius: 16px;
  background: var(--color-menu-background); color: var(--color-text-primary); box-shadow: var(--shadow-overlay);
}
.cp-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.cp-dialog::backdrop { background: var(--color-surface-scrim, rgba(0, 0, 0, .5)); }
.cp-dialog-close { position: absolute; top: 12px; right: 12px; margin: 0; }
.cp-dialog-art { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 56px; height: 40px; margin-bottom: 4px; }
.cp-dialog-art span { border-radius: 4px; border: 1px solid var(--color-border-brand); background: var(--color-surface-brand-subtle); }
.cp-dialog-title { margin: 0; padding-right: 32px; font-family: var(--font-heading); font-size: 18px; line-height: 24px; font-weight: 600; text-wrap: balance; }
.cp-dialog-text { margin: 0; color: var(--color-text-secondary); line-height: 18px; }
.cp-dialog-actions { display: flex; gap: 8px; margin-top: 8px; }
.cp-dialog-actions .cp-btn { flex: 1; height: 40px; font-size: 14px; }

.cp-feature { width: min(640px, calc(100vw - 32px)); padding: 0; overflow: hidden auto; }
.cp-feature[open] { gap: 0; }
.cp-feature .cp-dialog-close { z-index: 1; }
.cp-feature .cp-dialog-close .cp-icon-btn { background: var(--color-menu-background); }
.cp-feature-media { aspect-ratio: 16 / 10; max-width: 100%; background: var(--color-surface-pane, #0c0c0d); border-bottom: 1px solid var(--color-border-primary); }
.cp-feature-media video, .cp-feature-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cp-feature-body { display: flex; flex-direction: column; gap: 8px; padding: 20px 24px 24px; }
.cp-feature-eyebrow { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--color-text-brand); font-size: 12px; font-weight: 500; }
@media (max-width: 520px) {
  .cp-feature-body { padding: 16px; }
  /* Stacked, flex: 1 would size them from a zero basis and squash them. */
  .cp-feature .cp-dialog-actions { flex-direction: column; }
  .cp-feature .cp-dialog-actions .cp-btn { flex: none; height: 44px; }
}

/* --- phone and tablet menu ------------------------------------------------------ */

.cp-menu-btn, .cp-back { display: none; }
.cp-drawer { position: fixed; inset: 0; z-index: 60; }
.cp-drawer-scrim { position: absolute; inset: 0; background: var(--color-surface-scrim, rgba(0, 0, 0, .5)); opacity: 0; transition: opacity 200ms ease-out; }
.cp-drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--color-surface-global); border-right: 1px solid var(--color-border-primary); box-shadow: var(--shadow-overlay);
  transform: translateX(-100%); transition: transform 200ms ease-out; outline: none;
}
.cp-drawer.is-open .cp-drawer-scrim { opacity: 1; }
.cp-drawer.is-open .cp-drawer-panel { transform: none; }
.cp-drawer-head { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 8px 0 16px; flex: none; }
.cp-drawer-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--color-text-primary); font-family: var(--font-heading); font-size: 14px; font-weight: 600; }
.cp-drawer-logo svg { display: block; }
.cp-drawer-group { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--color-border-primary); }
.cp-drawer-label { margin: 0; padding: 4px 16px 4px; color: var(--color-text-tertiary); }
.cp-drawer-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 16px; border: 0; background: transparent;
  color: var(--color-text-primary); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.cp-drawer-item > svg:first-child { color: var(--color-text-secondary); flex: none; width: 16px; }
.cp-drawer-item > span:not([class]) { flex: 1; }
.cp-drawer-lock { color: var(--color-text-tertiary); }
.cp-drawer-cta, .cp-drawer-cta > svg:first-child { color: var(--color-text-brand); }
.cp-switch { position: relative; width: 36px; height: 20px; flex: none; border-radius: 10px; background: var(--color-surface-elevated); transition: background 150ms; }
.cp-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 8px;
  background: var(--color-text-white, #fff); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform 150ms;
}
[aria-checked="true"] > .cp-switch { background: var(--color-button-primary-default); }
[aria-checked="true"] > .cp-switch::after { transform: translateX(16px); }
@media (hover: hover) { .cp-drawer-item:hover { background: var(--color-surface-hover); } }

/* Small laptops: keep the market row on one line. */
@media (max-width: 1180px) {
  .cp-hide-lg { display: none; }
}

/* Phones and tablets: one-row market header, the menu instead of the rail, and
   panels full screen over the chart with a back arrow. */
@media (max-width: 900px) {
  .cp-head { flex-wrap: nowrap; gap: 12px; padding: 8px 12px 8px 8px; min-height: 0; }
  .cp-hide-md { display: none; }
  .cp-menu-btn, .cp-back { display: inline-flex; }
  .cp-panel-head { padding-left: 4px; justify-content: flex-start; }
  .cp-panel-head .cp-panel-title { flex: 1; min-width: 0; }
  .cp-pick { min-width: 0; flex: 0 1 auto; }
  .cp-pick-pair { overflow: hidden; text-overflow: ellipsis; }
  .cp-body[data-view="chart"] .cp-side, .cp-body[data-view="side"] .cp-chart { display: none; }
  .cp-side { flex: 1; border-left: 0; }
  .cp-panel { width: 100%; flex: 1; }
  .cp-rail { display: none; }
  .cp-tip { display: none; }
  /* iOS Safari zooms the page into any field under 16px when it gets focus. */
  .cp-pop .cp-input { font-size: 16px; }
  .cp-wl-remove { opacity: 1; }
  /* Superchart's own toolbars are wider than a phone: let them scroll, not clip. */
  .cp-chart-mount .superchart-top-bar, .cp-chart-mount .superchart-bottom-bar { overflow-x: auto; scrollbar-width: none; }
  .cp-chart-mount .superchart-top-bar::-webkit-scrollbar, .cp-chart-mount .superchart-bottom-bar::-webkit-scrollbar { display: none; }
}

@media (max-width: 520px) {
  .cp-hide-sm { display: none; }
  .cp-head { gap: 8px; }
  .cp-pick { height: 36px; gap: 6px; padding: 0 8px 0 6px; }
  .cp-badge [data-exchange-name] { display: none; }
  .cp-badge { padding: 0 4px; }
  .cp-stat-change .cp-stat-label { display: none; }
  .cp-price { font-size: 16px; line-height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-skel, .flash-up, .flash-down { animation: none; }
}

/* A library preview on a phone: the frame is small, so the market header goes
   and the plot gets the height. The market is fixed by the page around it, and
   "Add to chart" opens the full terminal. */
@media (max-width: 640px) {
  .cp--embed .cp-head { display: none; }
}
