:root {
  --bg: #0f0f0f; --panel: #1e1e1e; --hover: #2a2a2a; --line: #2e2e2e; --gap: #000;
  --text: #dbdbdb; --muted: #8c8c8c; --up: #089981; --down: #f23645; --accent: #2962ff;
  --font: -apple-system, BlinkMacSystemFont, "Trebuchet MS", "Sarabun", Roboto, Ubuntu, sans-serif;
  --mnav: 0px; --dashbg: rgba(15,15,15,.9); --code: #0a0a0a; --legendhover: rgba(42,42,42,.85); --grid-hi: #fff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--gap); color: var(--text); font: 14px/1.3 var(--font); display: flex; flex-direction: column; overflow: hidden; }
button, select, input, textarea { background: transparent; color: var(--text); border: 0; border-radius: 6px; padding: 6px 9px; font: inherit; }
select, input { background: var(--panel); border: 1px solid var(--line); }
select option { background: var(--panel); }
button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .12s; }
button:hover { background: var(--hover); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #1e53e5; }
button.icon { padding: 6px; }
button:disabled { opacity: .5; cursor: default; }
svg { flex-shrink: 0; }
.grow { flex: 1; }
.up { color: var(--up); } .down { color: var(--down); }
.m-only { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- top toolbar ---------- */
#topbar { height: 46px; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--bg); margin-bottom: 4px; flex-shrink: 0; }
.tb { height: 34px; white-space: nowrap; }
.pill { height: 34px; background: var(--panel); border-radius: 18px; padding: 0 14px 0 10px; font-weight: 600; font-size: 15px; min-width: 120px; }
.pill:hover { background: var(--hover); }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
#intervals { display: flex; gap: 1px; }
#intervals button { height: 34px; padding: 0 9px; font-size: 14px; }
#intervals button.active { background: var(--hover); color: var(--text); font-weight: 600; }
#status { color: var(--muted); font-size: 12px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

#body { flex: 1; display: flex; min-height: 0; gap: 4px; }

/* ---------- left drawing toolbar ---------- */
#drawbar { width: 52px; background: var(--bg); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; flex-shrink: 0; overflow-y: auto; }
#drawbar button { width: 40px; height: 40px; justify-content: center; padding: 0; border-radius: 6px; color: var(--text); }
#drawbar button svg { width: 24px; height: 24px; }
#drawbar button.active { color: var(--accent); background: #2962ff22; }
#drawbar .dsep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; flex-shrink: 0; }

/* ---------- chart area ---------- */
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 4px; }
#chartWrap { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
#charts { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#charts > .pane { position: relative; min-height: 70px; }
#charts > .pane + .pane { border-top: 1px solid var(--line); }
#rangeBar { height: 36px; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-top: 1px solid var(--line); flex-shrink: 0; font-size: 13px; }
#ranges { display: flex; gap: 1px; overflow-x: auto; scrollbar-width: none; }
#ranges button, #rangeBar > button { padding: 4px 8px; font-size: 13px; }
#logBtn.active { color: var(--accent); }
#clock { color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 8px; white-space: nowrap; }

/* legend */
.legend { position: absolute; left: 10px; top: 8px; right: 90px; z-index: 5; font-size: 13px; pointer-events: none; display: flex; flex-direction: column; gap: 3px; }
.legend .main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 15px; }
.legend .main .ttl { font-weight: 500; color: var(--text); }
.legend .main .sub { color: var(--muted); font-size: 14px; }
.legend .ohlc { font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; font-variant-numeric: tabular-nums; }
.legend .ohlc span { color: var(--muted); }
.legend .rows { display: flex; flex-direction: column; gap: 2px; }
.legend.folded .rows .row { display: none; }
.legend .fold { pointer-events: auto; width: 26px; height: 22px; padding: 0; justify-content: center; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; margin-top: 2px; }
.legend .row { display: flex; align-items: center; gap: 8px; pointer-events: auto; padding: 1px 6px 1px 0; border-radius: 4px; width: fit-content; min-height: 22px; }
.legend .row:hover { background: var(--legendhover); }
.legend .row .name { color: var(--muted); }
.legend .row .val { font-variant-numeric: tabular-nums; }
.legend .row .acts { display: none; gap: 0; }
.legend .row:hover .acts { display: flex; }
.legend .row .acts button { padding: 1px 5px; font-size: 13px; color: var(--muted); }
.legend .row .acts button:hover { color: var(--text); }
.legend .row.off .name, .legend .row.off .val { opacity: .45; }

/* overlay canvas (volume profile, drawings) */
.pane canvas.overlay { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.pane.drawing, .pane.drawing canvas { cursor: crosshair !important; touch-action: none; }
.pane.ov-move canvas { cursor: move !important; }
.pane.ov-point canvas { cursor: pointer !important; }

/* CDC & VP dashboard */
.dash { position: absolute; z-index: 6; font-size: 12px; max-height: calc(100% - 150px); overflow: auto; border-radius: 6px; }
.dash.collapsed tr:not(:first-child) { display: none; }
.dash tr:first-child th { cursor: pointer; }
.dash tr:first-child th::after { content: " ▾"; opacity: .7; }
.dash.collapsed tr:first-child th::after { content: " ▸"; }
.dash.bottom-left { left: 10px; bottom: 34px; } .dash.bottom-right { right: 80px; bottom: 34px; }
.dash.top-left { left: 10px; top: 8px; } .dash.top-right { right: 80px; top: 8px; }
.dash.middle-left { left: 10px; top: 50%; transform: translateY(-50%); }
.dash table { border-collapse: collapse; background: var(--dashbg); border: 1px solid var(--line); backdrop-filter: blur(4px); }
.dash th { color: #fff; text-align: left; padding: 4px 8px; font-weight: 600; }
.dash td { padding: 3px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.dash td.k { color: var(--muted); }
.dash td:last-child { text-align: right; }

/* ---------- bottom panel ---------- */
#bottom { height: 40%; background: var(--bg); display: flex; flex-direction: column; flex-shrink: 0; }
#bottom.collapsed { height: 38px; }
#bottom.collapsed .panel { display: none !important; }
#bottomTabs { display: flex; align-items: center; gap: 2px; height: 38px; padding: 0 6px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
#bottomTabs button { font-size: 13px; }
#bottomTabs button.active { color: var(--text); background: var(--hover); }
.panel { display: none; flex: 1; flex-direction: column; min-height: 0; }
.panel.active { display: flex; }
.ptool { display: flex; gap: 8px; align-items: center; padding: 8px; flex-wrap: wrap; }
.ptool.filters { border-top: 1px solid var(--line); gap: 12px; padding: 6px 8px; }
.ptool.filters label { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.ptool.filters select, .ptool.filters input { padding: 4px 6px; }
#scanCount { color: var(--muted); font-size: 13px; }
.pbody { flex: 1; overflow: auto; min-height: 0; }
.pbody.editor { display: flex; gap: 6px; padding: 0 8px 8px; }
#scriptCode { flex: 1; font: 13px/1.55 Consolas, "Cascadia Code", "SF Mono", monospace; resize: none; background: var(--code); border: 1px solid var(--line); tab-size: 2; }
#scriptHelp { width: 45%; margin: 0; padding: 10px; background: var(--panel); color: var(--muted); font-size: 12px; overflow: auto; white-space: pre-wrap; border-radius: 6px; }

#scanTable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
#scanTable th, #scanTable td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
#scanTable th { cursor: pointer; position: sticky; top: 0; background: var(--bg); color: var(--muted); font-weight: 500; z-index: 1; }
#scanTable th:hover { color: var(--text); }
#scanTable td:first-child, #scanTable th:first-child { text-align: left; font-weight: 600; position: sticky; left: 0; background: var(--bg); }
#scanTable th:first-child { z-index: 2; }
#scanTable tbody tr { cursor: pointer; }
#scanTable tbody tr:hover td { background: var(--hover); }
.zone { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- watchlist ---------- */
#watch { width: 340px; background: var(--bg); display: flex; flex-direction: column; flex-shrink: 0; position: relative; }
#watch.hidden { display: none; }
.whead { display: flex; gap: 2px; padding: 8px 8px 6px; align-items: center; position: relative; }
.whead select { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; background: transparent; border-color: transparent; padding: 6px; }
.whead select:hover { background: var(--hover); }
.wcols, #watchlist li { display: grid; grid-template-columns: 1fr 76px 60px 66px; gap: 6px; padding: 0 12px; align-items: center; }
.wcols { color: var(--muted); font-size: 12px; height: 30px; border-bottom: 1px solid var(--line); }
.wcols span:not(:first-child), #watchlist li > span:not(:first-child) { text-align: right; }
#watchlist { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; font-variant-numeric: tabular-nums; }
#watchlist li { height: 40px; cursor: pointer; position: relative; font-size: 14px; }
#watchlist li:hover { background: var(--hover); }
#watchlist li.sel { background: #2962ff26; }
#watchlist li.sel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
#watchlist .s { display: flex; align-items: center; gap: 8px; min-width: 0; }
#watchlist .s b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#watchlist .s small { color: var(--muted); font-size: 10px; }
.av { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
#watchlist li .rm { position: absolute; right: 6px; top: 9px; display: none; width: 22px; height: 22px; line-height: 22px; background: var(--hover); border-radius: 4px; text-align: center; color: var(--muted); }
#watchlist li:hover .rm { display: block; }
#watchlist li.dragover { box-shadow: inset 0 2px 0 var(--accent); }
#details { border-top: 1px solid var(--line); padding: 14px; min-height: 150px; }
#details .hd { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
#details .nm { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
#details .big { font-size: 30px; font-weight: 600; letter-spacing: -.5px; }
#details .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 12px; color: var(--muted); font-size: 13px; }
#details .grid b { color: var(--text); font-weight: 500; float: right; }

/* right icon bar */
#rightbar { width: 50px; background: var(--bg); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 6px; flex-shrink: 0; }
#rightbar button { width: 40px; height: 40px; padding: 0; justify-content: center; color: var(--muted); }
#rightbar button.active { color: var(--text); background: var(--hover); }

/* ---------- menus & modal ---------- */
.menu { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; z-index: 50; min-width: 210px; box-shadow: 0 8px 28px rgba(0,0,0,.6); }
.menu div { padding: 9px 16px; cursor: pointer; }
.menu div:hover { background: var(--hover); }
.menu .swatches { display: flex; gap: 8px; padding: 10px 16px; cursor: default; }
.menu .swatches:hover { background: none; }
.menu .swatches span { width: 20px; height: 20px; border-radius: 4px; cursor: pointer; border: 1px solid #fff3; }
.menu .swatches span:hover { outline: 2px solid #fff; }
#listMenu { right: 8px; top: 44px; }
#ctx { position: fixed; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 100; }
#modal[hidden] { display: none; }
.dialog { background: var(--panel); border-radius: 10px; width: min(580px, calc(100vw - 32px)); max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0,0,0,.7); }
.dhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; font-size: 17px; font-weight: 600; border-bottom: 1px solid var(--line); }
#dBody { overflow: auto; }
.dsearch { width: calc(100% - 36px); margin: 14px 18px; padding: 10px 14px; font-size: 16px; border-radius: 8px; }
.dlist div { display: flex; gap: 10px; align-items: center; padding: 10px 18px; cursor: pointer; }
.dlist div:hover, .dlist div.hl { background: var(--hover); }
.dlist .sy { font-weight: 600; min-width: 110px; }
.dlist .nm { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlist .ex { color: var(--muted); font-size: 12px; }
.dlist .grp { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; cursor: default; padding-top: 14px; }
.dlist .grp:hover { background: none; }
.form { padding: 12px 18px; display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; }
.form .fgroup { grid-column: 1 / -1; color: var(--accent); font-weight: 600; margin-top: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.form input[type=color] { padding: 0; height: 32px; width: 64px; }
.form input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.dfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }

/* mobile bottom nav (hidden on desktop) */
#mnav { display: none; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  #watch { width: 300px; }
  .wcols, #watchlist li { grid-template-columns: 1fr 70px 54px 60px; padding: 0 8px; }
}

/* ---------- mobile ---------- */
@media (max-width: 768px) {
  :root { --mnav: calc(58px + env(safe-area-inset-bottom)); }
  .d-only { display: none !important; }
  .m-only { display: inline-flex !important; }
  body { font-size: 15px; }
  #topbar { height: 50px; padding: 0 6px; margin-bottom: 0; border-bottom: 1px solid var(--line); }
  .pill { min-width: 0; padding: 0 12px 0 10px; }
  #intervals, #rightbar { display: none; }
  #intervalSel { height: 34px; border-radius: 17px; padding: 0 10px; font-weight: 600; }
  #status { max-width: 30vw; font-size: 11px; }
  #body { gap: 0; padding-bottom: var(--mnav); }
  #center { gap: 0; }

  .legend { left: 8px; top: 6px; right: 64px; }
  .legend .main { font-size: 14px; }
  .legend .main .sub { font-size: 12px; }
  .legend .ohlc { font-size: 12px; gap: 6px; }
  .legend .row { font-size: 12px; }
  .legend .row .acts { display: flex; }
  .legend .row .acts button[data-a="eye"] { display: none; }
  #charts > .pane { min-height: 90px; }
  #rangeBar { height: 34px; }
  #clock { display: none; }
  .dash { font-size: 11px; max-height: calc(100% - 120px); }
  .dash.bottom-right, .dash.top-right { right: 64px; }

  /* drawing toolbar → floating strip toggled from the bottom nav */
  #drawbar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--mnav) + 8px); width: auto; height: 54px; flex-direction: row; padding: 0 6px; border-radius: 12px; background: var(--panel);
    box-shadow: 0 6px 24px rgba(0,0,0,.6); z-index: 40; overflow-x: auto; overflow-y: hidden; display: none; }
  #drawbar.open { display: flex; }
  #drawbar button { width: 44px; height: 44px; flex-shrink: 0; }
  #drawbar .dsep { width: 1px; height: 28px; margin: 0 4px; }

  /* watchlist and bottom panels become full-screen sheets */
  #watch, #bottom { position: fixed; left: 0; right: 0; top: 50px; bottom: var(--mnav); width: auto; height: auto; z-index: 30; display: none; }
  #watch.open, #watch.hidden.open { display: flex; }
  #bottom.open { display: flex; height: auto; }
  #bottom.open .panel.active { display: flex !important; }
  #bottomTabs { display: none; }
  .wcols, #watchlist li { grid-template-columns: 1fr 76px 58px 66px 24px; padding: 0 12px; }
  #watchlist li { height: 54px; font-size: 15px; }
  #watchlist li .rm { display: block; position: static; background: none; }
  .av { width: 28px; height: 28px; font-size: 12px; }
  #details { display: none; }
  .ptool { gap: 6px; }
  .ptool.filters { gap: 8px 12px; max-height: 32vh; overflow: auto; }
  .pbody.editor { flex-direction: column; }
  #scriptHelp { width: auto; max-height: 40%; }
  #scanTable th, #scanTable td { padding: 10px; }

  /* modal → bottom sheet */
  #modal { padding-top: 0; align-items: flex-end; }
  .dialog { width: 100vw; max-height: 88vh; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dlist div { padding: 13px 18px; }
  .form { grid-template-columns: 1fr auto; }
  .form select, .form input[type=number] { max-width: 50vw; }

  #mnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--mnav); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); z-index: 45; }
  #mnav button { flex: 1; flex-direction: column; gap: 2px; justify-content: center; font-size: 11px; color: var(--muted); border-radius: 0; padding: 4px 0; }
  #mnav button.active { color: var(--accent); }
  #mnav button:hover { background: none; }
}

/* ---------- light theme ---------- */
:root[data-theme="light"] {
  --bg: #ffffff; --panel: #f0f3fa; --hover: #e9ecf2; --line: #e0e3eb; --gap: #e0e3eb;
  --text: #131722; --muted: #6a6d78; --dashbg: rgba(255,255,255,.94); --code: #fafbfd; --legendhover: rgba(240,243,250,.95);
}
:root[data-theme="light"] .dash th { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9ccd4; }
:root[data-theme="light"] .menu, :root[data-theme="light"] .dialog { box-shadow: 0 8px 28px rgba(0,0,0,.18); }
:root[data-theme="light"] #modal { background: rgba(0,0,0,.35); }

/* ---------- pane splitter (drag to resize indicator panes) ---------- */
.splitter { position: absolute; left: 0; right: 0; top: -5px; height: 10px; z-index: 9; cursor: row-resize; touch-action: none; }
.splitter::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: transparent; transition: background .15s; }
.splitter:hover::after, .splitter.active::after { background: var(--accent); }
#autoBtn.active { color: var(--accent); }

/* ---------- mobile quick bar (symbol / timeframe wheels) ---------- */
#mbar { display: none; }
@media (max-width: 768px) {
  :root { --mbar: 54px; }
  #body { padding-bottom: calc(var(--mnav) + var(--mbar)); }
  #drawbar { bottom: calc(var(--mnav) + var(--mbar) + 8px); }
  #mbar { display: flex; align-items: center; gap: 4px; position: fixed; left: 0; right: 0; bottom: var(--mnav); height: var(--mbar); padding: 0 8px 0 14px;
    background: var(--bg); border-top: 1px solid var(--line); z-index: 44; }
  .wheel { height: 100%; overflow: hidden; position: relative; touch-action: none; user-select: none; cursor: ns-resize; min-width: 96px;
    mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent); -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent); }
  .wheel.iv { min-width: 64px; }
  .wheel .track { display: flex; flex-direction: column; justify-content: center; height: 100%; }
  .wheel .it { height: 16px; line-height: 16px; font-size: 13px; color: var(--muted); white-space: nowrap; }
  .wheel .it.cur { height: 24px; line-height: 24px; font-size: 20px; font-weight: 700; color: var(--text); }
  #mbar button { width: 44px; height: 44px; justify-content: center; }
  #mDraw.active { color: var(--accent); }
}

/* ---------- portfolio ---------- */
#portSum { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
#portSum[hidden] { display: none; }
#portSum b { color: var(--text); font-weight: 600; }
#portSum b.up { color: var(--up); } #portSum b.down { color: var(--down); }
#watchlist .s small.badge { font-size: 10px; font-weight: 600; padding: 1px 4px; border-radius: 3px; background: var(--hover); }
#watchlist .s small.badge.up { color: var(--up); } #watchlist .s small.badge.down { color: var(--down); }
#details .pos { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#details .pos .pt { font-weight: 600; font-size: 13px; }
#details .pos .pt small { color: var(--muted); font-weight: 400; }
#details .pos .pl { font-size: 18px; font-weight: 600; margin-top: 8px; }
@media (max-width: 768px) { #details { display: block; min-height: 0; padding: 10px 14px; } #details > :not(.pos) { display: none; } #details .pos { margin: 0; padding: 0; border: 0; } }
#watchlist .s b { flex-shrink: 0; max-width: 90px; }
#watchlist .s small:not(.badge) { overflow: hidden; min-width: 0; }
#watchlist .s:has(.badge) small:not(.badge) { display: none; }
#watchlist .flag { position: absolute; left: 3px; top: 50%; width: 4px; height: 18px; margin-top: -9px; border-radius: 2px; }

/* ---------- brand ---------- */
#brand { display: flex; align-items: center; gap: 8px; margin-right: 8px; text-decoration: none; color: var(--text); font-size: 16px; font-weight: 700; letter-spacing: -.2px; flex-shrink: 0; }
#brand img { border-radius: 7px; display: block; }
#brand b { background: linear-gradient(90deg, #3ddc84, #19c3e6); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (max-width: 768px) { #brand { display: none; } }

/* ---------- cloud sync ---------- */
#syncBtn { position: relative; color: var(--muted); }
#syncBtn[data-state="ok"] { color: var(--up); }
#syncBtn[data-state="pending"], #syncBtn[data-state="syncing"] { color: var(--accent); }
#syncBtn[data-state="syncing"] svg { animation: vtpulse 1s ease-in-out infinite; }
#syncBtn[data-state="error"] { color: var(--down); }
#syncBtn[data-state="offline"] { color: #ff9800; }
#syncBtn[data-state="off"]::after { content: ""; position: absolute; right: 5px; bottom: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
@keyframes vtpulse { 50% { opacity: .35; } }
#installBtn[hidden] { display: none; }
.sync { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.sync p { margin: 0; color: var(--text); }
.sync .hint, .sync label { color: var(--muted); font-size: 13px; }
.sync .row { display: flex; gap: 6px; }
.sync .row input { flex: 1; min-width: 0; font-family: Consolas, monospace; font-size: 13px; }
.sync > button.primary { align-self: flex-start; }

/* ---------- symbol search tabs ---------- */
.stabs { display: flex; gap: 4px; padding: 0 18px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.stabs button { white-space: nowrap; padding: 5px 12px; border-radius: 16px; background: var(--hover); font-size: 13px; color: var(--muted); }
.stabs button.active { background: var(--accent); color: #fff; }
.dlist .av { width: 26px; height: 26px; }
.dlist .empty { color: var(--muted); cursor: default; justify-content: center; padding: 24px 18px; }
.dlist .empty:hover { background: none; }

/* ---------- settings ---------- */
.dialog.wide { width: min(820px, calc(100vw - 32px)); height: min(640px, 86vh); }
.dialog.wide #dBody { flex: 1; overflow: hidden; }
.settings { display: flex; height: 100%; }
.snav { width: 200px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.snav button { width: 100%; justify-content: flex-start; gap: 10px; padding: 9px 12px; color: var(--muted); font-size: 14px; }
.snav button.active { background: var(--hover); color: var(--text); font-weight: 600; }
.sbody { flex: 1; overflow: auto; padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 12px; }
.sbody h3 { margin: 0; font-size: 18px; }
.sbody .lead { margin: 0; color: var(--muted); line-height: 1.6; }
.scard { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.scard small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.scard .row { display: flex; gap: 6px; width: 100%; flex-wrap: wrap; }
.scard .row input { flex: 1; min-width: 180px; font: 15px Consolas, "SF Mono", monospace; letter-spacing: 1px; text-transform: uppercase; }
.scard .row button, .sfoot button, .scard > button { background: var(--hover); }
.scard .row button.primary, .sfoot button.primary, .scard > button.primary { background: var(--accent); }
button.danger { color: var(--down); }
.scard.code { align-items: center; text-align: center; }
.bigcode { font: 700 26px/1.2 Consolas, "SF Mono", monospace; letter-spacing: 2px; padding: 6px 0; user-select: all; }
.scard.code .row { justify-content: center; }
.qr { width: 172px; height: 172px; background: #fff; border-radius: 10px; padding: 6px; display: flex; align-items: center; justify-content: center; }
.qr svg { width: 100%; height: 100%; }
.qr small { color: #555; }
.srow { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 4px 0; cursor: pointer; }
.srow > span:first-child { display: flex; flex-direction: column; }
.srow b { font-weight: 500; }
.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--line); position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; border: 0; padding: 0; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }
.seg { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 2px; }
.seg button { padding: 5px 14px; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }
.sstatus { margin: 0; font-weight: 600; }
.sstatus.ok { color: var(--up); } .sstatus.busy { color: var(--accent); } .sstatus.err { color: var(--down); } .sstatus.warn { color: #ff9800; }
.sstatus small { color: var(--muted); font-weight: 400; }
.sfoot { display: flex; gap: 8px; align-items: center; }
.scard.stats { flex-direction: row; flex-wrap: wrap; gap: 8px 18px; }
.scard.stats b { font-size: 18px; }
.scard.about { flex-direction: row; align-items: center; gap: 14px; }
.scard.about img { border-radius: 16px; }
.scard.about div { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 768px) {
  .dialog.wide { width: 100vw; height: 92vh; }
  .settings { flex-direction: column; }
  .snav { width: auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 8px; scrollbar-width: none; }
  .snav button { width: auto; white-space: nowrap; padding: 8px 12px; }
  .sbody { padding: 14px; }
  .bigcode { font-size: 21px; letter-spacing: 1px; }
}
.sbody { min-width: 0; overflow-x: hidden; }
.scard { max-width: 100%; min-width: 0; }
.bigcode { font-size: clamp(15px, 5.2vw, 26px); letter-spacing: .5px; overflow-wrap: anywhere; }
@media (max-width: 768px) { .dialog.wide { max-width: 100vw; } .scard .row input { min-width: 0; } }

/* ---------- admin announcement ---------- */
#announce { display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin-bottom: 4px; background: linear-gradient(90deg, #2962ff33, #19c3e633); color: var(--text); font-size: 14px; flex-shrink: 0; }
#announce span { flex: 1; }
#announce button { padding: 2px 8px; color: var(--muted); }
