.sando-mobile-controls {
  display: none;
}

/* La regla necesita recibir los dos toques incluso cuando el modo móvil está en Navegar. */
.chart-page.sando-pip-ruler-active .drawing-overlay,
.chart-page.sando-pip-ruler-active[data-sando-mobile-mode] .drawing-overlay {
  pointer-events: auto !important;
  cursor: crosshair !important;
  touch-action: none !important;
}

.sando-mobile-controls[hidden],
.sando-mobile-controls [hidden] {
  display: none !important;
}

.sando-chart-zoom-controls {
  z-index: 76;
  position: fixed;
  display: flex;
  gap: 5px;
  padding: 5px;
  color: #e8eef7;
  background: #071321ed;
  border: 1px solid #ffffff1f;
  border-radius: 12px;
  box-shadow: 0 15px 38px #0008;
}

.drawing-overlay-cursor ~ * {
  cursor: inherit;
}

.chart-page .chart-renderer,
.chart-page .chart-renderer canvas {
  cursor: grab;
}

html.sando-chart-panning .chart-renderer,
html.sando-chart-panning .chart-renderer canvas {
  cursor: grabbing !important;
}

.sando-chart-zoom-controls[hidden] {
  display: none !important;
}

.sando-chart-zoom-controls button {
  display: flex;
  min-width: 45px;
  min-height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #91a1b5;
  cursor: pointer;
  background: #ffffff07;
  border: 1px solid transparent;
  border-radius: 8px;
  touch-action: manipulation;
}

.sando-chart-zoom-controls button:hover,
.sando-chart-zoom-controls button:focus-visible,
.sando-chart-zoom-controls button.active {
  color: #fff;
  background: #3b74ff20;
  border-color: #6f9aff55;
}

.sando-chart-zoom-controls button > span {
  color: #9db8ff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.sando-chart-zoom-controls button > small {
  color: inherit;
  font-size: 6px;
  font-weight: 800;
}

.sando-history-status {
  z-index: 8;
  position: absolute;
  top: 12px;
  left: 50%;
  max-width: min(360px, calc(100% - 230px));
  padding: 8px 13px;
  color: #b9c8da;
  background: #071321ed;
  border: 1px solid #ffffff1f;
  border-radius: 999px;
  box-shadow: 0 12px 32px #0008;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
  pointer-events: none;
  transform: translateX(-50%);
}

.sando-history-status[hidden] {
  display: none !important;
}

.sando-history-status[data-state="loading"] {
  color: #9db8ff;
  border-color: #6f9aff55;
}

.sando-history-status[data-state="success"] {
  color: #72e3ba;
  border-color: #55d6a655;
}

.sando-history-status[data-state="error"] {
  color: #ff9ca6;
  border-color: #ef6d7a55;
}

.drawing-tools .sando-pip-ruler-button.active {
  color: #fff !important;
  background: linear-gradient(145deg, #f5c45126, #d99b2618) !important;
  border-color: #f1bd4c99 !important;
  box-shadow: inset 0 0 0 1px #f1bd4c22, 0 8px 22px #0004 !important;
}

.drawing-tools .sando-pip-ruler-button.active svg {
  color: #f6c95c !important;
}

.sando-pip-ruler-overlay {
  pointer-events: none;
}

.sando-pip-ruler-guide {
  fill: none;
  stroke: #f3c453;
  stroke-width: 2.2;
  filter: drop-shadow(0 2px 4px #000b);
}

.sando-pip-ruler-projection {
  fill: none;
  stroke: #f3c45388;
  stroke-width: 1;
  stroke-dasharray: 5 5;
}

.sando-pip-ruler-point {
  fill: #081522;
  stroke: #f3c453;
  stroke-width: 2.5;
}

.sando-pip-ruler-card {
  fill: #091827f5;
  stroke: #f3c45399;
  stroke-width: 1;
  filter: drop-shadow(0 12px 18px #000a);
}

.sando-pip-ruler-card.positive {
  stroke: #55d6a6aa;
}

.sando-pip-ruler-card.negative {
  stroke: #ef6d7aaa;
}

.sando-pip-ruler-title,
.sando-pip-ruler-copy {
  fill: #f7f9fc;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
  paint-order: stroke;
  stroke: #07131f;
  stroke-width: 2px;
}

.sando-pip-ruler-title {
  fill: #f4c65d;
  font-size: 12px;
}

.sando-pip-ruler-copy {
  fill: #b7c6d8;
  font-size: 10px;
}

html:has(.chart-page.sando-chart-fullscreen),
body:has(.chart-page.sando-chart-fullscreen) {
  overflow: hidden !important;
}

.chart-page.sando-chart-fullscreen {
  min-height: 100dvh !important;
  padding: 0 !important;
  background: #050c16 !important;
}

.chart-page.sando-chart-fullscreen .chart-header,
.chart-page.sando-chart-fullscreen .chart-titlebar,
.chart-page.sando-chart-fullscreen .chart-footer,
.chart-page.sando-chart-fullscreen .community-launcher,
.chart-page.sando-chart-fullscreen .community-panel {
  display: none !important;
}

.chart-page.sando-chart-fullscreen .chart-shell {
  min-height: 100dvh !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.chart-page.sando-chart-fullscreen .chart-workspace,
.chart-page.sando-chart-fullscreen .chart-workspace-wide {
  min-height: calc(100dvh - 192px) !important;
}

.chart-page.sando-chart-fullscreen .chart-canvas,
.chart-page.sando-chart-fullscreen .chart-workspace-wide .chart-canvas,
.chart-page.sando-chart-fullscreen .chart-workspace.with-rsi .chart-canvas,
.chart-page.sando-chart-fullscreen .chart-workspace.with-macd .chart-canvas,
.chart-page.sando-chart-fullscreen .chart-workspace.with-both .chart-canvas {
  height: calc(100dvh - 192px) !important;
}

@media (hover: hover) and (pointer: fine) {
  .chart-renderer .tv-lightweight-charts tr:first-child > td:first-child {
    cursor: grab !important;
  }

  .chart-renderer .tv-lightweight-charts tr:first-child > td:first-child:active {
    cursor: grabbing !important;
  }

  html.sando-chart-panning .chart-renderer,
  html.sando-chart-panning .chart-renderer * {
    cursor: grabbing !important;
  }

  .chart-renderer .tv-lightweight-charts tr:first-child > td:last-child,
  .chart-renderer .tv-lightweight-charts tr:nth-child(2) > td:last-child {
    cursor: ns-resize !important;
  }

  .drawing-overlay {
    right: auto !important;
    left: 0 !important;
    width: calc(100% - 88px) !important;
  }

  html.sando-price-scaling,
  html.sando-price-scaling * {
    cursor: ns-resize !important;
    user-select: none !important;
  }
}

/* Un fallo temporal de cotización no debe bloquear el historial ya dibujado. */
.chart-canvas .chart-error {
  pointer-events: none;
}

.chart-canvas .chart-error button,
.chart-canvas .chart-error a {
  pointer-events: auto;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  :root {
    --sando-mobile-nav: calc(69px + env(safe-area-inset-bottom));
  }

  body:has(.chart-page) {
    overscroll-behavior-x: none;
  }

  .chart-page {
    padding-bottom: var(--sando-mobile-nav) !important;
    overflow-x: clip !important;
  }

  .chart-header {
    min-height: 58px !important;
    gap: 10px !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-bottom: 1px solid #ffffff14 !important;
  }

  .chart-header nav,
  .chart-header-action {
    display: none !important;
  }

  .chart-brand {
    margin-right: auto;
  }

  .chart-brand-symbol {
    width: 34px !important;
    height: 34px !important;
  }

  .sando-vip-entry {
    min-height: 38px !important;
    margin: 0 !important;
    padding: 0 11px !important;
    font-size: 9px !important;
    white-space: nowrap;
  }

  .chart-shell {
    min-height: calc(100svh - 58px) !important;
    overflow: visible !important;
  }

  .chart-toolbar {
    display: grid !important;
    grid-template-columns: minmax(148px, 1.25fr) minmax(86px, .9fr) auto !important;
    gap: 7px !important;
    min-height: 58px !important;
    padding: 7px 8px !important;
    overflow: hidden !important;
  }

  .chart-market-control,
  .chart-market-control select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .chart-market-control label {
    display: none !important;
  }

  .chart-market-control select {
    min-height: 42px !important;
    padding-inline: 9px 28px !important;
    font-size: 10px !important;
  }

  .chart-timeframes {
    min-width: 0 !important;
    max-width: none !important;
    overflow-x: auto !important;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }

  .chart-timeframes::-webkit-scrollbar {
    display: none;
  }

  .chart-timeframes button {
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    min-height: 42px !important;
  }

  .chart-quote {
    min-width: 64px !important;
    padding-left: 4px !important;
  }

  .chart-live-meta {
    display: none !important;
  }

  .chart-price-live {
    font-size: 13px !important;
  }

  .chart-titlebar {
    min-height: 48px !important;
    padding: 7px 10px !important;
  }

  .chart-titlebar h1 {
    margin-top: 3px !important;
    font-size: 15px !important;
  }

  .chart-titlebar p,
  .drawing-toolbar,
  .indicator-toolbar {
    display: none !important;
  }

  .chart-workspace,
  .chart-workspace-wide {
    min-height: max(540px, calc(100svh - 164px)) !important;
  }

  .chart-canvas,
  .chart-workspace-wide .chart-canvas {
    height: max(540px, calc(100svh - 164px)) !important;
  }

  .chart-workspace.with-rsi,
  .chart-workspace.with-macd,
  .chart-workspace-wide.with-rsi,
  .chart-workspace-wide.with-macd {
    min-height: max(650px, calc(100svh - 118px)) !important;
  }

  .chart-workspace.with-rsi .chart-canvas,
  .chart-workspace.with-macd .chart-canvas,
  .chart-workspace-wide.with-rsi .chart-canvas,
  .chart-workspace-wide.with-macd .chart-canvas {
    height: max(650px, calc(100svh - 118px)) !important;
  }

  .chart-workspace.with-both,
  .chart-workspace-wide.with-both {
    min-height: max(790px, calc(100svh + 42px)) !important;
  }

  .chart-workspace.with-both .chart-canvas,
  .chart-workspace-wide.with-both .chart-canvas {
    height: max(790px, calc(100svh + 42px)) !important;
  }

  .chart-canvas {
    contain: layout paint;
  }

  .chart-footer {
    min-height: 48px !important;
    padding: 9px 10px !important;
  }

  .chart-footer p {
    font-size: 7px !important;
  }

  .chart-page[data-sando-mobile-mode="navigate"] .drawing-overlay {
    pointer-events: none !important;
    touch-action: auto !important;
  }

  .chart-page[data-sando-mobile-mode="navigate"] .chart-renderer,
  .chart-page[data-sando-mobile-mode="navigate"] .chart-renderer * {
    touch-action: none !important;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
  }

  html.sando-mobile-chart-gesture .chart-renderer {
    cursor: grabbing !important;
  }

  .chart-page[data-sando-mobile-mode="edit"] .drawing-overlay,
  .chart-page[data-sando-mobile-mode="edit"] .drawing-overlay-cursor {
    pointer-events: all !important;
    touch-action: none !important;
  }

  .chart-page[data-sando-mobile-mode="edit"] .drawing-hit-area {
    pointer-events: none !important;
  }

  .chart-page[data-sando-mobile-mode="edit"] .drawing-selectable,
  .chart-page[data-sando-mobile-mode="edit"] .drawing-selectable * {
    pointer-events: visiblePainted !important;
    cursor: move !important;
    touch-action: none !important;
  }

  .chart-page[data-sando-mobile-mode="edit"] .drawing-edit-handle {
    r: 10px;
    stroke-width: 3px !important;
    cursor: grab !important;
    pointer-events: all !important;
  }

  .sando-mobile-controls {
    display: block;
    color: #f3f7fc;
    font-family: Arial, Helvetica, sans-serif;
  }

  .sando-mobile-backdrop {
    z-index: 88;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    background: #02070ec7;
    border: 0;
  }

  .sando-mobile-toolbox {
    z-index: 90;
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--sando-mobile-nav);
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav) - 10px);
    background: linear-gradient(160deg, #0b1a2b 0%, #06101d 100%);
    border: 1px solid #ffffff1f;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: #6f9aff8c #ffffff0a;
    scroll-behavior: auto !important;
    box-shadow: 0 -22px 70px #000b;
  }

  .sando-mobile-toolbox::-webkit-scrollbar {
    width: 6px;
  }

  .sando-mobile-toolbox::-webkit-scrollbar-track {
    background: #ffffff08;
  }

  .sando-mobile-toolbox::-webkit-scrollbar-thumb {
    background: #6f9aff82;
    border: 1px solid #0a1726;
    border-radius: 999px;
  }

  .sando-mobile-toolbox > header {
    z-index: 1;
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    min-height: 68px;
    padding: 11px 13px 10px 16px;
    background: #0b1929f5;
    border-bottom: 1px solid #ffffff17;
  }

  .sando-mobile-toolbox > header > div {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
  }

  .sando-mobile-toolbox > header small {
    color: #6f9aff;
    letter-spacing: .14em;
    font-size: 7px;
    font-weight: 900;
  }

  .sando-mobile-toolbox > header strong {
    font-size: 15px;
  }

  .sando-mobile-toolbox > header > button {
    width: 44px;
    height: 44px;
    color: #b8c4d3;
    cursor: pointer;
    background: #ffffff08;
    border: 1px solid #ffffff18;
    border-radius: 12px;
    font-size: 24px;
  }

  .sando-mobile-toolbox-content {
    padding: 2px 12px calc(20px + env(safe-area-inset-bottom));
  }

  .sando-mobile-tool-section {
    padding: 17px 0 4px;
    border-bottom: 1px solid #ffffff10;
  }

  .sando-mobile-tool-section:last-child {
    border-bottom: 0;
  }

  .sando-mobile-section-heading {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0 3px 10px;
  }

  .sando-mobile-section-heading strong {
    color: #e8eef7;
    font-size: 11px;
    letter-spacing: .04em;
  }

  .sando-mobile-section-heading small {
    color: #71839a;
    font-size: 8px;
  }

  .sando-mobile-tool-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sando-mobile-tool-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 64px;
    padding: 8px;
    color: #a9b7c8;
    text-align: left;
    cursor: pointer;
    background: #ffffff08;
    border: 1px solid #ffffff17;
    border-radius: 12px;
    touch-action: manipulation;
  }

  .sando-mobile-tool-card:active {
    transform: scale(.985);
  }

  .sando-mobile-tool-card.active {
    color: #dce7ff;
    background: linear-gradient(135deg, #3b74ff28, #55d6a60d);
    border-color: #6f9aff66;
    box-shadow: inset 0 0 0 1px #6f9aff18;
  }

  .sando-mobile-tool-card[data-kind="vip"] {
    background: linear-gradient(135deg, #d9a44112, #3b74ff0a);
    border-color: #d9a44138;
  }

  .sando-mobile-tool-card[data-kind="vip"].active {
    border-color: #55d6a666;
    background: linear-gradient(135deg, #55d6a61c, #d9a44112);
  }

  .sando-mobile-tool-card.locked {
    border-style: dashed;
  }

  .sando-mobile-card-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #8eadff;
    background: #3b74ff17;
    border: 1px solid #6f9aff2e;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 900;
  }

  .sando-mobile-tool-card[data-kind="vip"] .sando-mobile-card-icon {
    color: #e1ba61;
    background: #d9a44114;
    border-color: #d9a44135;
  }

  .sando-mobile-card-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7px;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sando-mobile-card-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
  }

  .sando-mobile-card-copy strong {
    color: #e2e9f3;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sando-mobile-card-copy small {
    color: #72849a;
    font-size: 7px;
    line-height: 1.25;
  }

  .sando-mobile-card-copy i {
    color: #6f9aff;
    font-size: 7px;
    font-style: normal;
    font-weight: 800;
  }

  .sando-mobile-tool-card[data-kind="vip"] .sando-mobile-card-copy i {
    color: #d9a441;
  }

  /* Mobile VIP controls v23: one compact control surface per tool. */
  .sando-mobile-vip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .sando-mobile-vip-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    min-width: 0;
    min-height: 76px;
    overflow: hidden;
    background: linear-gradient(135deg, #d9a44115, #3b74ff0a 62%, #081728);
    border: 1px solid #d9a44145;
    border-radius: 14px;
    box-shadow: inset 0 1px 0 #ffffff08, 0 8px 24px #0002;
  }

  .sando-mobile-vip-card.active {
    background: linear-gradient(135deg, #55d6a61b, #d9a44111 58%, #081728);
    border-color: #55d6a675;
  }

  .sando-mobile-vip-card.locked {
    border-style: dashed;
    background: linear-gradient(135deg, #d9a4410f, #ffffff05);
  }

  .sando-mobile-vip-main {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 74px;
    padding: 9px 8px 9px 9px;
    color: #dfe7f1;
    text-align: left;
    cursor: pointer;
    background: transparent;
    border: 0;
    touch-action: manipulation;
  }

  .sando-mobile-vip-main:active {
    background: #ffffff08;
  }

  .sando-mobile-vip-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: #f1c55b;
    background: linear-gradient(145deg, #f0bd3d2d, #8c671b1f);
    border: 1px solid #d9a44155;
    border-radius: 11px;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: -.03em;
  }

  .sando-mobile-vip-card.active .sando-mobile-vip-icon {
    color: #7ff0c5;
    background: #55d6a61c;
    border-color: #55d6a65c;
  }

  .sando-mobile-vip-main .sando-mobile-card-copy strong {
    color: #eef3fa;
    font-size: 10px;
  }

  .sando-mobile-vip-main .sando-mobile-card-copy small {
    display: -webkit-box;
    overflow: hidden;
    font-size: 7px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .sando-mobile-vip-main .sando-mobile-card-copy i {
    color: #e1b950;
    font-size: 6.5px;
    letter-spacing: .04em;
  }

  .sando-mobile-vip-card.active .sando-mobile-card-copy i {
    color: #62dfb1;
  }

  .sando-mobile-vip-actions {
    display: flex;
    width: 50px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 6px;
    background: #030b1566;
    border-left: 1px solid #ffffff0e;
  }

  .sando-mobile-vip-switch,
  .sando-mobile-vip-settings {
    display: grid;
    min-width: 38px;
    min-height: 30px;
    place-items: center;
    color: #8797aa;
    cursor: pointer;
    background: #ffffff08;
    border: 1px solid #ffffff16;
    border-radius: 9px;
    touch-action: manipulation;
  }

  .sando-mobile-vip-switch {
    gap: 2px;
    padding: 4px 3px 3px;
  }

  .sando-mobile-vip-switch > span {
    position: relative;
    display: block;
    width: 27px;
    height: 14px;
    background: #4c596b;
    border: 1px solid #6d7888;
    border-radius: 999px;
    transition: background .18s ease, border-color .18s ease;
  }

  .sando-mobile-vip-switch > span i {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    background: #c5ced8;
    border-radius: 50%;
    box-shadow: 0 1px 4px #0009;
    transition: transform .18s ease;
  }

  .sando-mobile-vip-switch small {
    color: #8c9aac;
    font-size: 6px;
    font-weight: 900;
    line-height: 1;
  }

  .sando-mobile-vip-switch.active > span {
    background: #1f9e78;
    border-color: #55d6a6;
  }

  .sando-mobile-vip-switch.active > span i {
    background: #e4fff5;
    transform: translateX(13px);
  }

  .sando-mobile-vip-switch.active small {
    color: #65e5b5;
  }

  .sando-mobile-vip-switch.locked > span {
    background: #4b3137;
    border-color: #86505c;
  }

  .sando-mobile-vip-settings {
    color: #aab7c8;
    font-size: 14px;
  }

  .sando-mobile-vip-settings:active,
  .sando-mobile-vip-switch:active {
    color: #fff;
    background: #ffffff12;
    transform: scale(.96);
  }

  .sando-mobile-vip-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 12px;
    color: #9aa9bb;
    background: #d9a44109;
    border: 1px dashed #d9a44132;
    border-radius: 12px;
  }

  .sando-mobile-vip-loading > span {
    width: 20px;
    height: 20px;
    flex: none;
    border: 2px solid #d9a4413a;
    border-top-color: #d9a441;
    border-radius: 50%;
    animation: sando-mobile-spin .9s linear infinite;
  }

  .sando-mobile-vip-loading > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .sando-mobile-vip-loading strong {
    color: #e0e7f0;
    font-size: 10px;
  }

  .sando-mobile-vip-loading small {
    color: #75869b;
    font-size: 8px;
  }

  @keyframes sando-mobile-spin {
    to { transform: rotate(360deg); }
  }

  .sando-mobile-modebar {
    z-index: 91;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: var(--sando-mobile-nav);
    padding: 5px 7px calc(5px + env(safe-area-inset-bottom));
    background: #07111ef7;
    border-top: 1px solid #ffffff1c;
    box-shadow: 0 -14px 38px #0008;
  }

  .sando-mobile-modebar button {
    display: flex;
    min-width: 0;
    min-height: 58px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #73859b;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    touch-action: manipulation;
  }

  .sando-mobile-modebar button > span {
    font-size: 17px;
    line-height: 1;
  }

  .sando-mobile-modebar button strong {
    color: #aebac9;
    font-size: 9px;
  }

  .sando-mobile-modebar button small {
    overflow: hidden;
    max-width: 100%;
    font-size: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sando-mobile-modebar button.active {
    color: #82a5ff;
    background: #3b74ff1c;
    border-color: #6f9aff45;
  }

  .sando-mobile-modebar button.active strong {
    color: #f1f5fb;
  }

  .sando-mobile-edit-guide,
  .sando-mobile-prompt {
    z-index: 86;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(var(--sando-mobile-nav) + 10px);
    color: #dbe4ef;
    background: #0a1726f2;
    border: 1px solid #d9a4415c;
    border-radius: 13px;
    box-shadow: 0 14px 40px #0008;
  }

  .sando-mobile-edit-guide {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 8px 8px 8px 12px;
  }

  .sando-mobile-edit-guide > div {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 3px;
  }

  .sando-mobile-edit-guide strong {
    color: #f1c766;
    font-size: 10px;
  }

  .sando-mobile-edit-guide small {
    color: #8798ac;
    font-size: 7px;
  }

  .sando-mobile-edit-guide button {
    min-width: 82px;
    min-height: 42px;
    color: #ffabb2;
    cursor: pointer;
    background: #ef6d7a12;
    border: 1px solid #ef6d7a45;
    border-radius: 9px;
    font-size: 8px;
    font-weight: 800;
  }

  .sando-mobile-prompt {
    padding: 12px 14px;
    color: #cbd6e4;
    font-size: 9px;
    line-height: 1.45;
    text-align: center;
  }

  .community-launcher {
    bottom: calc(var(--sando-mobile-nav) + 12px) !important;
    right: 10px !important;
    width: 46px !important;
    min-width: 46px !important;
    height: 46px !important;
    min-height: 46px !important;
    padding: 7px !important;
  }

  .sando-settings-panel:not([hidden]) {
    z-index: 94 !important;
    position: fixed !important;
    inset: 8px 8px calc(var(--sando-mobile-nav) + 8px) !important;
    display: block !important;
    padding: 15px 12px 24px !important;
    background: #081522f8 !important;
    border: 1px solid #ffffff1d !important;
    border-radius: 16px !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    box-shadow: 0 28px 80px #000d !important;
  }

  .sando-settings-head {
    gap: 10px !important;
  }

  .sando-settings-head button,
  .sando-settings-actions button,
  .sando-settings-grid select,
  .sando-settings-grid input {
    min-height: 44px !important;
  }

  .sando-settings-grid {
    grid-template-columns: 1fr !important;
  }

  .sando-rsi-panel {
    max-width: calc(100% - 72px);
    backdrop-filter: none !important;
  }
}

@media (min-width: 600px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  .sando-mobile-tool-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sando-mobile-tool-grid.sando-mobile-vip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .sando-mobile-tool-grid.sando-mobile-vip-grid {
    grid-template-columns: 1fr;
  }

  .sando-mobile-vip-card {
    min-height: 70px;
  }

  .sando-mobile-vip-main {
    min-height: 68px;
  }
}

@media (max-width: 380px) {
  .chart-toolbar {
    grid-template-columns: minmax(138px, 1.2fr) minmax(75px, .8fr) auto !important;
  }

  .chart-titlebar small,
  .chart-brand small {
    display: none !important;
  }

  .sando-vip-entry {
    max-width: 116px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sando-mobile-toolbox-content {
    padding-inline: 9px;
  }

  .sando-mobile-tool-grid {
    gap: 6px;
  }

  .sando-mobile-tool-card {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 6px;
    min-height: 62px;
    padding: 7px;
  }

  .sando-mobile-card-icon {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  .sando-chart-zoom-controls {
    gap: 3px;
    padding: 4px;
    border-radius: 11px;
  }

  .sando-chart-zoom-controls button {
    min-width: 42px;
    width: 42px;
    min-height: 42px;
    padding: 0;
  }

  .sando-chart-zoom-controls button > small {
    display: none;
  }

  .sando-history-status {
    top: 8px;
    max-width: calc(100% - 112px);
    padding: 7px 10px;
    font-size: 8px;
  }

  .chart-page.sando-chart-fullscreen .chart-shell {
    min-height: calc(100dvh - var(--sando-mobile-nav)) !important;
  }

  .chart-page.sando-chart-fullscreen .chart-workspace,
  .chart-page.sando-chart-fullscreen .chart-workspace-wide,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-rsi,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-macd,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-both {
    min-height: calc(100dvh - 58px - var(--sando-mobile-nav)) !important;
  }

  .chart-page.sando-chart-fullscreen .chart-canvas,
  .chart-page.sando-chart-fullscreen .chart-workspace-wide .chart-canvas,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-rsi .chart-canvas,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-macd .chart-canvas,
  .chart-page.sando-chart-fullscreen .chart-workspace.with-both .chart-canvas {
    height: calc(100dvh - 58px - var(--sando-mobile-nav)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sando-mobile-vip-loading > span {
    animation: none !important;
  }
}

/* Mobile layout hardening v20: keeps every control reachable above the safe-area navigation. */
@media (max-width: 820px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  html,
  body,
  .chart-page,
  .chart-shell,
  .chart-workspace,
  .chart-canvas {
    max-width: 100% !important;
  }

  body:has(.chart-page) {
    width: 100%;
    min-width: 0;
    overflow-x: clip !important;
  }

  .chart-toolbar > *,
  .chart-titlebar > *,
  .sando-mobile-tool-card > * {
    min-width: 0;
  }

  .chart-workspace,
  .chart-workspace-wide,
  .chart-canvas,
  .chart-workspace-wide .chart-canvas {
    min-height: max(420px, calc(var(--sando-visual-height, 100dvh) - 233px)) !important;
    height: max(420px, calc(var(--sando-visual-height, 100dvh) - 233px)) !important;
  }

  .chart-workspace.with-rsi,
  .chart-workspace.with-macd,
  .chart-workspace-wide.with-rsi,
  .chart-workspace-wide.with-macd,
  .chart-workspace.with-rsi .chart-canvas,
  .chart-workspace.with-macd .chart-canvas,
  .chart-workspace-wide.with-rsi .chart-canvas,
  .chart-workspace-wide.with-macd .chart-canvas {
    min-height: max(500px, calc(var(--sando-visual-height, 100dvh) - 175px)) !important;
    height: max(500px, calc(var(--sando-visual-height, 100dvh) - 175px)) !important;
  }

  .chart-workspace.with-both,
  .chart-workspace-wide.with-both,
  .chart-workspace.with-both .chart-canvas,
  .chart-workspace-wide.with-both .chart-canvas {
    min-height: max(590px, calc(var(--sando-visual-height, 100dvh) - 112px)) !important;
    height: max(590px, calc(var(--sando-visual-height, 100dvh) - 112px)) !important;
  }

  .sando-mobile-summary,
  .sando-mobile-power {
    bottom: calc(var(--sando-mobile-nav) + 8px) !important;
  }

  /* Mobile visual hierarchy v24: advanced modules live inside Herramientas. */
  .sando-harmonic-quick-controls,
  .sando-mobile-power {
    display: none !important;
  }

  .sando-mobile-summary {
    right: 8px !important;
  }

  body:has(.sando-mobile-controls[data-sheet-open="true"]) .sando-mobile-summary,
  body:has(.sando-mobile-controls[data-sheet-open="true"]) .sando-mobile-power {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .community-launcher {
    bottom: calc(var(--sando-mobile-nav) + 62px) !important;
  }

  .community-panel {
    bottom: var(--sando-mobile-nav) !important;
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav) - 8px) !important;
  }

  .sando-intelligence-scrim,
  .sando-harmonic-scrim,
  .risk-calculator-scrim {
    bottom: var(--sando-mobile-nav) !important;
  }

  .sando-intelligence-drawer {
    right: 0 !important;
    bottom: var(--sando-mobile-nav) !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: min(58dvh, 540px) !important;
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav)) !important;
  }

  .sando-intelligence-drawer.sheet-full {
    height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav)) !important;
  }

  .sando-intelligence-content {
    height: calc(100% - 135px) !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }

  .sando-smc-panel {
    box-sizing: border-box !important;
    top: auto !important;
    right: 0 !important;
    bottom: var(--sando-mobile-nav) !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav) - 6px) !important;
    border-radius: 18px 18px 0 0 !important;
  }

  .sando-smc-scroll {
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav) - 278px) !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }

  .sando-harmonic-panel {
    box-sizing: border-box !important;
    top: 8px !important;
    right: 0 !important;
    bottom: var(--sando-mobile-nav) !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .harmonic-body,
  .sando-smc-scroll,
  .sando-intelligence-content,
  .sando-mobile-toolbox {
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch;
  }

  .harmonic-toast-stack {
    right: 8px !important;
    bottom: calc(var(--sando-mobile-nav) + 8px) !important;
    left: 8px !important;
    width: auto !important;
  }

  .risk-calculator-drawer {
    box-sizing: border-box !important;
    inset: 8px 0 calc(var(--sando-mobile-nav) + 8px) !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: auto !important;
    border: 1px solid #d9a44147 !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .risk-calculator-drawer-body {
    padding-bottom: calc(30px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sando-vip-modal {
    box-sizing: border-box;
    padding: 10px 10px calc(var(--sando-mobile-nav) + 10px) !important;
  }

  .sando-vip-modal-card {
    max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav) - 20px);
    overflow: auto !important;
    overscroll-behavior: contain;
  }

  .sando-mobile-tool-card,
  .sando-mobile-toolbox > header > button,
  .sando-sheet-handle,
  .sando-intelligence-head > button,
  .harmonic-head button,
  .sando-smc-head button {
    touch-action: manipulation;
  }
}

@media (max-width: 480px) {
  .chart-toolbar {
    grid-template-areas:
      "market quote"
      "timeframes timeframes" !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    min-height: 96px !important;
    align-items: center !important;
  }

  .chart-market-control { grid-area: market; }
  .chart-timeframes { grid-area: timeframes; }
  .chart-quote { grid-area: quote; min-width: 70px !important; }

  .chart-timeframes button {
    flex-basis: 43px !important;
    width: 43px !important;
    min-width: 43px !important;
    min-height: 38px !important;
  }

  .chart-workspace,
  .chart-workspace-wide,
  .chart-canvas,
  .chart-workspace-wide .chart-canvas {
    min-height: max(390px, calc(var(--sando-visual-height, 100dvh) - 271px)) !important;
    height: max(390px, calc(var(--sando-visual-height, 100dvh) - 271px)) !important;
  }

  .sando-mobile-tool-card {
    min-height: 68px;
  }

  .sando-mobile-card-copy strong {
    white-space: normal;
  }

  .sando-mobile-card-copy small {
    line-height: 1.35;
  }
}

@media (max-width: 340px) {
  .chart-header { padding-inline: 7px !important; }
  .chart-brand strong { font-size: 10px !important; }
  .sando-vip-entry { max-width: 104px; padding-inline: 8px !important; }
  .sando-mobile-tool-grid { grid-template-columns: 1fr; }
  .sando-mobile-tool-card { grid-template-columns: 40px minmax(0, 1fr); }
  .sando-mobile-summary { grid-template-columns: 1fr 42px 1fr; right: 58px; }
  .sando-mobile-power { width: 42px; }
}

@media (max-height: 560px) and (orientation: landscape) and (max-width: 1024px) {
  .chart-titlebar { display: none !important; }
  .chart-toolbar { min-height: 58px !important; padding-block: 5px !important; }
  .chart-market-control select,
  .chart-timeframes button { min-height: 44px !important; }
  .chart-workspace,
  .chart-workspace-wide,
  .chart-canvas,
  .chart-workspace-wide .chart-canvas {
    min-height: max(280px, calc(var(--sando-visual-height, 100dvh) - 179px)) !important;
    height: max(280px, calc(var(--sando-visual-height, 100dvh) - 179px)) !important;
  }
  .sando-mobile-toolbox { max-height: calc(var(--sando-visual-height, 100dvh) - var(--sando-mobile-nav)) !important; }
  .sando-mobile-toolbox > header { min-height: 54px; }
}

/* Contrato de interacción responsive: el tamaño visual y el hitbox coinciden.
   Estas reglas amplían únicamente controles; no alteran cálculos ni estados. */
.chart-brand,
.chart-header nav a,
.chart-header-action,
.sando-vip-entry,
.chart-market-control select,
.chart-timeframes button,
.drawing-actions button,
.chart-tutorial-hint,
.risk-calculator-toggle,
.chart-size-toggle,
.sando-settings-button,
.sando-zone-vip-settings,
.sando-smc-settings-button,
.sando-ai-head-actions button,
.sando-ai-launcher-mobile,
.sando-ai-send,
.sando-smc-head button,
.harmonic-head button,
.sando-intelligence-head button {
  min-height: 44px !important;
}

.sando-drawer-loading button {
  min-height: 44px !important;
}

.chart-timeframes button,
.drawing-actions button,
.sando-settings-button,
.sando-zone-vip-settings,
.sando-smc-settings-button,
.sando-ai-head-actions button,
.sando-ai-send,
.sando-smc-head button,
.harmonic-head button,
.sando-intelligence-head button {
  min-width: 44px !important;
}

/* Los dibujos que no caben permanecen disponibles mediante scroll y nunca
   reciben clics a través del bloque de acciones situado a la derecha. */
.drawing-tools {
  position: relative;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
}

.drawing-tools > button {
  scroll-snap-align: start;
}

.drawing-actions {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  background: #081321;
}

@media (min-width: 481px) and (max-width: 820px) {
  .chart-toolbar {
    grid-template-columns: minmax(148px, 1fr) minmax(332px, 1.35fr) minmax(72px, .4fr) !important;
  }

  .chart-market-control select {
    min-height: 44px !important;
  }

  .chart-timeframes button {
    flex-basis: 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

@media (max-width: 480px) {
  .chart-toolbar {
    min-height: 106px !important;
  }

  .chart-market-control select,
  .chart-timeframes button {
    min-height: 44px !important;
  }

  .chart-timeframes button {
    flex-basis: 44px !important;
    width: 44px !important;
    min-width: 44px !important;
  }
}
