
:root {
  color-scheme: dark;
  --bg: #070a0f;
  --surface: #0d1118;
  --surface-raised: #121824;
  --surface-hover: #182132;
  --border: #243043;
  --text: #f4f7fb;
  --text-secondary: #93a4b8;
  --text-muted: #5f7086;
  --accent: #14f195;
  --accent-secondary: #8b5cf6;
  --accent-cyan: #22d3ee;
  --buy: #16c784;
  --sell: #ea3943;
  --warning: #f5b849;
  --danger: #ff5c7a;
  --shadow: 0 12px 40px rgb(0 0 0 / 0.28);
  --avatar-bg: #d8e0ea;
  --avatar-fg: #1c2534;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-raised: #f0f4fa;
  --surface-hover: #e8eef7;
  --border: #d5dfec;
  --text: #101724;
  --text-secondary: #4e6076;
  --text-muted: #7a8ba1;
  --accent: #059669;
  --accent-secondary: #7c3aed;
  --accent-cyan: #0284c7;
  --buy: #0e9f6e;
  --sell: #d92d3a;
  --warning: #b7791f;
  --danger: #d9365e;
  --shadow: 0 12px 36px rgb(16 23 36 / 0.12);
  --avatar-bg: #1c2534;
  --avatar-fg: #d8e0ea;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  transform: translateY(-140%);
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  padding: 10px clamp(12px, 2vw, 24px);
  backdrop-filter: blur(14px);
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/*
 * The sidebar lives below the sticky top-nav in normal document flow (not an overlay), so it
 * structurally can never cover it -- collapsing only ever changes its width, never its
 * position. Two layers on purpose: .sidebar itself has no position/height rules of its own, so
 * the flex row's default stretch alignment makes it run the full remaining page height
 * (edge-to-edge, pump.fun-style) even on a page taller than the viewport. .sidebar-inner is
 * the one that's actually sticky, capped to the viewport height -- if position:sticky were put
 * on .sidebar directly instead, its height would equal its own containing block's height
 * (they're stretched to match), leaving sticky with zero room to move within its container and
 * silently doing nothing while the whole box scrolled away with the page.
 *
 * No overflow rule on .sidebar itself, on purpose: overflow:hidden (or any value other than
 * visible) on an ancestor of a position:sticky element makes that ancestor the sticky
 * element's scrolling container per the CSS spec, even though it never actually scrolls
 * itself (it just clips). .sidebar-inner would then stick relative to .sidebar's own box --
 * which scrolls away with the page -- instead of relative to the real viewport, breaking
 * sticky entirely once the page is taller than one screen. .sidebar-inner already has its own
 * overflow-x: hidden below to clip collapsed-state content, so nothing here needs to
 * duplicate that.
 */
.sidebar {
  flex: 0 0 208px;
  width: 208px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  transition: flex-basis 0.15s ease, width 0.15s ease, border-color 0.15s ease;
}

/* display: flex + column, with min-height matching max-height, so .sidebar-footer (the
   Shrink/Expand toggle) can be pushed all the way to the bottom of the visible viewport via
   margin-top: auto -- without a real height here the column would only hug its own content
   and the footer would sit right after the last nav link instead of pinned to the bottom. */
.sidebar-inner {
  position: sticky;
  top: 64px;
  min-height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Collapses to a narrow icon-only rail: every item (including the footer toggle) keeps its
   icon and just hides its text label -- see .sidebar.collapsed .sidebar-nav a span,
   .sidebar.collapsed .sidebar-toggle span below. */
.sidebar.collapsed {
  flex-basis: 60px;
  width: 60px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 8px 8px 12px;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 8px;
}

/* .sidebar-toggle sits in .sidebar-footer, below the nav links, styled identically to the
   a. links above it (same layout/spacing/type) so it still reads as a menu item rather than
   a separate control bolted onto the sidebar. */
.sidebar-nav a,
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.sidebar-nav a svg,
.sidebar-toggle svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-toggle-icon-chevron {
  transform: none;
}

/* Collapsed shows a menu (hamburger) icon instead of the collapse chevron -- a clearer "open
   the sidebar" affordance than a lone chevron once the sidebar itself is down to its icon
   rail. */
.sidebar-toggle-icon-menu {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-icon-chevron {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-icon-menu {
  display: block;
}

.sidebar-nav a span,
.sidebar-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-nav a span,
.sidebar.collapsed .sidebar-toggle span {
  display: none;
}

.sidebar-nav a[data-admin-nav][hidden] {
  display: none;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus-visible,
.sidebar-nav a[aria-current="page"],
.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  background: var(--surface-raised);
  color: var(--text);
  outline: none;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.token-avatar {
  background: var(--avatar-bg);
}

.selected-visual {
  background:
    linear-gradient(135deg, rgb(20 241 149 / 0.92), rgb(34 211 238 / 0.64) 46%, rgb(139 92 246 / 0.82)),
    var(--surface-raised);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
}

.brand-mark img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.brand-mark svg,
.nav-actions svg,
.search-wrap svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  color: #07100d;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-name {
  display: inline-flex;
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.3px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-name-curve {
  color: var(--text);
}

.brand-name-radar {
  color: var(--accent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 65%, transparent);
}

.brand-subtitle {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}


.icon-button,
.wallet-button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
}

.wallet-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 500;
}

.wallet-button.connected {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--surface-hover);
  color: var(--text);
  outline: none;
}

.wallet-button:hover,
.wallet-button:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--surface-hover);
  outline: none;
}

.wallet-button.connected:hover,
.wallet-button.connected:focus-visible {
  border-color: transparent;
  background: var(--surface-hover);
}

.wallet-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.wallet-button-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-size: 11px;
  font-weight: 750;
}

.wallet-button-avatar[hidden] {
  display: none;
}

.wallet-button-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wallet-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  background: rgb(3 6 12 / 0.4);
  padding: calc(56px + 8px) 16px 16px;
}

.wallet-popover-backdrop[hidden] {
  display: none;
}

.wallet-popover {
  width: min(100%, 320px);
  max-height: 80vh;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.wallet-popover-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.wallet-popover-section {
  display: grid;
  gap: 6px;
}

.wallet-popover-total {
  font-size: 26px;
  font-weight: 800;
}

.wallet-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wallet-popover-sol {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  padding: 4px 10px 4px 6px;
  font-size: 12px;
  font-weight: 720;
}

.wallet-popover-sol-icon {
  width: 14px;
  height: 14px;
}

.wallet-popover-address-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.wallet-popover-address-row code {
  overflow: hidden;
  color: var(--text-secondary);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-popover-copy {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.wallet-popover-copy:hover {
  color: var(--text-secondary);
  background: var(--surface-raised);
}

.wallet-popover-copy-icon-copy,
.wallet-popover-copy-icon-check {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wallet-popover-copy-icon-check {
  display: none;
  color: var(--buy);
}

.wallet-popover-copy.copied .wallet-popover-copy-icon-copy {
  display: none;
}

.wallet-popover-copy.copied .wallet-popover-copy-icon-check {
  display: block;
}

.wallet-popover-provider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 720;
}

.wallet-popover-provider svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wallet-popover-positions-head {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.wallet-popover-positions {
  display: grid;
  gap: 6px;
}

.wallet-popover-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.wallet-popover-position {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wallet-popover-position-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-size: 10px;
  font-weight: 850;
}

.wallet-popover-position-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wallet-popover-position-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-popover-position-meta {
  color: var(--text-muted);
  font-size: 11px;
}

.wallet-popover-position-value {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 720;
  text-align: right;
}

.wallet-popover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wallet-popover-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
}

.wallet-popover-profile svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.wallet-popover-profile:hover,
.wallet-popover-profile:focus-visible {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-raised));
}

.wallet-popover-disconnect {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--sell);
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
}

.wallet-popover-disconnect:hover {
  background: color-mix(in srgb, var(--sell) 14%, var(--surface-raised));
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:not(:disabled) {
  cursor: pointer;
}

button:not(:disabled):hover,
button:not(:disabled):focus-visible {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--border));
  outline: none;
}

.terminal {
  position: relative;
  width: min(100%, 1760px);
  margin: 0 auto;
  padding: clamp(12px, 2vw, 22px);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.search-wrap {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
}

.search-wrap svg {
  color: var(--text-muted);
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgb(3 6 12 / 0.6);
  backdrop-filter: blur(2px);
  padding: 12vh 16px 16px;
}

.search-dialog-backdrop[hidden] {
  display: none;
}

.search-dialog {
  width: min(100%, 640px);
  max-height: 76vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}

.search-dialog .search-wrap {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  min-height: 46px;
}

.search-dialog-close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.search-dialog-close:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.search-dialog-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-dialog .search-results {
  margin-top: 12px;
}

.market-tabs {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.market-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
  height: auto;
  padding: 0 14px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 720;
}

.market-tabs button svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.market-tabs button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-tabs button[aria-selected="true"] {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.filter-toggle {
  position: relative;
  align-self: center;
  flex: 0 0 auto;
}

.filter-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filter-toggle.active::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface-raised);
}

/*
 * Scoped to .terminal (the market section itself, which sits alongside the sidebar and below
 * the sticky top-nav in .app-body) rather than position: fixed to the whole viewport, so
 * opening filters dims and slides over only the screener content -- the sidebar and header
 * stay fully visible and interactive.
 */
.filter-drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: flex;
  justify-content: flex-end;
  background: rgb(3 6 12 / 0);
  transition: background 0.22s ease;
}

.filter-drawer-backdrop[hidden] {
  display: none;
}

.filter-drawer-backdrop.open {
  background: rgb(3 6 12 / 0.6);
}

.filter-drawer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 320px);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.filter-drawer-backdrop.open .filter-drawer {
  transform: translateX(0);
}

.filter-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-drawer-header h2 {
  font-size: 15px;
}

.filter-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.filter-field span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.filter-field select,
.filter-field input {
  width: 100%;
  height: 36px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
}

.filter-reset {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 0 10px;
  cursor: pointer;
}

.filter-reset[hidden] {
  display: none;
}

.filter-reset:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text);
}

.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.search-results[hidden] {
  display: none;
}

.search-result {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.search-result:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--border));
  outline: none;
}

.search-result-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.search-result-icon img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.search-result-title,
.search-result-subtitle,
.search-result-kind {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
}

.search-result-subtitle {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11px;
}

.search-result-kind {
  max-width: 72px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 780;
  text-align: right;
  text-transform: uppercase;
}

.screener-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 12px;
}

.table-panel,
.side-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.panel-heading:has(.market-tabs) {
  min-height: 44px;
  padding: 6px 8px;
}

.panel-heading > div {
  flex: 1;
  min-width: 0;
}

.panel-heading.compact {
  min-height: auto;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-heading p {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  height: 44px;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr {
  background: var(--surface);
}

tbody tr:hover,
tbody tr[aria-selected="true"] {
  background: var(--surface-hover);
}

td {
  color: var(--text-secondary);
  font-size: 13px;
}

.token-cell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.token-cell.has-rank {
  grid-template-columns: 26px 34px minmax(0, 1fr);
}

/* Trending position: a crown for the top three (gold, silver, bronze), the number for the rest. */
.token-rank {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.token-rank svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.token-rank.rank-1 {
  color: #f5b301;
}

.token-rank.rank-2 {
  color: #aeb8c4;
}

.token-rank.rank-3 {
  color: #cd7f32;
}

.token-card.has-rank {
  position: relative;
}

.token-card > .token-rank {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--surface, #0b0f14);
  font-size: 10px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.token-card > .token-rank svg {
  width: 14px;
  height: 14px;
}

.token-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  color: var(--avatar-fg);
  font-size: 12px;
  font-weight: 850;
}

.token-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.token-name,
.token-symbol {
  display: block;
  overflow: hidden;
  max-width: 240px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-name {
  color: var(--text);
  font-weight: 760;
}

.token-symbol {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.positive {
  color: var(--buy);
}

.negative {
  color: var(--sell);
}

/*
 * One-shot flash on price/PnL cells when auto-refresh brings in a changed value (see
 * computeFlashMap). No animation-fill-mode is set, so once the animation ends the browser
 * falls back to each cell's normal static color (e.g. .positive/.negative) automatically --
 * the "fade back to the original color" happens for free, no JS cleanup needed. These classes
 * are only ever applied to a freshly created element, so the animation always plays from 0%.
 */
@keyframes flash-glow-up {
  0% {
    color: var(--buy);
    text-shadow: 0 0 10px color-mix(in srgb, var(--buy) 80%, transparent), 0 0 20px color-mix(in srgb, var(--buy) 40%, transparent);
  }
  100% {
    color: inherit;
    text-shadow: none;
  }
}

@keyframes flash-glow-down {
  0% {
    color: var(--sell);
    text-shadow: 0 0 10px color-mix(in srgb, var(--sell) 80%, transparent), 0 0 20px color-mix(in srgb, var(--sell) 40%, transparent);
  }
  100% {
    color: inherit;
    text-shadow: none;
  }
}

.flash-up {
  animation: flash-glow-up 1.1s ease-out;
}

.flash-down {
  animation: flash-glow-down 1.1s ease-out;
}

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

.risk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 24px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 780;
}

.risk.low {
  background: color-mix(in srgb, var(--buy) 15%, transparent);
  color: var(--buy);
}

.risk.medium {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}

.risk.high {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

.risk.unknown {
  background: color-mix(in srgb, var(--text-muted) 15%, transparent);
  color: var(--text-secondary);
}

.watch-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.watch-toggle:hover {
  border-color: var(--border);
  color: var(--text-secondary);
}

.watch-toggle.active {
  color: var(--warning);
}

.watch-toggle:disabled {
  cursor: default;
  opacity: 0.6;
}

.token-card-head .watch-toggle {
  margin-left: auto;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-bottom: 12px;
}

.launchpad-section {
  display: grid;
  gap: 8px;
  padding: 0 12px;
}

.launchpad-section h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.launchpad-list {
  display: grid;
  gap: 6px;
}

.launchpad-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 6px 8px;
  cursor: pointer;
}

.launchpad-item:hover,
.launchpad-item:focus-visible {
  background: var(--surface-hover);
}

.launchpad-item .token-avatar {
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.launchpad-item-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launchpad-item-meta {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launchpad-item-price {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

.launchpad-list .empty-state {
  padding: 10px;
  font-size: 12px;
}

.card-grid {
  display: none;
}

.token-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.token-card-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.token-card .token-avatar {
  width: 38px;
  height: 38px;
}

.token-card-price {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.token-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.token-card-stats div {
  min-width: 0;
  background: var(--surface-raised);
  padding: 8px;
}

.empty-state {
  display: grid;
  gap: 12px;
  min-height: 100px;
  place-items: center;
  margin: 12px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 10px;
  text-align: center;
}

.mobile-dock,
.sidebar-backdrop,
.sheet-close,
.panel-close,
.market-select,
.token-card-volume {
  display: none;
}

@media (max-width: 1023px) {
  .screener-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1022px) {
  .top-nav {
    min-height: 58px;
    gap: 8px;
  }

  /*
   * Full-width equal-split tabs (the desktop/tablet default) only work when there's enough
   * room per tab to keep labels readable. Below 1022px the sidebar alone can leave as little
   * as ~200px for this whole panel, which would ellipsis-truncate "Watchlist" down to a
   * single letter. Falling back to natural-width, horizontally scrollable tabs here keeps
   * every label fully readable at the cost of a swipe instead of a tap layout.
   */
  .market-tabs {
    overflow-x: auto;
  }

  .market-tabs button {
    flex: 0 0 auto;
    min-width: auto;
  }

  .brand-subtitle {
    display: none;
  }

  .wallet-button {
    width: 38px;
    justify-content: center;
    padding: 0;
  }

  .wallet-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /*
   * Mobile navigation: the sidebar is completely hidden by default (no icon rail) and slides in
   * as a full-labelled drawer when the dock's Menu button is pressed. The desktop
   * collapsed/expanded preference is ignored here -- the drawer is always full width.
   */
  .top-nav {
    min-height: 52px;
    padding: 8px 12px;
  }

  .wallet-button {
    display: none;
  }

  /*
   * The menu is a bottom sheet: it slides up from the bottom edge, has rounded top corners, and
   * sits flush with the bottom of the screen (no margin, no bottom radius). The floating dock is
   * hidden completely while it is open (body.menu-open).
   */
  .sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    flex: none;
    width: 100%;
    border-top: 1px solid var(--border);
    border-right: 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(102%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }

  .sidebar.collapsed {
    flex: none;
    width: 100%;
  }

  .sidebar.mobile-open {
    transform: translateY(0);
    visibility: visible;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.22s ease;
  }

  .sidebar-inner {
    position: static;
    max-height: 78vh;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar-inner::before {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--border);
  }

  .sidebar-nav {
    padding: 8px 10px 4px;
  }

  .sheet-close {
    display: block;
    margin: 4px 10px 12px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  /* The dock hides behind every overlay: the menu sheet / activity panel (body.menu-open) and
     the filter, search and wallet bottom sheets. */
  body.menu-open .mobile-dock,
  body:has(#filterDrawerBackdrop:not([hidden])) .mobile-dock,
  body:has(#searchDialogBackdrop:not([hidden])) .mobile-dock,
  body:has(#walletPopoverBackdrop:not([hidden])) .mobile-dock {
    display: none;
  }

  /* Popups: full-width bottom sheets with rounded top corners, flush with the screen bottom. */
  .search-dialog-backdrop,
  .wallet-popover-backdrop {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .search-dialog,
  .wallet-popover {
    width: 100%;
    max-height: 88vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .search-dialog {
    padding-top: 0;
  }

  .search-dialog::before,
  .wallet-popover::before,
  .filter-drawer::before {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 36px;
    height: 4px;
    margin: 8px auto 10px;
    border-radius: 999px;
    background: var(--border);
  }

  .wallet-popover::before {
    margin: -6px auto 0;
  }

  .filter-drawer::before {
    margin: -8px auto 0;
  }

  .filter-drawer-backdrop {
    position: fixed;
    align-items: flex-end;
  }

  .filter-drawer {
    width: 100%;
    height: auto;
    max-height: 88vh;
    border-top: 1px solid var(--border);
    border-right: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }

  .filter-drawer-backdrop.open .filter-drawer {
    transform: translateY(0);
  }

  .sidebar.collapsed .sidebar-nav a span {
    display: inline;
  }

  .sidebar-footer {
    display: none;
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.55);
  }

  .mobile-dock {
    position: fixed;
    left: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    width: min(calc(100% - 16px), 400px);
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    padding: 4px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
  }

  .dock-item {
    display: flex;
    min-width: 0;
    height: 40px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 0 4px;
    text-decoration: none;
    cursor: pointer;
  }

  .dock-item svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .dock-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dock-item[aria-current="page"] {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
  }

  #dockWalletText {
    font-size: 11px;
  }

  .dock-avatar {
    display: grid;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--avatar-bg);
    color: var(--avatar-fg);
    font-size: 9px;
    font-weight: 800;
  }

  .dock-avatar[hidden] {
    display: none;
  }

  .dock-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /*
   * One vertical rhythm for every section: the page is a flex column with a single 10px gap,
   * so spacing above and below each section is identical. .screener-layout dissolves
   * (display: contents) so its two children can be ordered alongside the token cards -- the
   * Launchpad Activity panel (.side-panel) is deliberately last.
   */
  .terminal {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 10px calc(80px + env(safe-area-inset-bottom));
  }

  .screener-layout {
    display: contents;
  }

  .table-panel {
    order: 2;
  }

  .card-grid {
    order: 3;
    display: grid;
  }

  /*
   * Launchpad Activity leaves the page flow on mobile and becomes a right-hand slide-in panel,
   * opened from the dock's Activity button (and hidden along with the dock while open).
   */
  .side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(340px, 88vw);
    overflow-y: auto;
    border-radius: 16px 0 0 16px;
    border-right: 0;
    gap: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(102%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }

  .side-panel.mobile-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.22s ease;
  }

  .panel-close {
    display: grid;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    padding: 0;
    cursor: pointer;
  }

  .panel-close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }

  .table-scroll {
    display: none;
  }

  .panel-heading {
    min-height: 0;
    padding: 8px 10px;
  }

  /*
   * Compact token card: a tight header (small avatar, name over symbol, price, star) and the
   * three stats on a single inline row under a hairline, instead of three boxed cells.
   */
  .card-grid {
    gap: 8px;
  }

  .token-card {
    padding: 8px 10px;
  }

  /*
   * Two-row header: the name and price share the first row; the ticker/address and the volume
   * share the second. The name/symbol wrapper span dissolves (display: contents) so its two
   * lines become individual grid items that line up with the price and volume on their right.
   */
  .token-card-head {
    grid-template-columns: 32px minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 1px;
    align-items: center;
  }

  .token-card-head > span:nth-child(2) {
    display: contents;
  }

  .token-card .token-avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .token-card .token-name {
    grid-column: 2;
    grid-row: 1;
  }

  .token-card .token-symbol {
    grid-column: 2;
    grid-row: 2;
  }

  .token-card-price {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .token-card-volume {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
  }

  .token-card-volume svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .token-card .watch-toggle {
    grid-column: 4;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .token-card .token-avatar {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    font-size: 11px;
  }

  .token-card .token-name {
    font-size: 13px;
    line-height: 1.25;
  }

  .token-card .token-symbol {
    margin-top: 0;
    font-size: 10.5px;
  }

  .token-card-price {
    font-size: 13px;
  }

  .token-card .watch-toggle {
    padding: 0 2px;
    font-size: 15px;
  }

  .token-card-stats {
    display: flex;
    gap: 0;
    overflow: visible;
    margin-top: 7px;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    padding-top: 6px;
  }

  .token-card-stats div {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    align-items: baseline;
    gap: 5px;
    background: transparent;
    padding: 0;
  }

  .token-card-stats dt {
    margin: 0;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .token-card-stats dd {
    margin: 0;
    overflow: hidden;
    font-size: 12px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /*
   * On phones the tab row is replaced by a dropdown that drives the very same tab buttons (so
   * the filtering logic lives in one place). The original row stays in the DOM, just hidden.
   */
  .market-tabs {
    display: none;
  }

  .market-select {
    position: relative;
    display: block;
    flex: 1;
    min-width: 0;
  }

  .market-select-trigger {
    display: flex;
    width: 100%;
    height: 36px;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 720;
    padding: 0 10px;
    cursor: pointer;
  }

  .market-select-icon,
  .market-select-option-icon {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .market-select svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .market-select-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .market-select-chevron {
    color: var(--text-muted);
    transition: transform 0.15s ease;
  }

  .market-select-trigger[aria-expanded="true"] .market-select-chevron {
    transform: rotate(180deg);
  }

  .market-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 30;
    display: grid;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    padding: 4px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  }

  .market-select-menu[hidden] {
    display: none;
  }

  .market-select-option {
    display: flex;
    height: 38px;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 0 10px;
    text-align: left;
    cursor: pointer;
  }

  .market-select-option[aria-selected="true"] {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
  }
}

@media (max-width: 374px) {
  .terminal {
    padding: 10px;
  }

  .brand-name {
    font-size: 14px;
  }

  .market-tabs button {
    padding-inline: 8px;
  }

  .token-card-price {
    font-size: 12px;
  }
}
