/* ==========================================================================
   NORDENOS MAILROOM — NATIVE MOBILE PWA LAYER
   Desktop (> 768px) remains 100% untouched; mobile (<= 768px) becomes a
   native-grade iOS/Android standalone PWA experience.
   ========================================================================== */

:root {
  --mobile-topbar-h: 54px;
  --mobile-tabbar-h: 62px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Strictly hidden on desktop (> 768px) */
.mobile-tabbar,
.mobile-sheet-backdrop,
.mobile-sheet,
.mobile-search-sheet,
.mobile-back-btn,
.mobile-brand-mark,
.mobile-icon-action,
.mobile-pwa-banner,
.mobile-section-strip,
.mobile-filter-toggle,
.mobile-composer-tabs,
.mobile-lab-tabs,
.mobile-studio-dock,
.mobile-only-row,
.mobile-only-inline {
  display: none;
}

/* Offline status banner (works on all viewports) */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 14px;
  background: linear-gradient(90deg, #072546 0%, #0b3c70 100%);
  color: #e4f7ff;
  font-size: 12px;
  font-weight: 540;
  border-bottom: 1px solid rgba(56, 228, 255, 0.24);
}
.offline-banner svg { color: var(--aqua); }

/* Studio page frame wrapper (neutral on desktop) */
.studio-page-frame {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   MOBILE APP SHELL & VIEWPORT (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  html, body {
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
  }

  body {
    background: var(--canvas);
    padding-bottom: calc(var(--mobile-tabbar-h) + var(--sab) + 12px);
    -webkit-tap-highlight-color: transparent;
  }

  body.mobile-detail-open {
    padding-bottom: calc(78px + var(--sab));
  }

  body.mobile-studio-active {
    padding-bottom: 0;
    overflow: hidden;
  }

  body.sheet-open {
    overflow: hidden;
  }

  /* Prevent iOS Safari input auto-zoom */
  input:not([type="checkbox"]):not([type="color"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Native tactile tap feedback */
  button, a, .tool, .list-row {
    -webkit-tap-highlight-color: transparent;
  }

  /* Hide desktop sidebar & desktop topbar controls completely on mobile */
  .layout {
    grid-template-columns: minmax(0, 1fr);
    min-height: 100dvh;
  }
  .sidebar,
  .sidebar-scrim,
  .menu-toggle,
  .crumb-root,
  .crumb .slash,
  .global-search-wrap,
  .new-wrap,
  .topbar-profile-meta,
  .desktop-only-row {
    display: none !important;
  }

  /* ===================== NATIVE FROSTED TOP APP BAR ===================== */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 35;
    height: calc(var(--mobile-topbar-h) + var(--sat));
    padding: var(--sat) calc(14px + var(--sar)) 0 calc(14px + var(--sal));
    background: rgba(244, 249, 255, 0.88);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(10, 38, 71, 0.08);
    gap: 10px;
    user-select: none;
  }

  .crumb {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
  }

  .crumb-current {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--abyss);
    line-height: 1.2;
  }

  body.mobile-home .mobile-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    overflow: hidden;
    box-shadow: 0 3px 10px -2px rgba(0, 102, 230, 0.28);
  }
  body.mobile-home .mobile-brand-mark img {
    width: 30px;
    height: 30px;
    display: block;
  }

  /* Native iOS/Android back button inside topbar */
  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 0;
    background: rgba(13, 196, 242, 0.12);
    color: #03538c;
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 580;
    height: 34px;
    padding: 0 11px 0 6px;
    border-radius: 99px;
    flex: none;
    transition: background-color 0.15s ease, transform 0.14s var(--ease);
  }
  .mobile-back-btn:active {
    transform: scale(0.95);
    background: rgba(13, 196, 242, 0.22);
  }
  .mobile-back-btn[hidden] { display: none !important; }
  body.mobile-detail-open .crumb-current {
    font-size: 16px;
    font-weight: 580;
  }

  .top-actions {
    gap: 8px;
    flex: none;
  }

  .mobile-icon-action {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(10, 38, 71, 0.10);
    background: rgba(255, 255, 255, 0.90);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
    transition: transform 0.14s var(--ease), background-color 0.15s ease;
  }
  .mobile-icon-action:active {
    transform: scale(0.92);
    background: #ffffff;
  }

  .topbar-profile {
    padding: 2px;
    min-height: 38px;
    width: 38px;
    justify-content: center;
    border-radius: 50%;
    border-color: rgba(10, 38, 71, 0.10);
  }
  .topbar-profile .avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  /* ===================== CONTENT SPACING ===================== */
  .content {
    padding: 14px calc(14px + var(--sar)) 24px calc(14px + var(--sal));
  }

  .page-head {
    margin-bottom: 12px;
    gap: 10px;
  }
  .page-title-group {
    gap: 8px;
  }
  h1 {
    font-size: 24px;
    letter-spacing: -0.035em;
  }
  h2 {
    font-size: 17px;
  }

  .card {
    border-radius: 18px;
    box-shadow: 0 2px 12px -4px rgba(6, 32, 64, 0.065), 0 1px 2px rgba(6, 24, 43, 0.03);
  }
  .card-head {
    padding: 15px 16px 11px;
  }
  .card-head h2 {
    font-size: 16.5px;
    font-weight: 560;
  }
  .box {
    padding: 16px;
  }

  /* ===================== NATIVE BOTTOM TAB BAR ===================== */
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    justify-items: center;
    height: calc(var(--mobile-tabbar-h) + var(--sab));
    padding: 4px calc(6px + var(--sar)) var(--sab) calc(6px + var(--sal));
    background: rgba(252, 254, 255, 0.92);
    backdrop-filter: blur(26px) saturate(190%);
    -webkit-backdrop-filter: blur(26px) saturate(190%);
    border-top: 1px solid rgba(10, 38, 71, 0.085);
    box-shadow: 0 -8px 28px -12px rgba(6, 28, 56, 0.12);
    user-select: none;
    transition: transform 0.24s var(--ease), opacity 0.2s ease;
  }

  body.mobile-detail-open .mobile-tabbar,
  body.mobile-studio-active .mobile-tabbar {
    transform: translateY(115%);
    opacity: 0;
    pointer-events: none;
  }

  .mobile-tab {
    position: relative;
    border: 0;
    background: transparent;
    width: 100%;
    height: 52px;
    padding: 4px 2px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 10.5px;
    font-weight: 540;
    letter-spacing: -0.01em;
    border-radius: 12px;
    transition: color 0.16s ease, transform 0.14s var(--ease);
  }
  .mobile-tab:active {
    transform: scale(0.92);
  }
  .mobile-tab-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-tab-icon {
    width: 42px;
    height: 28px;
    border-radius: 99px;
    transition: background-color 0.2s var(--ease), color 0.18s ease, transform 0.2s var(--ease-spring);
  }
  .mobile-tab[aria-current="page"] {
    color: #0058c4;
    font-weight: 620;
  }
  .mobile-tab[aria-current="page"] .mobile-tab-icon {
    background: linear-gradient(135deg, rgba(44, 224, 255, 0.24) 0%, rgba(0, 102, 230, 0.13) 100%);
    color: #0060df;
    transform: translateY(-1px);
  }
  .mobile-tab[aria-current="page"] .mobile-tab-icon svg {
    stroke-width: 2.05;
  }
  .mobile-tab-label {
    line-height: 1;
    white-space: nowrap;
  }
  .mobile-tab-badge {
    position: absolute;
    top: -3px;
    right: 3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 99px;
    background: linear-gradient(135deg, #2ce0ff 0%, #0066e6 100%);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px #ffffff, 0 2px 8px rgba(0, 102, 230, 0.42);
  }

  /* Center Arctic-Cyan Create FAB */
  .mobile-fab {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: radial-gradient(125% 125% at 22% 15%, #5af0ff 0%, #0dc4f2 42%, #0066e6 100%);
    color: #ffffff;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 22px -4px rgba(0, 102, 230, 0.48), 0 2px 6px rgba(13, 196, 242, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.42);
    transform: translateY(-4px);
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
  }
  .mobile-fab svg {
    stroke-width: 2.3;
    transition: transform 0.22s var(--ease);
  }
  .mobile-fab:active {
    transform: translateY(-2px) scale(0.91);
  }
  .mobile-fab[aria-expanded="true"] svg {
    transform: rotate(45deg);
  }

  /* ===================== NATIVE BOTTOM SHEETS ===================== */
  .mobile-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(6, 24, 43, 0.44);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: fadeIn 0.18s ease;
  }

  .mobile-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    max-height: min(86dvh, 720px);
    background: linear-gradient(180deg, #ffffff 0%, #f5faff 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -18px 50px -10px rgba(4, 24, 52, 0.28);
    transform: translateY(100%);
    transition: transform 0.28s var(--ease);
    overflow: hidden;
    will-change: transform;
  }
  .mobile-sheet.open {
    transform: translateY(0);
  }

  .mobile-sheet-handle-zone {
    flex: none;
    display: grid;
    place-items: center;
    padding: 10px 0 4px;
    touch-action: none;
    cursor: grab;
  }
  .mobile-sheet-handle {
    width: 38px;
    height: 4.5px;
    border-radius: 99px;
    background: rgba(10, 38, 71, 0.18);
  }

  .mobile-sheet-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 18px 12px;
    border-bottom: 1px solid var(--line);
  }
  .mobile-sheet-head strong {
    display: block;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--abyss);
  }
  .mobile-sheet-head .muted {
    display: block;
    font-size: 12px;
    margin-top: 1px;
  }
  .mobile-sheet-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: rgba(10, 38, 71, 0.065);
    color: var(--text);
    display: grid;
    place-items: center;
    flex: none;
  }
  .mobile-sheet-close:active {
    transform: scale(0.92);
    background: rgba(10, 38, 71, 0.12);
  }

  .mobile-sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px calc(22px + var(--sab));
  }

  .mobile-sheet-section-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 620;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-soft);
    margin: 16px 4px 8px;
  }
  .mobile-sheet-section-label:first-child { margin-top: 2px; }

  /* Create Action Sheet */
  .mobile-create-featured {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 16px;
    border: 1px solid rgba(13, 196, 242, 0.34);
    background: linear-gradient(135deg, rgba(56, 228, 255, 0.14) 0%, rgba(0, 102, 230, 0.07) 100%);
    text-align: left;
    color: var(--abyss);
    margin-bottom: 4px;
    transition: transform 0.14s var(--ease);
  }
  .mobile-create-featured:active { transform: scale(0.98); }
  .mobile-create-featured > div { flex: 1; min-width: 0; }
  .mobile-create-featured strong {
    display: block;
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 600;
  }
  .mobile-create-featured small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
  }
  .mobile-create-featured > svg { color: #0284c7; flex: none; }

  .mobile-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .mobile-create-tile {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 10px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 540;
    line-height: 1.2;
    text-align: left;
    box-shadow: var(--shadow-xs);
    transition: transform 0.14s var(--ease), border-color 0.14s ease;
  }
  .mobile-create-tile:active {
    transform: scale(0.96);
    border-color: var(--line-cyan);
    background: #f5fbff;
  }
  .mobile-create-tile .tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .mobile-create-tile .tile-icon svg { width: 15px; height: 15px; }
  .mobile-create-tile > span:last-child {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* More / App Hub Sheet (iOS Settings-style grouped rows) */
  .mobile-hub-profile {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 16px;
    border: 1px solid rgba(13, 196, 242, 0.22);
    background: #ffffff;
    text-align: left;
    box-shadow: var(--shadow-xs);
    transition: transform 0.14s var(--ease);
  }
  .mobile-hub-profile:active { transform: scale(0.98); }
  .mobile-hub-profile .avatar {
    width: 42px;
    height: 42px;
    font-size: 14px;
  }
  .mobile-hub-profile-copy { flex: 1; min-width: 0; }
  .mobile-hub-profile-copy strong {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--abyss);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-hub-profile-copy span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-hub-group {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
  }
  .mobile-hub-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    min-height: 52px;
    border: 0;
    border-bottom: 1px solid rgba(10, 38, 71, 0.055);
    background: transparent;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 520;
    text-align: left;
    transition: background-color 0.12s ease;
  }
  .mobile-hub-row:last-child { border-bottom: 0; }
  .mobile-hub-row:active { background: rgba(13, 196, 242, 0.09); }
  .mobile-hub-row.active {
    background: rgba(13, 196, 242, 0.08);
    color: #034a8c;
    font-weight: 600;
  }
  .mobile-hub-row .tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .mobile-hub-row .tile-icon svg { width: 16px; height: 16px; }
  .mobile-hub-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-hub-chevron {
    color: var(--muted-soft);
    display: inline-flex;
    opacity: 0.7;
  }

  /* iOS Install Steps inside Sheet */
  .ios-install-steps {
    display: grid;
    gap: 10px;
  }
  .ios-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid var(--line);
  }
  .ios-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2ce0ff 0%, #0066e6 100%);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 650;
    display: grid;
    place-items: center;
    flex: none;
  }
  .ios-step strong { display: block; font-size: 14px; color: var(--abyss); margin-bottom: 2px; }
  .ios-step svg { display: inline-block; vertical-align: -2px; color: #0284c7; }

  /* ===================== FULL-SCREEN SPOTLIGHT SEARCH SHEET ===================== */
  .mobile-search-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--canvas);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.2s var(--ease), transform 0.24s var(--ease);
  }
  .mobile-search-sheet.open {
    opacity: 1;
    transform: translateY(0);
  }

  .mobile-search-bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(10px + var(--sat)) calc(14px + var(--sar)) 10px calc(14px + var(--sal));
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
  }
  .mobile-search-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
  }
  .mobile-search-input-wrap > svg {
    position: absolute;
    left: 12px;
    color: var(--muted-soft);
    pointer-events: none;
  }
  .mobile-search-input-wrap input[type="search"] {
    min-height: 42px;
    padding: 8px 38px 8px 40px !important;
    border-radius: 12px;
    background: #eef5fb;
    border: 1px solid transparent;
    box-shadow: none;
  }
  .mobile-search-input-wrap input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
  }
  .mobile-search-input-wrap input[type="search"]:focus {
    background: #ffffff;
    border-color: var(--cyan);
  }
  .mobile-search-clear {
    position: absolute;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(10, 38, 71, 0.10);
    color: var(--text);
    display: grid;
    place-items: center;
  }
  .mobile-search-cancel {
    border: 0;
    background: transparent;
    color: #0060df;
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 560;
    padding: 8px 4px;
    flex: none;
  }

  .mobile-search-chips {
    flex: none;
    display: flex;
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    padding: 10px 14px;
    scrollbar-width: none;
    background: rgba(244, 249, 255, 0.9);
    border-bottom: 1px solid var(--line);
  }
  .mobile-search-chips::-webkit-scrollbar { display: none; }
  .mobile-chip {
    flex: none;
    min-height: 32px;
    padding: 0 13px;
    border-radius: 99px;
    border: 1px solid rgba(10, 38, 71, 0.11);
    background: #ffffff;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 540;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  .mobile-chip[aria-pressed="true"] {
    background: linear-gradient(135deg, #0b3c70 0%, #0066e6 100%);
    border-color: transparent;
    color: #ffffff;
    font-weight: 580;
    box-shadow: 0 4px 12px -4px rgba(0, 102, 230, 0.45);
  }

  .mobile-search-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px calc(24px + var(--sab));
  }
  .mobile-search-group-title {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 620;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-soft);
    margin: 12px 4px 7px;
  }
  .mobile-search-group-title:first-child { margin-top: 2px; }
  .mobile-search-card {
    overflow: hidden;
  }

  /* ===================== MOBILE HOME SCREEN ===================== */
  .mobile-pwa-banner {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    margin-bottom: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(235, 249, 255, 0.94) 100%);
    border: 1px solid rgba(13, 196, 242, 0.30);
    box-shadow: 0 8px 22px -10px rgba(6, 44, 92, 0.15);
  }
  .mobile-pwa-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex: none;
    box-shadow: 0 4px 10px -2px rgba(0, 102, 230, 0.25);
  }
  .mobile-pwa-copy {
    flex: 1;
    min-width: 0;
  }
  .mobile-pwa-copy strong {
    display: block;
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--abyss);
  }
  .mobile-pwa-copy span {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.3;
  }
  .mobile-pwa-dismiss {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--muted-soft);
    display: grid;
    place-items: center;
    flex: none;
  }

  .hero {
    padding: 20px 18px 18px;
    min-height: 0;
    border-radius: 22px;
    margin-bottom: 14px;
  }
  .hero-eyebrow {
    font-size: 10.5px;
    padding: 4px 10px;
    margin-bottom: 10px;
  }
  .hero h2 {
    font-size: 25px;
    line-height: 1.1;
    margin-bottom: 14px;
  }
  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .hero-actions .button {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    font-size: 13px;
    justify-content: center;
  }
  .hero-btn-third {
    display: none;
  }
  .hero-quick {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 13px -18px 0;
    padding: 0 18px 2px;
    scrollbar-width: none;
  }
  .hero-quick::-webkit-scrollbar { display: none; }
  .hero-quick-label { flex: none; }
  .hero-pill {
    flex: none;
    max-width: 230px;
    min-height: 34px;
  }
  .hero-art {
    opacity: 0.25;
    left: 44%;
  }
  .hero-chip { display: none; }

  /* 2x2 iOS Widget Bento Grid */
  .toolgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }
  .tool {
    padding: 14px;
    min-height: 118px;
    border-radius: 18px;
  }
  .tool:hover { transform: none; }
  .tool:active {
    transform: scale(0.97);
    border-color: var(--line-cyan);
  }
  .tool-top { margin-bottom: 10px; }
  .tool .tile-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .tool .tile-icon svg { width: 17px; height: 17px; }
  .tool strong { font-size: 15.5px; font-weight: 580; }
  .tool-stat { font-size: 21px; }
  .tool-preview {
    padding-top: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, #000 84%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 84%, transparent 100%);
  }
  .tool-chip {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 2px 7px;
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .home-side { gap: 14px; }
  .card-tabs-bar { padding: 0 16px 11px; }
  .card-tabs-bar .seg-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .card-tabs-bar .seg-tabs button {
    justify-content: center;
    min-height: 34px;
  }

  /* Active Signature preview safely bounded on mobile */
  .sig-spotlight {
    padding: 0 14px 14px;
  }
  .sig-spotlight-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }
  .sig-spotlight .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .sig-spotlight .actions .button {
    width: 100%;
    min-height: 38px;
  }

  /* Mobile Quick Launcher rows inside Shortcuts card */
  .shortcuts { padding: 2px 16px 16px; }
  .mobile-only-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    padding: 10px 0;
    border: 0;
    border-bottom: 1px solid rgba(10, 38, 71, 0.06);
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    font-weight: 520;
    text-align: left;
  }
  .mobile-only-row:last-of-type {
    border-bottom: 0;
    margin-bottom: 10px;
  }
  .mobile-only-row svg { color: var(--muted-soft); }

  /* ===================== TOUCH-FRIENDLY LIST ROWS ===================== */
  .list-row {
    padding: 12px 13px;
    gap: 11px;
    min-height: 62px;
  }
  .list-row:active {
    background: rgba(13, 196, 242, 0.08);
  }
  .list-row > .tag { display: none; }
  .list-row .tile-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
  .row-main strong {
    font-size: 14.5px;
    font-weight: 560;
  }
  .row-sub {
    font-size: 12px;
    margin-top: 2px;
  }
  .row-actions {
    gap: 2px;
  }
  .row-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .row-quick-copy {
    opacity: 0.92;
    color: #0284c7;
    background: rgba(13, 196, 242, 0.09);
  }
  .row-quick-copy:active {
    background: rgba(13, 196, 242, 0.22);
    transform: scale(0.92);
  }

  /* ===================== MOBILE LIBRARY SECTION STRIP & MASTER-DETAIL ===================== */
  .mobile-section-strip {
    display: flex;
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    margin: -4px -14px 12px;
    padding: 2px 14px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-section-strip::-webkit-scrollbar { display: none; }
  body.mobile-detail-open .mobile-section-strip,
  body.mobile-detail-open .page-head,
  body.mobile-detail-open .collection-tabs,
  body.mobile-detail-open .approvals {
    display: none;
  }

  .mobile-section-pill {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 13px;
    border-radius: 99px;
    border: 1px solid rgba(10, 38, 71, 0.10);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 540;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: transform 0.14s var(--ease), background-color 0.16s ease, color 0.16s ease;
  }
  .mobile-section-pill:active { transform: scale(0.95); }
  .mobile-section-pill[aria-pressed="true"] {
    background: linear-gradient(135deg, #083466 0%, #0066e6 100%);
    border-color: transparent;
    color: #ffffff;
    font-weight: 580;
    box-shadow: 0 6px 16px -6px rgba(0, 102, 230, 0.48);
  }
  .mobile-section-pill .pill-count {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.72;
    font-variant-numeric: tabular-nums;
  }
  .mobile-section-pill .pill-alert {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    background: #38e4ff;
    color: #051c36;
  }

  /* Single-row scrollable collection sub-tabs */
  .collection-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    margin: 0 0 12px;
    scrollbar-width: none;
  }
  .collection-tabs::-webkit-scrollbar { display: none; }
  .collection-tabs button {
    flex: 1 0 auto;
    justify-content: center;
    min-height: 36px;
  }

  /* Compact Master Controls + Collapsible Extra Filters */
  .master-controls {
    padding: 12px 13px;
    gap: 9px;
  }
  .mobile-filter-toggle {
    display: inline-grid;
    place-items: center;
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 11px;
  }
  .mobile-filter-toggle.active {
    border-color: var(--line-cyan);
    background: rgba(13, 196, 242, 0.12);
    color: #03538c;
  }
  .mobile-filter-toggle .filter-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 99px;
    background: #0066e6;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px #ffffff;
  }
  .master-extra-filters {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .master-extra-filters.open {
    display: grid;
  }
  .master-extra-filters select {
    min-height: 40px;
  }
  .filter-row .seg-tabs button {
    min-height: 34px;
    font-size: 12.5px;
  }

  /* Detail Stage Screen Push */
  .workspace-split {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .workspace-split.has-detail .detail-stage {
    animation: mobileDetailIn 0.22s var(--ease) both;
  }
  .stage-head {
    padding: 14px 15px;
    gap: 11px;
  }
  .stage-head .stage-back {
    display: none !important; /* Handled by native #mobile-back in topbar */
  }
  .stage-title-wrap {
    flex: 1 1 100%;
    gap: 11px;
  }
  .stage-title-wrap h2 {
    font-size: 18px;
    white-space: normal;
    line-height: 1.25;
  }
  .stage-controls {
    width: 100%;
    justify-content: space-between;
  }
  .stage-controls .seg-tabs {
    flex: 1;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
  .stage-controls .seg-tabs button {
    justify-content: center;
    min-height: 34px;
    font-size: 13px;
  }
  .stage-body {
    padding: 15px 15px 22px;
    gap: 14px;
  }

  /* Hide redundant H1 when mobile section strip already shows active section & count */
  .mobile-section-strip + .page-head {
    display: none;
  }
  .mobile-section-strip + .page-head:has(.role-pill) {
    display: flex;
    margin-bottom: 10px;
  }
  .mobile-section-strip + .page-head:has(.role-pill) h1,
  .mobile-section-strip + .page-head:has(.role-pill) .count-pill {
    display: none;
  }

  /* Safe preview container & responsive chrome on mobile */
  .preview-chrome {
    flex-wrap: wrap;
    gap: 8px;
    padding: 9px 12px;
  }
  .preview-dots { display: none; }
  .sig-preview-tools {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: wrap;
  }
  .preview {
    padding: 14px 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .preview-headers {
    padding: 10px 14px;
  }
  .fields-panel {
    padding: 13px 14px;
  }
  .fields-panel-head select {
    width: 100% !important;
    min-height: 40px !important;
  }
  .field-insert {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .field-insert select,
  .field-insert input {
    grid-column: 1 / -1;
    max-width: none;
    min-height: 40px;
  }
  .field-insert .button {
    width: 100%;
    min-height: 38px;
  }

  /* Sticky Frosted Bottom Action Dock for Use / Edit / Create / Proposal */
  .stage-actions-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 42;
    margin: 0 !important;
    padding: 10px calc(14px + var(--sar)) calc(10px + var(--sab)) calc(14px + var(--sal));
    background: rgba(252, 254, 255, 0.94);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(10, 38, 71, 0.09);
    box-shadow: 0 -8px 26px -12px rgba(6, 28, 56, 0.16);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 8px;
  }
  .stage-actions-dock::-webkit-scrollbar { display: none; }
  .stage-actions-dock .spacer { display: none; }
  .stage-actions-dock .button {
    flex: none;
    min-height: 44px;
    padding: 0 15px;
    font-size: 13.5px;
    border-radius: 12px;
  }
  .stage-actions-dock .button.primary {
    flex: 1 0 auto;
    min-width: 140px;
    background: linear-gradient(135deg, #0b3c70 0%, #0066e6 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 6px 18px -6px rgba(0, 102, 230, 0.52);
  }
  .stage-actions-dock .button.primary:hover,
  .stage-actions-dock .button.primary:active {
    background: linear-gradient(135deg, #08305c 0%, #0054bf 100%);
    color: #ffffff;
  }

  /* ===================== COMPOSER MOBILE MODE SWITCHER ===================== */
  .mobile-composer-tabs,
  .mobile-lab-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
    margin: 0 0 14px;
    border-radius: 13px;
    background: rgba(10, 38, 71, 0.065);
    border: 1px solid rgba(10, 38, 71, 0.06);
  }
  .mobile-composer-tabs button,
  .mobile-lab-tabs button {
    border: 0;
    border-radius: 9px;
    min-height: 36px;
    padding: 6px 10px;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 540;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  }
  .mobile-composer-tabs button[aria-pressed="true"],
  .mobile-lab-tabs button[aria-pressed="true"] {
    background: #ffffff;
    color: #034a8c;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(6, 24, 43, 0.10);
  }

  .mobile-only-inline {
    display: inline-flex;
  }

  .composer-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .composer-grid[data-cm-view="write"] .composer-side-col { display: none; }
  .composer-grid[data-cm-view="preview"] [data-cm-panel="write"],
  .composer-grid[data-cm-view="preview"] [data-cm-panel="drafts"] { display: none; }
  .composer-grid[data-cm-view="drafts"] [data-cm-panel="write"],
  .composer-grid[data-cm-view="drafts"] [data-cm-panel="preview"] { display: none; }

  .composer-grid [data-cm-panel="preview"] .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .composer-grid [data-cm-panel="preview"] .actions .button {
    width: 100%;
    min-height: 42px;
  }
  .composer-grid [data-cm-panel="preview"] #copy-draft-email,
  .composer-grid [data-cm-panel="preview"] #export-draft {
    grid-column: 1 / -1;
  }
  .composer-grid [data-cm-panel="preview"] #copy-draft-email {
    background: linear-gradient(135deg, #0b3c70 0%, #0066e6 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 6px 18px -6px rgba(0, 102, 230, 0.45);
  }

  /* ===================== EMAIL TEST LAB MOBILE SWITCHER ===================== */
  .dual-preview {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .dual-preview[data-lab-view="mobile"] [data-lab-panel="desktop"] { display: none; }
  .dual-preview[data-lab-view="desktop"] [data-lab-panel="mobile"] { display: none; }
  .dual-preview .preview.mobile {
    max-width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* ===================== ATTACHMENTS MOBILE POLISH ===================== */
  .dropzone {
    padding: 20px 14px;
    border-radius: 16px;
    margin-bottom: 12px;
  }
  .toolbar {
    gap: 8px;
    margin-bottom: 10px;
  }
  .toolbar input[type="search"] {
    flex: 1 1 100%;
  }
  .toolbar select {
    flex: 1 1 calc(50% - 4px);
    max-width: none;
    min-height: 40px;
  }
  .toolbar:has(#select-all) {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -14px 12px;
    padding: 2px 14px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar:has(#select-all)::-webkit-scrollbar { display: none; }
  .toolbar:has(#select-all) .spacer { display: none; }
  .toolbar:has(#select-all) .button,
  .toolbar:has(#select-all) .muted { flex: none; }
  .page-head:has(#pick-files) #pick-files {
    width: 100%;
    min-height: 42px;
    background: linear-gradient(135deg, #0b3c70 0%, #0066e6 100%);
    color: #ffffff;
    border-color: transparent;
  }

  #attach-list .list-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  #attach-list .list-row .row-actions {
    width: 100%;
    padding-left: 28px;
    justify-content: flex-start;
    gap: 8px;
  }
  #attach-list .list-row .row-actions .button {
    flex: 1;
    min-height: 36px;
  }

  /* ===================== OUT OF OFFICE, SETTINGS, INTEGRATIONS ===================== */
  .settings-grid,
  .integration-grid,
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .integration-card {
    padding: 18px;
  }
  .pair-studio {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .pair-studio .button { width: 100%; min-height: 44px; }
  .pair-code-box {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pair-code-box .button {
    margin-left: 0 !important;
    width: 100%;
    min-height: 40px;
  }

  /* ===================== SIGNATURE GALLERY MOBILE ===================== */
  .sig-gallery {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .sig-gallery-card {
    padding: 13px;
    border-radius: 16px;
  }
  .sig-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .sig-card-actions .button {
    width: 100%;
    min-height: 38px;
  }

  /* ===================== SIGNATURE STUDIO — CANVA-STYLE NATIVE MOBILE EDITOR ===================== */
  body.mobile-studio-active .content {
    padding: 0;
  }
  .detail-stage.studio-mode {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    height: calc(100dvh - var(--mobile-topbar-h) - var(--sat));
    min-height: 0;
    overflow: hidden;
  }
  .studio {
    height: 100%;
    padding: 0;
    gap: 0;
    background: #e3eef7;
    display: flex;
    flex-direction: column;
  }
  .studio-head {
    flex: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    padding: 8px 12px;
    gap: 8px;
    background: rgba(255, 255, 255, 0.96);
  }
  .studio-title { display: none; }
  .studio-actions {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .studio-actions [data-studio-template],
  .studio-actions [data-studio-cancel] {
    display: none;
  }
  .studio-actions [data-studio-save] {
    margin-left: auto;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 99px;
    background: linear-gradient(135deg, #0b3c70 0%, #0066e6 100%);
    color: #ffffff;
    border-color: transparent;
  }

  .studio-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
  }

  /* Live Interactive Canvas pinned in upper half */
  .studio-canvas-pane {
    order: 0;
    flex: 0 0 auto;
    max-height: 46%;
    overflow-y: auto;
    overflow-x: hidden;
    border: 0;
    border-bottom: 1px solid rgba(10, 38, 71, 0.10);
    border-radius: 0;
    padding: 10px 12px 16px;
    background: #e3eef7;
  }
  .studio-canvas-head {
    margin-bottom: 6px;
    font-size: 10px;
  }
  .studio-page-frame {
    position: relative;
    width: 100%;
    overflow: visible;
    display: block;
  }
  .studio-page {
    width: 600px !important;
    max-width: none !important;
    min-height: 220px;
    margin: 0;
    zoom: 1 !important;
    padding: 20px 22px;
    border-radius: 12px;
  }
  .studio-drag { display: none; }
  .studio-block-tools {
    top: -18px;
    right: 0;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
  }
  .studio-block-tools button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  /* Lower Tool Drawer controlled by data-mob-panel */
  .studio-palette-pane,
  .studio-inspector {
    order: 1;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 0;
    border-radius: 0;
    background: #ffffff;
  }
  .studio[data-mob-panel="blocks"] .studio-inspector { display: none; }
  .studio[data-mob-panel="style"] .studio-palette-pane,
  .studio[data-mob-panel="details"] .studio-palette-pane { display: none; }
  .studio .studio-tabs { display: none; }

  .studio-palette-pane {
    padding: 12px 14px 18px;
  }
  .studio-palette-pane h3,
  .studio-palette-pane > .note { display: none; }
  .studio-palette {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding-bottom: 8px;
  }
  .studio-palette-item {
    width: auto;
    min-width: 0;
    height: 76px;
    min-height: 76px;
    padding: 8px 6px;
    border-radius: 12px;
    gap: 6px;
  }
  .studio-inspector-body {
    padding: 14px 14px 20px;
  }
  .studio-field-grid {
    gap: 10px;
  }
  .studio-field input,
  .studio-field select {
    height: 40px;
    min-height: 40px;
  }

  /* Bottom 3-Tab Studio Dock */
  .mobile-studio-dock {
    flex: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px calc(10px + var(--sar)) calc(7px + var(--sab)) calc(10px + var(--sal));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px -10px rgba(6, 28, 56, 0.12);
  }
  .mobile-studio-dock button {
    border: 0;
    border-radius: 11px;
    min-height: 44px;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 560;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .mobile-studio-dock button[aria-pressed="true"] {
    background: rgba(13, 196, 242, 0.14);
    color: #03538c;
    font-weight: 620;
  }

  /* Studio Icon/Emoji Modals become Native Bottom Sheets */
  .studio-overlay {
    padding: 0;
    align-items: end;
    justify-items: stretch;
  }
  .studio-modal {
    width: 100%;
    max-height: 84dvh;
    border-radius: 22px 22px 0 0;
    padding-bottom: var(--sab);
  }

  /* ===================== FLOATING MOBILE TOAST ===================== */
  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(var(--mobile-tabbar-h) + var(--sab) + 12px);
    max-width: none;
    justify-content: center;
    border-radius: 99px;
    padding: 11px 18px;
    font-size: 13.5px;
    z-index: 70;
  }
  body.mobile-detail-open .toast {
    bottom: calc(74px + var(--sab));
  }
  body.mobile-studio-active .toast {
    bottom: calc(68px + var(--sab));
  }

  /* Loading Skeleton */
  .loading-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .loading-pulse { height: 180px; border-radius: 20px; }
  .loading-grid div { height: 110px; border-radius: 16px; }
}

/* Standalone PWA polish (when launched from Home Screen) */
@media (display-mode: standalone) and (max-width: 768px) {
  .mobile-pwa-banner { display: none !important; }
}

/* Keyframes for native mobile transitions */
@keyframes mobileDetailIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
