/* Praxis chapter shell — mobile + desktop polish */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.shell {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.topnav {
  padding-left: max(14px, env(safe-area-inset-left, 14px));
  padding-right: max(14px, env(safe-area-inset-right, 14px));
}

.sb-foot {
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
}

.praxis-home {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.65;
  transition: opacity 0.2s;
}

.praxis-home:hover {
  opacity: 1;
}

.progress-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.48rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tab {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sec-btn,
.quiz button,
.btn {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.quiz button {
  padding: 10px 12px;
  line-height: 1.35;
}

/* Read + Prove: unified full-page scroll (all viewports) */
body.tab-read .shell,
body.tab-prove .shell {
  height: auto;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

body.tab-read,
body.tab-prove {
  overflow: auto;
  height: auto;
}

body.tab-read .body,
body.tab-prove .body {
  display: block;
  min-height: 0;
  overflow: visible;
}

body.tab-read .sidebar,
body.tab-prove .sidebar {
  max-height: none !important;
  overflow: visible;
  border-right: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

body.theme-chem.tab-read .sidebar,
body.theme-chem.tab-prove .sidebar {
  border-bottom-color: rgba(245, 158, 11, 0.12);
}

body.theme-bio.tab-read .sidebar,
body.theme-bio.tab-prove .sidebar {
  border-bottom-color: rgba(34, 211, 238, 0.12);
}

body.tab-read .sb-scroll,
body.tab-prove .sb-scroll {
  overflow: visible;
}

body.tab-read .main-panel,
body.tab-prove .main-panel {
  min-height: auto;
  overflow: visible;
}

body.tab-read .main-panel.scroll,
body.tab-prove .main-panel.scroll {
  overflow: visible;
}

.sb-scroll.custom-scrollbar,
.main-panel.scroll.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.sb-scroll.custom-scrollbar::-webkit-scrollbar,
.main-panel.scroll.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.sb-scroll.custom-scrollbar::-webkit-scrollbar-thumb,
.main-panel.scroll.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

@media (max-width: 900px) {
  .ch-name {
    font-size: 1.05rem;
    line-height: 1.25;
  }

  .ch-sub {
    font-size: 0.62rem;
    line-height: 1.45;
  }

  .tab {
    font-size: 0.52rem;
    padding: 10px 4px;
  }

  .tab span {
    display: none;
  }

  .main-panel.scroll {
    padding: 16px max(14px, env(safe-area-inset-left, 14px)) 24px max(14px, env(safe-area-inset-right, 14px));
  }

  /* Reality: split — study panel + 3D canvas */
  body.tab-reality .body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 44dvh) minmax(280px, 1fr);
  }

  body.tab-reality .sidebar {
    max-height: 44dvh;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  }

  body.theme-chem.tab-reality .sidebar {
    border-bottom-color: rgba(245, 158, 11, 0.12);
  }

  body.theme-bio.tab-reality .sidebar {
    border-bottom-color: rgba(34, 211, 238, 0.12);
  }

  body.tab-reality .main-panel {
    min-height: 280px;
  }

  body.tab-reality .stage-label,
  body.tab-reality .stage-mode {
    font-size: 0.42rem;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.tab-reality .stage-mode {
    max-width: 50%;
  }
}

@media (max-width: 480px) {
  .paper-head h2 {
    font-size: 1.15rem;
  }

  .pq {
    padding: 12px;
  }

  .pq-actions {
    flex-direction: column;
  }

  .pq-actions button {
    width: 100%;
    min-height: 44px;
  }
}

/* Badge / account modals — mobile safe (detail styles injected by praxis-core.js) */
.badge-overlay {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  padding-top: max(20px, env(safe-area-inset-top, 20px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
}

.badge-overlay.show {
  align-items: center;
}

@media (max-width: 480px) {
  .badge-card {
    max-width: 100%;
    margin: auto 0;
    padding: 22px 18px 18px;
  }

  .badge-title {
    font-size: 1.35rem !important;
  }

  .badge-seal-wrap {
    width: 170px !important;
    height: 220px !important;
  }
}
