/* Phone pass (task 38). Every rule below 760 px, so desktop and tablet render exactly as before. Tokens only. */


@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; }

  /* Cabinet header: nickname shrinks with an ellipsis, a clear gap before the logout button */
  .topbar-user { gap: 12px; min-width: 0; }
  .user-chip { min-width: 0; }
  .user-chip > .avatar { flex: none; }
  .user-chip > span:not(.avatar) { min-width: 0; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-user form, .topbar-user .icon-btn { flex: none; }
}
@media (max-width: 400px) {
  .lang-switch > summary { gap: 4px; padding: 0 6px; }
  .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; }
  /* The RU/EN switch sits in the bar too (task 334): the search gives up its width first, the button never shrinks. */
  .topbar { gap: 10px; }
  .topbar .search { flex-basis: 0; }
  .topbar-user .button { flex: none; white-space: nowrap; }
  .topbar-user { gap: 6px; }
  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; }
  /* One line height for every cell: .num sets 1, so number cells sat higher than text cells beside them. */
  .data-cards td, .data-cards td.num, .data-cards td.r { line-height: 1.35; }
  .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 on phones, exchange-app layout: order form left, book right, chart folded under the chart button ── */
  .term { grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr); }
  .market-head { gap: 4px 14px; padding: 8px 12px; min-height: 0; }
  .mh-markets { position: static; }
  .mh-card { position: static; }
  .mh-card-pop { left: 12px; right: 12px; width: auto; }
  .mh-info { width: 44px; height: 44px; }
  .inst-facts > div { grid-template-columns: 1fr; gap: 2px; }
  .mh-name, .mh-badges .feed-src { display: none; }
  .mh-badges { order: 9; flex-basis: 100%; margin: 0; align-items: center; }
  .mh-id { min-height: 44px; }
  .mh-ticker { font-size: 17px; }
  .mh-price strong { font-size: 17px; }
  .mh-price span { font-size: 13px; }
  .mh-facts { flex-basis: 100%; order: 5; }
  .mh-badges { margin: 0; }
  .mh-list { left: 0; right: 0; top: 100%; width: auto; border-radius: 0; border-inline: 0; }
  .chart-toggle { display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; padding: 0; background: none; border: 0; border-radius: var(--radius-sm); color: var(--muted-strong); }
  .chart-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
  .area-chart { height: clamp(320px, 50svh, 520px); }
  .order-panel { padding: 10px 6px 12px 12px; }
  .order-panel form { gap: 10px; }
  .op-pct { flex-wrap: wrap; gap: 4px 8px; font-size: 12px; }
  .op-step { flex: 1 0 140px; }
  .op-step button { flex: none; width: 44px; height: 44px; font-size: 18px; }
  .op-pct-in { flex: 1; min-width: 44px; height: 44px; font-size: 14px; }
  .op-lev select, .op-type-select select, .unit-select select, .unit-btn { min-height: 44px; }
  .op-check { min-height: 44px; }
  .op-slider input { height: 44px; }
  .op-notches { top: 26px; }
  .op-row { flex-wrap: wrap; }
  .op-avail { flex-basis: 100%; font-size: 12px; }
  .op-type-select { display: none; }
  .unit-btn { padding: 0 6px; font-size: 11px; }
  .input-unit input { padding: 0 8px; font-size: 13px; }
  .unit-select select { padding: 0 24px 0 6px; font-size: 12px; background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; }
  /* Order form on phones (Chip, 09.11): 8px rhythm, leverage and order type on one row, the amount
     with its unit, one grey line «≈ qty · макс. qty» instead of the «Макс. позиция» box, then one row
     of slider and percent field. The ± steppers and the «Доля объёма» caption go (the field still
     takes typed input and arrow keys); the slider snaps to the marks. Long/Short stay in view. */
  /* Order type as a segmented switch on its own row, then one size row: leverage, then a wide, brighter
     amount field with a fixed USDT label inside (Chip, 09.11). The unit switch is hidden on phones; dense
     lets the amount fill the leverage row even when a limit price field sits between them in the markup. */
  .order-panel form { grid-template-columns: auto minmax(0, 1fr); grid-auto-flow: row dense; gap: 8px; }
  .order-panel form > * { grid-column: 1 / -1; }
  .order-panel form > .op-row { display: contents; }
  .order-panel form > .op-row > .op-avail { grid-column: 1 / -1; }
  .order-panel form > .op-types { grid-row: 2; }
  .order-panel form > .op-row > .op-lev { grid-column: 1; }
  .order-panel form > .op-field:has(#o-amount) { grid-column: 2; }
  .it-app .order-panel form > .op-types { display: flex; gap: 0; padding: 2px; border: 1px solid var(--it-border); border-bottom: 1px solid var(--it-border); border-radius: var(--it-radius); background: var(--it-bg); }
  .it-app .order-panel form > .op-types > button { flex: 1; min-height: 38px; margin: 0; padding: 0 6px; border: 0; border-radius: var(--it-radius); color: var(--it-muted); font-size: 13px; font-weight: 500; }
  .it-app .order-panel form > .op-types > button[aria-checked='true'] { background: var(--it-raised); color: var(--it-text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--it-border); }
  .it-app .order-panel form > .op-types > button:nth-child(2) { order: -1; }
  .it-app .order-panel form > .op-types > button:focus-visible { outline: 2px solid var(--it-buy); outline-offset: -2px; }
  .it-app .order-panel form > .op-field:has(#o-amount) .input-unit { min-height: 44px; background: var(--it-raised); border: 1px solid var(--it-faint); }
  .it-app .order-panel form > .op-field:has(#o-amount) .input-unit:focus-within { border-color: var(--it-buy); }
  .it-app .order-panel form > .op-field:has(#o-amount) .input-unit input { min-height: 42px; background: none; color: var(--it-text); font-size: 16px; font-weight: 600; }
  .order-panel form > .op-field:has(#o-amount) .unit-select { display: none; }
  .order-panel form > .op-field:has(#o-amount) .op-unit-fixed { display: block; flex: none; padding: 0 12px 0 4px; color: var(--it-muted); font-size: 13px; font-weight: 600; }
  .order-panel form > .op-max { display: none; }
  .order-panel form > .op-size { order: 1; }
  .order-panel form > #o-amount-hint ~ *:not(.op-size) { order: 2; }
  /* The market execution note (two lines on a phone) goes under the order sums, so Long/Short follow the slider directly (Chip, 09.11). */
  .order-panel form > #o-amount-hint ~ .op-exec-hint.hint { order: 3; margin-top: 4px; }
  .op-hint-max { display: inline; }
  #o-amount-hint { margin: -2px 0 0; font-size: 12px; color: var(--muted); }
  .op-size { display: flex; align-items: flex-start; gap: 12px; }
  .op-size .op-slider { flex: 1; min-width: 0; padding-top: 0; }
  .op-size .op-slider input { height: 36px; }
  .op-size .op-notches { top: 18px; }
  .op-size .op-notches i { width: 2px; height: 8px; margin: -4px 0 0 -1px; border: 0; border-radius: 1px; background: var(--line-strong); }
  .op-size .op-notches i.on { background: var(--accent-fill); }
  .op-ticks { display: block; height: 14px; margin: 2px 10px 0; font-size: 11px; }
  .op-ticks span:first-child { transform: translateX(-10px); }
  .op-ticks span:last-child { transform: translateX(calc(-100% + 10px)); }
  .op-ticks span.on { color: var(--ink); }
  .op-size .op-pct { display: block; flex: none; }
  .op-size .op-pct label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .op-size .op-step button { display: none; }
  .op-size .op-pct .hint { display: none; }
  .op-max { flex-wrap: wrap; gap: 0 8px; padding: 6px 10px; font-size: 12px; }
  .op-brackets { grid-template-columns: minmax(0, 1fr); }
  .submit { min-height: 48px; }
  /* Long/Short labels on phones (Chip, 09.11): bold and 15% larger than the measured 12px (Octo's button font: inherit). */
  .order-panel .op-sides .submit { font-weight: 700; font-size: 13.8px; white-space: nowrap; }
  .order-sum { font-size: 11.5px; }
  .order-sum > div { flex-wrap: wrap; gap: 0 8px; }
  .area-margin { padding: 12px; }
  .area-margin dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .area-margin dl > div { display: grid; gap: 2px; }
  .area-margin dd { text-align: left; font-size: 14px; }
  .book > .tabs-flat { display: none; }
  .book-head, .book-side button { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 4px; padding: 0 10px 0 6px; }
  .book-head { padding-top: 12px; }
  .book .book-total { display: none; }
  .book-asks li:nth-last-child(n + 9), .book-bids li:nth-child(n + 9) { display: none; }
  .book-ratio { margin-top: 0; }
  .book-side button { min-height: 26px; font-size: 12px; }
  .book-mid { display: grid; gap: 2px; padding: 8px 10px 8px 6px; }
  .book-mid strong { font-size: 17px; }
  .book-ratio { padding: 8px 10px 10px 6px; gap: 4px; font-size: 11px; }
  .book-ratio b { margin: 0 3px; }
  .tool-btn { width: 44px; height: 44px; }
  .seg button { min-height: 44px; min-width: 44px; }
  .tabs-mini button, .watch-tabs button { min-height: 46px; }
  .tables-head > .tabs-flat { overflow-x: auto; scrollbar-width: none; }
  .tables-head > .tabs-flat::-webkit-scrollbar { display: none; }
  .watch-search input { min-height: 44px; }
  .row-actions button { min-height: 44px; }
  .term .button { 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; }
  .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, .term-foot .term-cookie { display: inline-flex; align-items: center; min-height: 44px; }
  .watch-list { max-height: 60svh; }
  .grid-table.data-cards { min-width: 0; font-size: 14px; }
  .grid-table.data-cards tr { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 12px; }
  .data-cards td[data-label="TP / SL"] { grid-column: span 2; }
  .data-cards td[data-label]::before { margin-bottom: 1px; }
  .data-cards .row-actions { display: flex; gap: 8px; }
  .data-cards .row-actions button { flex: 1; }
  body.is-terminal .toast { bottom: calc(72px + 8px + 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; }
  .kyc-card { padding: 16px 16px 4px; }
  .kyc-card .channel { grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row; }
  .kyc-card .kyc-later { grid-column: 1 / -1; max-width: none; }
}

/* Direct USDT pay box on phones: QR above the address, buttons full width. */
@media (max-width: 759px) {
  .usdt-wallet { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .usdt-qr { width: 168px; }
  .usdt-address { justify-items: stretch; width: 100%; }
  .usdt-address .button, .usdt-sum .button { width: 100%; justify-content: center; }
  .usdt-sum { justify-items: stretch; }
  .usdt-total strong { font-size: 2rem; white-space: nowrap; }
}
