/* v2 mobile shell: chart-first. Loaded last to replace the former squeezed desktop. */
.mobile-nav, .mobile-sheet, .mobile-shade, .mobile-drawing-bar { display: none; }
.mobile-chart-strip { display: none; }
.account-notice { position: fixed; z-index: 160; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(480px, calc(100vw - 24px)); padding: 12px; border: 1px solid var(--blue); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); color: var(--text); }
.account-notice button { padding: 10px; margin-left: 8px; background: var(--blue); color: white; border: 0; border-radius: 6px; }
.sync-indicator { font-size: 11px; color: var(--muted); }
.sync-indicator[data-kind="offline"] { color: var(--down); }
.mobile-sheet [hidden] { display: none !important; }
.session-loading { position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); color: var(--text); }
.session-loading img { width: 60px; height: 60px; border-radius: 16px; }
.session-loading strong { font-size: 22px; }
.session-loading span { color: var(--muted); font-size: 13px; }
.session-loading button { padding: 12px 24px; border: 0; border-radius: 8px; background: var(--blue); color: #fff; font-size: 14px; }
body.auth-checking #lock-screen { display: none; }
body:not(.auth-checking) .session-loading { display: none; }

@media (max-width: 1024px) {
  html, body { min-width: 0; width: 100%; overflow: hidden; overscroll-behavior: none; }
  .terminal-shell { width: 100%; height: var(--mobile-height, 100dvh); min-height: 0; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  .top-toolbar, .top-toolbar.timeframes-expanded {
    flex: 0 0 auto; height: calc(54px + env(safe-area-inset-top)); min-height: 0;
    flex-wrap: nowrap; padding: env(safe-area-inset-top) 10px 0; gap: 7px; overflow: visible;
  }
  .top-toolbar > .divider, .top-toolbar > .toolbar-spacer,
  #mobile-watchlist-toggle, .top-toolbar > .intervals { display: none !important; }
  .top-toolbar .app-logo, .top-toolbar.timeframes-expanded .app-logo { display: grid; flex: 0 0 32px; width: 32px; height: 32px; align-self: center; margin: 0; border-radius: 10px; }
  .app-logo img { width: 32px; height: 32px; }
  .symbol-picker { min-width: 0; height: 44px; padding: 0; margin: 0; gap: 5px; flex: 1 1 auto; justify-content: flex-start; }
  .symbol-picker strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  .symbol-picker .coin-icon { display: none; }
  .symbol-picker .market-tag { display: inline; font-size: 10px; flex-shrink: 0; }
  .connection-badge { flex: 0 0 auto; margin: 0; padding: 0; height: auto; font-size: 10px; }
  .connection-badge b { max-width: 48px; overflow: hidden; white-space: nowrap; }
  .terminal-body { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; width: 100%; }
  .chart-workspace { flex: 1; width: 100%; min-height: 0; border: 0; }
  .quote-strip { flex: 0 0 37px; min-height: 0; padding: 6px 12px; display: flex; justify-content: center; gap: 0; }
  .quote-identity { display: none; }
  .ohlc-row { display: flex; width: 100%; gap: 10px; overflow: hidden; font-size: 10px; flex-wrap: nowrap; white-space: nowrap; }
  .ohlc-row > span { display: none; }
  .ohlc-row > span:nth-child(4) { display: inline; font-size: 0; }
  .ohlc-row > span:nth-child(4) b { font-size: 20px; letter-spacing: -.6px; }
  .ohlc-row > #ohlc-change { display: inline; font-size: 12px; margin-right: auto; }
  .ohlc-row > span:nth-child(2), .ohlc-row > span:nth-child(3) { display: inline; font-size: 10px; }
  .chart-stage { min-height: 80px; flex: 1 1 0; width: 100%; touch-action: none; }
  .mobile-chart-strip { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; height: 28px; flex: 0 0 28px; background: var(--bg); color: var(--muted); font-size: 11px; }
  .mobile-ema52 b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 500; margin-left: 6px; }
  .mobile-chart-strip button { height: 28px; border: 0; background: none; color: var(--blue); font-size: 11px; padding: 0 8px; touch-action: manipulation; }
  .mobile-chart-strip button[hidden] { display: none; }
  .mobile-chart-controls { display: flex; align-items: center; gap: 2px; }
  .mobile-chart-strip [data-chart-text-toggle] { font-size: 11px; padding: 0 4px; min-width: 104px; }
  .chart-message small { overflow-wrap: anywhere; }
  .range-toolbar { flex: 0 0 22px; height: 22px; min-height: 0; padding: 0 10px; overflow: hidden; }
  .range-toolbar > button, .range-toolbar > #last-update { display: none; }
  .range-toolbar #history-status { max-width: 80%; overflow: hidden; text-overflow: ellipsis; font-size: 9px; margin: 0; order: -1; }
  .mobile-nav { display: grid; flex: 0 0 auto; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); z-index: 125; gap: 4px; }
  .mobile-nav button { display: grid; place-content: center; gap: 2px; min-height: 50px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11px; touch-action: manipulation; }
  .mobile-nav button > span { font-size: 23px; line-height: 25px; }
  .mobile-nav button b { font-weight: 550; white-space: nowrap; }
  .mobile-nav button.active { color: var(--blue); background: var(--blue-soft); }
  .mobile-shade.open { display: block; position: fixed; inset: 0; background: #0006; z-index: 120; }
  .mobile-sheet.open { display: flex; position: fixed; z-index: 124; flex-direction: column; left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); bottom: calc(64px + env(safe-area-inset-bottom)); max-height: calc(var(--mobile-height, 100dvh) - 140px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border: 1px solid var(--line); border-radius: 20px 20px 12px 12px; background: var(--panel); box-shadow: 0 -10px 50px #0003; overflow: hidden; }
  .mobile-sheet > header { display: flex; flex: 0 0 54px; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); }
  .mobile-sheet > header strong { font-size: 17px; }
  .mobile-sheet > header button { height: 40px; min-width: 44px; border: 0; background: var(--panel-soft); border-radius: 10px; font-size: 22px; }
  .mobile-sheet-body { overflow-y: auto; min-height: 0; padding: 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .mobile-section-note { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
  .mobile-sheet button { touch-action: manipulation; }
  .mobile-sheet input:not([type="checkbox"]):not([type="color"]), .mobile-sheet select { font-size: 16px; min-height: 40px; }
  .mobile-sheet .drawing-toolbar { display: grid; position: static; grid-template-columns: repeat(4, minmax(0,1fr)); padding: 0; overflow: visible; gap: 8px; border: 0; }
  .mobile-sheet .draw-button { width: 100%; height: 62px; min-width: 0; background: var(--panel-soft); grid-template-rows: 32px 18px; border-radius: 11px; font-size: 26px; }
  .mobile-sheet .draw-button em { font-size: 11px; }
  .mobile-sheet .draw-button.active { background: var(--blue-soft); color: var(--blue); }
  .mobile-sheet .draw-divider, .mobile-sheet .drawing-tip { display: none; }
  .mobile-sheet .tool-menu { grid-column: 1 / -1; position: static; width: 100%; max-height: none; padding: 5px; margin: 2px 0; box-shadow: none; border-radius: 10px; overflow: visible; }
  .mobile-sheet .tool-menu button { width: 100%; min-height: 62px; padding: 9px 44px 9px 8px; grid-template-columns: 38px 1fr; grid-template-rows: 22px auto; }
  .mobile-sheet .tool-menu button b { font-size: 14px; }
  .mobile-sheet .tool-menu button small { white-space: normal; font-size: 11px; line-height: 1.4; }
  .mobile-sheet .tool-favorite { width: 40px; height: 44px; right: 0; }
  .mobile-sheet .editor-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); padding: 14px 0 0; gap: 7px; border: 0; overflow: visible; white-space: normal; }
  .mobile-sheet .editor-actions > button { min-height: 44px; font-size: 12px; padding: 8px 3px; }
  .mobile-sheet .editor-actions > span { display: none; }
  .mobile-sheet .magnet-control { display: flex; grid-column: 1/-1; flex-wrap: wrap; padding: 10px; gap: 8px; }
  .mobile-sheet .magnet-control > span, .mobile-sheet .magnet-indicators, .mobile-sheet .magnet-distance span { display: inline-flex; font-size: 12px; }
  .mobile-sheet .magnet-control .magnet-distance { display: inline-flex; }
  .mobile-sheet .quick-tools { position: static; margin: 0 0 12px; max-width: 100%; box-shadow: none; }
  .mobile-sheet .quick-handle { display: none; }
  .mobile-sheet .quick-tools button { min-width: 70px; height: 50px; }
  .mobile-sheet .quick-tools.empty { display: none; }
  .mobile-sheet .intervals { display: flex; flex-wrap: wrap; position: static; gap: 8px; }
  .mobile-sheet .intervals > button { height: 44px; font-size: 13px; padding: 0 12px; background: var(--panel-soft); }
  .mobile-sheet .intervals #more-intervals, .mobile-sheet .intervals #expand-timeframes, .mobile-sheet .timeframe-menu-head { display: none !important; }
  .mobile-sheet .primary-intervals, .mobile-sheet .timeframe-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); flex: 1 0 100%; width: 100%; gap: 7px; padding: 0; }
  .mobile-sheet .primary-intervals button, .mobile-sheet .timeframe-grid button { display: block; min-width: 0; width: 100%; min-height: 44px; padding: 3px 0; font-size: 12px; background: var(--panel-soft); border-radius: 8px; }
  .mobile-sheet [data-interval].active { color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
  .mobile-sheet .timeframe-menu, .mobile-sheet .timeframe-menu.hidden { display: block !important; position: static; width: 100%; padding: 0; max-height: none; border: 0; box-shadow: none; overflow: visible; }
  .mobile-sheet .custom-timeframe { width: 100%; min-height: 44px; margin-top: 10px; }
  .mobile-sheet .flat-custom-timeframe { display: none !important; }
  .mobile-sheet .watchlist-panel { display: flex; position: static; width: 100%; padding: 0; max-height: none; transform: none; border: 0; box-shadow: none; }
  .mobile-sheet .watchlist-header { height: 44px; min-height: 44px; }
  .mobile-sheet .watchlist-header strong, .mobile-sheet #mobile-watchlist-close { display: none !important; }
  .mobile-sheet .watchlist-header::before { content: "收藏的交易品种"; color: var(--muted); }
  .mobile-sheet [data-mobile-panel][hidden] .watchlist-header::before { content: none; }
  .mobile-sheet .watchlist-columns { grid-template-columns: 1fr 88px 64px; }
  .mobile-sheet .watchlist { overflow: visible; }
  .mobile-sheet .watch-row { min-height: 56px; grid-template-columns: 1fr 88px 64px; }
  .mobile-sheet .asset b, .mobile-sheet .watch-price, .mobile-sheet .watch-change { font-size: 12px; }
  .mobile-sheet .symbol-detail { display: none; }
  .mobile-sheet .watch-remove { opacity: .8; width: 30px; height: 40px; }
  body.mobile-watchlist-open::before { display: none; }
  .mobile-sheet #indicator-panel, .mobile-sheet #indicator-panel.hidden { display: block !important; position: static; width: 100%; max-height: none; padding: 0; border: 0; box-shadow: none; overflow: visible; }
  .mobile-sheet #indicator-panel > .floating-head { display: none; }
  .mobile-sheet .indicator-row { min-height: 60px; grid-template-columns: minmax(0,1fr) 52px 46px; }
  .mobile-sheet .indicator-row label { padding: 0 4px; font-size: 14px; gap: 4px; }
  .mobile-sheet .indicator-row small { font-size: 10px; }
  .mobile-sheet .indicator-row label { min-width: 0; grid-template-columns: 20px minmax(48px,auto) minmax(0,1fr); }
  .mobile-sheet .indicator-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
  .object-panel { z-index: 150; }
  .mobile-sheet .overlay-toggle, .mobile-sheet .indicator-settings-button { width: 42px; height: 40px; font-size: 12px; margin: 0; }
  .mobile-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .mobile-settings-grid button, .mobile-settings-grid .toolbar-button { width: 100%; min-height: 48px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--panel-soft); font-size: 14px; }
  .mobile-settings-grid button span { display: inline !important; }
  .mobile-account-card { border: 1px solid var(--line); padding: 14px; border-radius: 12px; margin-bottom: 12px; background: var(--panel-soft); }
  .mobile-account-card strong { display: block; font-size: 16px; margin-bottom: 5px; }
  .mobile-account-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
  .mobile-drawing-bar.active { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--panel-soft); flex-shrink: 0; border-top: 1px solid var(--line); }
  .mobile-drawing-bar span { flex: 1; color: var(--blue); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mobile-drawing-bar button { padding: 7px 9px; min-height: 38px; border: 0; border-radius: 8px; background: var(--panel); font-size: 12px; }
  .editor-dialog { width: calc(100vw - 16px); max-width: 750px; max-height: calc(var(--mobile-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px); margin: auto; }
  .editor-dialog input, .editor-dialog select { min-height: 40px; font-size: 16px; }
  .symbol-dialog { z-index: 150; padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
  .symbol-search-card { width: 100%; height: 100%; max-height: none; }
  .symbol-result { grid-template-columns: minmax(130px,1fr) 74px 32px; padding: 8px; gap: 4px; min-height: 60px; }
  .symbol-result > :nth-child(2), .symbol-result .symbol-source { display: none; }
  .symbol-search-tabs { flex-wrap: wrap; overflow: visible; gap: 5px; }
  .symbol-search-tabs button { padding: 6px 10px; }
  .symbol-search-footer { flex-wrap: wrap; gap: 6px; }
  .symbol-search-footer small { display: block; flex-basis: 100%; font-size: 10px; line-height: 1.4; }
  .lock-screen { padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow: auto; }
  .lock-card { width: min(390px, 100%); padding: 28px 22px; }
  #access-user, #access-password, #access-submit { height: 48px; font-size: 16px; }
  #access-error { height: auto; min-height: 18px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 155; }
}
@media (max-width: 1024px) and (orientation: landscape) {
  .top-toolbar, .top-toolbar.timeframes-expanded { height: calc(44px + env(safe-area-inset-top)); }
  .quote-strip { flex-basis: 27px; padding: 2px 12px; }
  .ohlc-row > span:nth-child(4) b { font-size: 16px; }
  .mobile-nav { padding-top: 0; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; }
  .mobile-nav button > span { font-size: 20px; }
  .mobile-sheet.open { bottom: calc(48px + env(safe-area-inset-bottom)); max-height: calc(var(--mobile-height, 100dvh) - 60px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); left: 15%; right: 15%; }
  .range-toolbar { display: none; }
}
