/* 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;
  }
  #panel .coin-columns {
    height: 42px;
    min-height: 42px;
    font-size: 9px;
  }
  #panel .coin-row {
    height: 25px;
    min-height: 25px;
    font-size: 11px;
  }
  #panel .coin-row .sorted {
    font-size: 12px;
  }
  #panel .coin-row .symbol {
    font-size: 11px;
  }
  #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; }
}
