/* The mobile app has its own full-screen panels; desktop layout stays in app.css. */
#mobile-shell,
.mobile-chart-alert {
  display: none;
}
@media (max-width: 649.98px), (max-width: 949.98px) and (max-height: 499.98px) {
  body {
    --mobile-top: calc(42px + env(safe-area-inset-top));
    --mobile-bottom: calc(103px + env(safe-area-inset-bottom));
    padding-top: env(safe-area-inset-top);
  }
  #toolbar {
    height: 42px;
    padding: 4px 5px 5px;
    gap: 6px;
    font-size: 14px;
  }
  #toolbar .toolbar-center,
  #toolbar .toolbar-left > .tools:nth-child(2),
  #toolbar .toolbar-right [data-action="search"],
  #toolbar .toolbar-right .mobile-only,
  #toolbar .toolbar-right .sound-tool,
  #toolbar .toolbar-right .language-tool,
  #toolbar .toolbar-right .brand,
  #toolbar .settings-label {
    display: none;
  }
  #toolbar .toolbar-left {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #toolbar .toolbar-left > .tools {
    flex-shrink: 0;
  }
  #toolbar .toolbar-right {
    margin-left: 0;
  }
  #toolbar .toolbar-right > .tools {
    flex-direction: row;
  }
  #toolbar .toolbar-right [data-action="settings"] {
    order: 3;
  }
  #toolbar .toolbar-right [data-action="theme"],
  #toolbar .toolbar-right .fullscreen-tool,
  #toolbar .toolbar-left .group-tool {
    display: flex;
  }
  #toolbar .tool {
    height: 33px;
    min-width: 33px;
    padding: 0 7px;
  }
  #toolbar .tools {
    height: 33px;
    padding: 0;
  }
  #toolbar svg {
    width: 18px;
    height: 18px;
  }
  #workspace,
  #workspace.panel-closed {
    height: calc(100dvh - var(--mobile-top) - var(--mobile-bottom));
    grid-template-columns: minmax(0, 1fr);
    padding: 0 5px;
    gap: 0;
    min-height: 0;
  }
  #rail {
    display: none;
  }
  #board {
    grid-column: 1;
    grid-row: 1;
    gap: 0;
  }
  #panel {
    position: static;
    width: auto;
    z-index: auto;
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
  }
  body:not([data-mobile-screen="chart"]) #board {
    display: none;
  }
  body[data-mobile-screen="chart"] #panel {
    display: none;
  }
  #panel .panel-head {
    height: 28px;
    min-height: 28px;
    font-size: 13px;
    padding: 0 6px;
  }
  #panel .panel-head [data-action="search"] {
    display: none;
  }
  /* Плотность как у ScalpBoard на телефоне: строка 24 px, шрифт 11 px,
     двухстрочный заголовок колонок, сортируемая колонка жирнее и ярче. */
  #panel .coin-columns {
    height: 44px;
    min-height: 44px;
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: 0.02em;
  }
  #panel .coin-row {
    height: 24px;
    min-height: 24px;
    font-size: 11px;
    border-bottom: 0;
  }
  #panel .coin-row .sorted {
    font-size: 12px;
    font-weight: 600;
    color: var(--bright);
  }
  #panel .coin-row .symbol {
    font-size: 11px;
    font-weight: 400;
    color: var(--bright);
    letter-spacing: 0.02em;
  }
  #panel .panel-head {
    height: 34px;
    min-height: 34px;
    font-size: 14px;
  }
  /* Ценовые уведомления: таблица как на большом экране, но под палец. */
  #panel .event-columns {
    height: 34px;
    font-size: 10px;
    letter-spacing: 0.02em;
    grid-template-columns: 1.2fr 1fr 1.1fr 28px;
  }
  #panel .compact-event {
    min-height: 44px;
    font-size: 12px;
    grid-template-columns: 1.2fr 1fr 1.1fr 28px;
    border-bottom: 1px solid #80808012;
  }
  #panel .compact-event button:first-child {
    font-size: 12px;
    font-weight: 500;
    color: var(--bright);
    line-height: 1.25;
  }
  #panel .compact-event button small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
  }
  #panel .compact-event > span small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
  }
  #panel .compact-event .event-remove {
    position: static;
    display: flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }
  #panel .compact-event .event-remove svg {
    width: 14px;
    height: 14px;
  }
  #panel .coin-row .symbol::before {
    content: "";
    display: block;
    flex: 0 0 9px;
    height: 9px;
    background: #4a4a4a;
    clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%);
  }
  #panel .coin-row .symbol:has(.color-tag)::before {
    display: none;
  }
  #panel .coin-row .color-tag {
    width: 9px;
    height: 9px;
    border-radius: 0;
  }
  .chart-head {
    height: 28px;
    min-height: 28px;
    font-size: 13px;
    line-height: 28px;
  }
  .chart-title {
    font-size: 12px;
    height: 28px;
    font-weight: 400;
    gap: 4px;
  }
  .chart-metrics {
    height: 28px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .chart-metrics .metric,
  .chart-metrics .metric:nth-child(n) {
    display: inline-flex;
    font-size: 13px;
    padding: 0 6px;
    gap: 4px;
  }
  .chart-metrics .metric svg {
    width: 14px;
    height: 14px;
  }
  .has-focus .chart-title {
    display: none;
  }
  .chart-action {
    opacity: 1;
    min-width: 25px;
    height: 27px;
  }
  .chart-card:not(.focus-card) .drawing-dock {
    display: flex;
  }
  .drawing-dock {
    top: 42%;
  }
  .drawing-dock .mobile-chart-alert {
    display: flex;
  }
  .focus-toggle {
    opacity: 1;
    bottom: 3px;
    right: 3px;
  }
  #mobile-shell {
    display: flex;
    flex-direction: column;
    gap: 7px;
    height: var(--mobile-bottom);
    padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
    background: var(--bg);
  }
  .mobile-utilities {
    height: 43px;
    min-height: 43px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }
  .mobile-sort-filter,
  .mobile-chart-selectors,
  .mobile-coin-picker {
    display: flex;
    min-width: 0;
    gap: 1px;
  }
  .mobile-sort-filter {
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
  }
  .mobile-sort-filter button {
    background: var(--tool);
    padding: 0 7px;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 43px;
    font-size: 13px;
  }
  .mobile-sort-filter button:last-child {
    width: 43px;
    justify-content: center;
  }
  .mobile-sort-filter svg {
    width: 16px;
    height: 16px;
  }
  .mobile-chart-selectors {
    max-width: 58%;
  }
  .mobile-chart-selectors select {
    border: 0;
    border-radius: 3px;
    background: var(--tool);
    padding: 0 4px;
    height: 43px;
    font-size: 12px;
  }
  #mobile-timeframe {
    max-width: 44px;
  }
  .mobile-coin-picker {
    background: var(--tool);
    border-radius: 3px;
  }
  .mobile-coin-picker select {
    width: 79px;
  }
  .mobile-coin-picker button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    padding: 0;
  }
  .mobile-coin-picker button svg {
    width: 13px;
    height: 13px;
  }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) 43px;
    gap: 1px;
    height: 43px;
    min-height: 43px;
  }
  .mobile-nav button {
    background: var(--tool);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 3px 0;
    font-size: 11px;
    border: 1px solid transparent;
  }
  .mobile-nav button.active {
    background: var(--active);
    border-color: #666;
  }
  .mobile-nav svg {
    width: 17px;
    height: 17px;
  }
  .mobile-sort-options {
    padding: 12px;
    display: grid;
    gap: 6px;
    overflow-y: auto;
  }
  .mobile-sort-options .choice {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    text-align: left;
  }
  .filter-popover {
    top: auto !important;
    bottom: var(--mobile-bottom);
    max-height: calc(100dvh - var(--mobile-bottom) - 12px);
    overflow-y: auto;
  }
  #toasts {
    bottom: calc(var(--mobile-bottom) + 8px);
  }
}

/* "Поток" on phones: two full-width control rows, touch-sized rows. */
@media (max-width: 649.98px), (max-width: 949.98px) and (max-height: 499.98px) {
  .mobile-nav button { font-size: 10px; }
  /* Coin sort and filters do not apply to the flow list. */
  body[data-mobile-screen="flow"] .mobile-utilities { display: none; }
  #panel .flow-controls { flex-direction: column; gap: 6px; padding: 6px; }
  #panel .flow-controls .segmented { width: 100%; }
  #panel .flow-controls .segmented button { flex: 1; min-height: 34px; padding: 0 4px; font-size: 12px; }
  #panel .flow-columns { height: 30px; font-size: 10px; grid-template-columns: 20px 1.2fr 1fr 0.95fr 0.85fr; }
  #panel .flow-row { min-height: 38px; font-size: 12px; grid-template-columns: 20px 1.2fr 1fr 0.95fr 0.85fr; }
  #panel .flow-row button { min-height: 38px; font-size: 13px; }
  #panel .flow-row .venue { display: none; }
  #panel .flow-row small { font-size: 11px; }
  #panel .flow-rank { font-size: 11px; }
  #panel .panel-note { font-size: 10px; line-height: 1.4; padding: 6px; }
}

/* Док рисования в фокусе на телефоне: пять инструментов крупно слева,
   глаз и корзина отдельным блоком внизу слева. */
@media (max-width: 649.98px), (max-width: 949.98px) and (max-height: 499.98px) {
  .focus-card .drawing-dock:not(.drawing-dock-bottom) [data-tool="cursor"],
  .focus-card .drawing-dock [data-tool="radial"],
  .focus-card .drawing-dock [data-tool="magnet"],
  .focus-card .drawing-dock [data-tool="eye"],
  .focus-card .drawing-dock [data-tool="undo"],
  .focus-card .drawing-dock [data-tool="redo"],
  .focus-card .drawing-dock .drawing-separator { display: none; }
  /* Компактно, как у ScalpBoard: кнопка 24 px, иконка 15 px, узкая колонка. */
  .focus-card .drawing-dock {
    top: 40%;
    left: 4px;
    width: auto;
    height: auto;
    max-height: none;
    padding: 3px;
    gap: 3px;
    border-radius: 6px;
    overflow: visible;
  }
  .focus-card .drawing-dock.drawing-dock-bottom:not([hidden]) {
    display: flex !important;
    top: auto;
    bottom: 34px;
  }
  .focus-card .drawing-button {
    width: 24px;
    height: 24px;
    min-height: 24px;
    flex-basis: 24px;
    padding: 4px;
  }
  .focus-card .drawing-button svg { width: 15px; height: 15px; stroke-width: 1.6; }
  .focus-card .drawing-editor { top: 6px; left: 60px; height: 40px; }
  .focus-card .drawing-editor .drawing-button { width: 30px; height: 30px; min-height: 30px; flex-basis: 30px; }
}

@media (max-width: 649.98px), (max-width: 949.98px) and (max-height: 499.98px) {
  #toolbar .toolbar-right .account-tool.corner { display: flex; order: 9; margin-left: 4px; width: 33px; min-width: 33px; }
}
