/* Mobile shell — MODALS, SHEETS, TOASTS (see mshell/modals.js).
   Shared helpers (showConfirm / showChoice / showPrompt, the transfer
   sheet, change-password …) all render .modal-host > .modal; here they
   become board-language bottom sheets: slate card, hairline border,
   grab handle, pill buttons, mono micro-labels. Prefix: mwm-. */
@media (max-width: 979px) {
  /* ------------------------------------------------------ backdrop */
  html.web-shell .modal-host:not(.pin-overlay) {
    background: rgba(4, 5, 7, 0.62);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    align-items: flex-end; padding: 0;
  }
  /* ---------------------------------------------------- the sheet */
  html.web-shell .modal-host:not(.pin-overlay) > .modal {
    position: relative; box-sizing: border-box;
    width: 100%; max-width: 560px; margin: 0 auto;
    max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto;
    background: var(--mws-card); color: var(--mws-ink);
    border: 1px solid var(--mws-line); border-bottom: 0;
    border-radius: 24px 24px 0 0;
    padding: 30px 20px calc(22px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  }
  /* grab handle (CSS for every sheet; transfer/monthly also get a node) */
  html.web-shell .modal-host:not(.pin-overlay) > .modal::before {
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 99px; background: var(--mws-line-strong);
  }
  html.web-shell .modal-host > .modal.mwm-sheet::before { display: none; }
  html.web-shell .mwm-grab {
    width: 38px; height: 4px; border-radius: 99px; background: var(--mws-line-strong);
    margin: -18px auto 14px;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal > h3,
  html.web-shell .modal-host:not(.pin-overlay) > .modal > .modal-title {
    margin: 0 0 8px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em;
    color: var(--mws-ink);
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal > .muted,
  html.web-shell .modal-host:not(.pin-overlay) > .modal .modal-body {
    font-size: 13px; line-height: 1.55; color: var(--mws-ink-2);
  }
  /* inputs inside sheets */
  html.web-shell .modal-host:not(.pin-overlay) > .modal .field { margin-left: 0; margin-right: 0; }
  html.web-shell .modal-host:not(.pin-overlay) > .modal input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  html.web-shell .modal-host:not(.pin-overlay) > .modal select {
    height: 46px; box-sizing: border-box; width: 100%; max-width: none;
    border-radius: 12px; padding: 0 14px;
    background: var(--mws-bg); border: 1px solid var(--mws-line); color: var(--mws-ink);
    font-size: 16px; box-shadow: none;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal input[type="number"],
  html.web-shell .modal-host:not(.pin-overlay) > .modal input[inputmode="decimal"],
  html.web-shell .modal-host:not(.pin-overlay) > .modal input[inputmode="numeric"] {
    font-family: var(--mws-mono); font-weight: 600;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal input:focus,
  html.web-shell .modal-host:not(.pin-overlay) > .modal select:focus {
    outline: none; border-color: rgba(240, 185, 11, 0.5); box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.12);
  }
  /* pill buttons */
  html.web-shell .modal-host:not(.pin-overlay) > .modal .button-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 12px;
    margin-top: 18px;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal .button-row .btn,
  html.web-shell .modal-host:not(.pin-overlay) > .modal .mws-btn {
    height: 48px; min-height: 48px; border-radius: 999px; margin: 0; width: 100%;
    padding: 0 16px; font-size: 14.5px; font-weight: 800;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal .btn.ghost {
    background: transparent; color: var(--mws-ink); border: 1px solid var(--mws-line-strong); box-shadow: none;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal .btn.danger {
    background: transparent; color: var(--mws-down); border: 1px solid rgba(234, 57, 67, 0.4); box-shadow: none;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal .btn:not(.ghost):not(.danger):not(.tiny) {
    background: linear-gradient(180deg, #fcd535 0%, #f0b90b 100%); color: #1a1206; border: 0;
    box-shadow: 0 8px 30px -8px rgba(240, 185, 11, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal .btn.tiny {
    height: 36px; min-height: 36px; border-radius: 999px; padding: 0 14px;
    font-size: 12px; font-weight: 700; width: auto;
    background: transparent; color: var(--mws-gold); border: 1px solid rgba(240, 185, 11, 0.35);
  }
  /* vertical stack: primary first (column-reverse keeps DOM order) */
  html.web-shell .modal-host > .modal .button-row.mwm-stack {
    display: flex; flex-direction: column-reverse; gap: 10px;
  }

  /* ---------------------------------------------------- transfer */
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .transfer-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
    gap: 8px; align-items: end; margin-top: 14px;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .transfer-col { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .transfer-label {
    font-family: var(--mws-mono); font-size: 9.5px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--mws-ink-3);
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .transfer-swap {
    display: flex; justify-content: center; align-self: end; margin: 0; padding: 0 0 3px;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .transfer-swap .btn.tiny {
    width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--mws-well); border: 1px solid var(--mws-line); color: var(--mws-gold);
  }
  html.web-shell .mwm-swapic { display: inline-flex; transform: rotate(90deg); }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer > div > .muted {
    font-size: 12px; color: var(--mws-ink-3);
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer > div > .muted strong { color: var(--mws-ink); font-family: var(--mws-mono); font-weight: 600; }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer > .muted {
    font-size: 9.5px; margin: 14px 0 6px !important; font-family: var(--mws-mono); letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--mws-ink-3);
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .input-with-suffix {
    display: flex; gap: 8px; align-items: center;
  }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .input-with-suffix input { flex: 1 1 auto; min-width: 0; }
  html.web-shell .modal-host:not(.pin-overlay) > .modal.mwm-transfer .input-with-suffix .btn.tiny { flex-shrink: 0; height: 46px; min-height: 46px; }

  /* -------------------------------------------- profit by month */
  html.web-shell .mwm-monthly { display: flex; flex-direction: column; gap: 12px; }
  html.web-shell .mwm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  html.web-shell .mwm-title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
  html.web-shell .mwm-x {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--mws-well); border: 1px solid var(--mws-line); color: var(--mws-ink-2);
  }
  html.web-shell .mwm-sub { font-size: 12px; color: var(--mws-ink-3); margin-top: -6px; }
  html.web-shell .mwm-life {
    background: var(--mws-well); border: 1px solid var(--mws-line); border-radius: 14px;
    padding: 14px; display: flex; flex-direction: column; gap: 6px;
  }
  html.web-shell .mwm-life-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  html.web-shell .mwm-life-v { font-family: var(--mws-mono); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
  html.web-shell .mwm-life-cap { font-family: var(--mws-mono); font-size: 10.5px; color: var(--mws-ink-3); }
  html.web-shell .mwm-life-emul {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--mws-mono); font-size: 12px; font-weight: 600;
  }
  html.web-shell .mwm-mlist { display: flex; flex-direction: column; }
  html.web-shell .mwm-pad { padding: 20px 0; }
  html.web-shell .mwm-year {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 2px 6px;
  }
  html.web-shell .mwm-year-v { font-family: var(--mws-mono); font-size: 11px; font-weight: 600; }
  html.web-shell .mwm-mrow {
    display: flex; align-items: center; gap: 12px; min-width: 0;
    padding: 11px 0; border-top: 1px solid var(--mws-line-2);
  }
  html.web-shell .mwm-mico {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--mws-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
    background: rgba(32, 199, 117, 0.1); color: var(--mws-up);
  }
  html.web-shell .mwm-mico.down { background: rgba(234, 57, 67, 0.1); color: var(--mws-down); }
  html.web-shell .mwm-mico.cur { background: rgba(240, 185, 11, 0.14); color: var(--mws-gold); }
  html.web-shell .mwm-mmeta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  html.web-shell .mwm-mmeta .nm { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
  html.web-shell .mwm-mmeta .sub { font-family: var(--mws-mono); font-size: 11px; color: var(--mws-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.web-shell .mwm-emtag { color: var(--mws-demo); }
  html.web-shell .mwm-mv { font-family: var(--mws-mono); font-size: 14px; font-weight: 600; flex-shrink: 0; }
  html.web-shell .mwm-close { margin-top: 4px; }

  /* ------------------------------------- Earn asset detail pop-up */
  html.web-shell .tfx-mp-dmodal-bg:has(> .tfx-wl-emodal) {
    position: fixed; inset: 0; z-index: 40;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(4, 5, 7, 0.62);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    animation: fade-in 0.15s ease-out;
  }
  html.web-shell .tfx-mp-dmodal.tfx-wl-emodal {
    position: relative; box-sizing: border-box;
    width: 100%; max-width: 560px; margin: 0;
    max-height: calc(100dvh - 40px); overflow-y: auto;
    background: var(--mws-card); color: var(--mws-ink);
    border: 1px solid var(--mws-line); border-bottom: 0; border-radius: 24px 24px 0 0;
    padding: 30px 20px calc(22px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column; gap: 0;
    animation: slide-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  html.web-shell .tfx-wl-emodal::before {
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 99px; background: var(--mws-line-strong);
  }
  html.web-shell .tfx-wl-emodal .dhead { display: flex; align-items: center; gap: 12px; min-width: 0; }
  html.web-shell .tfx-wl-emodal .dhc { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  html.web-shell .tfx-wl-emodal .dnm { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.web-shell .tfx-wl-emodal .dtitle { font-family: var(--mws-mono); font-size: 10.5px; color: var(--mws-ink-3); }
  html.web-shell .tfx-wl-emodal .eapr {
    flex-shrink: 0; font-family: var(--mws-mono); font-size: 10.5px; font-weight: 700;
    padding: 4px 9px; border-radius: 999px;
    color: var(--mws-up); background: rgba(32, 199, 117, 0.1); border: 1px solid rgba(32, 199, 117, 0.3);
  }
  html.web-shell .tfx-wl-emodal .dx {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--mws-well); border: 1px solid var(--mws-line); color: var(--mws-ink-2);
    font-size: 13px;
  }
  html.web-shell .tfx-wl-emodal .ebig {
    margin: 16px 0 10px; padding: 16px; text-align: left;
    background: var(--mws-well); border: 1px solid var(--mws-line); border-radius: 14px;
  }
  html.web-shell .tfx-wl-emodal .ebig .n { font-family: var(--mws-mono); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
  html.web-shell .tfx-wl-emodal .ebig .u { font-family: var(--mws-mono); font-size: 12px; color: var(--mws-ink-3); margin-top: 4px; }
  html.web-shell .tfx-wl-emodal .ekv {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 0; border-top: 1px solid var(--mws-line-2); font-size: 13.5px;
  }
  html.web-shell .tfx-wl-emodal .ebig + .ekv { border-top: 0; }
  html.web-shell .tfx-wl-emodal .ekv .k { color: var(--mws-ink-2); min-width: 0; }
  html.web-shell .tfx-wl-emodal .ekv .v { font-family: var(--mws-mono); font-size: 13px; font-weight: 600; text-align: right; color: var(--mws-ink); }
  html.web-shell .tfx-wl-emodal .ekv .v.gain { color: var(--mws-up); }
  html.web-shell .tfx-wl-emodal .enote {
    margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--mws-ink-3);
    padding: 10px 12px; border-radius: 12px; background: rgba(32, 199, 117, 0.06);
    border: 1px solid rgba(32, 199, 117, 0.18);
  }
  html.web-shell .tfx-wl-emodal .tfx-mp-dmodal-loading {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 26px 0; color: var(--mws-ink-3); font-size: 13px; text-align: center;
  }
  html.web-shell .tfx-wl-emodal .tfx-mp-dmodal-loading .close-btn {
    height: 44px; padding: 0 22px; border-radius: 999px; cursor: pointer;
    background: transparent; color: var(--mws-ink); border: 1px solid var(--mws-line-strong);
    font-weight: 800; font-size: 14px;
  }

  /* --------------------------------------------------------- toast */
  html.web-shell .toast-host {
    left: 16px; right: 16px; transform: none; width: auto; max-width: none;
    bottom: calc(var(--nav-h, 64px) + 14px + env(safe-area-inset-bottom, 0));
    align-items: center; z-index: 60;
  }
  html.web-shell .toast-host .toast {
    box-sizing: border-box; width: 100%; max-width: 440px;
    display: flex; align-items: center; gap: 10px; text-align: left;
    padding: 12px 14px; border-radius: 14px;
    background: #171a21; color: var(--mws-ink); border: 1px solid var(--mws-line);
    font-family: var(--font); font-size: 13.5px; font-weight: 700; line-height: 1.4;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  }
  html.web-shell .toast-host .toast::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--mws-gold); box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.15);
  }
  html.web-shell .toast-host .toast.ok::before,
  html.web-shell .toast-host .toast.success::before { background: var(--mws-up); box-shadow: 0 0 0 3px rgba(32, 199, 117, 0.15); }
  html.web-shell .toast-host .toast.error::before,
  html.web-shell .toast-host .toast.err::before { background: var(--mws-down); box-shadow: 0 0 0 3px rgba(234, 57, 67, 0.15); }
  html.web-shell .toast-host .toast.error,
  html.web-shell .toast-host .toast.err { border-color: rgba(234, 57, 67, 0.35); }
  html.web-shell .toast-host .toast.ok,
  html.web-shell .toast-host .toast.success { border-color: rgba(32, 199, 117, 0.3); }
  /* logged-out screens have no tab bar */
  html.web-shell body[data-screen="auth"] .toast-host { bottom: calc(24px + env(safe-area-inset-bottom, 0)); }

  /* ---------------------------------------------- success splash */
  html.web-shell .splash-card {
    background: var(--mws-card); border: 1px solid var(--mws-line); border-radius: 20px;
    color: var(--mws-ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  }
  html.web-shell .splash-card .splash-title { font-weight: 800; }
  html.web-shell .splash-card .splash-sub { font-family: var(--mws-mono); font-size: 11px; color: var(--mws-ink-3); }
}
