/* White workspace with lavender focus and selection states. */
body:has(#terminal:not([hidden])) { background: #f6f6f8; }
#terminal, #mast:not(.mast-home), body:has(#terminal:not([hidden])) #dialog {
  color-scheme: light;
  --ink: #19171e;
  --muted: #5d5965;
  --pale: #5130ac;
  --accent: #6742d3;
  --accent-bright: #5130ac;
  --accent-ink: #fff;
  --line: #e4e2e9;
  --panel: #fff;
  --control: #fff;
  --control-hover: #f0eafd;
  --green: #087765;
  --red: #b73557;
  --warn: #9b510c;
  color: var(--ink);
}
#mast:not(.mast-home) { background: #fff; border-color: var(--line); }
#mast:not(.mast-home) .brand { color: var(--ink); }
#mast:not(.mast-home) .mast-work-tools a, #mast:not(.mast-home) .mast-work-tools button {
  border-color: var(--line); color: var(--pale); background: #fcfcfd;
}
#mast:not(.mast-home) .mast-work-tools :is(a,button):hover { border-color: #ccc0ef; background: #f1eaff; }
#terminal { background: #f6f6f8; grid-template-columns: clamp(198px,17vw,238px) minmax(0,1fr); }
#terminal :focus-visible, #mast:not(.mast-home) :focus-visible { outline-color: var(--accent); }
#terminal .rail { display: block; background: #fff; border-color: var(--line); }
#rail-content { display: grid; grid-template-rows: 1fr 1fr; height: 100%; }
#terminal .rail-compact-toggle { display: none; }
#terminal .rail-section { border-color: var(--line); padding-inline: 9px; }
#terminal .rail-heading h2, #terminal .recent-token strong, #terminal .recent-token time { color: var(--ink); }
#terminal .rail-heading small, #terminal .trending-rank { color: #665782; }
#terminal .recent-token:hover, #terminal .recent-token[aria-current] {
  background: #f1e9ff; color: #3f24a0; border-color: #ddd0fb; box-shadow: none;
}
#terminal .rail-manage { color: var(--pale); }
#terminal .rail-scroll { scrollbar-color: #cec0ef transparent; }
#terminal .rail-tabs .control:not(.cell-button) { color: var(--muted); background: transparent; border-color: transparent; }
#terminal .rail-tabs .control[aria-pressed=true]:not(.cell-button) { color: #45239e; border-color: #ded0fb; background: #efe7ff; }
#terminal .avatar { background: #f0eef3; color: #56349f; }
#terminal main { padding: 15px clamp(12px,2vw,28px) 28px; }
#terminal[data-view=overview] .lookup-area { margin-bottom: 12px; }
#terminal #search, #terminal .wallet-search { background: #fff; border-color: #e0dee7; }
#terminal :is(#search,.wallet-search):focus-within { border-color: var(--accent); }
#terminal :is(#search,.wallet-search) input::placeholder { color: var(--muted); }
#terminal kbd { color: #6449a7; background: #f4effc; border-color: #e4dbf5; }
#terminal #search button.primary, #terminal .wallet-search button.primary {
  color: #fff; background: #633dcf; border-color: #633dcf;
}
#terminal #search button.primary:hover, #terminal .wallet-search button.primary:hover { background: #5030ad; border-color: #5030ad; }
#terminal #tools a { color: var(--muted); }
#terminal #tools a:hover, #terminal #tools a[aria-current] { color: #4c2aaf; background: #ede4fb; }
#terminal #tools a[aria-current] { border-bottom-color: #6943d9; }
#terminal .workspace-status { background: #fff; border-color: var(--line); color: var(--muted); }
#terminal .workspace-status span:first-child { color: var(--ink); }

#terminal :is(.panel,.token-head,.metrics,.coin-details,.risk-hero,.intro,.matches) { background: #fff; border-color: var(--line); }
#terminal :is(.panel header,.chart-controls,.chart-foot,.map-foot,.graph-toolbar,.detail-tabs) { background: #fcfcfd; border-color: var(--line); }
#terminal :is(.panel h2,.token-title h1,.quote strong,.metrics dd,.metrics div:first-child dd,.risk-hero strong,.page-title h1,
  .chart-pair b,.pool-label b,.pool-value b,.activity-values b,.chart-summary b,.holder-bars b,.inspector-body dd) { color: var(--ink); }
#terminal .quote small.positive, #terminal .chart-summary b.positive { color: var(--green); }
#terminal .quote small.negative, #terminal .chart-summary b.negative { color: var(--red); }
#terminal :is(.token-source,.token-title .ticker,.metrics dt,.risk-hero p,.chart-venue,.chart-denomination,.chart-foot,.chart-summary,
   .activity-values,.volume-axis,.holder-bars .rank,.holder-label,.pool-label small,.chart-caption,.empty,.caption,.module-title) { color: var(--muted); }
#terminal .token-head .avatar.large { width: 36px; height: 36px; border: 1px solid #e4e1e9; font-size: .99rem; }
#terminal .token-head {
  min-height: 61px; padding: 8px 10px; margin-bottom: 8px; border: 1px solid #e4e1e9;
  border-radius: 11px; box-shadow: 0 2px 4px #36205008;
}
#terminal .token-title { gap: 9px; }
#terminal .token-title h1 { font-size: clamp(1.1rem,2vw,1.6rem); letter-spacing: -.055em; line-height: 1.04; }
#terminal .ticker { font-size: .7rem; font-weight: 620; }
#terminal .quote strong { font-size: clamp(1.07rem,2.2vw,1.62rem); line-height: .93; }
#terminal .quote { text-align: right; }
#terminal .identity { margin-top: 3px; }
#terminal .token-head .mint-copy:not(.cell-button) {
  background: #f5effd; color: #534078; border-color: #eadff8; min-height: 20px; padding: 1px 5px;
}
#terminal .token-actions .control { min-height: 31px; }
#terminal .control, #terminal button.control:not(.cell-button), #terminal .button {
  color: var(--ink); background: #fff; border-color: #e3e0e9; border-radius: 7px;
}
#terminal .control:hover, #terminal button.control:not(.cell-button):hover, #terminal .button:hover {
  background: #f1e9fe; border-color: #cfc0f3; color: #4f2bad;
}
#terminal button.control:not(.cell-button):disabled { background: #f5f1fb; color: #6d617f; border-color: #e9dff7; opacity: .8; }
#terminal button.control[aria-busy=true]::before { border-color: #dfd1f8; border-top-color: #663bd0; }
#terminal button.watch-control:not(.cell-button) {
  color: #42248d; background: #eee5ff; border-color: #dfcef8; font-weight: 655;
}
#terminal button.watch-control[aria-pressed=true]:not(.cell-button) { color: #fff; background: #5b35c1; border-color: #5b35c1; }
#terminal .matches { padding: 6px; box-shadow: 0 10px 32px #2f1c5127; }
#terminal .matches button { color: var(--ink); }
#terminal .matches button:hover { background: #f2e9fd; border-color: #e6d7f6; }
#terminal :is(th,td,.filters,.wallet-list-toolbar,.chart-caption,.map-navigation) { border-color: var(--line); }
#terminal th { color: #5f5372; background: #f7f7f9; }
#terminal tbody tr:hover, #terminal tbody tr.selected { background: #f3ebfd; }
#terminal :is(.data-link,.cell-button,.rail-heading small) { color: #5130aa; }
#terminal :is(.filters,.wallet-identity,.wallet-insights div,.source-tag,.subtle-count,.graph-zoom,.graph-stage .map-legend) {
  background: #f8f8fa; border-color: var(--line); color: var(--muted);
}
#terminal :is(.filters input:not([type=checkbox]),.filters select,.inline-search input,.group-select select) {
  background: #fff; border-color: #e4dbf4; color: var(--ink);
}
#terminal :is(.filter-end,.feed-status,.wallet-list-toolbar,.wallet-identity code,.counterparties h3,.coverage-list dt,.coverage-list dd,.wallet-insights dt) { color: var(--muted); }
#terminal .feed-status.streaming, #terminal .coverage-list dd.available { color: var(--green); }
#terminal .counterparty:not(.cell-button) { color: #4e327f; border-color: #e4dbf4; background: #f5effc; }
#terminal .graph-stage { background: #fdfcfe; }
#terminal .graph-stage circle { fill: #f1e8ff; stroke: #9574dd; }
#terminal .graph-stage circle.has-holdings { fill: color-mix(in srgb,var(--cluster) 63%,#fff); }
#terminal .graph-stage circle[aria-pressed=true] { fill: #6b41d1; stroke: #472593; }
#terminal .graph-stage line { stroke: #855dc4; }
#terminal .pnl-history line { stroke: #ded3f5; }
#terminal .pnl-history polyline { stroke: #663bc9; }
#terminal .horizontal-bar, #terminal .pool-depth, #terminal .metric-meter, #terminal .activity-split { background: #eeebf2; }
#terminal .metric-meter i, #terminal .horizontal-bar i { background: #7548d9; }
#terminal button.pool-row:not(.cell-button) { background: #fff; border-color: var(--line); }
#terminal button.pool-row[aria-pressed=true]:not(.cell-button) { background: #f1eafd; }
#terminal button.pool-row:not(.cell-button):hover { background: #f5effb; }
#terminal :is(.segmented,.chart-controls .avatar,.pair-icons .avatar) { background: #f6f0fc; border-color: #e8ddf7; }
#terminal .segmented button.control:not(.cell-button) { color: var(--muted); background: transparent; border-color: transparent; }
#terminal .segmented button.control[aria-pressed=true]:not(.cell-button) { color: #4e2ba8; background: #eaddff; border-color: #e1cef9; }
#terminal .detail-tabs button.control[aria-pressed=true]:not(.cell-button) { color: #4e2ba8; background: #eee5fb; border-bottom-color: #6b41d1; }
body:has(#terminal:not([hidden])) :is(#dialog,.toast) { color: #24163d; background: #fff; border-color: #ded2f4; }
body:has(#terminal:not([hidden])) #dialog :is(button,a) { color: #5130ac; background: #f6f0ff; border-color: #e7d8fb; }

@keyframes scan-ping { 50% { box-shadow: 0 0 0 3px #875ce54a; } }

.scan-board { display: grid; grid-template-columns: minmax(0,2.45fr) minmax(260px,1fr); gap: 10px; align-items: start; }
.scan-board .price-panel { border-radius: 12px; overflow: hidden; margin: 0; }
.scan-board .chart-body { --chart-height: clamp(355px,calc(100dvh - 500px),470px); background: white; }
#terminal .candle-readout { color: #5d536f; }
#terminal .candle-readout b { color: var(--green); }
#terminal .candle-readout.candle-down b { color: var(--red); }
.chart-pool { display: flex; min-width: 0; }
.chart-pool select { color: #4a2b7c; background: #f7f2fd; border: 1px solid #e3d7f4; border-radius: 7px; max-width: 183px; min-height: 29px; padding: 2px 5px; font-size: .73rem; }
.chart-loading { min-height: var(--chart-height); display: grid; align-content: center; justify-items: center; gap: 13px; color: #7254ad; font-size: .84rem; background: #fdfcfe; }
.chart-loading svg { width: 55px; height: 55px; padding: 10px; border: 1px solid #e3d2ff; background: #f2e7ff; border-radius: 15px; animation: scan-ping 1.3s ease-in-out infinite; }
.scan-summary { display: grid; min-width: 0; gap: 8px; }
.rug-card { --risk-bg: #6136c6; --risk-text: #fff; --risk-tint: #f0e6ff; background: #fff; border: 1px solid #e1d8ef; border-radius: 12px; overflow: hidden; }
.rug-card[data-risk=unknown] { --risk-bg: #eee3ff; --risk-text: #56319a; }
.rug-card[data-risk=elevated] { --risk-bg: #ffdeb0; --risk-text: #713809; --risk-tint: #fff0d8; }
.rug-card[data-risk=high] { --risk-bg: #a22a61; --risk-text: #fff; --risk-tint: #fde8f1; }
.rug-readout { color: var(--risk-text); background: var(--risk-bg); padding: 11px 13px; }
.rug-readout h2 { font-size: .88rem; font-weight: 650; letter-spacing: -.015em; }
.rug-number { display: flex; align-items: baseline; gap: 7px; margin-top: 6px; }
.rug-number strong { font-size: clamp(2.9rem,5vw,4.6rem); line-height: .84; letter-spacing: -.09em; padding-right: 4px; font-weight: 710; }
.rug-number span { font: .71rem var(--mono); opacity: .88; }
.rug-readout p { margin-top: 6px; font-size: .79rem; font-weight: 665; }
.rug-readout small { display: block; font-size: .67rem; opacity: .89; margin-top: 5px; }
.rug-track { height: 4px; margin-top: 9px; overflow: hidden; border-radius: 4px; background: color-mix(in srgb,var(--risk-text) 28%,transparent); }
.rug-track progress { width: 100%; height: 100%; display: block; border: 0; appearance: none; color: var(--risk-text); background: transparent; }
.rug-track progress::-webkit-progress-bar { background: transparent; }
.rug-track progress::-webkit-progress-value { background: currentColor; border-radius: 4px; transform-origin: left; }
.rug-track progress::-moz-progress-bar { background: currentColor; }
.detections { display: grid; padding: 8px 11px 10px; }
.detection-head { display: flex; align-items: center; justify-content: space-between; color: #24183b; }
.detection-head h3 { font-size: .8rem; font-weight: 690; }
.detection-head > span { padding: 1px 6px; color: #552e9c; background: var(--risk-tint); border-radius: 5px; font: 600 .65rem var(--mono); }
.detection-list { margin: 3px 0 5px; padding: 0; list-style: none; }
.detection-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; border-bottom: 1px solid #ede6f5; padding: 6px 0; }
.detection-list strong { display: block; color: #34264b; font-size: .75rem; line-height: 1.19; font-weight: 680; }
.detection-list small { color: #6b5c7d; font: .64rem var(--mono); }
.detection-list li > b { border-radius: 5px; background: var(--risk-tint); color: #683851; padding: 3px 5px; font: 600 .67rem var(--mono); }
#terminal .detections .empty { padding: 7px 0; font-size: .75rem; }
.risk-link { font-size: .73rem; font-weight: 680; color: #5d32bc; padding: 4px 0 1px; width: fit-content; }
.risk-link:hover { text-decoration: underline; }
.scan-summary .metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0; border-radius: 10px; }
.scan-summary .metrics div { padding: 6px 8px; min-width: 0; }
.scan-summary .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.scan-summary .metrics div:nth-child(even) { border-right: 0; }
.scan-summary .metrics dt { font-size: .68rem; }
.scan-summary .metrics dd { font-size: .99rem; }
.scan-detail-drawer { margin: 10px 0 8px; background: #fff; border: 1px solid #e7ddf5; border-radius: 9px; }
.scan-detail-drawer summary { cursor: pointer; padding: 9px 11px; color: #4b3374; font-size: .79rem; font-weight: 660; }
.detail-drawer-body { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: 8px; padding: 0 8px 8px; }
.detail-drawer-body > * { min-width: 0; }

@media (max-width: 1100px) {
  #terminal { grid-template-columns: 195px minmax(0,1fr); }
  .scan-board { grid-template-columns: minmax(0,1.8fr) minmax(221px,1fr); }
}
@media (max-width: 915px) {
  #terminal { display: block; }
  #terminal .rail { min-height: 0; height: auto; position: static; padding: 0 9px; }
  #terminal .rail-compact-toggle {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px;
    background: transparent; border-color: transparent; min-height: 31px; color: #53388b; font-size: .75rem;
  }
  .rail-compact-toggle svg { width: 17px; height: 17px; }
  .rail-compact-toggle i { width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); margin: 0 2px 3px 2px; }
  .rail-compact-toggle[aria-expanded=true] i { transform: rotate(225deg); margin-bottom: -2px; }
  #rail-content { grid-template-rows: auto auto; }
  #terminal .rail:not([data-expanded]) #rail-content { display: none; }
}
@media (max-width: 730px) {
  .scan-board { grid-template-columns: minmax(0,1fr); }
  .scan-board .chart-body { --chart-height: 340px; }
  .scan-tools > div { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-drawer-body { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 530px) {
  #terminal main { padding: 7px 8px 16px; }
  #terminal[data-view=overview] .lookup-area { margin-bottom: 7px; }
  #terminal[data-view=overview] #search { min-height: 43px; padding-left: 8px; gap: 5px; }
  #terminal[data-view=overview] #search button.primary { min-height: 31px; }
  #terminal .token-head { padding: 6px 8px; gap: 5px; }
  #terminal .token-actions { width: auto; padding: 0; flex: none; }
  #terminal .token-actions [data-action=refresh-token] { display: none; }
  #terminal .token-actions .control { padding-inline: 5px; min-height: 27px; font-size: .67rem; }
  #terminal .token-title h1 { font-size: 1.05rem; min-width: 0; }
  #terminal .token-title { min-width: 100px; }
  #terminal .token-head .avatar.large { width: 29px; height: 29px; }
  #terminal .token-title .ticker, #terminal .token-source { display: none; }
  #terminal .quote strong { font-size: .96rem; }
  #terminal .quote small { font-size: .63rem; }
  .scan-board .chart-body { --chart-height: clamp(280px,44dvh,360px); }
  .chart-pool select { max-width: 126px; font-size: .65rem; }
  #terminal .chart-controls { gap: 4px; }
  #terminal .chart-venue { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-loading svg, .rug-track progress::-webkit-progress-value { animation: none; }
}
