/* ============================================================
   TradingView — terminal landing (v4)
   The product IS the page: top bar + left watchlist + center
   chart canvas + right info/order panel + bottom status ticker.
   Authentic TradingView app palette. Nothing like the marketing
   pages. No frameworks.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

:root {
  --bg: #131722;
  --bg-2: #0e1015;
  --panel: #1e222d;
  --panel-2: #262b38;
  --line: #2a2e39;
  --line-2: #363a45;
  --text: #d1d4dc;
  --muted: #787b86;
  --dim: #5d606b;
  --blue: #2962ff;
  --blue-l: #4a7bff;
  --up: #26a69a;
  --down: #ef5350;
  --up-bg: rgba(38, 166, 154, 0.14);
  --down-bg: rgba(239, 83, 80, 0.14);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Trebuchet MS", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, Arial, sans-serif;
  --top-h: 52px;
  --status-h: 30px;
  --rail-w: 244px;
  --panel-w: 320px;
  --tools-w: 44px;
}

body {
  margin: 0; font-family: var(--sans); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.skip { position: absolute; left: -9999px; top: 0; background: var(--blue); color: #fff; padding: 0.5rem 1rem; z-index: 1000; }
.skip:focus { left: 8px; top: 8px; }
a { color: inherit; }

/* ---------------- Terminal shell ---------------- */
.term-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 560px; }

/* Top bar */
.topbar { flex: 0 0 var(--top-h); display: flex; align-items: center; gap: 0; padding: 0 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tb-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; text-decoration: none; color: var(--text); padding-right: 12px; }
.tb-brand img { width: 26px; height: 26px; object-fit: contain; }
.tb-sep { width: 1px; height: 26px; background: var(--line); margin: 0 6px; }
.tb-symbol { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 5px; cursor: pointer; }
.tb-symbol:hover { background: var(--panel); }
.tb-symbol .s { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.tb-symbol .x { color: var(--muted); font-size: 11px; }
.tb-search { display: none; }
.tb-intervals { display: none; gap: 2px; }
.tb-intervals button { font-family: var(--mono); font-size: 12px; color: var(--muted); background: none; border: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.tb-intervals button:hover { background: var(--panel); color: var(--text); }
.tb-intervals button.on { background: var(--panel-2); color: var(--text); }
.tb-tools { display: none; align-items: center; gap: 2px; }
.tb-tools button { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); background: none; border: none; border-radius: 5px; cursor: pointer; }
.tb-tools button:hover { background: var(--panel); color: var(--text); }
.tb-tools svg { width: 18px; height: 18px; }
.tb-spacer { flex: 1; }
.tb-right { display: flex; align-items: center; gap: 8px; }

@media (min-width: 720px) { .tb-search { display: flex; } }
@media (min-width: 900px) { .tb-intervals { display: inline-flex; } }
@media (min-width: 1180px) { .tb-tools { display: inline-flex; } }

.tb-search { align-items: center; gap: 7px; height: 32px; padding: 0 10px; margin-left: 6px; min-width: 150px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; font-family: var(--mono); }
.tb-search svg { width: 14px; height: 14px; }
.tb-search kbd { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--dim); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-family: var(--sans); font-size: 13px; font-weight: 700; text-decoration: none; border: 1px solid transparent; border-radius: 6px; padding: 8px 14px; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-l); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn--ghost:hover { background: var(--panel); border-color: var(--muted); }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn--block { width: 100%; }

/* Language menu */
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; font-size: 12.5px; font-weight: 600; color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; }
.lang summary::-webkit-details-marker { display: none; }
.lang summary::after { content: ""; width: 5px; height: 5px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translateY(-1px); }
.lang summary:hover { background: var(--panel); }
.lang__menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 158px; list-style: none; margin: 0; padding: 5px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 16px 40px -14px rgba(0,0,0,0.7); z-index: 80; }
.lang__menu a { display: block; padding: 8px 10px; color: var(--muted); text-decoration: none; font-size: 13px; border-radius: 5px; }
.lang__menu a:hover { background: var(--panel-2); color: var(--text); }
.lang__menu a[aria-current="true"] { color: var(--blue-l); font-weight: 700; }

/* Workspace */
.workspace { flex: 1; display: flex; min-height: 0; }

/* Left watchlist rail */
.rail { flex: 0 0 var(--rail-w); display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--line); min-height: 0; }
.rail__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.rail__head h2 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.rail__head .cnt { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.rail__cols { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 6px 12px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); border-bottom: 1px solid var(--line); }
.rail__cols span:not(:first-child) { text-align: right; }
.wl { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.wl li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-left: 2px solid transparent; }
.wl li:hover { background: var(--panel); }
.wl li.on { background: var(--panel); border-left-color: var(--blue); }
.wl__sym { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wl__dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.wl__name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl__last { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.wl__chg { font-family: var(--mono); font-size: 11.5px; text-align: right; min-width: 54px; padding: 1px 5px; border-radius: 4px; }
.up { color: var(--up); } .down { color: var(--down); }
.chg-up { color: var(--up); background: var(--up-bg); } .chg-down { color: var(--down); background: var(--down-bg); }

/* Chart area */
.chartwrap { flex: 1; display: flex; min-width: 0; background: var(--bg); }
.charttools { display: none; flex: 0 0 var(--tools-w); flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.charttools button { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); background: none; border: none; border-radius: 5px; cursor: pointer; }
.charttools button:hover { background: var(--panel); color: var(--text); }
.charttools button.on { background: var(--panel-2); color: var(--blue-l); }
.charttools svg { width: 18px; height: 18px; }
.charttools .div { width: 22px; height: 1px; background: var(--line); margin: 4px 0; }
@media (min-width: 1180px) { .charttools { display: flex; } }

.chart { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.chart svg.js-chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart__legend { position: absolute; top: 10px; left: 14px; z-index: 6; font-family: var(--mono); font-size: 12px; pointer-events: none; }
.chart__legend .sym { font-weight: 700; font-size: 14px; color: var(--text); font-family: var(--sans); }
.chart__legend .tf { color: var(--dim); margin-left: 6px; }
.chart__legend .ohlc { margin-top: 5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chart__legend .ohlc b { font-weight: 600; }
.chart__watermark { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; pointer-events: none; opacity: 0.05; font-weight: 800; font-size: 84px; letter-spacing: -0.03em; color: var(--text); }
.chart__badge { position: absolute; left: 14px; bottom: 12px; z-index: 6; display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; background: rgba(30,34,45,0.82); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 20px; font-size: 12px; color: var(--muted); }
.chart__badge .live { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px var(--up-bg); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--up-bg); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* Crosshair */
.chart .cross { position: absolute; z-index: 5; pointer-events: none; display: none; }
.chart .cx { top: 0; bottom: 26px; width: 0; border-left: 1px dashed var(--line-2); }
.chart .cy { left: 0; right: 62px; height: 0; border-top: 1px dashed var(--line-2); }
.chart.crossing .cross { display: block; }
.chart .ctag { position: absolute; z-index: 6; pointer-events: none; display: none; font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--blue); color: #fff; white-space: nowrap; }
.chart.crossing .ctag { display: block; }
.chart .ptag { right: 0; transform: translateY(-50%); }
.chart .ttag { bottom: 2px; transform: translateX(-50%); }

/* Right panel */
.panel { flex: 0 0 var(--panel-w); display: flex; flex-direction: column; background: var(--bg-2); border-left: 1px solid var(--line); overflow-y: auto; }
.pnl { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pnl__quote { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pnl__price { font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: -0.01em; }
.pnl__chg { font-family: var(--mono); font-size: 13px; padding: 2px 7px; border-radius: 5px; }
.pnl__sub { margin-top: 2px; font-size: 12px; color: var(--dim); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.stats div { background: var(--bg-2); padding: 8px 10px; }
.stats dt { font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); font-family: var(--mono); }
.stats dd { margin: 2px 0 0; font-family: var(--mono); font-size: 13px; color: var(--text); }
.trade { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trade a { display: flex; flex-direction: column; align-items: center; padding: 9px; border-radius: 7px; text-decoration: none; font-weight: 700; }
.trade .b { background: var(--up-bg); color: var(--up); border: 1px solid rgba(38,166,154,0.3); }
.trade .s { background: var(--down-bg); color: var(--down); border: 1px solid rgba(239,83,80,0.3); }
.trade small { font-family: var(--mono); font-weight: 500; font-size: 11px; opacity: 0.85; margin-top: 1px; }

.getapp { background: linear-gradient(160deg, rgba(41,98,255,0.14), rgba(41,98,255,0.03)); }
.getapp h3 { margin: 0 0 3px; font-size: 14px; font-weight: 800; }
.getapp p { margin: 0 0 11px; font-size: 12px; color: var(--muted); }
.getapp p b { color: var(--text); }
.getapp .os-links { display: flex; gap: 6px; margin-top: 10px; }
.getapp .os-links a { flex: 1; display: grid; place-items: center; gap: 4px; padding: 9px 4px; border: 1px solid var(--line-2); border-radius: 7px; text-decoration: none; color: var(--muted); font-size: 11px; }
.getapp .os-links a:hover { border-color: var(--blue); color: var(--text); background: var(--panel); }
.getapp .os-links img { width: 18px; height: 18px; }

.pnl__label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); font-family: var(--mono); margin: 0 0 8px; }

/* Bottom status bar */
.statusbar { flex: 0 0 var(--status-h); display: flex; align-items: center; gap: 0; background: var(--bg-2); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; }
.statusbar__ticker { flex: 1; overflow: hidden; min-width: 0; -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); }
.tt-track { display: inline-flex; gap: 26px; white-space: nowrap; padding-left: 100%; animation: ticker 40s linear infinite; }
.statusbar__ticker:hover .tt-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.tt { display: inline-flex; align-items: baseline; gap: 7px; }
.tt b { color: var(--text); font-weight: 700; }
.statusbar__right { display: none; align-items: center; gap: 14px; padding: 0 14px; border-left: 1px solid var(--line); height: 100%; }
.statusbar__right .on-air { display: inline-flex; align-items: center; gap: 6px; }
.statusbar__right .on-air i { width: 6px; height: 6px; border-radius: 50%; background: var(--up); }
@media (min-width: 760px) { .statusbar__right { display: flex; } }

/* ---------------- Below-the-fold sheet ---------------- */
.sheet { border-top: 1px solid var(--line); }
.sheet__inner { max-width: 1100px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.sheet h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
.sheet h2 .g { color: var(--blue-l); }
.sheet .lead { color: var(--muted); margin: 0 0 2rem; max-width: 60ch; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue-l); margin: 0 0 0.7rem; }

.dl-rows { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 680px) { .dl-rows { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .dl-rows { grid-template-columns: repeat(3, 1fr); } }
.dl-row { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); transition: border-color 0.15s, background 0.15s; }
.dl-row:hover { border-color: var(--blue); background: var(--panel-2); }
.dl-row__ic { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 7px; background: rgba(255,255,255,0.03); flex: 0 0 auto; }
.dl-row__ic img { width: 20px; height: 20px; }
.dl-row__b { flex: 1; min-width: 0; }
.dl-row__b b { font-size: 14px; }
.dl-row__b small { display: block; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.dl-row__go { font-family: var(--mono); font-size: 12px; color: var(--blue-l); }

.faq { display: grid; gap: 8px; max-width: 820px; margin-top: 2.5rem; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.faq summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--blue-l); font-weight: 400; font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0; padding: 0 16px 14px; color: var(--muted); font-size: 13px; }

.foot { border-top: 1px solid var(--line); }
.foot__inner { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.foot__note { font-family: var(--mono); font-size: 12px; color: var(--dim); border: 1px solid var(--line); border-left: 2px solid var(--blue); border-radius: 6px; padding: 12px 14px; line-height: 1.7; margin-bottom: 1.6rem; }
.foot__links { display: flex; flex-wrap: wrap; gap: 1.2rem 2rem; margin-bottom: 1.4rem; }
.foot__links a { color: var(--muted); text-decoration: none; font-size: 13px; }
.foot__links a:hover { color: var(--blue-l); }
.foot__copy { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 1.2rem; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--dim); }

/* ---------------- Responsive: stack the terminal ---------------- */
@media (max-width: 899px) {
  .term-app { height: auto; min-height: 0; }
  .workspace { flex-direction: column; }
  .rail { flex-basis: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .wl { max-height: 220px; }
  .chartwrap { order: -1; }
  .chart { height: 52vh; min-height: 320px; }
  .panel { flex-basis: auto; border-left: none; border-top: 1px solid var(--line); }
  .statusbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tt-track { animation-duration: 40s; }
  .chart__badge .live { animation: none; }
}
