:root,
:root[data-theme="light"] {
  --bg: #fff;
  --panel: #fff;
  --panel-soft: #f7f8fa;
  --hover: #f0f3fa;
  --text: #131722;
  --muted: #787b86;
  --line: #e0e3eb;
  --blue: #2962ff;
  --blue-soft: #e9efff;
  --up: #089981;
  --down: #f23645;
  --shadow: 0 6px 24px rgba(19, 23, 34, .14);
}

:root[data-theme="dark"] {
  --bg: #131722;
  --panel: #131722;
  --panel-soft: #1e222d;
  --hover: #2a2e39;
  --text: #d1d4dc;
  --muted: #787b86;
  --line: #2a2e39;
  --blue: #2962ff;
  --blue-soft: rgba(41, 98, 255, .18);
  --up: #26a69a;
  --down: #ef5350;
  --shadow: 0 8px 28px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body, button, input { font: 12px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif; }
body { min-width: 920px; color: var(--text); background: var(--bg); }
button, input { color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

.terminal-shell { display: flex; flex-direction: column; width: 100vw; height: 100vh; background: var(--bg); }
.top-toolbar { position: relative; z-index: 20; display: flex; align-items: center; flex: 0 0 46px; min-width: 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.app-logo { display: grid; place-items: center; align-self: stretch; width: 52px; overflow:hidden; background:#fff; }
.app-logo img{display:block;width:46px;height:46px;object-fit:cover}
.symbol-picker, .toolbar-button, .toolbar-icon, .publish-button, .intervals button { height: 34px; border: 0; border-radius: 5px; background: transparent; }
.symbol-picker { display: flex; align-items: center; gap: 7px; margin-left: 6px; padding: 0 9px; }
.symbol-picker:hover, .toolbar-button:hover, .toolbar-icon:hover, .intervals button:hover { background: var(--hover); }
.coin-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: #f7931a; font-weight: 750; }
.coin-icon.large { width: 26px; height: 26px; font-size: 15px; }
.market-tag { padding: 2px 5px; border-radius: 3px; color: var(--muted); background: var(--panel-soft); font-size: 10px; }
.chevron { color: var(--muted); font-size: 14px; }
.divider { width: 1px; height: 24px; margin: 0 4px; background: var(--line); }
.intervals { display: flex; align-items: center; gap: 1px; min-width:0; }
.primary-intervals { display: flex; align-items: center; gap: 1px; min-width:0; }
.intervals button { min-width: 38px; padding: 0 7px; color: var(--muted); font-weight: 600; }
.intervals button.active { color: var(--blue); background: var(--blue-soft); }
.intervals { position: relative; }
.timeframe-set-toggle { min-width: 44px!important; color: var(--blue)!important; border: 1px solid var(--line)!important; }
.more-intervals { min-width: 54px !important; color: var(--blue) !important; }
.expand-timeframes{min-width:44px!important;color:var(--blue)!important;border:1px solid var(--line)!important}
.viewport-lock-button{white-space:nowrap;border:1px solid var(--line)!important;flex-shrink:0}
.viewport-lock-button[aria-pressed="true"]{color:var(--blue)!important;background:var(--blue-soft)!important;border-color:var(--blue)!important}
.top-toolbar.timeframes-expanded{align-items:flex-start;flex-basis:auto;min-height:46px;height:auto;padding-top:5px;padding-bottom:5px}
.top-toolbar.timeframes-expanded .app-logo{align-self:stretch;margin-top:-5px;margin-bottom:-5px}
.top-toolbar.timeframes-expanded .intervals{align-items:flex-start;flex:1 1 420px;flex-wrap:wrap;min-height:34px}
.top-toolbar.timeframes-expanded .primary-intervals{flex:1 1 360px;flex-wrap:wrap}
.flat-custom-timeframe{min-width:72px!important;color:var(--blue)!important;border:1px dashed var(--line)!important}
.top-toolbar.timeframes-expanded .toolbar-button,.top-toolbar.timeframes-expanded .toolbar-icon,.top-toolbar.timeframes-expanded .publish-button,.top-toolbar.timeframes-expanded .connection-badge,.top-toolbar.timeframes-expanded .toolbar-spacer{margin-top:0}
.timeframe-menu { position: absolute; z-index: 90; top: 39px; left: 0; width: 430px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.timeframe-menu-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.timeframe-menu-head button{height:26px!important;min-width:110px!important;color:var(--blue)!important;background:var(--blue-soft)!important;font-size:10px}
.timeframe-menu strong { display: block; padding: 2px 5px 8px; color: var(--muted); font-size: 11px; font-weight: 500; }
.timeframe-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.timeframe-grid button, .custom-timeframe { height: 29px; border: 0; border-radius: 4px; color: var(--text); background: transparent; font-size: 11px; }
.timeframe-grid button:hover, .custom-timeframe:hover { color: var(--blue); background: var(--blue-soft); }
.custom-timeframe { width: 100%; margin-top: 7px; border-top: 1px solid var(--line); border-radius: 0; color: var(--blue); text-align: left; }
.timeframe-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--panel); box-shadow: 0 16px 64px #0004; }
.timeframe-dialog::backdrop { background: #0006; }
.timeframe-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.timeframe-dialog h2 { margin: 0; font-size: 22px; font-weight: 650; }
.timeframe-dialog-close { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 30px; font-weight: 300; }
.timeframe-dialog-close:hover { background: var(--hover); }
.timeframe-dialog-body { padding: 24px; }
.timeframe-dialog-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 18px; margin-bottom: 18px; }
.timeframe-dialog-row label { font-size: 16px; }
.timeframe-dialog-row input, .timeframe-dialog-row select { width: 100%; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--panel); font: inherit; font-size: 16px; }
.timeframe-dialog-row input:focus, .timeframe-dialog-row select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.timeframe-dialog-preview { margin: 4px 0 8px; color: var(--blue); font-size: 14px; }
.timeframe-dialog-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.timeframe-dialog-error { min-height: 18px; margin: 8px 0 0; color: var(--down); font-size: 12px; line-height: 1.5; }
.timeframe-dialog-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--line); }
.timeframe-dialog-footer button { min-width: 80px; min-height: 42px; padding: 8px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 15px; }
.timeframe-dialog-footer .timeframe-dialog-submit { border-color: var(--blue); color: #fff; background: var(--blue); }
.timeframe-dialog-footer .timeframe-dialog-submit:disabled { border-color: var(--line); color: var(--muted); background: var(--panel-soft); cursor: not-allowed; }
@media (max-width: 480px) {
  .timeframe-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; }
  .timeframe-dialog-header { padding: 16px 18px; }
  .timeframe-dialog h2 { font-size: 20px; }
  .timeframe-dialog-body { padding: 20px 18px 14px; }
  .timeframe-dialog-row { grid-template-columns: 60px minmax(0, 1fr); gap: 14px; }
  .timeframe-dialog-footer { padding: 14px 18px; }
  .timeframe-dialog-footer button { min-height: 44px; }
}
.toolbar-button { display: flex; align-items: center; gap: 6px; margin-left: 3px; padding: 0 10px; color: var(--text); }
.tool-glyph { color: var(--blue); font-size: 17px; }
.toolbar-spacer { flex: 1; }
.connection-badge { display: flex; align-items: center; gap: 6px; margin-right: 5px; padding: 0 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.connection-badge span, .market-state span { width: 7px; height: 7px; border-radius: 50%; background: #f0b90b; box-shadow: 0 0 0 3px rgba(240,185,11,.13); }
.connection-badge.live span, .market-state span { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 15%, transparent); }
.connection-badge.error span { background: var(--down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 15%, transparent); }
.toolbar-icon { width: 34px; margin-right: 2px; color: var(--muted); font-size: 17px; }
.publish-button { height: 30px; margin: 0 8px 0 3px; padding: 0 13px; color: #fff; background: var(--blue); font-weight: 650; }
.publish-button:hover { filter: brightness(1.08); }

.terminal-body { display: grid; grid-template-columns: 62px minmax(500px, 1fr) 294px; flex: 1 1 auto; min-height: 0; }
.drawing-toolbar { position: relative; z-index: 10; display: flex; align-items: center; flex-direction: column; gap: 2px; padding-top: 5px; border-right: 1px solid var(--line); background: var(--panel); }
.draw-button { position: relative; display: grid; grid-template-rows: 27px 12px; place-items: center; width: 54px; height: 46px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 27px; }
.draw-button:hover { color: var(--text); background: var(--hover); }
.draw-button.active { color: var(--blue); background: var(--blue-soft); }
.draw-button em { display: block; color: currentColor; font-size: 10px; font-style: normal; line-height: 1; }
.draw-button small { position: absolute; right: 4px; bottom: 12px; font-size: 9px; font-weight: 700; }
.draw-divider { width: 42px; height: 1px; margin: 4px 0; background: var(--line); }
.drawing-tip { position: absolute; z-index: 30; left: 64px; top: 154px; display: none; width: max-content; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--text); background: var(--panel-soft); box-shadow: var(--shadow); }
.drawing-tip.visible { display: block; }
.tool-menu { position: absolute; z-index: 60; left: 64px; top: 50px; width: 370px; max-height: calc(100vh - 90px); overflow: auto; padding: 8px 0; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.tool-menu strong { display: block; padding: 5px 14px 8px; color: var(--muted); font-size: 11px; font-weight: 500; }
.tool-menu button { display: grid; grid-template-columns: 32px 1fr; grid-template-rows: 18px 15px; align-items: center; width: 100%; min-height: 47px; padding: 5px 12px; border: 0; color: var(--text); background: transparent; text-align: left; }
.tool-menu button:hover { background: var(--hover); }
.tool-menu button > span { grid-row: 1 / span 2; color: var(--text); font-size: 20px; text-align: center; }
.tool-menu button b { font-size: 12px; font-weight: 600; }
.tool-menu button small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.chart-workspace { display: flex; min-width: 0; min-height: 0; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.quote-strip { display: flex; align-items: center; min-height: 48px; padding: 5px 10px; border-bottom: 1px solid var(--line); }
.quote-identity { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.quote-identity strong { display: block; font-size: 13px; }
.quote-identity small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; }
.ohlc-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: 11px; }
.ohlc-row b { color: var(--text); font-weight: 550; }
#ohlc-change.up, #detail-change.up, .watch-change.up { color: var(--up); }
#ohlc-change.down, #detail-change.down, .watch-change.down { color: var(--down); }
.chart-stage { position: relative; isolation: isolate; flex: 1 1 auto; min-height: 320px; overflow: hidden; }
.chart-message { position: absolute; z-index: 8; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; color: var(--muted); background: color-mix(in srgb, var(--panel) 90%, transparent); }
.chart-message.error strong { color: var(--down); }
.chart-message small { max-width: 80%; text-align: center; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.chart-message.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.range-toolbar { display: flex; align-items: center; flex: 0 0 30px; gap: 2px; padding: 0 6px; border-top: 1px solid var(--line); color: var(--muted); background: var(--panel); }
.range-toolbar button { height: 23px; padding: 0 7px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 10px; }
.range-toolbar button:hover, .range-toolbar button.active { color: var(--blue); background: var(--blue-soft); }
.range-spacer { flex: 1; }
.range-toolbar > span:not(.range-spacer) { margin-left: 8px; white-space: nowrap; font-size: 10px; }

.watchlist-panel { display: flex; min-height: 0; flex-direction: column; background: var(--panel); }
.watchlist-header { display: flex; align-items: center; justify-content: space-between; height: 42px; padding: 0 10px 0 13px; font-size: 13px; }
.watchlist-actions { display: flex; align-items: center; gap: 3px; }
.watchlist-header button { width: 26px; height: 26px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 18px; }
.watchlist-header button:hover { background: var(--hover); }
.watchlist-columns { display: grid; grid-template-columns: 1fr 76px 62px; padding: 6px 9px 6px 13px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.watchlist-columns span:not(:first-child) { text-align: right; }
.watchlist { padding: 3px 0 7px; border-bottom: 1px solid var(--line); }
.watch-item { position: relative; display: flex; align-items: stretch; padding-right: 27px; }
.watch-row { display: grid; grid-template-columns: 1fr 76px 62px; align-items: center; width: 100%; min-height: 39px; padding: 3px 4px 3px 11px; border: 0; background: transparent; text-align: left; }
.watch-row:hover { background: var(--hover); }
.watch-row.active { background: var(--blue-soft); }
.watch-remove { position: absolute; top: 7px; right: 3px; width: 23px; height: 25px; padding: 0; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 17px; opacity: .25; }
.watch-item:hover .watch-remove, .watch-remove:focus-visible { opacity: 1; }
.watch-remove:hover { color: var(--down); background: var(--hover); }
.asset { display: grid; grid-template-columns: 23px 1fr; align-items: center; min-width: 0; }
.asset i { grid-row: 1 / span 2; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: #fff; background: #78839a; font-size: 10px; font-style: normal; font-weight: 750; }
.asset i.btc { background: #f7931a; }.asset i.eth { background: #627eea; }.asset i.bnb { color: #17191f; background: #f3ba2f; }.asset i.sol { background: linear-gradient(135deg,#9945ff,#14f195); }.asset i.xrp { background: #23292f; }.asset i.gold { color: #342700; background: #d7b64d; }
.asset b { overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.asset small { color: var(--muted); font-size: 9px; }
.watch-price, .watch-change { text-align: right; font-size: 11px; }
.watch-price { font-variant-numeric: tabular-nums; }
.symbol-detail { min-height: 0; padding: 14px 13px; overflow: auto; }
.detail-head { display: flex; align-items: center; gap: 8px; }
.detail-head strong, .detail-head small { display: block; }
.detail-head small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.detail-price { display: flex; align-items: baseline; gap: 5px; margin-top: 14px; }
.detail-price strong { font-size: 25px; letter-spacing: -.5px; }
.detail-price span { color: var(--muted); }
.detail-change { margin-top: 2px; font-weight: 650; }
.market-state { display: flex; align-items: center; gap: 7px; margin: 13px 0; color: var(--up); font-size: 10px; }
.symbol-detail dl { margin: 0; border-top: 1px solid var(--line); }
.symbol-detail dl div { display: flex; align-items: center; justify-content: space-between; min-height: 31px; border-bottom: 1px solid var(--line); }
.symbol-detail dt { color: var(--muted); }.symbol-detail dd { margin: 0; font-variant-numeric: tabular-nums; }
.data-proof { display: flex; align-items: center; gap: 9px; margin-top: 13px; padding: 9px; border-radius: 6px; background: var(--panel-soft); }
.data-proof > span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: var(--up); }
.data-proof b, .data-proof small { display: block; }.data-proof b { font-size: 10px; }.data-proof small { margin-top: 1px; color: var(--muted); font-size: 9px; }

.floating-panel { position: fixed; z-index: 80; top: 43px; left: 360px; width: 252px; padding-bottom: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.floating-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 10px 0 13px; border-bottom: 1px solid var(--line); }
.floating-head button { width: 25px; height: 25px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 18px; }
.floating-head button:hover { background: var(--hover); }
.floating-panel label { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; min-height: 39px; padding: 0 13px; cursor: pointer; }
.floating-panel label:hover { background: var(--hover); }
.floating-panel input { width: 15px; height: 15px; accent-color: var(--blue); }
.floating-panel label small { color: var(--muted); }
.indicator-row { display: grid; grid-template-columns: 1fr 42px 30px; align-items: center; border-bottom: 1px solid var(--line); }
.indicator-row > label { border-bottom: 0; }
.indicator-settings-button { width: 25px; height: 25px; margin-right: 5px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; }
.indicator-settings-button:hover { color: var(--blue); background: var(--hover); }
.overlay-toggle { width: 36px; height: 22px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: transparent; font-size: 9px; }
.overlay-toggle.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.indicator-config { margin: 5px 8px 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-soft); }
.config-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px; border-bottom: 1px solid var(--line); }
.config-head button { width: 22px; height: 22px; border: 0; color: var(--muted); background: transparent; font-size: 16px; }
.config-fields { padding: 7px 9px 3px; }
.config-fields label { display: flex; align-items: center; justify-content: space-between; min-height: 31px; padding: 0; border: 0; color: var(--muted); font-size: 10px; }
.config-fields input[type="number"] { width: 74px; height: 25px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); text-align: right; }
.color-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-top: 3px; }
.color-fields label { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.color-fields input[type="color"] { width: 100%; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: transparent; }
.apply-config { width: calc(100% - 18px); height: 29px; margin: 3px 9px 7px; border: 0; border-radius: 4px; color: #fff; background: var(--blue); font-size: 11px; }
.source-code-note { display: block; padding: 0 9px 8px; color: var(--muted); font-size: 9px; }
.symbol-dialog { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .36); }
.dialog-card { width: min(430px, calc(100vw - 34px)); padding-bottom: 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: var(--shadow); }
.dialog-card input { display: block; width: calc(100% - 28px); height: 39px; margin: 16px 14px 10px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); text-transform: uppercase; }
.dialog-card > button { height: 34px; margin-left: 14px; padding: 0 16px; border: 0; border-radius: 5px; color: #fff; background: var(--blue); font-weight: 650; }
.dialog-card > small { margin-left: 10px; color: var(--muted); }
.symbol-search-card{width:min(820px,calc(100vw - 34px));height:min(720px,calc(100vh - 50px));padding:0;display:flex;flex-direction:column;overflow:hidden}
.symbol-search-card .floating-head{flex:0 0 auto;padding:17px 20px;border-bottom:1px solid var(--line);font-size:20px}
.symbol-search-input{display:flex;align-items:center;gap:8px;margin:14px 18px 8px;padding:0 12px;border:2px solid var(--blue);border-radius:7px;background:var(--panel-soft)}
.symbol-search-input span{font-size:25px;color:var(--muted)}.symbol-search-input input{width:100%;height:48px;margin:0;padding:0;border:0;background:transparent;font-size:17px;outline:0}
.symbol-search-tabs{display:flex;gap:7px;padding:2px 18px 10px}.symbol-search-tabs button{border:0;border-radius:18px;padding:7px 14px;background:var(--panel-soft);color:var(--text)}.symbol-search-tabs button.active{background:var(--text);color:var(--panel)}
.symbol-results{flex:1;overflow:auto;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.symbol-results>p{padding:18px;color:var(--muted)}
.symbol-result{display:grid;grid-template-columns:minmax(170px,.85fr) minmax(210px,1.35fr) 105px 94px 42px;align-items:center;gap:10px;width:100%;min-height:58px;padding:6px 17px;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--text);text-align:left}.symbol-result:hover,.symbol-result.selected{background:var(--blue-soft)}
.symbol-result .symbol-code{display:flex;align-items:center;gap:10px;color:var(--blue);font-weight:700}.symbol-result .symbol-icon{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;color:#fff;background:#f7931a}.symbol-result small{color:var(--muted)}.symbol-result .symbol-market{text-align:right}.symbol-result .symbol-source{font-weight:650}.symbol-result .symbol-add{font-size:23px;text-align:center}
.symbol-search-footer{display:flex;align-items:center;gap:13px;padding:12px 18px}.symbol-search-footer button{height:36px;padding:0 16px;border:0;border-radius:5px;background:var(--blue);color:#fff;font-weight:650}.symbol-search-footer small{color:var(--muted)}
.toast { position: fixed; z-index: 120; left: 50%; bottom: 44px; transform: translateX(-50%); padding: 8px 12px; border-radius: 5px; color: #fff; background: rgba(19, 23, 34, .9); box-shadow: var(--shadow); }

@media (max-width: 1100px) {
  .terminal-body { grid-template-columns: 62px minmax(500px, 1fr) 250px; }
  .quote-identity { min-width: 215px; }
  .ohlc-row span:nth-last-child(-n+1) { display: none; }
  .watchlist-columns, .watch-row { grid-template-columns: 1fr 68px 54px; }
}

@media (max-height: 680px) {
  .symbol-detail { padding-top: 9px; }
  .detail-price { margin-top: 8px; }
  .market-state { margin: 8px 0; }
}

/* Mobile browser layout keeps the chart primary while preserving every
   desktop tool. Toolbars scroll horizontally instead of shrinking hit areas. */
@media (max-width: 760px) {
  html, body { overflow: hidden; overscroll-behavior: none; }
  body { min-width: 0; min-height: 100%; }
  button, input, select { font-size: 13px; }
  .mobile-only { display: inline-grid !important; }
  .terminal-shell { height: 100dvh; min-height: 100%; }

  .top-toolbar {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left));
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .top-toolbar::-webkit-scrollbar, .drawing-toolbar::-webkit-scrollbar, .range-toolbar::-webkit-scrollbar { display: none; }
  .app-logo { flex: 0 0 42px; width: 42px; height: 40px; border-radius: 7px; }
  .app-logo img { width: 40px; height: 40px; }
  .symbol-picker { flex: 0 0 auto; height: 40px; margin-left: 0; padding: 0 7px; }
  .symbol-picker .coin-icon { display: none; }
  .divider { flex: 0 0 1px; margin: 0 2px; }
  .intervals { flex: 0 0 auto; }
  .primary-intervals { flex: 0 0 auto; }
  .primary-intervals button:nth-child(n+5) { display: none; }
  .top-toolbar.timeframes-expanded { align-items: center; min-height: 48px; padding-top: 4px; padding-bottom: 4px; flex-wrap: nowrap; }
  .top-toolbar.timeframes-expanded .app-logo { align-self: auto; margin: 0; }
  .top-toolbar.timeframes-expanded .intervals, .top-toolbar.timeframes-expanded .primary-intervals { flex: 0 0 auto; flex-wrap: nowrap; }
  .top-toolbar.timeframes-expanded .primary-intervals button { display: inline-block; }
  .intervals button { min-width: 42px; height: 40px; padding: 0 7px; }
  .timeframe-set-toggle { min-width: 48px !important; }
  .more-intervals, .expand-timeframes { min-width: 52px !important; }
  .toolbar-button { flex: 0 0 auto; height: 40px; margin-left: 0; padding: 0 10px; }
  .toolbar-icon { flex: 0 0 40px; width: 40px; height: 40px; margin: 0; }
  .toolbar-spacer { display: none; }
  .connection-badge { flex: 0 0 auto; height: 40px; margin: 0; padding: 0 7px; }
  .publish-button { flex: 0 0 auto; height: 38px; margin: 0; padding: 0 11px; }
  .timeframe-menu {
    position: fixed;
    top: 54px;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
    max-height: min(62dvh, 480px);
    overflow-y: auto;
  }
  .timeframe-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .timeframe-grid button, .custom-timeframe { min-height: 42px; font-size: 13px; }

  .terminal-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 55px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
  }
  .drawing-toolbar {
    grid-row: 1;
    z-index: 40;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left));
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .draw-button { flex: 0 0 48px; width: 48px; height: 47px; grid-template-rows: 26px 13px; font-size: 23px; touch-action: manipulation; }
  .draw-button em { font-size: 9px; }
  .draw-divider { flex: 0 0 1px; width: 1px; height: 36px; margin: 0 3px; }
  .drawing-tip { position: fixed; left: 10px; top: 112px; max-width: calc(100vw - 20px); }
  .tool-menu {
    position: fixed;
    z-index: 95;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: 108px;
    width: auto;
    max-height: calc(100dvh - 124px - env(safe-area-inset-bottom));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .tool-menu button { min-height: 56px; grid-template-rows: 21px 18px; padding-top: 7px; padding-bottom: 7px; }
  .tool-menu button b { font-size: 14px; }
  .tool-menu button small { font-size: 11px; }

  .chart-workspace { grid-row: 2; min-width: 0; border-right: 0; }
  .quote-strip { min-height: 58px; padding: 5px 8px; align-items: flex-start; flex-direction: column; gap: 3px; overflow: hidden; }
  .quote-identity { min-width: 0; width: 100%; gap: 6px; }
  .quote-identity .coin-icon { display: none; }
  .quote-identity small { max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ohlc-row { width: max-content; max-width: 100%; gap: 8px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; scrollbar-width: none; }
  .ohlc-row::-webkit-scrollbar { display: none; }
  .chart-stage { min-height: 220px; touch-action: none; }
  .range-toolbar { flex: 0 0 40px; min-width: 0; padding: 0 max(6px, env(safe-area-inset-right)) max(env(safe-area-inset-bottom), 0px) max(6px, env(safe-area-inset-left)); overflow-x: auto; scrollbar-width: none; }
  .range-toolbar button { flex: 0 0 auto; min-width: 42px; height: 31px; font-size: 11px; }
  .range-toolbar > span:not(.range-spacer) { flex: 0 0 auto; margin-left: 4px; }
  .range-spacer { min-width: 5px; }

  .watchlist-panel {
    position: fixed;
    z-index: 110;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 360px);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    border-left: 1px solid var(--line);
    box-shadow: -14px 0 34px rgba(0,0,0,.28);
    transform: translateX(105%);
    transition: transform .22s ease;
  }
  body.mobile-watchlist-open::before { content: ""; position: fixed; z-index: 105; inset: 0; background: rgba(0,0,0,.42); }
  body.mobile-watchlist-open .watchlist-panel { transform: translateX(0); }
  .watchlist-header { min-height: 50px; padding-left: 15px; }
  .watchlist-header button { width: 38px; height: 38px; font-size: 22px; }
  .watchlist { flex: 1 1 auto; overflow-y: auto; }
  .watch-row { min-height: 48px; }
  .watch-remove { top: 10px; width: 30px; height: 30px; opacity: .7; }
  .symbol-detail { display: none; }

  .floating-panel { top: 58px; left: 8px; right: 8px; width: auto; max-height: calc(100dvh - 70px); }
  .floating-panel label { min-height: 46px; }
  .symbol-dialog { align-items: stretch; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .symbol-search-card { width: 100%; height: 100%; max-height: none; border-radius: 10px; }
  .symbol-search-card .floating-head { padding: 10px 13px; font-size: 17px; }
  .symbol-search-input { margin: 10px 10px 7px; }
  .symbol-search-input input { height: 44px; font-size: 16px; }
  .symbol-search-tabs { gap: 5px; padding: 2px 10px 8px; overflow-x: auto; }
  .symbol-search-tabs button { flex: 0 0 auto; min-height: 38px; }
  .symbol-result { grid-template-columns: minmax(135px,1fr) 74px 32px; min-height: 62px; padding: 7px 10px; gap: 5px; }
  .symbol-result > :nth-child(2), .symbol-result .symbol-source { display: none; }
  .symbol-result .symbol-market { text-align: right; }
  .symbol-search-footer { padding: 9px 10px; }
  .symbol-search-footer small { display: none; }
  .toast { bottom: calc(50px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); text-align: center; }
  .lock-screen { padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .lock-card { width: 100%; max-width: 390px; padding: 27px 22px 23px; }
  #access-user, #access-password, #access-submit { height: 48px; font-size: 16px; }
}

@media (max-width: 390px) {
  .app-logo { display: none; }
  .symbol-picker { margin-left: 0; }
  .toolbar-button span:last-child { display: none; }
  .toolbar-button { width: 40px; justify-content: center; padding: 0; }
  .primary-intervals button:nth-child(n+4) { display: none; }
  .market-tag { display: none; }
}

@media (max-width: 760px) and (orientation: landscape) {
  .top-toolbar { min-height: 44px; padding-top: 2px; padding-bottom: 2px; }
  .terminal-body { grid-template-rows: 49px minmax(0, 1fr); }
  .draw-button { height: 43px; }
  .quote-strip { min-height: 42px; flex-direction: row; align-items: center; }
  .quote-identity { width: auto; flex: 0 0 auto; }
  .ohlc-row { flex: 1 1 auto; }
  .tool-menu { top: 98px; max-height: calc(100dvh - 106px); }
  .range-toolbar { flex-basis: 36px; }
}
body.locked .terminal-shell{display:none}
.lock-screen{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#0f131c;color:#e8edf7;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
.lock-card{width:min(360px,calc(100vw - 40px));padding:34px 30px 28px;border:1px solid #2b3446;border-radius:16px;background:#171d29;box-shadow:0 20px 70px #0008;text-align:center}
.lock-logo{display:block;width:88px;height:88px;margin:0 auto 10px;border-radius:50%;object-fit:cover;box-shadow:0 8px 28px #0005}.lock-card h1{font-size:24px;margin:0 0 8px}.lock-card p{margin:0 0 20px;color:#9aa7bb;font-size:14px}
#access-user,#access-password{width:100%;height:42px;margin-top:9px;padding:0 12px;border:1px solid #3a465b;border-radius:8px;background:#0f141e;color:#fff;font-size:15px;outline:none}#access-user:focus,#access-password:focus{border-color:#3b9cff}
.remember-login{display:flex;align-items:center;gap:7px;margin-top:12px;color:#b4bfd0;font-size:13px;text-align:left}.remember-login input{width:16px;height:16px;accent-color:#3b9cff}
#access-submit{width:100%;height:42px;margin-top:12px;border:0;border-radius:8px;background:#3b9cff;color:#fff;font-weight:600;font-size:15px;cursor:pointer}#access-submit:hover{background:#55aaff}
#access-error{display:block;height:18px;margin-top:10px;color:#ff6b7a;font-size:12px}
[data-theme="light"] .lock-screen{background:#eef2f7;color:#182131}[data-theme="light"] .lock-card{background:#fff;border-color:#d5dce8;box-shadow:0 20px 70px #41516a22}[data-theme="light"] #access-user,[data-theme="light"] #access-password{background:#f7f9fc;color:#182131;border-color:#c8d2e1}
