/* Phone optimisation. Loaded after styles.css so these rules win. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: rgba(99,102,241,.15); }
button, a, input, select, label, summary { touch-action: manipulation; }
.topbar { padding-top: env(safe-area-inset-top); }
.footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.bal-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.note summary { cursor: pointer; }
.del-btn { color: var(--bad); border-color: #fecaca; }
.mode-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mode-list .radio-card { padding: 10px 12px; }
@media (max-width: 600px) { .mode-list { grid-template-columns: 1fr; } }

@media (max-width: 860px) {
  /* Dashboard: one column, most important card first (balance, then what to pay / request). */
  .dash-page { display: flex; flex-direction: column; gap: 14px; }
  .dash-page .dash, .dash-page .dash > .stack { display: contents; }
  .dash-page .stack > * + * { margin-top: 0; }
  .dash-page > .checklist, .dash-page > .code-card { margin: 0; }
  .dash-page .o1 { order: 1; } .dash-page .o2 { order: 2; } .dash-page .o2b { order: 2; }
  .dash-page > .checklist { order: 3; } .dash-page > .code-card { order: 4; }
  .dash-page .o5 { order: 5; } .dash-page .o6 { order: 6; } .dash-page .o7 { order: 7; } .dash-page .o8 { order: 8; }
}

@media (max-width: 760px) {
  /* Menu: big tap targets. */
  .nav a, .nav button.link { padding: 14px 12px; font-size: 1rem; text-align: left; }
  .nav .btn.primary { margin-top: 6px; justify-content: center; }
  .nav { box-shadow: 0 16px 32px rgba(0,0,0,.35); max-height: calc(100vh - 64px); overflow-y: auto; }
  .nav-profile { order: -1; border-bottom: 1px solid rgba(255,255,255,.1); border-radius: 0 !important; margin-bottom: 4px; }
}

@media (max-width: 600px) {
  .container { padding: 18px 14px 36px; }
  .card { padding: 16px; border-radius: 16px; }
  h1 { font-size: 1.55rem; }
  .page-head { margin-bottom: 14px; }

  /* No zoom-on-focus on iPhone: inputs must be at least 16px. */
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; }

  /* Landing */
  .hero { padding: 24px 20px 28px; border-radius: 20px; gap: 0; }
  .hero-gem { display: none; }
  .hero h1 { font-size: 1.95rem; }
  .hero p { font-size: 1rem; }
  .hero .row .btn { flex: 1; }
  .hero-tag { font-size: .78rem; }
  .hero-trust { gap: 8px 14px; font-size: .82rem; }
  .privacy-promo { margin-top: 18px; padding: 18px 14px; border-radius: 20px; }
  .privacy-promo .grid { gap: 10px; }
  .card.pp, .timeline .card { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: start; }
  .card.pp .tl-icon, .timeline .tl-icon { grid-row: span 2; font-size: 1.5rem; margin: 0; }
  .steps { gap: 10px; margin-top: 16px; }

  /* Dashboard */
  .stat .value { font-size: 1.9rem; }
  .code-card { gap: 14px; }
  .code-card > div:first-child { width: 100%; }
  .connect { min-width: 0; max-width: none; width: 100%; }
  .connect input { min-width: 0; }
  .checklist ol { grid-template-columns: 1fr; gap: 10px; }
  .req { padding: 14px; }
  .req .row { width: 100%; }
  .req .row .btn { flex: 1; }
  .dep .row { width: 100%; }
  .dep .row .btn { flex: 1; }
  .role-opt { padding: 16px; }

  /* Dialogs become bottom sheets with the buttons always in reach. */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh;
    padding: 20px 16px 0; animation: sheet-up .2s ease-out; }
  .modal-actions { position: sticky; bottom: 0; background: #fff; z-index: 1;
    margin: 16px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .modal > :last-child:not(.modal-actions):not(form) { margin-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1; }
  .pd { grid-template-columns: 1fr; gap: 0; }
  .pd dt { margin-top: 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
  .pd dt:first-child { margin-top: 0; }

  /* Tables that read better as stacked rows. */
  table.resp thead { display: none; }
  table.resp tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.resp tr:last-child { border-bottom: 0; }
  table.resp td { display: block; border: 0; padding: 2px 0; text-align: left !important; }
  table.resp td .btn { margin-top: 6px; width: 100%; }

  /* Admin */
  .tabs { margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .payout-req .row.spread { flex-direction: column; align-items: stretch !important; }
  .payout-req .row.spread > .badge { align-self: flex-start; }
  .payout-req .row .btn, .report .row .btn { flex: 1; }
  .search { max-width: none; width: 100%; }

  /* Cashout */
  .cashout { border-radius: 20px; padding: 16px; }
  .co-title { margin-top: 22px; }
  .co-steps { grid-template-columns: 1fr; }

  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .legal { padding: 18px 16px; }
  .profile-card { gap: 14px; }
  .avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none !important; } }
