/* Guide-only layout corrections. The original product stylesheet stays intact. */
html:has(.guide-page),
body:has(.guide-page) {
  height: auto !important;
  min-height: 100%;
  overflow-y: auto !important;
}
.guide-page,
.guide-page * {
  box-sizing: border-box;
}
.guide-page .guide-reading h1,
.guide-page .guide-reading h2,
.guide-page .guide-testimonial blockquote {
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: pretty;
}
.guide-page .guide-stage,
.guide-page .guide-stage :where(div, aside, section, header) {
  min-width: 0;
}
.guide-page .guide-stage .viewer-error {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
}
.guide-page .guide-testimonial img {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin-inline: auto;
  border-radius: 8px;
}

@media (max-width: 900px) {
  /* The embedded panels have less room than a full-width app workspace. */
  .guide-page .guide-stage .reaction-workspace,
  .guide-page .guide-stage .sn2-module,
  .guide-page .guide-stage .butane-info-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
    min-width: 0 !important;
    max-width: 100%;
  }
  .guide-page .guide-stage .explanation-drawer.open {
    position: static !important;
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    min-height: 0;
    transform: none;
    z-index: auto;
  }
  .guide-page .guide-stage .drawer-body {
    overflow: visible !important;
    min-height: 0;
  }
}

@media (max-width: 600px) {
  .guide-page .guide-reading {
    width: calc(100% - 32px);
  }
  .guide-page .guide-topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px 12px;
  }
  .guide-page .guide-topbar nav {
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 0;
  }
  .guide-page .guide-topbar nav a,
  .guide-page .guide-theme {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .guide-page .guide-reading h2 {
    font-size: clamp(20px, 5.4vw, 23px);
    line-height: 1.55;
  }
  .guide-page .guide-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .guide-page .guide-actions .guide-button,
  .guide-page .guide-limit .guide-button {
    width: 100%;
    min-height: 46px;
    white-space: normal;
    word-break: keep-all;
  }
  .guide-page .guide-join {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .guide-page .guide-demo-section {
    padding-inline: 8px;
  }
  .guide-page .guide-demo-section > .guide-reading {
    width: 100%;
    padding-inline: 8px;
  }
  .guide-page .guide-sampler {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }
  .guide-page .guide-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 8px;
    overflow: visible;
    border-radius: 12px 12px 0 0;
  }
  .guide-page .guide-tabs button {
    min-width: 0;
    width: 100%;
    min-height: 56px;
    padding: 8px 5px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    white-space: normal;
    word-break: keep-all;
  }
  .guide-page .guide-tabs button span {
    font-size: 11px;
  }
  .guide-page .guide-demo-help {
    padding: 12px;
  }
  .guide-page .guide-stage {
    padding: 0 8px 16px;
    width: 100%;
  }
  .guide-page .guide-stage .card,
  .guide-page .guide-stage .jsmol-card {
    max-width: 100%;
    min-width: 0 !important;
  }
  .guide-page .guide-stage :is(h2, h3, h4, p, button) {
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  .guide-page .guide-stage input[type="range"] {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .guide-page .guide-stage .viewer-controls,
  .guide-page .guide-stage .viewer-utility-controls {
    flex-wrap: wrap;
    min-width: 0;
    gap: 8px;
  }
  .guide-page .guide-stage .viewer-controls {
    padding: 10px 8px;
  }
  .guide-page .guide-stage .viewer-controls button {
    max-width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 10px;
    white-space: normal;
  }
  .guide-page .guide-stage .viewer-utility-controls > div {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* R/S: stack progress text above the previous/next actions. */
  .guide-page .guide-stage-rs > div > div:first-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .guide-page .guide-stage-rs > div > div:first-child > button {
    min-width: 0;
    white-space: normal;
  }
  .guide-page .guide-stage-rs > div > .card:last-child {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
    padding: 12px !important;
  }
  .guide-page .guide-stage-rs > div > .card:last-child > div {
    display: grid !important;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }
  .guide-page .guide-stage-rs > div > .card:last-child button {
    min-width: 0;
    justify-content: center;
    min-height: 44px;
    padding: 8px !important;
  }

  /* Newman: remove app-level reserved width and nested card gutters. */
  .guide-page .guide-stage .butane-module-root {
    padding: 0 !important;
    width: 100%;
    max-width: 100% !important;
  }
  .guide-page .guide-stage .module-variant-tabs {
    max-width: 100% !important;
    flex-wrap: wrap;
  }
  .guide-page .guide-stage .butane-visual-layout > .card,
  .guide-page .guide-stage .butane-info-layout > .card {
    padding: 10px !important;
  }
  .guide-page .guide-stage .butane-info-layout,
  .guide-page .guide-stage .butane-strain-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .guide-page .guide-stage .butane-module-root .card-header,
  .guide-page .guide-stage .butane-module-root > .card > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }
  .guide-page .guide-stage .butane-newman-svg {
    width: 100% !important;
    max-width: 280px;
    height: auto !important;
  }
  .guide-page .guide-stage .butane-energy-graph-shell {
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
  }

  /* SN2: keep the slider and four stage buttons usable within one column. */
  .guide-page .guide-stage .sn2-container {
    padding: 0 !important;
  }
  .guide-page .guide-stage-sn2 .drawer-header,
  .guide-page .guide-stage-sn2 .drawer-body {
    padding: 12px !important;
  }
  .guide-page .guide-stage-sn2 .drawer-header {
    flex-wrap: wrap;
  }
  .guide-page .guide-stage-sn2 .visual-lab-sticky-column > div > div:first-child {
    flex-wrap: wrap;
    gap: 6px;
  }
  .guide-page .guide-stage-sn2 .visual-lab-sticky-column > div > div:last-child {
    padding: 12px !important;
  }
  .guide-page .guide-stage-sn2 div:has(> input[type="range"]) {
    flex: 1 0 100% !important;
    min-width: 0;
  }
  .guide-page .guide-stage-sn2 div:has(> button:nth-child(4)):not(:has(> :not(button))) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .guide-page .guide-stage-sn2 div:has(> button:nth-child(4)):not(:has(> :not(button))) > button {
    min-height: 40px;
    white-space: normal;
  }
  .guide-page .guide-stage-sn2 .sn2-mech-svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
  }
  .guide-page .guide-stage-sn2 table {
    table-layout: fixed;
    width: 100%;
    overflow-wrap: anywhere;
  }
  .guide-page .guide-stage-sn2 td,
  .guide-page .guide-stage-sn2 th {
    padding: 7px 6px !important;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }
}
