/* styles.css — Task 3 shell chrome: light default + dark via [data-theme] */
:root {
  --bg: #fff;
  --chrome: #ebebeb;
  --grid: #e0e3eb;
  --text: #0f0f0f;
  --up: #089981;
  --down: #F23645;
  --topbar-h: 48px;
  --rail-w: 48px;
  --axis-w: 72px;
  --timeaxis-h: 28px;
  --footer-h: 32px;
  --border: #e0e3eb;
  --btn-hover: #f0f3fa;
}
[data-theme="dark"] {
  --bg: #131722;
  --grid: #2a2e39;
  --text: #d1d4dc;
  --up: #089981;
  --down: #F23645;
  --border: #2a2e39;
  --btn-hover: #2a2e39;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--chrome);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
button {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 6px 8px;
  border-radius: 4px;
}
button:hover { background: var(--btn-hover); }
#topbar {
  height: var(--topbar-h);
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
#topbar #sym { font-weight: 700; font-size: 14px; min-width: 128px; height: 28px; }
#main { flex: 1; display: flex; min-height: 0; }
#rail {
  width: var(--rail-w);
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 4px;
  gap: 1px;
  overflow-y: auto;
}
#rail button { font-size: 15px; padding: 6px 0; text-align: center; }
#rail button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; margin: 0 auto; }
#rail button svg .f { fill: currentColor; stroke: none; }
.rail-sep { display: block; height: 1px; margin: 4px 6px; background: var(--border); }

/* Each rail entry pairs the glyph (arms the group's tool; re-clicking the
   armed group's glyph toggles its menu) with a chevron (opens the tool menu),
   the way the original sidebar splits them. The chevron is always visible —
   like the original's persistent arrow — as a full-height strip on the
   button's right edge, so the menu is discoverable without hovering. */
.rail-item { position: relative; display: block; }
#rail .rail-btn { width: 100%; padding: 6px 0; color: var(--text); background: none; border: 0; border-radius: 4px; cursor: pointer; }
#rail .rail-chev {
  position: absolute; top: 0; bottom: 0; right: 0;
  width: 15px; padding: 0; border: 0; background: none; color: var(--text);
  opacity: 1; cursor: pointer; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}
#rail .rail-chev svg { width: 8px; height: 12px; stroke-width: 2.5; }
.rail-item:hover .rail-chev { opacity: 1; color: var(--text); }
.rail-item.open .rail-chev { opacity: 1; color: #2962FF; }
.rail-item:hover .rail-btn { background: var(--btn-hover); }
#rail .rail-btn.active { background: var(--btn-hover); outline: 1px solid var(--grid); }
#rail .rail-btn.engaged { background: rgba(41, 98, 255, 0.16); outline: 1px solid #2962FF; color: #2962FF; }

/* Tool menu: section headers, shortcuts on the right, switches at the end. */
#tool-menu { position: fixed; z-index: 70; display: flex; flex-direction: column; min-width: 240px; max-height: calc(100vh - 16px); overflow-y: auto; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,0.28); }
#tool-menu .tool-menu-head { padding: 6px 8px 4px; font-size: 11px; color: #787b86; letter-spacing: 0.03em; }
#tool-menu .tool-menu-sec { padding: 8px 8px 3px; font-size: 11px; font-weight: 600; color: #787b86; text-transform: uppercase; letter-spacing: 0.04em; }
#tool-menu button { display: flex; align-items: center; gap: 8px; text-align: left; padding: 7px 8px; border: 0; background: none; color: inherit; border-radius: 4px; font-size: 13px; width: 100%; cursor: pointer; }
#tool-menu button:hover { background: var(--btn-hover); }
#tool-menu button.current { color: #2962FF; }
#tool-menu button svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tool-menu .tool-menu-label { flex: 1 1 auto; white-space: nowrap; }
#tool-menu .tool-menu-hot { margin-left: auto; padding-left: 12px; font-size: 11px; color: #787b86; }
#tool-menu .tool-menu-icon { flex: 0 0 16px; display: inline-flex; }
#tool-menu .tool-menu-switch { margin-left: auto; width: 26px; height: 15px; border-radius: 8px; background: var(--grid); position: relative; flex: 0 0 26px; }
#tool-menu .tool-menu-switch i { position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--text); transition: transform .12s ease; }
#tool-menu button.on .tool-menu-switch { background: #2962FF; }
#tool-menu button.on .tool-menu-switch i { transform: translateX(11px); background: #fff; }

/* Icons group opens an emoji grid rather than a menu. */
#emoji-picker { position: fixed; z-index: 70; width: 320px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 8px 26px rgba(0,0,0,0.3); }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.emoji-grid button { border: 0; background: none; font-size: 18px; line-height: 1; padding: 4px 0; border-radius: 4px; cursor: pointer; }
.emoji-grid button:hover { background: var(--btn-hover); }
/* Icon size slider: 1x–10x the base glyph, with a live preview. */
.emoji-size { display: flex; align-items: center; gap: 8px; padding: 6px 4px 8px; font-size: 12px; color: #787b86; }
.emoji-size input[type="range"] { flex: 1; accent-color: #2962FF; cursor: pointer; }
.emoji-size-val { min-width: 28px; text-align: right; color: var(--text); }
.emoji-size-preview { min-width: 60px; text-align: center; line-height: 1; }
/* Text tool picker: same rows as the icon picker (size 1–100x, indicator-
   style color + Auto, opacity), shown while the text tool is armed. */
#text-size-picker { position: fixed; z-index: 70; width: 300px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 8px 26px rgba(0,0,0,0.3); }
#text-size-picker input[type="color"] { width: 30px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; }
#text-size-picker .text-auto { font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
#locked-badge { margin-right: 8px; }
#chart-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
#ohlc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
#sell, #buy {
  padding: 3px 10px;
  border-radius: 4px;
  background: transparent;
  font-weight: 600;
  border: 1px solid currentColor;
}
#sell { color: var(--down); border-color: var(--down); }
#buy { color: #2962FF; border-color: #2962FF; }
#mid { flex: 1; display: flex; min-height: 0; }
#canvas-stack { flex: 1; position: relative; min-width: 0; }
/* Data status overlay: honest loading / error states, no fake candles */
#data-status { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg); color: var(--text); font-size: 13px; }
#data-status .msg { color: #787b86; font-size: 12px; max-width: 420px; text-align: center; word-break: break-word; }
#data-status button { background: var(--btn-hover); border: 1px solid var(--border); border-radius: 4px; padding: 6px 14px; color: var(--text); cursor: pointer; font: inherit; }
#data-status button:hover { border-color: #2962FF; color: #2962FF; }
#data-status .spinner { width: 18px; height: 18px; border: 2px solid var(--grid); border-top-color: #2962FF; border-radius: 50%; animation: tv-spin 0.8s linear infinite; }
@keyframes tv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #data-status .spinner { animation: none; } }
#canvas-stack canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#price-axis { width: var(--axis-w); min-width: 72px; border-left: 1px solid var(--border); cursor: ns-resize; user-select: none; }
#time-axis { height: var(--timeaxis-h); min-height: 28px; border-top: 1px solid var(--border); cursor: ew-resize; user-select: none; }
#rangebar {
  height: var(--footer-h);
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
#clock { font-variant-numeric: tabular-nums; }
/* App menu dropdown + dialogs (page language, dark-aware via vars) */
#app-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 180px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
#app-menu button { text-align: left; padding: 7px 10px; border-radius: 4px; font-size: 13px; }
#app-menu button:hover { background: var(--btn-hover); }
dialog { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
dialog::backdrop { background: rgba(0,0,0,0.25); }
dialog input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; font: inherit; width: 100%; box-sizing: border-box; margin-top: 2px; }
dialog label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #787b86; }
.suggest { display: flex; flex-direction: column; max-height: 180px; overflow: auto; border-radius: 4px; }
.suggest:empty { display: none; }
.suggest button { text-align: left; padding: 6px 8px; border-radius: 4px; font-size: 13px; }
.suggest button:hover { background: var(--btn-hover); }
.suggest-empty { color: #787b86; font-size: 12px; padding: 4px 8px; }
.suggest-more { color: #787b86; font-size: 12px; padding: 4px 8px; }
.suggest-warn { color: #F23645; font-size: 12px; padding: 4px 8px; }
.sym-install-link { color: #2962FF; font-size: 12px; margin-left: 6px; text-decoration: none; }
.sym-install-link:hover { text-decoration: underline; }
.sym-head { display: flex; align-items: center; }
#sym-x { margin-left: auto; font-size: 14px; padding: 2px 8px; border-radius: 4px; }
#sym-x:hover { background: var(--btn-hover); }
/* Watchlist sidebar (matches captured Symbol/Last/Chg/Chg% structure) */
#watch { width: 320px; min-width: 280px; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; overflow-y: auto; font-size: 12px; }
#watch-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
#watch-cols, .wrow { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; padding: 4px 12px; align-items: center; }
#watch-cols { color: #787b86; border-bottom: 1px solid var(--border); }
#watch-cols span:nth-child(n+2), .wrow span:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.wgroup { padding: 8px 12px 2px; color: #787b86; font-size: 11px; letter-spacing: 0.04em; }
.wrow { cursor: pointer; border: none; background: transparent; color: inherit; font: inherit; text-align: left; width: 100%; }
.wrow:hover { background: var(--btn-hover); }
.wrow .up { color: var(--up); }
.wrow .down { color: var(--down); }
/* Indicators modal (page language: same font/vars as shell; dark via vars) */
#ind-dialog {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  min-width: 360px;
  max-width: 480px;
  max-height: 80vh;
  font: inherit;
}
#ind-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
#ind-dialog .ind-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
#ind-dialog .ind-title { font-weight: 700; font-size: 14px; flex: 1; }
#ind-dialog #ind-filter {
  flex: 2;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
#ind-dialog .ind-close { font-weight: 700; }
#ind-dialog .ind-sec { padding: 8px 12px; }
#ind-dialog .ind-sec-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.7;
  margin: 4px 0 6px;
}
#ind-dialog #ind-active-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 30vh;
  overflow-y: auto;
}
#ind-dialog .ind-empty { opacity: 0.7; padding: 4px 0; }
#ind-dialog .ind-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
}
#ind-dialog .ind-card-top { display: flex; align-items: center; gap: 6px; }
#ind-dialog .ind-card-label { font-weight: 600; }
#ind-dialog .ind-param {
  display: flex;
  align-items: center;
  gap: 6px;
}
#ind-dialog .ind-param span { min-width: 70px; opacity: 0.8; }
#ind-dialog .ind-param input[type="number"] {
  width: 90px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
#ind-dialog .ind-param input[type="color"] {
  width: 36px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
}
#ind-dialog #ind-groups { display: flex; flex-direction: column; gap: 8px; max-height: 36vh; overflow-y: auto; }
#ind-dialog .ind-group-head { display: flex; align-items: center; gap: 6px; font-weight: 700; padding: 2px 0; }
#ind-dialog .ind-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#ind-dialog .ind-row-label { flex: 1; }
#ind-dialog .ind-count {
  min-width: 22px;
  text-align: center;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 6px;
  opacity: 0.8;
}
#ind-dialog .ind-count:not(:empty) { opacity: 1; }
@media (max-width: 1500px) { #watch { display: none; } }
/* Task 8 polish: responsive desktop reflow */
@media (max-width: 1400px) {
  :root { --axis-w: 56px; }
  #price-axis { width: 56px; min-width: 56px; }
  #time-axis { margin-right: var(--axis-w); }
}
@media (max-width: 1100px) {
  :root { --rail-w: 36px; }
  #rail { width: 36px; min-width: 36px; padding: 2px; }
  #rail button { font-size: 13px; padding: 4px 0; }
}
/* Exchange-grade market selector: tiers, recents, split view, network plot. */
#sym-dialog {
  width: min(700px, calc(100vw - 48px));
  max-width: 96vw;
  max-height: 88vh;
  overflow-y: auto;
}
#sym-tabs { display: flex; gap: 4px; }
#sym-tabs button {
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text);
}
#sym-tabs button:hover { background: var(--btn-hover); }
#sym-tabs button.on { background: var(--btn-hover); outline: 1px solid #2962FF; color: #2962FF; }
#sym-source-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#sym-source-tabs .sym-tab, #sym-split-dir .sym-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  max-width: 220px;
}
#sym-split-dir .sym-tab { flex-direction: row; align-items: center; }
#sym-source-tabs .sym-tab.on, #sym-split-dir .sym-tab.on { border-color: #2962FF; color: #2962FF; }
#sym-source-tabs .sym-tab:disabled { opacity: 0.6; cursor: not-allowed; }
.sym-tab-label { font-weight: 600; }
.sym-reason { font-size: 11px; color: #787b86; font-weight: 400; }
/* Full scrollable pulldowns (no row cap) with sticky count headers. */
.suggest.sym-deep { max-height: 220px; }
.sym-count {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  color: #787b86;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
}
#sym-dialog .suggest button { display: flex; align-items: center; gap: 8px; }
#sym-dialog .sym-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sym-dialog .suggest button mark {
  background: rgba(41, 98, 255, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.sym-badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-hover);
  color: #787b86;
  white-space: nowrap;
}
.sym-badge.live { color: var(--up); border-color: var(--up); }
/* Recents row. */
#sym-recents .sym-recents-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 0 4px; }
#sym-recents .sym-recent {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
}
#sym-recents .sym-recent:hover { border-color: #2962FF; color: #2962FF; background: var(--btn-hover); }
/* Base/quote split view. */
#sym-split-cols { display: flex; gap: 8px; }
#sym-split-cols .sym-split-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#sym-split-cols .sym-split-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 4px;
}
#sym-split-cols .sym-split-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 6px 8px;
  border-radius: 0;
  font-size: 13px;
}
#sym-split-cols .sym-split-list button:hover { background: var(--btn-hover); }
#sym-split-cols .sym-split-list button.on { color: #2962FF; background: var(--btn-hover); }
/* Network plot canvas + interval select. */
#sym-plot { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
#sym-interval {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  width: 100%;
  margin-top: 2px;
}
