#manual-content,
#manual-scroll-area,
#less-command-result,
#less-command-result-body,
pre[data-api-key] {
  overscroll-behavior: none;
}

#manual-scroll-area {
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 15, 13, 0.92) transparent;
}

#manual-scroll-area::-webkit-scrollbar {
  width: 12px;
}

#manual-scroll-area::-webkit-scrollbar-track {
  background: transparent;
}

#manual-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(15, 15, 13, 0.92);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

#manual-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(22, 22, 18, 0.96);
  border: 3px solid transparent;
  background-clip: padding-box;
}

#less-command-result-body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#less-command-result-body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

#less-command-result-body[data-layout="nowrap"] {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

pre[data-api-key] {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

pre[data-api-key]::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ─── Mobile: edge-to-edge terminal ─── */
@media (max-width: 639px) {
  /* Terminal window: full screen, no inset, no rounded corners */
  #manual-content {
    width: 100dvw !important;
    margin: 0 !important;
    height: 100vh !important;
    min-height: 100vh !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* Top bar: flush to top of screen */
  #manual-top-bar {
    top: 0 !important;
    width: 100dvw !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
  }

  /* Scroll area: full height, tighter horizontal padding */
  #manual-scroll-area {
    width: 100dvw !important;
    height: 100vh !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-top: 52px !important;
    padding-bottom: 80px !important;
  }

  /* Status bar: no rounded corners (bottom controlled by JS syncChrome) */
  .less-status-bar {
    width: 100dvw !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  /* Command line: flush to bottom, no rounded corners */
  .less-command-line {
    width: 100dvw !important;
    bottom: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  /* Result window: full width, no radius (bottom controlled by JS syncChrome) */
  #less-command-result {
    width: 100dvw !important;
    border-radius: 0 !important;
  }

  #less-command-overlay {
    width: 100dvw !important;
    border-radius: 0 !important;
    top: 0 !important;
  }

  /* Man header: 2-column on narrow screens */
  #man-header > span:last-child {
    display: none;
  }

  #man-header {
    grid-template-columns: 1fr auto !important;
  }

  /* Man footer: 2-column */
  #man-footer > span:last-child {
    display: none;
  }

  #man-footer {
    grid-template-columns: 1fr auto !important;
  }

  /* Environment section: stack to single column */
  #environment-section > div {
    grid-template-columns: 1fr !important;
    row-gap: 3px !important;
  }

  /* Larger tap target for the :help link in status bar */
  #less-help-link {
    padding: 8px 0 !important;
    margin: -8px 0 !important;
  }

  /* Hide status: operational on mobile */
  .status-operational {
    display: none !important;
  }
}

/* ─── Mobile command palette (bottom sheet) ─── */
#mobile-palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

#mobile-palette.is-open {
  display: flex;
  pointer-events: auto;
}

#mobile-palette-bd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: brightness(0.7);
}

#mobile-palette-sheet {
  position: relative;
  z-index: 1;
  background: #161612;
  border-top: 1px solid #252520;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}

#mobile-palette.is-entering #mobile-palette-sheet {
  animation: palette-slide-in 0.24s cubic-bezier(0.32, 0.72, 0, 1) both;
}

#mobile-palette.is-closing #mobile-palette-sheet {
  transform: translateY(100%);
}

@keyframes palette-slide-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

#mobile-palette-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #252520;
  margin: 12px auto 0;
}

#mobile-palette-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 11px;
  border-bottom: 1px solid #252520;
}

#mobile-palette-cmds {
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: 65vh;
  -webkit-overflow-scrolling: touch;
}

#mobile-palette-cmds button {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid #252520;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  gap: 12px;
  box-sizing: border-box;
}

#mobile-palette-cmds button:last-child {
  border-bottom: none;
}

#mobile-palette-cmds button:active {
  background: rgba(200, 160, 80, 0.08);
}

#mobile-palette-footer {
  padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  border-top: 1px solid #252520;
  text-align: center;
}
