@media (max-width: 1180px) {
  .app-frame { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .app-header { grid-template-columns: 200px minmax(0,1fr) 112px; }
  .mail-layout { grid-template-columns: 350px minmax(0,1fr); }
  .mailbox-panel { position: fixed; z-index: 20; left: 0; top: 72px; bottom: 0; width: 300px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 18px 0 40px rgba(34,50,78,.14); }
  body.accounts-open .mailbox-panel { transform: translateX(0); }
  .mobile-back-button { display: grid; }
  .search-control { width: min(230px,24vw); }
}

@media (max-width: 820px) {
  body { background: #f3f5f8; }
  .app-header { height: auto; min-height: 120px; grid-template-columns: 1fr auto; align-content: center; padding: 10px 12px; }
  .brand-lockup { grid-column: 1; }
  .header-auth-actions { grid-column: 2; grid-row: 1; }
  .acquire-toolbar { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: minmax(0,1fr) 140px 118px; }
  .search-control { width: 100%; }
  .select-control { min-width: 0; }
  .primary-button { padding: 0 15px; }
  .quantity-control { display: none; }
  .mail-layout { height: calc(100% - 120px - 66px - var(--safe-bottom)); display: block; }
  .mailbox-panel, .inbox-panel, .reader-panel { width: 100%; height: 100%; border: 0; }
  .mailbox-panel { position: static; transform: none; box-shadow: none; }
  .inbox-panel, .reader-panel { display: none; }
  body[data-mobile-view="inbox"] .mailbox-panel, body[data-mobile-view="reader"] .mailbox-panel { display: none; }
  body[data-mobile-view="inbox"] .inbox-panel { display: flex; }
  body[data-mobile-view="reader"] .reader-panel { display: flex; }
  body[data-mobile-view="mailboxes"] .mailbox-panel, body[data-mobile-view="inbox"] .inbox-panel, body[data-mobile-view="reader"] .reader-panel { animation: mobile-panel-in .2s cubic-bezier(.2,.75,.25,1) both; }
  @keyframes mobile-panel-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
  .mailbox-list { height: calc(100% - 64px); }
  .mobile-back-button { display: none; }
  .reader-back { display: grid; }
  .mobile-nav { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; height: calc(66px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(3,1fr); padding-bottom: var(--safe-bottom); border-top: 1px solid var(--line); background: rgba(250,251,253,.94); backdrop-filter: blur(22px); }
  .mobile-nav button { border: 0; display: grid; place-content: center; justify-items: center; gap: 3px; color: var(--muted); background: transparent; font-size: 10px; }
  .mobile-nav button.active { color: var(--blue); }
  .mobile-nav svg { width: 21px; height: 21px; }
  .reader-content { padding: 10px; }
  .mail-surface { border-radius: 17px; }
  .reader-empty .brand-art { width: min(520px,95%); }
  .toast { bottom: calc(80px + var(--safe-bottom)); }
}

@media (max-width: 560px) {
  .app-header { min-height: 168px; }
  .acquire-toolbar { grid-template-columns: minmax(92px,1fr) 86px 100px; grid-template-rows: 42px 42px; gap: 9px; }
  .search-control { grid-column: 1 / -1; }
  .select-control { grid-column: 1; grid-row: 2; }
  .quantity-control { grid-column: 2; grid-row: 2; display: flex; justify-content: center; gap: 3px; padding: 0 4px; }
  .quantity-control > span { display: none; }
  .quantity-control button { width: 25px; height: 30px; }
  .quantity-control strong { min-width: 17px; }
  .acquire-toolbar > .primary-button { grid-column: 3; grid-row: 2; padding: 0 10px; }
  .mail-layout { height: calc(100% - 168px - 66px - var(--safe-bottom)); }
  .panel-heading { min-height: 58px; }
  .mailbox-list { height: calc(100% - 58px); }
  .mailbox-card { grid-template-columns: 36px minmax(0,1fr) auto; }
  .mailbox-address { font-size: 12px; }
  .mail-head { padding: 22px 18px 20px; }
  .mail-head h1 { font-size: 25px; }
  .mail-title-row { margin-bottom: 19px; }
  .mail-body { padding: 24px 18px 52px; font-size: 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  #composeBackdrop,#settingsBackdrop,#authBackdrop { place-items: stretch; padding: 0; background: #f7f8fb; backdrop-filter: none; }
  #composeBackdrop > section,#settingsBackdrop > section,#authBackdrop > section { animation: mobile-modal-in .2s cubic-bezier(.2,.75,.25,1) both; }
  @keyframes mobile-modal-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
  .compose-modal { width: 100%; height: 100dvh; min-height: 0; display: flex; flex-direction: column; border: 0; border-radius: 0; box-shadow: none; }
  .compose-modal > header { flex: 0 0 auto; height: auto; min-height: calc(58px + var(--safe-top)); padding-top: var(--safe-top); }
  .compose-modal > label,.compose-row { flex: 0 0 50px; grid-template-columns: 74px minmax(0,1fr); padding: 0 16px; }
  .compose-editor { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 18px 20px; }
  .compose-files { flex: 0 0 auto; max-height: 96px; overflow-y: auto; padding: 7px 16px; }
  .compose-modal footer { flex: 0 0 auto; min-height: calc(54px + var(--safe-bottom)); display: flex; align-items: flex-start; padding: 10px 18px calc(10px + var(--safe-bottom)); }
  .compose-modal footer button { min-height: 34px; padding: 0 4px; font-size: 14px; }
  .settings-modal { width: 100%; height: 100dvh; max-height: none; display: flex; flex-direction: column; overflow: hidden; border: 0; border-radius: 0; box-shadow: none; }
  .settings-modal > header { flex: 0 0 auto; height: auto; min-height: calc(68px + var(--safe-top)); padding: var(--safe-top) 20px 0; background: rgba(250,251,253,.94); backdrop-filter: blur(20px); }
  .settings-modal header h2 { margin-top: 2px; font-size: 24px; }
  .auth-modal { width: 100%; height: 100dvh; max-height: none; display: flex; flex-direction: column; border: 0; border-radius: 0; box-shadow: none; }
  .auth-modal-header { flex: 0 0 auto; height: auto; min-height: calc(58px + var(--safe-top)); padding: var(--safe-top) 14px 0; background: rgba(250,251,253,.94); backdrop-filter: blur(20px); }
  .auth-content { min-height: 0; flex: 1; max-height: none; overflow-y: auto; }
  .auth-panel { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 30px 22px calc(48px + var(--safe-bottom)); }
  .auth-panel[hidden] { display: none; }
  .auth-panel input { font-size: 16px; }
  .auth-form-panel { justify-content: flex-start; padding-top: max(36px,8vh); }
  .auth-links,.auth-form-panel .primary-button,.auth-form-panel .login-fields,.auth-form-panel .login-error { width: 100%; }
  .settings-form { min-height: 0; flex: 1; overflow-y: auto; padding: 16px 16px calc(28px + var(--safe-bottom)); }
  .settings-group > label, .settings-group > div { grid-template-columns: 120px minmax(0,1fr); }
  #rechargeBackdrop { place-items: end stretch; padding: 0; }
  .recharge-modal { width: 100%; border-radius: 24px 24px 0 0; padding-bottom: var(--safe-bottom); }
}
