/* Phone pass (task 38). Every rule below 760 px except the two hidden-by-default
   phone controls, so desktop and tablet render exactly as before. Tokens only. */

.quick-trade, .watch-toggle { display: none; }

@media (max-width: 759px) {
  /* ── Shared: tap targets, readable small print ── */
  .search, .search input { min-height: 44px; }
  .footer-cols a, .footer-cols .link-btn { min-height: 44px; }
  .footer-legal { font-size: 0.8125rem; line-height: 1.55; }
  .auth-switch .text-link, .auth-main .text-link { display: inline-flex; align-items: center; min-height: 44px; }
  .check-line { padding-block: 10px 6px; }
  .check-line input { width: 22px; height: 22px; }

  /* Landing header: brand, start button and menu fit from 360 px */
  .header-inner { gap: 10px; }
  .header-actions { gap: 4px; flex: none; }
  .site-header .brand { gap: 8px; min-width: 0; }
}
@media (max-width: 400px) {
  .site-header .brand { font-size: 1.15rem; letter-spacing: -0.005em; }
  .site-header .brand svg, .site-header .brand .brand-mark { width: 24px; height: 24px; }
  .site-header .brand small { padding: 2px 4px; letter-spacing: 0.04em; }
  .header-actions .button-sm { padding-inline: 14px; }
  /* Room for the search field: avatar without the nickname, guest login stays in the order panel */
  .user-chip > span:not(.avatar) { display: none; }
  .topbar-user .button-quiet { display: none; }
}
@media (max-width: 759px) {

  .footer-cols a, .footer-cols .link-btn { min-width: 44px; }
  .topbar-brand, .topbar .brand { min-width: 44px; justify-content: center; }
  .topbar .button { min-height: 44px; }
  select.pt-input { min-height: 44px; }

  /* ── Tables become cards: header row hidden, each cell carries its label ── */
  .data-cards thead { display: none; }
  .data-cards, .data-cards tbody { display: block; min-width: 0; width: 100%; }
  .data-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 18px 2px; border-bottom: 1px solid var(--line); }
  .data-cards tr:hover, .data-cards tbody tr:hover td { background: none; }
  .data-cards td, .data-cards td.r, .data-cards td.num { display: block; padding: 0; border: 0; white-space: normal; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .data-cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; font-family: var(--font-body); font-size: 0.75rem; font-weight: 500; color: var(--muted); }
  .data-cards td:first-child { grid-column: 1 / -1; font-size: 1rem; font-weight: 600; }
  .data-cards td:first-child::before { display: none; }
  .data-cards td:first-child a, .data-cards td:first-child .link-btn { display: inline-flex; align-items: center; min-height: 44px; }
  .data-cards td:last-child:not([data-label]) { grid-column: 1 / -1; }
  .data-cards td:last-child:not([data-label]) .button { width: 100%; justify-content: center; }
  .data-cards td small { display: inline; margin-left: 6px; }
  .data-cards td a { display: inline-flex; align-items: center; min-height: 44px; }
  .data-cards .edit-row { display: block; }
  .data-cards .edit-row td { grid-column: auto; }
  .table-wrap:has(.data-cards) { overflow: visible; }

  /* Comparison table (challenges): rule as a heading, the two models side by side */
  .model-table thead { display: none; }
  .model-table, .model-table tbody { display: block; }
  .model-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; padding: 16px 0; border-top: 1px solid var(--line); }
  .model-table th, .model-table td { padding: 0; border: 0; text-align: left; }
  .model-table th[scope="row"] { grid-column: 1 / -1; font-weight: 600; color: var(--ink); }
  .model-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-family: var(--font-body); font-size: 0.75rem; color: var(--muted); }
  .board-wrap:has(.model-table) { overflow: visible; }

  /* Leaderboard filters: two columns, full-width button */
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  .filters select { min-width: 0; width: 100%; }
  .filters .button { width: 100%; justify-content: center; }
  .filters .hint { grid-column: 1 / -1; }

  /* ── Checkout ── */
  .checkout .steps { gap: 8px 18px; }
  .plan-switch-row a { min-height: 48px; }
  .promo-row { grid-template-columns: minmax(0, 1fr); }
  .promo-row .button { width: 100%; justify-content: center; }
  .receipt { gap: 14px; }
  .receipt-lines > div { flex-wrap: wrap; gap: 2px 16px; padding-block: 12px; }
  .receipt-lines dd { margin-left: auto; }

  /* ── Cabinet ── */
  .app-content { gap: 32px; padding: 20px 16px 48px; }
  .app-head { align-items: stretch; }
  .app-head-actions { width: 100%; display: grid; gap: 12px; }
  .app-head-actions > .button { width: 100%; justify-content: center; min-height: var(--btn-h); }
  .dashboard-account-controls select, .dashboard-account-controls .button { min-height: 48px; }
  .band { padding: 18px 16px; }
  .band-head { margin-bottom: 6px; }
  .fig { padding: 16px 18px; }
  .profile > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pt-tabs a { min-height: 44px; display: inline-flex; align-items: center; }
  .pt-copy { flex-wrap: wrap; }
  .pt-copy code { flex: 1 1 100%; overflow-wrap: anywhere; }
  .pt-copy button, .pt-row .button { width: 100%; justify-content: center; }
  .help-topic-head { padding: 14px 16px; }
  .app-content .help-questions summary { min-height: 52px; padding-block: 14px; }

  /* ── Terminal: chart and buy/sell first; markets fold away under the positions ── */
  .term { grid-template-areas: "market" "chart" "side" "tables" "watch" "margin" "foot"; }
  .area-right { display: contents; }
  .area-side { grid-area: side; scroll-margin-top: 64px; }
  .area-watch { grid-area: watch; }
  .area-chart { height: clamp(340px, 54svh, 560px); }
  .market-head { gap: 6px 18px; padding: 10px 16px 8px; min-height: 0; }
  .mh-badges { margin: 0; }
  .badge { min-height: 26px; font-size: 12px; }
  .tool-btn { width: 44px; height: 44px; }
  .seg button { min-height: 44px; min-width: 44px; }
  .side-tabs button, .tabs-mini button, .watch-tabs button { min-height: 46px; }
  .watch-search input { min-height: 44px; }
  .row-actions button, .presets button { min-height: 44px; }
  .term .button, .switch { min-height: 44px; }
  .axis-switches { gap: 14px; }
  .axis-switches button { position: relative; width: 30px; height: 30px; }
  .axis-switches button::after { content: ""; position: absolute; inset: -7px; }
  .order-panel input[type="range"] { height: 44px; }
  .w-name small, .watch-head, .grid-table th, .grid-table small, .legend-title span, .count { font-size: 12px; }
  .term-foot { font-size: 12px; padding-bottom: 16px; }
  .term-foot a { display: inline-flex; align-items: center; min-height: 44px; }
  .watch-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--bg); border: 0; color: var(--ink); font: 600 15px var(--font-body); }
  .watch-toggle svg { color: var(--muted-strong); transition: transform 160ms ease; }
  .area-watch.is-open .watch-toggle svg { transform: rotate(180deg); }
  .area-watch:not(.is-open) > .watch { display: none; }
  .watch-list { max-height: 60svh; }
  .grid-table.data-cards { min-width: 0; font-size: 14px; }
  .grid-table.data-cards tr { padding: 16px; }
  .data-cards .row-actions { display: flex; gap: 8px; }
  .data-cards .row-actions button { flex: 1; }
  .quick-trade { position: fixed; left: 0; right: 0; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 35; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px 12px; background: var(--bg); border-top: 1px solid var(--line); }
  .quick-trade button { display: grid; justify-items: center; gap: 0; min-height: 52px; border: 0; border-radius: var(--radius-sm); font: 650 16px var(--font-body); line-height: 1.2; }
  .quick-trade small { font-size: 12px; font-weight: 500; opacity: 0.85; }
  .qt-buy { background: var(--profit); color: var(--on-profit); }
  .qt-sell { background: var(--loss); color: var(--on-loss); }
  .quick-trade button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  body.is-terminal .app { padding-bottom: calc(72px + 70px + env(safe-area-inset-bottom)); }
  body.is-terminal .toast { bottom: calc(72px + 78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 759px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .channel { grid-template-columns: minmax(0, 1fr) auto; }
  .channel form { grid-column: 1 / -1; }
}
