/* DivineChecker — mobile & layout polish (loaded last) */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: clip;
  overscroll-behavior-x: none;
}

/* CardNav is the real mobile nav — kill the legacy fixed bottom sidebar tabs */
@media (max-width: 860px) {
  body.card-nav-enabled .tabs,
  body.card-nav-enabled nav.sidebar-nav {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    backdrop-filter: none !important;
    pointer-events: none !important;
    height: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
  }

  body.card-nav-enabled .page {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 900px) {
  /* Sticky chrome: nav + status */
  html[data-theme="alt"] body.card-nav-enabled .app-main-chrome {
    position: sticky;
    top: 0;
    z-index: 120;
    background: #09090b;
    border-bottom: 1px solid rgba(39, 39, 42, 0.9);
    padding: 0 0 8px;
  }

  html[data-theme="alt"] body.card-nav-open .app-main-chrome {
    z-index: 200;
    background: #09090b !important;
  }

  html[data-theme="alt"] .card-nav-mount {
    padding: 8px 10px 0 !important;
    position: static !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* Two-row nav: actions on top, tabs full-width below */
  html[data-theme="alt"] .card-nav-top {
    display: grid !important;
    grid-template-columns: auto 1fr !important;
    grid-template-rows: auto auto;
    height: auto !important;
    min-height: 0;
    padding: 6px 8px 8px !important;
    row-gap: 6px;
    column-gap: 8px;
  }

  html[data-theme="alt"] .card-nav-left {
    grid-column: 1;
    grid-row: 1;
  }

  html[data-theme="alt"] .card-nav-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  html[data-theme="alt"] .card-nav-primary-tabs {
    display: flex !important;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    width: 100% !important;
    max-width: none !important;
    height: 38px;
    gap: 4px;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  html[data-theme="alt"] .card-nav-primary-tabs::-webkit-scrollbar {
    display: none;
  }

  html[data-theme="alt"] .card-nav-quick-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
    font-size: 0.78rem;
    font-weight: 600;
    height: 36px;
    text-align: center;
  }

  html[data-theme="alt"] .card-nav-user-bar {
    display: none !important;
  }

  html[data-theme="alt"] .app-main-scroll {
    padding: 8px 12px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Hide redundant page title under nav on phone */
  html[data-theme="alt"] body.card-nav-enabled .app-main-scroll > .rb-topbar.app-topbar {
    display: none !important;
  }

  /* Expanded hamburger: stack cards, no overlapping GSAP transforms */
  html[data-theme="alt"] body.card-nav-open .card-nav-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  html[data-theme="alt"] body.card-nav-open .nav-card {
    transform: none !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
  }

  html[data-theme="alt"] body.card-nav-open .nav-card-link {
    min-height: 40px;
    line-height: 1.35;
  }

  /* Compact collapsible status pill under nav */
  html[data-theme="alt"] .app-main-chrome .online-bar:not(.hidden) {
    display: block !important;
    margin: 6px 10px 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  .online-bar-toggle {
    min-height: 36px;
    width: auto;
    max-width: 100%;
  }

  .online-count {
    font-size: 12px;
    padding: 0;
  }

  .online-users {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .online-bar--collapsed .online-users {
    display: none !important;
  }

  .ocean-activity-filters {
    gap: 6px;
  }

  .ocean-activity-chip {
    min-height: 32px;
    padding: 6px 12px;
  }

  .ocean-activity-target {
    max-width: 100%;
  }

  /* Compact check hero — kill desktop 72vh centering on phones */
  html[data-theme="alt"]:has(#tab-check.active) .rb-content {
    min-height: 0 !important;
    justify-content: flex-start !important;
  }

  html[data-theme="alt"]:has(#tab-check.active) #tab-check {
    min-height: 0 !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    padding-top: 8px !important;
  }

  html[data-theme="alt"] .check-idle-intro {
    min-height: 0 !important;
    padding: 16px 8px 20px !important;
    align-items: flex-start !important;
  }

  html[data-theme="alt"] .check-idle-intro-content {
    padding-top: 4px !important;
  }

  html[data-theme="alt"] #tab-check.active,
  html[data-theme="alt"] body.floating-lines-active #tab-check.active {
    min-height: 0 !important;
  }

  html[data-theme="alt"] .check-hero-title {
    font-size: 1.45rem !important;
    margin-bottom: 10px !important;
  }

  html[data-theme="alt"] .check-hero-lead {
    font-size: 1.05rem !important;
    margin: 0 0 8px !important;
  }

  html[data-theme="alt"] .check-hero-sub {
    margin: 0 auto 16px !important;
    font-size: 0.875rem !important;
  }

  /* Top tabs: even chips, no overflow crook */
  html[data-theme="alt"] .card-nav-primary-tabs {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 4px !important;
    height: auto !important;
    overflow: visible !important;
  }

  html[data-theme="alt"] .card-nav-quick-tab {
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 2px !important;
    font-size: 0.68rem !important;
    letter-spacing: -0.02em;
    height: 34px !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html[data-theme="alt"] .card-nav-top {
    border-radius: 12px !important;
  }

  html[data-theme="alt"] .hamburger-menu,
  html[data-theme="alt"] .card-nav-icon-btn,
  html[data-theme="alt"] .card-nav-cta-button {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
  }

  html[data-theme="alt"] .card-nav-cta-button {
    padding: 0 !important;
  }

  html[data-theme="alt"] .site-floating-lines {
    opacity: 0.35 !important;
  }

  /* Soften ferrofluid if it ever shows */
  html[data-theme="alt"] .site-ferrofluid-canvas {
    opacity: 0.35;
  }

  /* Modals */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content,
  .settings-modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(92dvh, 920px);
    margin: 0;
    border-radius: 18px 18px 0 0 !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .settings-toggle-row {
    min-height: 48px;
  }

  .settings-toggle-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  /* Auth */
  .auth-card {
    margin: 12px;
    padding: 18px 16px;
    width: auto;
    max-width: none;
  }

  .auth-card input,
  .auth-card button,
  .btn {
    min-height: 44px;
  }

  /* Check flow */
  .check-hero-cta,
  #startCheckBtn,
  #completeCheckBtn,
  #logsCompleteCheckBtn {
    width: 100%;
    min-height: 48px;
  }

  .check-key-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    overflow: visible;
  }

  .key-token-row {
    flex-direction: column;
    align-items: stretch;
  }

  .key-copy-btn,
  .check-cancel-btn,
  .check-renew-btn {
    width: 100%;
    min-height: 44px;
  }

  .check-sessions-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 8px;
    padding-bottom: 4px;
  }

  .check-session-chip {
    flex: 0 0 auto;
  }

  /* Logs / lists */
  .logs-filter-group,
  .toolbar,
  .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions input,
  .toolbar-actions select,
  .audit-search-input {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .log-item {
    padding: 12px;
  }

  /* Ocean report */
  .ocean-section-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 8px;
    scrollbar-width: none;
  }

  .ocean-section-nav::-webkit-scrollbar {
    display: none;
  }

  .ocean-section-nav-btn {
    flex: 0 0 auto;
    min-height: 36px;
    white-space: nowrap;
  }

  .ocean-compact-status {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .ocean-compact-ok {
    flex: 1 1 calc(50% - 6px);
    min-width: 140px;
    justify-content: flex-start;
  }

  .ocean-table-wrap,
  .ocean-mft-scroll,
  .dc-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .ocean-table {
    min-width: 560px;
    font-size: 12px;
  }

  .ocean-card {
    padding: 12px;
  }

  .ocean-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .ocean-path-cell,
  .mono.ocean-path-cell {
    word-break: break-all;
    white-space: normal;
  }

  .logs-detail-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .logs-detail-toolbar .btn,
  #logsDetailBackBtn {
    width: 100%;
    justify-content: center;
  }

  .logs-detail-title {
    width: 100%;
    font-size: 16px !important;
  }

  .verdict-panel {
    position: sticky;
    bottom: 0;
    z-index: 40;
    margin-left: -12px;
    margin-right: -12px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
  }

  .verdict-panel .verdict-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .verdict-panel .btn {
    min-height: 44px;
  }

  /* Profile / dashboard / access */
  .profile-layout,
  .dashboard-grid,
  .dashboard-stats,
  .profile-stats,
  .hwid-risk-stats,
  .presence-upload-page {
    grid-template-columns: 1fr !important;
  }

  .profile-quick-actions {
    width: 100%;
    max-width: none;
  }

  .profile-quick-actions .btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .user-row,
  .access-grid,
  .team-feed-row {
    grid-template-columns: 1fr !important;
  }

  /* Footer */
  .site-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    font-size: 11px;
  }

  .site-footer-rw-logo {
    width: 36px;
    height: 36px;
  }

  /* Toast above home indicator */
  .app-toast {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    max-width: min(94vw, 420px);
  }

  /* Ghost cursor / heavy effects off on touch phones */
  .ghost-cursor {
    display: none !important;
  }
}

@media (max-width: 520px) {
  html[data-theme="alt"] .card-nav-quick-tab {
    font-size: 0.62rem !important;
    padding: 0 1px !important;
  }

  .ocean-compact-ok {
    flex: 1 1 100%;
  }

  .ocean-table {
    min-width: 480px;
  }

  .ocean-mods-filters {
    gap: 5px;
  }

  .ocean-mods-chip {
    padding: 6px 10px;
    font-size: 10px;
  }

  .ocean-mod-item {
    grid-template-columns: 4px minmax(0, 1fr);
    gap: 10px;
  }

  .ocean-mod-item .ocean-badge,
  .ocean-mod-item .ocean-mod-badges {
    grid-column: 2;
    justify-self: start;
    margin-top: 0;
    align-items: flex-start;
  }

  .verdict-panel .verdict-actions {
    grid-template-columns: 1fr;
  }

  .settings-modal-content h2 {
    font-size: 20px;
  }

  .hero-chip-btn,
  .open-settings-btn {
    min-height: 40px;
  }
}

/* Align common spacing across desktop too */
html[data-theme="alt"] .alt-pane > .card {
  box-sizing: border-box;
}

html[data-theme="alt"] .ocean-dashboard {
  gap: 14px;
}

html[data-theme="alt"] .online-bar-head {
  align-items: center;
}

html[data-theme="alt"] .online-bar-toggle {
  border-color: rgba(82, 82, 91, 0.85);
  background: rgba(24, 24, 27, 0.92);
  backdrop-filter: blur(12px);
}

html[data-theme="alt"] .online-count {
  border-radius: 0;
  background: none;
  border: none;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

/* Status under CardNav (desktop + mobile) */
html[data-theme="alt"] .app-main-chrome .online-bar {
  max-width: var(--rb-max-w, 1120px);
  margin: 0 auto;
  width: calc(100% - 48px);
  box-sizing: border-box;
  padding: 0 0 4px;
}

@media (min-width: 901px) {
  html[data-theme="alt"] .app-main-chrome .online-bar {
    margin-top: 2px;
  }
}

/* Access create form — phone stack */
@media (max-width: 900px) {
  html[data-theme="alt"] .alt-pane-access .access-create-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  html[data-theme="alt"] .alt-pane-access .access-expires-field {
    width: 100%;
  }

  html[data-theme="alt"] .alt-pane-access .access-users-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  html[data-theme="alt"] .alt-pane-access .access-users-search {
    width: 100%;
    min-height: 44px;
  }
}
