/* AlphaChart: Alphanotes' trading layout (dark ground, 4px gutters between panels, Inter at 12px, its green/red pair),
   with the chart as the centre of the page and an analytics column where Alphanotes has its order panel. */
:root {
  --base: #0e0f10;
  --panel: #131313;
  --field: #1f2021;
  --rule: rgb(255 255 255 / 0.06);
  --grid: rgb(255 255 255 / 0.05);
  --ink: #c6c8cc;
  --mute: #888c92;
  --soft-rule: #47494d;
  --up: #00a462;
  --down: #e4425a;
  --tier: #ea670c;
  --c-perp: #ea670c;
  --c-cb: #4c8dff;
  --c-kr: #a07cf0;
  --c-comb: #e6e7e9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--base); }
body { -webkit-text-size-adjust: 100%; }

.trade {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100vh;
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) max(4px, env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
  background: var(--base);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--ink);
}
.trade h2 { margin: 0; font-size: 12px; font-weight: 600; }
.trade a { color: inherit; text-decoration: none; }
.trade a:hover { color: #fff; }
.trade button { font: inherit; cursor: pointer; }
.trade a:focus-visible, .trade button:focus-visible { outline: 1px solid var(--up); outline-offset: 2px; }
.trade-mute { color: var(--mute); }
.trade-small { font-size: 11px; }
.up { color: var(--up); }
.down { color: var(--down); }
.trade-panel { background: var(--panel); border-radius: 4px; }

/* Header: nav left, logo centred, status right. */
.trade-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  min-height: 46px; padding: 6px 14px;
}
.trade-nav { display: flex; flex: 1 1 0; gap: 20px; min-width: 180px; color: var(--mute); font-weight: 600; }
.trade-nav a[aria-current="page"] { color: var(--ink); }
.trade-logo { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.trade-wordmark { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; color: var(--ink); }
.trade-wallet { display: flex; flex: 1 1 0; align-items: center; justify-content: flex-end; gap: 14px; min-width: 180px; }
.trade-status { display: inline-flex; align-items: center; gap: 8px; color: var(--mute); }
.trade-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.trade-dot.stale { background: var(--down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 18%, transparent); }

/* Square buttons with a thin border; a selected one is filled. */
.trade-soft, .trade-chip {
  padding: 5px 10px; border: 1px solid var(--soft-rule); border-radius: 2px;
  background: transparent; color: var(--ink); font-weight: 600;
}
.trade-soft:hover, .trade-chip:hover { border-color: var(--mute); }
.trade-chip { color: var(--mute); padding: 4px 9px; }
.trade-chip[aria-pressed="true"] { color: var(--ink); background: var(--field); border-color: var(--field); }
.trade-panes .trade-chip[aria-pressed="true"] {
  color: var(--ink); background: color-mix(in srgb, var(--up) 15%, var(--panel)); border-color: color-mix(in srgb, var(--up) 40%, var(--panel));
}
.trade-soft:disabled { opacity: 0.5; cursor: default; }

/* Market bar. */
.trade-market { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 30px; min-height: 62px; padding: 8px 14px; }
.trade-asset { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.trade-mark { font-weight: 600; font-size: 16px; }
.trade-coin {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #f3efe6, #b9c2c9); color: #1b2024; font-size: 12px; font-weight: 600;
}
.trade-stats { display: grid; grid-auto-flow: column; grid-template-rows: auto auto; align-items: baseline; justify-content: start; gap: 4px 30px; margin: 0; overflow-x: auto; }
.trade-stats div { display: contents; }
.trade-stats dt { grid-row: 1; color: var(--mute); font-size: 11px; font-weight: 500; white-space: nowrap; border-bottom: 1px dashed var(--soft-rule); justify-self: start; }
.trade-stats dd { grid-row: 2; margin: 0; white-space: nowrap; color: var(--ink); }

/* Body: chart fills the width beside the 380px analytics column. */
.trade-body { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
.trade-main { display: flex; flex: 999 1 640px; flex-direction: column; gap: 4px; min-width: 0; }
.trade-side { display: flex; flex: 1 1 360px; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }

.trade-body { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
.trade-chart { display: flex; flex: 999 1 640px; flex-direction: column; min-width: 0; min-height: 560px; height: calc(100vh - 46px - 62px - 20px); overflow: hidden; }
.trade-side { display: flex; flex: 1 1 340px; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
@media (min-width: 1100px) { .trade-side { flex: 0 0 360px; height: calc(100vh - 46px - 62px - 20px); min-height: 560px; } }
.trade-mini { display: flex; flex: 1 1 0; flex-direction: column; min-height: 170px; padding: 10px 12px 6px; }
.trade-mini-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.trade-mini-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-mini-head h2 .trade-mute { font-weight: 500; margin-left: 4px; }
.trade-mini-val { font-size: 15px; font-weight: 600; white-space: nowrap; }
.trade-mini-sub { margin: 3px 0 0; color: var(--mute); font-size: 11px; line-height: 1.35; min-height: 15px; }
.trade-mini-sub b { color: var(--ink); font-weight: 600; }
.trade-mini-chart { position: relative; flex: 1 1 auto; min-height: 90px; margin-top: 4px; }

.trade-chart-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.trade-group { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.trade-panes { margin-left: auto; }
.trade-chart-box { position: relative; flex: 1 1 auto; min-height: 0; }
.trade-chart-canvas { position: absolute; inset: 0; }
.trade-chart-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--mute); }
.trade-legends { position: absolute; z-index: 3; inset: 0 84px 0 0; pointer-events: none; }
.pane-legend {
  position: absolute; left: 10px; right: 0; display: grid; gap: 3px;
  font-size: 11px; line-height: 1.35; text-shadow: 0 0 4px var(--base), 0 0 2px var(--base);
}
.pane-legend .row { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.pane-legend .lbl { color: var(--mute); }
.pane-legend b { font-weight: 600; }
.trade-sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -0.5px; }

/* Analytics column. */
.trade-card { display: grid; gap: 8px; padding: 12px 14px; }
.trade-card p { margin: 0; }
.trade-big { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.trade-split { display: flex; height: 6px; border-radius: 1px; background: var(--down); overflow: hidden; }
.trade-split-buy { display: block; height: 100%; width: 50%; background: var(--up); transition: width 0.4s ease; }
.trade-split-key { display: flex; justify-content: space-between; }
.trade-split-key span:first-child { color: var(--up); }
.trade-split-key span:last-child { color: var(--down); }
.trade-mini { width: 100%; border-collapse: collapse; }
.trade-mini th { color: var(--mute); font-weight: 500; font-size: 11px; text-align: right; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.trade-mini td { text-align: right; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.trade-mini th:first-child, .trade-mini td:first-child { text-align: left; }
.trade-kv { display: grid; gap: 0; margin: 0; }
.trade-kv div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.trade-kv dt { color: var(--mute); }
.trade-kv dd { margin: 0; text-align: right; }
.trade-depth { display: grid; gap: 10px; }
.trade-depth-row { display: grid; gap: 4px; }
.trade-depth-head { display: flex; justify-content: space-between; gap: 8px; }
.trade-depth-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; height: 8px; }
.trade-depth-bar .b { justify-self: end; height: 100%; background: color-mix(in srgb, var(--up) 70%, transparent); border-radius: 1px 0 0 1px; }
.trade-depth-bar .a { justify-self: start; height: 100%; background: color-mix(in srgb, var(--down) 70%, transparent); border-radius: 0 1px 1px 0; }
.trade-depth-nums { display: flex; justify-content: space-between; font-size: 11px; }
.trade-readout { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; line-height: 1.45; font-weight: 400; }
.trade-readout li { padding-left: 10px; border-left: 2px solid var(--soft-rule); }
.trade-readout li.up { border-left-color: var(--up); color: var(--ink); }
.trade-readout li.down { border-left-color: var(--down); color: var(--ink); }

/* Alerts. */
.trade-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 9px 14px; border-radius: 4px;
  background: color-mix(in srgb, var(--tier) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--tier) 45%, var(--panel));
}
.trade-banner.high { background: color-mix(in srgb, var(--down) 14%, var(--panel)); border-color: color-mix(in srgb, var(--down) 50%, var(--panel)); }
.trade-banner #alert-banner-detail { flex: 1 1 320px; color: var(--ink); font-weight: 400; line-height: 1.4; }
.trade-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--tier); }
.trade-banner.high .trade-pulse { background: var(--down); }
@media (prefers-reduced-motion: no-preference) {
  .trade-pulse { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
}
.trade-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trade-livebasis { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.trade-livebasis b { font-size: 15px; }
.trade-spark { flex: 1 1 110px; min-width: 90px; height: 28px; overflow: visible; }
.trade-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 330px; overflow-y: auto; }
.trade-alerts li { display: grid; gap: 3px; padding: 8px 0 8px 10px; border-bottom: 1px solid var(--rule); border-left: 2px solid var(--soft-rule); cursor: pointer; }
.trade-alerts li:hover { background: rgb(255 255 255 / 0.02); }
.trade-alerts li.watch { border-left-color: var(--tier); }
.trade-alerts li.high { border-left-color: var(--down); }
.trade-alerts li.open .when::before { content: "● "; color: var(--tier); }
.trade-alerts li.high.open .when::before { color: var(--down); }
.trade-alerts .when { display: flex; justify-content: space-between; gap: 8px; color: var(--mute); font-size: 11px; }
.trade-alerts .what { font-weight: 600; }
.trade-alerts .why { color: var(--mute); font-weight: 400; line-height: 1.4; font-size: 11.5px; }
.trade-alerts li:focus-visible { outline: 1px solid var(--up); outline-offset: -1px; }

.trade-alerts .who { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; }
.trade-addr { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px; color: var(--ink); text-decoration: underline; text-decoration-color: var(--soft-rule); text-underline-offset: 2px; }
.trade-addr:hover { text-decoration-color: var(--ink); }
.trade-tag { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 10.5px; font-weight: 600; background: var(--field); color: var(--ink); }
.trade-tag.twap { background: color-mix(in srgb, var(--tier) 22%, var(--panel)); color: #ffb37a; }
.trade-tabnote { margin: 0; padding: 10px 14px 0; font-weight: 400; }

.trade-tabhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 0; }
.trade-tabhead .trade-tabnote { padding: 0; }
#panel-alerts .trade-alerts { max-height: 460px; padding: 6px 14px 4px; }
#panel-alerts .trade-alerts li { padding-right: 8px; }
#watch-line { padding-bottom: 12px; }
.trade-count { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px; border-radius: 8px; background: var(--down); color: #fff; font-size: 10px; }

/* Bottom tabs. */
.trade-bottom { min-height: 260px; }
.trade-tabs { display: flex; gap: 18px; padding: 10px 14px 0; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.trade-tabs button { padding: 0 0 8px; border: 0; border-bottom: 1px solid transparent; margin-bottom: -1px; background: none; color: var(--mute); font-weight: 600; white-space: nowrap; }
.trade-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.trade-scroll { overflow-x: auto; }
.trade-scroll-tall { max-height: 420px; overflow-y: auto; }
.trade-table { width: 100%; border-collapse: collapse; }
.trade-table th {
  position: sticky; z-index: 1; top: 0; padding: 8px 10px; background: var(--panel);
  font-size: 11.5px; font-weight: 600; color: var(--mute); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--rule);
}
.trade-table td { padding: 7px 10px; white-space: nowrap; border-bottom: 1px solid var(--rule); }
.trade-table .r { text-align: right; }
.trade-table tbody tr:hover td { background: rgb(255 255 255 / 0.02); }
.trade-legend-row { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 14px 0; color: var(--mute); }
.trade-daily { position: relative; height: 240px; padding: 6px 10px 10px; }
.trade-daily svg { display: block; width: 100%; height: 100%; }
.trade-daily text { fill: var(--mute); font-size: 11px; font-family: inherit; }
.trade-tip {
  position: absolute; z-index: 5; pointer-events: none; padding: 6px 8px; border-radius: 3px;
  background: var(--field); border: 1px solid var(--soft-rule); font-size: 11px; line-height: 1.5; white-space: nowrap;
}

.trade-method { padding: 12px 14px; }
.trade-method ul { margin: 8px 0 0; padding-left: 16px; display: grid; gap: 6px; max-width: 110ch; color: var(--mute); font-weight: 400; line-height: 1.5; }
.trade-method b { color: var(--ink); font-weight: 600; }
.trade-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 20px; padding: 5px 14px 7px; font-size: 11px; color: var(--mute); }
.trade-footer a { text-decoration: underline; text-underline-offset: 2px; }

/* Phones: the chart keeps most of the screen; the stats bar scrolls sideways. */
@media (max-width: 720px) {
  .trade-header { justify-content: space-between; }
  .trade-nav { order: 3; flex-basis: 100%; gap: 16px; overflow-x: auto; }
  .trade-logo { order: 1; }
  .trade-wallet { order: 2; flex: 0 1 auto; min-width: 0; }
  .trade-status #st-text { font-size: 11px; }
  .trade-market { gap: 8px 20px; }
  .trade-stats { gap: 4px 20px; }
  .trade-chart { height: 70vh; min-height: 460px; }
  .trade-mini { min-height: 190px; }
  .trade-legends { right: 64px; }
  .pane-legend { font-size: 10px; }
  .pane-legend .row > span:nth-child(n+4) { display: none; }
  .trade-panes { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .trade-split-buy { transition: none; } }

/* Footer dock: the tabs for alerts, tables and method. They open a sheet over the chart instead of a page below it. */
.trade-dock { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 6px 16px; min-height: 36px; padding: 0 14px; }
.trade-dock .trade-tabs { border-bottom: 0; padding: 0; gap: 20px; }
.trade-dock .trade-tabs button { padding: 10px 0 8px; margin: 0; border-bottom: 2px solid transparent; }
.trade-dock .trade-tabs button[aria-selected="true"] { border-bottom-color: var(--tier); }
.trade-dock-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--mute); }
.trade-dock-note a { text-decoration: underline; text-underline-offset: 2px; }
.trade-sheet {
  position: fixed; z-index: 30; left: max(4px, env(safe-area-inset-left, 0px)); right: max(4px, env(safe-area-inset-right, 0px));
  bottom: calc(44px + env(safe-area-inset-bottom, 0px)); height: min(58vh, 540px); overflow: auto;
  border: 1px solid var(--soft-rule); box-shadow: 0 -16px 48px rgb(0 0 0 / 0.6);
}
.trade-sheet-close {
  position: sticky; float: right; top: 6px; z-index: 3; margin: 6px 8px 0 0; width: 26px; height: 26px; border: 1px solid var(--soft-rule);
  border-radius: 2px; background: var(--panel); color: var(--ink); font-size: 16px; line-height: 1;
}
.trade-sheet .trade-tabpanel { padding-top: 4px; }
.trade-sheet .trade-scroll-tall { max-height: none; }
#panel-alerts .trade-alerts { max-height: none; }
.trade-method ul { margin: 12px 0 14px; padding: 0 44px 0 30px; display: grid; gap: 7px; max-width: 120ch; color: var(--mute); font-weight: 400; line-height: 1.5; }
.trade-method b { color: var(--ink); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .trade-sheet:not([hidden]) { animation: sheet-in 0.18s ease-out; }
  @keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }
}

/* Desktop: the whole page fits the window; nothing scrolls but the sheet. */
@media (min-width: 1100px) and (min-height: 620px) {
  html, body { height: 100%; overflow: hidden; }
  .trade { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  .trade-body { flex: 1 1 auto; min-height: 0; }
  .trade-chart { height: auto; min-height: 0; }
  .trade-side { height: auto; min-height: 0; flex: 0 0 360px; }
  .trade-mini { min-height: 0; }
  .trade-mini-chart { min-height: 40px; }
}

/* Phones and short windows: the page scrolls and the dock stays at the bottom of the screen. */
@media not ((min-width: 1100px) and (min-height: 620px)) {
  .trade-dock { position: sticky; bottom: 0; z-index: 25; flex-wrap: wrap; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .trade-dock .trade-tabs { overflow-x: auto; max-width: 100%; }
  .trade-dock-note { display: none; }
  .trade-sheet { height: 70vh; }
}

.trade-key { margin-left: 6px; font-weight: 500; font-size: 11px; color: var(--mute); }
.trade-key .trade-sw { margin-left: 6px; margin-right: 4px; }

/* Labels on the price chart: the mono face, like the chart's own axis and markers. */
.pane-legend b, .pane-legend .lbl { font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-size: 10.5px; letter-spacing: -0.01em; }
.trade-stats dd.up, .trade-mini-val.up { color: var(--up); }
.trade-stats dd.down, .trade-mini-val.down { color: var(--down); }
