/* RC60: one responsive layer for phones, tablets, split-screen and touch input. */
:root {
  --app-header-height: calc(68px + var(--app-safe-top, 0px));
}
html:has(.app-shell) {
  scroll-padding-top: calc(var(--app-header-height) + 16px);
}
body .app-navbar {
  height: auto;
  min-height: calc(68px + var(--app-safe-top));
  flex-wrap: wrap;
  padding-block: calc(10px + var(--app-safe-top)) 10px;
  padding-left: max(12px, var(--app-safe-left));
  padding-right: max(12px, var(--app-safe-right));
}
body .app-navbar .header-wallet {
  height: 48px;
  min-height: 48px;
  padding: 1px;
  gap: 2px;
}
body .app-navbar .header-wallet-balance {
  min-height: 44px;
}
body .app-navbar .header-wallet-topup {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
}
body .app-navbar .header-wallet-value {
  white-space: nowrap;
}
body .app-navbar .header-account {
  min-width: 44px;
}
body .app-navbar .header-language-select {
  font-size: 1rem;
}
body .app-sidebar {
  padding-top: var(--app-safe-top);
  padding-bottom: var(--app-safe-bottom);
  padding-left: var(--app-safe-left);
  padding-right: var(--app-safe-right);
}
.dialog-viewport {
  padding-left: max(12px, var(--app-safe-left));
  padding-right: max(12px, var(--app-safe-right));
}
.dialog-panel,
.dialog-content {
  min-width: 0;
}
.dialog-content {
  overflow-wrap: anywhere;
  scroll-padding-block: 16px;
}
.app-button-label {
  min-width: 0;
  overflow-wrap: break-word;
}
.app-button svg,
.pricing-card-button svg {
  flex-shrink: 0;
}
.admin-table-scroll {
  container-type: inline-size;
  container-name: records;
}
.wallet-ledger {
  container-type: inline-size;
  container-name: ledger;
}
.support-frame {
  container-type: inline-size;
  container-name: support;
}
.support-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
}
.support-workspace > * {
  min-width: 0;
}
.support-workspace .support-back {
  display: none;
}
.support-messages {
  overscroll-behavior-y: contain;
  overflow-wrap: anywhere;
}
.support-workspace :is(h3, button) {
  overflow-wrap: anywhere;
}
.generator-jumps {
  scroll-margin-top: calc(var(--app-header-height) + 16px);
}
.generator-section {
  scroll-margin-top: calc(var(--app-header-height) + 88px);
}
.workspace-tabs {
  top: calc(var(--app-header-height) + 4px);
}

/* The same navigation breakpoint is used by Navbar, Sidebar, MobileDock and App. */
@media (max-width: 1279px) {
  .app-shell:not(.app-shell-exam) {
    display: block;
  }
  body .app-sidebar {
    width: min(312px, calc(100vw - 24px));
  }
  body .app-navbar .desktop-header-control {
    display: none;
  }
  body .app-navbar .navbar-controls {
    gap: 6px;
  }
  body .app-navbar .header-wallet-label {
    display: none;
  }
  body .app-navbar .header-wallet-balance {
    max-width: 112px;
    padding-inline: 8px;
  }
  body .app-navbar .header-account-chevron {
    display: none;
  }
  .app-workspace.has-mobile-dock {
    padding-bottom: calc(var(--app-dock-height, 84px) + 16px);
  }
  .mobile-dock {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 0;
    padding: 6px max(8px, var(--app-safe-right)) calc(6px + var(--app-safe-bottom))
      max(8px, var(--app-safe-left));
    border-top: 1px solid var(--app-border);
    background: var(--app-surface);
    box-shadow: 0 -4px 16px rgb(20 47 86 / 0.05);
  }
  .mobile-dock-link {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    max-width: 180px;
    min-height: 60px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 4px;
    border-radius: 10px;
    color: var(--app-muted);
    text-align: center;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.45;
  }
  .mobile-dock-link[aria-current='page'] {
    background: var(--app-surface-subtle);
    color: var(--app-primary);
  }
  .mobile-dock-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    flex-shrink: 0;
  }
  .mobile-dock-label {
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    overflow-wrap: break-word;
    font-size: inherit;
  }
  body .navbar-popover {
    top: calc(var(--visible-top, 0px) + var(--app-header-height) + 4px);
    max-height: calc(
      var(--visible-height, 100dvh) - var(--app-header-height) - 20px - var(--app-safe-bottom)
    );
    max-width: calc(100vw - 24px - var(--app-safe-left) - var(--app-safe-right));
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  .navbar-popover .notification-list {
    max-height: min(320px, calc(var(--visible-height, 100dvh) - var(--app-header-height) - 96px));
  }
  .generator-jumps {
    top: calc(var(--app-header-height) + 6px);
  }
  .app-toasts {
    bottom: calc(var(--app-dock-height, 0px) + 16px + var(--app-safe-bottom));
  }
  body.brand-public,
  body.brand-info {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  body .auth-form-layout {
    display: block;
    padding-top: calc(24px + var(--app-safe-top));
    padding-left: max(16px, var(--app-safe-left));
    padding-right: max(16px, var(--app-safe-right));
  }
  body .auth-brand-panel {
    display: none;
  }
  body .auth-header,
  body .auth-form-panel,
  body .auth-footer {
    max-width: 560px;
    margin-inline: auto;
  }
}

/* Apply readable native controls on iPad too, regardless of portrait/landscape. */
@media (max-width: 1279px), (any-pointer: coarse) {
  body
    :is(.app-shell, .dialog-viewport, .auth-form-layout)
    :is(input, select, textarea):not([type='checkbox']):not([type='radio']):not([type='range']):not(
      [type='hidden']
    ):not([type='file']) {
    font-size: max(16px, 1rem);
    line-height: 1.5;
  }
  body
    :is(.app-shell, .dialog-viewport, .auth-form-layout)
    :is(input, select):not([type='checkbox']):not([type='radio']):not([type='range']):not(
      [type='hidden']
    ):not([type='file']) {
    min-height: 44px;
  }
  :where(.app-workspace, .dialog-content, .exam-workspace) :is(button, summary) {
    min-height: 44px;
  }
  .exam-question-meta {
    flex-wrap: wrap;
    gap: 12px;
  }
  .exam-question-meta > div {
    flex: 1 1 200px;
    min-width: 0;
  }
  .exam-question-meta .exam-review-flag {
    max-width: 100%;
    flex-shrink: 1;
    white-space: normal;
  }
  .app-navbar .navbar-popover :is(.text-xs, .text-sm) {
    font-size: 0.875rem;
    line-height: 1.65;
  }
}
@media (min-width: 768px) and (max-width: 1279px) {
  body .app-page {
    padding-inline: 24px;
    padding-top: 28px;
  }
}
@media (max-width: 767px) {
  body .navbar-popover {
    left: max(12px, var(--app-safe-left));
    right: max(12px, var(--app-safe-right));
    width: auto;
  }
  body .direct-purchase-grid,
  body .native-credit-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  body .direct-purchase-grid .pricing-card,
  body .native-credit-grid .pricing-card {
    padding: 22px 18px;
  }
  .wallet-ledger-pagination {
    flex-wrap: wrap;
  }
  .support-workspace {
    display: block;
  }
  .support-workspace[data-thread-open='false'] .support-detail,
  .support-workspace[data-thread-open='true'] .support-list {
    display: none;
  }
  .support-workspace .support-back {
    display: inline-flex;
  }
  .support-workspace .support-detail {
    min-height: 300px;
  }
  .support-workspace .support-messages {
    min-height: 140px;
    max-height: min(520px, calc(var(--visible-height, 100dvh) * 0.55));
  }
}
@media (max-width: 479px) {
  .exam-header-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .exam-header-actions > :last-child:nth-child(odd) {
    grid-column: 1/-1;
  }
  .purchase-toolbar > span {
    flex-wrap: wrap;
  }
  .purchase-promo {
    width: 100%;
  }
}
@media (max-width: 600px) {
  body.brand-public .language-popover {
    inset-inline: auto;
    left: max(16px, env(safe-area-inset-left, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    width: auto;
    top: calc(112px + env(safe-area-inset-top, 0px));
    max-height: min(
      430px,
      calc(100dvh - 136px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
    );
  }
}
@media (max-width: 359px) {
  body .app-navbar .navbar-title-group {
    flex: 1 0 100%;
  }
  body .app-navbar .navbar-controls {
    width: 100%;
    justify-content: flex-end;
  }
  body .app-navbar .header-wallet {
    margin-inline-end: auto;
  }
  body .app-navbar {
    gap: 6px;
  }
}
@media (max-width: 1279px) and (max-height: 500px) and (orientation: landscape) {
  .mobile-dock {
    display: none;
  }
  .app-workspace.has-mobile-dock {
    padding-bottom: 16px;
  }
  .app-navbar,
  body .app-navbar,
  .exam-header,
  .generator-jumps {
    position: static;
  }
  .exam-navigation {
    position: static;
    padding: 12px 0;
    box-shadow: none;
  }
  .exam-workspace {
    padding-bottom: 16px;
  }
  .generator-section {
    scroll-margin-top: 16px;
  }
  body .navbar-popover {
    top: calc(var(--visible-top, 0px) + 8px);
    max-height: calc(var(--visible-height, 100dvh) - 16px);
  }
}
:root[data-keyboard-open='true'] .mobile-dock {
  display: none;
}
:root[data-keyboard-open='true'] .generator-jumps {
  position: static;
}
:root[data-keyboard-open='true'] .app-toasts {
  bottom: auto;
  top: calc(var(--visible-top, 0px) + 12px);
}
@container records (max-width:720px) {
  .admin-responsive-table:not(.admin-compact-table) {
    display: block;
    min-width: 0;
  }
  .admin-responsive-table:not(.admin-compact-table) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .admin-responsive-table:not(.admin-compact-table) tbody {
    display: grid;
    gap: 14px;
  }
  .admin-responsive-table:not(.admin-compact-table) tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-surface);
  }
  .admin-responsive-table:not(.admin-compact-table) .admin-data-cell {
    display: block;
    min-width: 0;
    padding: 10px;
    text-align: start;
    white-space: normal;
    font-size: 0.875rem;
  }
  .admin-responsive-table:not(.admin-compact-table)
    :is(.admin-cell-wide, .admin-data-cell:first-child, .admin-data-cell:last-child, td[colspan]) {
    grid-column: 1/-1;
  }
  .admin-responsive-table:not(.admin-compact-table) .admin-cell-label {
    display: block;
    margin-bottom: 5px;
    color: var(--app-muted);
    font-size: 0.8125rem;
    line-height: 1.6;
  }
  .admin-responsive-table:not(.admin-compact-table) .admin-cell-value {
    max-width: 100%;
    overflow-wrap: break-word;
  }
  .admin-responsive-table:not(.admin-compact-table) :is(button, .table-action) {
    min-height: 44px;
  }
}
@container ledger (max-width:700px) {
  .wallet-ledger-controls {
    grid-template-columns: minmax(0, 1fr);
  }
  .wallet-ledger-columns {
    display: none;
  }
  .wallet-ledger-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: start;
  }
  .wallet-ledger-info {
    grid-column: 1;
    grid-row: 1;
  }
  .wallet-ledger-amount {
    grid-column: 2;
    grid-row: 1;
    flex-direction: column;
    align-items: flex-end;
  }
  .wallet-ledger-balance,
  .wallet-ledger-receipt {
    grid-column: 1/-1;
  }
  .wallet-ledger-balance {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .wallet-ledger-balance > span {
    display: inline;
  }
}
@container support (max-width:740px) {
  .support-workspace {
    display: block;
  }
  .support-workspace[data-thread-open='false'] .support-detail,
  .support-workspace[data-thread-open='true'] .support-list {
    display: none;
  }
  .support-workspace .support-back {
    display: inline-flex;
  }
  .support-workspace .support-detail {
    min-height: 300px;
  }
  .support-workspace .support-messages {
    min-height: 140px;
    max-height: min(520px, calc(var(--visible-height, 100dvh) * 0.55));
  }
}
@media print {
  .mobile-dock,
  body .app-navbar,
  .support-back {
    display: none !important;
  }
}
