/* Echo: a plain dark trading-terminal look. Colors live in :root, so a
   redesign (plan milestone 6) mostly means changing these tokens. */

:root {
  --bg: #0b0f14;
  --panel: #11171f;
  --line: #1f2833;
  --grid: #161d26;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4c8dff;
  --up: #22c55e;
  --down: #ef4444;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
a { color: var(--accent); }

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

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; letter-spacing: .2px; }

.status { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status[data-status="live"]::before { background: var(--up); box-shadow: 0 0 0 3px rgb(34 197 94 / .2); }
.status[data-status="reconnecting"]::before { background: #f59e0b; }

.dash {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px;
  min-height: 0;
}

.toolbar {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.ticker { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
select, .timeframes button {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
select { font-weight: 600; }
.pair-name { color: var(--muted); }
.pair-label { font-size: 16px; }
[hidden] { display: none !important; }
.price { font-size: 22px; font-variant-numeric: tabular-nums; transition: color .3s; }
.price[data-dir="up"] { color: var(--up); }
.price[data-dir="down"] { color: var(--down); }

.timeframes { display: flex; gap: 4px; }
.timeframes button { cursor: pointer; min-width: 44px; }
.timeframes button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-wrap, .trades-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0;
}
.chart-wrap { position: relative; min-height: 360px; }
.chart { position: absolute; inset: 8px 8px 8px 52px; }
.chart.drawing { touch-action: none; }

/* Drawing tools: a column of buttons on the chart's left edge. */
.draw-tools {
  position: absolute; left: 6px; top: 8px; bottom: 8px; width: 38px; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 4px; overflow-y: auto;
}
.draw-tools button {
  width: 34px; height: 34px; padding: 7px; border-radius: 8px; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px solid transparent;
}
.draw-tools button:hover:not(:disabled) { color: var(--text); background: var(--bg); }
.draw-tools button[aria-pressed="true"] { color: #fff; background: var(--accent); }
.draw-tools button:disabled { opacity: .35; cursor: default; }
.draw-tools button[data-confirm] { color: #fff; background: var(--down); }
.draw-tools svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.draw-tools .sep { width: 22px; border-top: 1px solid var(--line); margin: 2px 0; }
.draw-colors { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.draw-colors button { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.draw-colors button[aria-pressed="true"] { border-color: var(--text); }
.chart-msg {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0;
  padding: 6px 10px; border-radius: 6px; background: var(--bg); color: var(--muted); font-size: 12px;
}

.trades-wrap { display: flex; flex-direction: column; overflow: hidden; }
.trades-wrap h2 { font-size: 13px; margin: 0; padding: 10px 12px 6px; color: var(--muted); font-weight: 600; }
.trades-head, .trades li {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; padding: 2px 12px;
  font-variant-numeric: tabular-nums;
}
.trades-head { color: var(--muted); font-size: 11px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.trades-head span:not(:first-child), .trades li span:not(:first-child) { text-align: right; }
.trades { list-style: none; margin: 0; padding: 4px 0; overflow: auto; flex: 1; font-size: 12px; }
.trades li.buy .price { color: var(--up); }
.trades li.sell .price { color: var(--down); }
.trades li .price { font-size: 12px; }
.trades li .time { color: var(--muted); }

.foot { padding: 10px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.notfound main { margin: auto; text-align: center; }

/* Wide screens: the dashboard fills the window. */
@media (min-width: 801px) {
  body { height: 100vh; height: 100dvh; }
}
@media (max-width: 800px) {
  .dash { grid-template-columns: 1fr; grid-template-rows: auto 60vh 360px; }
}

@media (prefers-reduced-motion: reduce) {
  .price { transition: none; }
}

/* Header account area */
.account { display: flex; align-items: center; gap: 12px; }
.account .who { color: var(--muted); font-size: 12px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button {
  font: inherit; font-size: 12px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer;
}

/* Sign-in pages */
.auth-page { align-items: stretch; }
.auth-card {
  width: min(400px, calc(100% - 32px)); margin: auto; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.auth-card h1 { font-size: 20px; margin: 16px 0 16px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.auth-card input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.auth-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.auth-card button {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 11px 14px; cursor: pointer; margin-top: 4px;
}
.auth-card button:disabled { opacity: .6; cursor: wait; }
.auth-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; }
.auth-note { color: var(--muted); font-size: 13px; margin: -6px 0 16px; }
.auth-links { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.auth-msg { margin: 16px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: rgb(239 68 68 / .12); color: #fca5a5; }
.auth-msg[data-kind="ok"] { background: rgb(34 197 94 / .12); color: #86efac; }

/* Header navigation */
.nav { display: flex; align-items: center; gap: 16px; }
.nav a:not(.brand) { color: var(--muted); text-decoration: none; font-size: 14px; }
.nav a:not(.brand):hover, .nav a[aria-current="page"]:not(.brand) { color: var(--text); }
.nav a[aria-current="page"]:not(.brand) { text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--accent); }

/* Status page */
.status-page { max-width: 900px; width: 100%; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 16px; align-content: start; }
.status-page h1 { font-size: 20px; margin: 0; }
.status-note { color: var(--muted); font-size: 13px; margin: 0; }
.status-msg { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0; }
.card .big { font-size: 22px; font-weight: 700; margin: 0; }
.card .big[data-state="ok"] { color: var(--up); }
.card .big[data-state="bad"] { color: var(--down); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.meter { display: grid; gap: 6px; font-size: 13px; }
.meter-head, .meter-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.meter-foot { color: var(--muted); font-size: 12px; }
.meter-bar { position: relative; height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.meter-bar span { position: absolute; inset: 0 auto 0 0; background: var(--up); }
.meter[data-level="warn"] .meter-bar span { background: #f5a524; }
.meter[data-level="stop"] .meter-bar span { background: var(--down); }
.meter-bar i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .6; }
.link-button { white-space: nowrap; }
@media (max-width: 560px) {
  .account .who { display: none; }
  .nav { gap: 12px; }
}
