/* SPI-17 follow-up (24 Nov 2026): no custom page-level scroll rail.
   The browser's native page scrollbar is used. Narrow 6px bars stay
   on inner scroll containers only (lab template, tables, chem-scroll). */
html { scrollbar-gutter: auto; }
/* Legal-page markup is different from the teaching-page header. */
html.legal-page #root header > div { display:flex !important; flex-direction:column !important; align-items:center !important; justify-content:center; gap:12px !important; padding:22px 20px !important; text-align:center !important; }
html.legal-page #root header > div > p:first-child { width:auto !important; max-width:100% !important; margin:0; font-size:14px !important; color:#f7f3e8; }
html.legal-page #root header > div > a:first-of-type { display:block; width:auto; margin:0; padding:0; border:0; }
html.legal-page #root header > div > a:first-of-type img { width:92px !important; height:auto; margin:auto; }
html.legal-page #root header h1 { margin:0 !important; text-align:center; }
html.legal-page #root header h1 span { font-size:clamp(25px,5.5vw,40px) !important; line-height:1.12; }
html.legal-page #root header h1 + p { display:block !important; width:auto; max-width:100%; margin:0; color:#d4e8f4 !important; text-align:center; overflow-wrap:anywhere; }
html.legal-page #root header > div > a:last-child { display:inline-flex; align-items:center; justify-content:center; width:auto !important; max-width:100%; margin:4px 0 0; padding:12px 18px; border-radius:10px; background:#f2a93b; color:#101d32; font-size:16px; line-height:1.4; white-space:normal; text-align:center; font-weight:750; }
html.legal-page #root main { width:100%; max-width:1000px; margin:auto; padding:24px 20px; }
html.legal-page #root main section { margin-top:24px; }
html.legal-page #root main p { line-height:1.65; }
@media(max-width:640px) { html.legal-page #root header > div { padding:18px 12px !important; } html.legal-page #root main { padding:20px 14px; } }
/* Matching persistent horizontal handle for the Elements table. */
.element-scroll-control { position:relative; width:100%; height:28px; margin:12px 0 8px; border-radius:14px; background:#dce3ec; border:1px solid #8c9bac; box-sizing:border-box; touch-action:none; user-select:none; cursor:pointer; }
.element-scroll-handle { position:absolute; top:2px; bottom:2px; left:0; min-width:72px; border-radius:12px; background:#101d32; border:2px solid #f2a93b; display:flex; align-items:center; justify-content:center; gap:4px; box-sizing:border-box; cursor:grab; touch-action:none; }
.element-scroll-handle span { display:block; height:10px; width:2px; border-radius:2px; background:#f7f3e8; pointer-events:none; }
.element-scroll-control.dragging .element-scroll-handle { background:#276d99; cursor:grabbing; }
.element-scroll-control:focus-visible { outline:3px solid #276d99; outline-offset:2px; }
.element-scroll-control[aria-disabled="true"] { opacity:1; cursor:default; }
.element-scroll-control[aria-disabled="true"] .element-scroll-handle { cursor:default; }
.element-scroll-help { color:#526073; font-size:14px; margin:0 0 12px; }

/* Phone layout: a visible rail with a smaller footprint. */
body { box-sizing:border-box; }
@media(max-width:640px) {
 body { width:100%; margin:0; padding-right:0 !important; }
 #root { width:100%; min-width:0; }
 #root header h1 span { font-size:1.375rem !important; }
 #root h2 { font-size:1.5rem !important; line-height:1.2; overflow-wrap:anywhere; }
 #root #home h2 { font-size:1.875rem !important; }
 #root h3, #root #compounds h3 { font-size:1.125rem !important; line-height:1.3; overflow-wrap:anywhere; }
 #root h4, #root .plan-message-grid h4 { font-size:1.0625rem !important; line-height:1.35; }
 #root p.text-lg, #root p.text-xl { font-size:1rem !important; line-height:1.5; }
 #root p, #root li, #root button, #root a { overflow-wrap:anywhere; }
 #root nav button, #root nav a { white-space:normal; }
}

@media (max-width:640px) {
  html:not(.legal-page) #root header > div { grid-template-columns:minmax(0,1fr); }
  html:not(.legal-page) #root header > div > img { grid-area:2 / 1; justify-self:center; }
  #root header h1, #root header h1 + p { grid-column:1; }
}

/* Keep native swipe scrolling while the Elements drag control is present. */
#elements .chem-scroll:has(+ .element-scroll-control) { scrollbar-width:none !important; }
#elements .chem-scroll:has(+ .element-scroll-control)::-webkit-scrollbar { display:none !important; height:0 !important; }

@media (max-width: 640px) {
  #root #student-go-pro { width:100%; min-width:0; }
  #root #student-go-pro > .flex,
  #root #student-go-pro .plan-message-grid,
  #root #student-go-pro > .grid {
    display:grid; grid-template-columns:minmax(0,1fr); gap:12px;
  }
  #root #student-go-pro .plan-message,
  #root #student-go-pro > .bg-black,
  #root #student-go-pro .plan-message-grid > div {
    box-sizing:border-box; width:100%; padding:14px; text-align:left;
  }
  #root #student-go-pro :is(h2,h3,h4,p) {
    white-space:normal; word-break:normal; overflow-wrap:normal;
  }
  #root #student-go-pro .plan-message p { font-size:1rem!important; line-height:1.5; }
  #root [aria-label="Go Pro levels"] {display:grid;grid-template-columns:minmax(0,1fr);width:100%;}
  #root [aria-label="Go Pro levels"] button {width:100%;white-space:normal;overflow-wrap:normal;}
}

/* Phone typography, alignment, and thinner scrollbar (23 Nov 2026 preview). Desktop unchanged. */
@media (max-width: 640px) {
  /* 90% of the 16px (Tailwind) root. Existing rem !important sizes in this file shrink with it. */
  html { font-size: 14.4px !important; }

  /* Keep form fields at 16px so iOS does not zoom on focus. */
  #root input, #root select, #root textarea { font-size: 16px !important; }

  /* Tap targets at least 44px. */
  #root button,
  #root nav button,
  #root nav a,
  #root input, #root select, #root textarea,
  #root [aria-label="Go Pro levels"] button {
    min-height: 44px;
  }

  /* Centre headings, labels, taglines, short lines, buttons and nav. */
  #root h1, #root h2, #root h3, #root h4, #root h5, #root h6,
  #root header, #root header p,
  #root nav,
  #root button,
  #root p.text-xs,
  #root label,
  #root footer, #root footer p {
    text-align: center;
  }
  #root header, #root nav { text-align: center; }

  /* Long body paragraphs stay left-aligned. */
  #root p, #root li, #root dd, #root blockquote { text-align: left; }
  /* Restore short lines that are also paragraphs. */
  #root header p,
  #root p.text-xs,
  #root footer p { text-align: center; }

  /* Forms stay usable. */
  #root input, #root textarea, #root select,
  #root form, #root form p { text-align: left; }
  #root button { text-align: center; }

  /* Do not restyle the swipeable periodic table or data grids. */
  #elements,
  #elements *,
  .chem-scroll,
  .chem-scroll *,
  table, th, td {
    text-align: initial;
  }

  /* Leftover px type in the mobile reflow/header styles, scaled by 90%. */
  #root header h1 + p { font-size: 11.7px !important; }
  #root header .main-site-label { font-size: 9.9px !important; }
  .table-shortcut-intro { font-size: 12.6px !important; text-align: left !important; }

  /* Short labels and one- or two-line leads stay centred. */
  #root p.font-black,
  #root p.text-xs + p,
  #root p.text-sm.font-bold,
  #root .hub-lead {
    text-align: center;
  }

  /* Page scroll uses the browser's native bar; no reserved rail gutter. */
  body { padding-right: 0 !important; }
}

/* Phone: double the Flame & Fume Ff tile above the heading (52px → 104px). */
@media (max-width: 640px) {
  #root header img[alt*="Flame and Fume Chemistry tile"],
  #root header img[src*="flame_fume_logo_tile"] {
    width: 104px !important;
    max-width: 104px !important;
    height: auto !important;
    justify-self: center;
    grid-column: 1 / -1;
  }
}

/* Phone spacing: chips keep whole words; tighter checkboxes; use side space (24 Nov 2026). Desktop unchanged. */
@media (max-width: 640px) {
  /* (a) Whole words stay together in chips, fields, buttons and labels. */
  #root button,
  #root a,
  #root label,
  #root span,
  #root input,
  #root select,
  #root textarea,
  #root [role="tab"],
  #root p,
  #root li,
  #root h1, #root h2, #root h3, #root h4 {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }

  /* Short chips / pills size to their text and wrap as a unit on the row. */
  #root button[class*="rounded-full"],
  #root a[class*="rounded-full"],
  #root span[class*="rounded-full"],
  #root [data-course-pill],
  #root #compounds [aria-pressed],
    #root [aria-label="Choose your course"] button {
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
    white-space: nowrap;
    width: auto;
    min-width: max-content;
    flex: 0 0 auto;
    max-width: 100%;
  }

  /* Long header CTAs may wrap at word boundaries, not mid-word. */
  #root header > div > div > button[class*="rounded-full"],
  #root header button[class*="min-h-\[40px\]"]:not(nav button) {
    white-space: normal;
    min-width: 0;
    max-width: 100%;
  }
  #root header nav button,
  #root header nav a {
    white-space: nowrap;
    min-width: max-content;
    flex: 0 0 auto;
  }

  /* Go Pro level tabs already go full width; wrap at words only. */
  #root [aria-label="Go Pro levels"] button {
    white-space: normal;
    min-width: 0;
    width: 100%;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  #root .flex:has(> button),
  #root .flex:has(> [class*="rounded-full"]),
  #root [role="tablist"],
  #root [data-element-chip],
  #root #compounds .flex:not(label) {
    flex-wrap: wrap;
  }
  #root #compounds label.flex {
    flex-wrap: nowrap !important;
    display: flex !important;
    align-items: center;
  }
  #root #elements label.flex {
    flex-wrap: nowrap !important;
    display: flex !important;
    align-items: center;
  }
  /* Course pills stay a sideways-scrolling row. */
  #root [data-course-filter] .chem-scroll,
  #root [data-course-filter] .chem-scroll > div {
    flex-wrap: nowrap !important;
  }

  /* Override the global min-width:0 that lets flex chips shrink and break words. */
  #root .flex > button,
  #root .flex > a[class*="rounded-full"],
  #root .flex > span[class*="rounded-full"] {
    min-width: max-content;
  }

  /* Inputs and selects use the full row. */
  #root input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  #root select,
  #root textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  #root label.flex input:not([type="checkbox"]):not([type="radio"]),
  #root label:has(svg) input:not([type="checkbox"]):not([type="radio"]) {
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100%;
  }
  #root label:has(> select) {
    display: block;
    width: 100%;
    min-width: 0;
  }

  /* (b) The tick itself stays small. 44px tap target comes from the label row. */
  #root input[type="checkbox"],
  #root input[type="radio"] {
    min-height: 0 !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 auto;
    align-self: flex-start;
    position: relative;
    top: 0.2em;
  }
  #root label:has(input[type="checkbox"]),
  #root label:has(input[type="radio"]) {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    margin-top: 0;
    margin-bottom: 0;
    padding: 10px 8px !important;
    min-height: 44px;
    box-sizing: border-box;
    width: 100%;
    text-align: left !important;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  #root label:has(input[type="checkbox"]) > input[type="checkbox"] {
    flex: 0 0 auto;
  }
  #root label:has(input[type="checkbox"]) > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }

  /* (c) Use the side space. Do not touch the 104px Ff tile. */
  html:not(.legal-page) #root main,
  html:not(.legal-page) #root [data-course-filter] > div,
  html:not(.legal-page) #root #flame-fume-progress > div,
  html:not(.legal-page) #root [aria-label="Choose your level"] > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  html:not(.legal-page) #root header > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #root main [class*="p-5"]:not([class*="gap-"]):not([class*="py-"]),
  #root main [class*="p-6"]:not([class*="gap-"]):not([class*="py-"]),
  #root main [class*="p-8"]:not([class*="gap-"]):not([class*="py-"]),
  #root main [class*="px-5"],
  #root main [class*="px-6"],
  #root .hub-course-card,
  #root #student-go-pro .plan-message,
  #root #student-go-pro > .bg-black,
  #root #student-go-pro .plan-message-grid > div {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  /* Compound cards use p-4 on the inner button; keep a 14px gutter there too. */
  #root #compounds button[aria-expanded] {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

/* Lab template, safety, search hint, tiles, sort, discovery (24 Nov 2026). Desktop unchanged except print. */
/* A) Lab write-up template: thin inner scrollbar, readable phone type, A4 print. */
.lab-template-print { display: none; }
#writeup-template.lab-template,
textarea.lab-template {
  box-sizing: border-box;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  white-space: pre-wrap;
}
#writeup-template.lab-template::-webkit-scrollbar,
textarea.lab-template::-webkit-scrollbar { width: 6px; height: 6px; }
#writeup-template.lab-template::-webkit-scrollbar-track,
textarea.lab-template::-webkit-scrollbar-track {
  background: #dce3ec; border-radius: 5px;
}
#writeup-template.lab-template::-webkit-scrollbar-thumb,
textarea.lab-template::-webkit-scrollbar-thumb {
  background: #101d32; border: 1px solid #f2a93b; border-radius: 3px;
}

@media (max-width: 640px) {
  #writeup-template.lab-template,
  textarea.lab-template {
    font-size: 15px !important;
    line-height: 1.45 !important;
    padding: 10px 12px !important;
    min-height: 16rem;
  }
  .lab-template-actions {
    width: 100%;
    justify-content: center;
  }
  .lab-template-actions button {
    white-space: normal;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
  }

  /* B) Safety reminder + similar callouts: stack, centre, keep inside the card. */
  #root .safety-reminder,
  #root .banner-callout {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 10px !important;
    overflow: hidden;
    max-width: 100%;
  }
  #root .safety-reminder-copy {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100%;
    gap: 6px;
  }
  #root .safety-reminder-icon { margin: 0 auto; }
  #root .safety-reminder p,
  #root .banner-callout p {
    text-align: center !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  #root .safety-reminder-btn,
  #root .banner-callout-btn {
    max-width: 100% !important;
    width: auto;
    min-width: 0 !important;
    flex: 0 1 auto !important;
    align-self: center;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    text-align: center;
    box-sizing: border-box;
  }

  /* C) Today: try Ca, Cs or 20 — symbol and explanation on one line. */
  #root .search-hint-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    max-width: 100%;
  }
  #root .search-hint-list li {
    display: grid;
    grid-template-columns: 2.75rem 1fr;
    column-gap: 10px;
    align-items: baseline;
    text-align: left;
    margin: 0;
    padding: 2px 0;
  }
  #root .search-hint-sym {
    font-weight: 800;
    text-align: left;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    white-space: nowrap;
  }
  #root .search-hint-exp {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }

  /* D) Periodic table tiles: centre number, symbol and mass; fit the mass. */
  #root #elements .periodic-grid,
  #root #elements .periodic-grid {
    grid-auto-rows: minmax(56px, auto) !important;
  }
  #root #elements .periodic-grid button.element-cell,
  #root .periodic-grid .element-cell {
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 3px 2px 5px !important;
    min-height: 56px;
    overflow: hidden;
  }
  #root #elements .periodic-grid button.element-cell > span,
  #root #elements .periodic-grid button.element-cell > .el-sym,
  #root #elements .periodic-grid button.element-cell > span:last-child {
    display: block !important;
    width: 100%;
    text-align: center !important;
    margin-left: auto;
    margin-right: auto;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
    min-width: 0;
  }
  /* Hide the element name on phones so the mass has room. */
  #root #elements .periodic-grid button.element-cell > span.hidden {
    display: none !important;
  }
  #root #elements .periodic-grid button.element-cell > span:first-child {
    font-size: 8px !important;
    line-height: 1.05 !important;
    font-weight: 800;
  }
  #root #elements .periodic-grid button.element-cell > .el-sym {
    font-size: 14px !important;
    line-height: 1.05 !important;
    margin: 1px 0 !important;
  }
  #root #elements .periodic-grid button.element-cell > span:last-child {
    font-size: 7.5px !important;
    line-height: 1.05 !important;
    letter-spacing: -0.02em;
    font-weight: 700;
  }
  #root #elements .periodic-grid .element-cell:not(button) {
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 8px !important;
    line-height: 1.15 !important;
    padding: 2px !important;
  }

  /* E) Centre the Beyond syllabus pill under the table filters. */
  #root [data-element-chip] {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100%;
    text-align: center;
  }

  /* F) Discovery story and similar label/value grids: stack as sub-headings. */
  #root .discovery-story-head,
  #root .discovery-story > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  #root .history-pill,
  #root .detail-pill,
  #root .discovery-story .rounded-full {
    display: inline-block;
    max-width: 100% !important;
    width: auto;
    box-sizing: border-box;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
    text-align: center;
    min-width: 0 !important;
    flex: 0 1 auto;
    line-height: 1.35;
  }
  #root .detail-fields li,
  #root .discovery-story ol li {
    display: block !important;
    width: 100%;
    margin: 0 0 10px !important;
    padding: 0;
    min-width: 0;
  }
  #root .detail-fields .detail-label,
  #root .discovery-story ol li .detail-label,
  #root .discovery-story ol li > span:first-child {
    display: block !important;
    width: 100% !important;
    max-width: 100%;
    margin: 0 0 2px;
    padding: 0;
    text-align: left;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  #root .detail-fields .detail-value,
  #root .discovery-story ol li .detail-value,
  #root .discovery-story ol li > span:last-child {
    display: block !important;
    width: 100% !important;
    max-width: 100%;
    min-width: 0 !important;
    text-align: left;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
    white-space: normal;
  }
}

/* Print: A4, chrome hidden, full template, no scroll box. */
@media print {
  @page { size: A4; margin: 16mm; }
  html, body {
    background: #fff !important;
    color: #111 !important;
    font-size: 11pt !important;
  }
  html[data-print="template"] #page-scroll-control,
  html[data-print="template"] .element-scroll-control,
  html[data-print="template"] .table-shortcut-wrap,
  html[data-print="template"] #root header,
  html[data-print="template"] #root [data-course-filter],
  html[data-print="template"] #root #flame-fume-progress,
  html[data-print="template"] #root [aria-label="Choose your level"],
  html[data-print="template"] #root footer,
  html[data-print="template"] #root nav,
  html[data-print="template"] #root main > section:not(#writeup),
  html[data-print="template"] #writeup > :not(.lab-template-card),
  html[data-print="template"] .lab-template-actions,
  html[data-print="template"] #writeup-template,
  html[data-print="template"] textarea.lab-template {
    display: none !important;
  }
  html[data-print="template"] #root main,
  html[data-print="template"] #writeup,
  html[data-print="template"] .lab-template-card {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  html[data-print="template"] .lab-template-print {
    display: block !important;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11pt;
    line-height: 1.45;
    color: #111;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
  }
}

/* G) Question lists + site-wide narrow internal scrollbars (24 Nov 2026). */
/* Site-wide: any native internal scrollbar is narrow (~6px).
   The page itself uses the browser's native scrollbar.
   The periodic table keeps its custom horizontal handle, so its native
   bar stays hidden when that handle is present. */
#root textarea,
#root pre,
#root [class*="overflow-auto"],
#root [class*="overflow-x-auto"],
#root [class*="overflow-y-auto"],
#root [class*="overflow-scroll"],
#root [class*="overflow-x-scroll"],
#root [class*="overflow-y-scroll"],
#root .chem-scroll,
#root .lab-template,
#writeup-template.lab-template {
  /* Chrome/Safari: classic 6px bar via ::-webkit-scrollbar below.
     scrollbar-width would hide those rules in Chromium. */
}
@supports not selector(::-webkit-scrollbar) {
  #root textarea,
  #root pre,
  #root [class*="overflow-auto"],
  #root [class*="overflow-x-auto"],
  #root [class*="overflow-y-auto"],
  #root [class*="overflow-scroll"],
  #root [class*="overflow-x-scroll"],
  #root [class*="overflow-y-scroll"],
  #root .chem-scroll,
  #root .lab-template,
  #writeup-template.lab-template {
    scrollbar-width: thin;
    scrollbar-color: #101d32 #dce3ec;
  }
}
#root textarea::-webkit-scrollbar,
#root pre::-webkit-scrollbar,
#root [class*="overflow-auto"]::-webkit-scrollbar,
#root [class*="overflow-x-auto"]::-webkit-scrollbar,
#root [class*="overflow-y-auto"]::-webkit-scrollbar,
#root [class*="overflow-scroll"]::-webkit-scrollbar,
#root [class*="overflow-x-scroll"]::-webkit-scrollbar,
#root [class*="overflow-y-scroll"]::-webkit-scrollbar,
#root .chem-scroll::-webkit-scrollbar,
#root .lab-template::-webkit-scrollbar,
#writeup-template.lab-template::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
#root textarea::-webkit-scrollbar-track,
#root pre::-webkit-scrollbar-track,
#root [class*="overflow-auto"]::-webkit-scrollbar-track,
#root [class*="overflow-x-auto"]::-webkit-scrollbar-track,
#root [class*="overflow-y-auto"]::-webkit-scrollbar-track,
#root [class*="overflow-scroll"]::-webkit-scrollbar-track,
#root [class*="overflow-x-scroll"]::-webkit-scrollbar-track,
#root [class*="overflow-y-scroll"]::-webkit-scrollbar-track,
#root .chem-scroll::-webkit-scrollbar-track,
#root .lab-template::-webkit-scrollbar-track,
#writeup-template.lab-template::-webkit-scrollbar-track {
  background: #dce3ec;
  border-radius: 4px;
}
#root textarea::-webkit-scrollbar-thumb,
#root pre::-webkit-scrollbar-thumb,
#root [class*="overflow-auto"]::-webkit-scrollbar-thumb,
#root [class*="overflow-x-auto"]::-webkit-scrollbar-thumb,
#root [class*="overflow-y-auto"]::-webkit-scrollbar-thumb,
#root [class*="overflow-scroll"]::-webkit-scrollbar-thumb,
#root [class*="overflow-x-scroll"]::-webkit-scrollbar-thumb,
#root [class*="overflow-y-scroll"]::-webkit-scrollbar-thumb,
#root .chem-scroll::-webkit-scrollbar-thumb,
#root .lab-template::-webkit-scrollbar-thumb,
#writeup-template.lab-template::-webkit-scrollbar-thumb {
  background: #101d32;
  border: 1px solid #f2a93b;
  border-radius: 3px;
}
/* Keep the custom element-table rail: native bar stays hidden there. */
#elements .chem-scroll:has(+ .element-scroll-control),
#root #elements .chem-scroll:has(+ .element-scroll-control) {
  scrollbar-width: none !important;
}
#elements .chem-scroll:has(+ .element-scroll-control)::-webkit-scrollbar,
#root #elements .chem-scroll:has(+ .element-scroll-control)::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

@media (max-width: 640px) {
  /* G) Lesson / practice question lists: less padding and indent, full-width text. */
  #root #plans article.rounded-\[28px\] > div.p-5,
  #root #plans article > div.space-y-6,
  #root #plans article > div.p-5 {
    padding: 14px !important;
  }
  #root #quiz > div.rounded-\[28px\],
  #root #quiz > div[class*="rounded"] {
    padding: 14px !important;
  }
  #root #plans article ol,
  #root #plans article ul.list-disc,
  #root #plans article ul.list-decimal,
  #root #quiz ol,
  #root #writeup ol,
  #root section ol.list-decimal {
    padding-left: 1.6em !important;
    margin-left: 0 !important;
    list-style-position: outside;
    font-size: 16px !important;
    line-height: 1.45 !important;
    max-width: 100%;
  }
  #root #plans article ol > li,
  #root #plans article ul.list-disc > li,
  #root #plans article ul.list-decimal > li,
  #root #quiz ol > li,
  #root #writeup ol > li,
  #root section ol.list-decimal > li {
    margin-top: 0.45em;
    margin-bottom: 0.45em;
    padding-left: 0.15em;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
    max-width: 100%;
  }
  #root #quiz h3.font-display {
    font-size: 1.15rem !important;
    line-height: 1.35 !important;
  }
}

/* H) Site-wide phone padding/overflow audit (24 Nov 2026). Desktop unchanged. */
@media (max-width: 640px) {
  /* Long pills/chips wrap at word boundaries instead of overflowing or clipping.
     Short chips still stay on one line when they fit. */
  #root main span[class*="rounded-full"],
  #root main button[class*="rounded-full"],
  #root main a[class*="rounded-full"],
  #root #plans article span[class*="rounded-full"],
  #root #plans article button[class*="rounded-full"] {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
  }
  /* Keep short filter, sort, nav and course chips on one line. */
  #root #compounds [aria-pressed],
    #root [data-course-pill],
  #root [aria-label="Choose your course"] button,
  #root header nav button,
  #root header nav a {
    white-space: nowrap !important;
    min-width: max-content;
    max-width: 100%;
  }

  /* Compact remaining p-4 cards (16px → 14px) and hub cards. */
  #root main [class*="p-4"]:not([class*="gap-"]):not([class*="py-"]),
  #root .hub-future-card,
  #root .hub-course-card {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Plan 1 sample: stop header pills being clipped by overflow-hidden. */
  #root #plans article.rounded-\[28px\],
  #root #plans article[class*="overflow-hidden"] {
    max-width: 100%;
    overflow-x: hidden;
  }
  #root #plans article > div:first-child,
  #root #plans article .flex {
    max-width: 100%;
    min-width: 0;
  }
  #root #plans article .flex-wrap {
    overflow-wrap: break-word;
  }

  /* Legal / homeschool pages: same 12px side gutters as the main site. */
  html.legal-page #root main,
  #root main {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* I) I-can checklists left-aligned; gold-header black pills readable (24 Nov 2026). */
/* Tick-box / "I can…" rows: box on the left, text left-aligned beside it.
   Applies on all viewports so no checklist text is centred. */
#root label:has(input[type="checkbox"]),
#root label:has(input[type="radio"]) {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  text-align: left !important;
  gap: 10px;
}
#root label:has(input[type="checkbox"]) > input[type="checkbox"],
#root label:has(input[type="radio"]) > input[type="radio"] {
  flex: 0 0 auto !important;
  align-self: flex-start;
  margin: 0.2em 0 0 0 !important;
}
#root label:has(input[type="checkbox"]) > *:not(input),
#root label:has(input[type="radio"]) > *:not(input),
#root label:has(input[type="checkbox"]) span,
#root label:has(input[type="radio"]) span {
  text-align: left !important;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
}

/* Theme recolours the Plan 1 header to gold + ink, so bg-black pills
   without an explicit text-white inherited ink-on-ink. Force white type. */
#root [class~="bg-[#ff5a00]"] .bg-black,
#root #plans article .bg-black {
  color: #fff !important;
}

/* Print override: only the lab template on A4, hide course hub and all chrome. */
@media print {
  html[data-print="template"] body * { visibility: hidden !important; }
  html[data-print="template"] #course-hub,
  html[data-print="template"] #page-scroll-control,
  html[data-print="template"] .element-scroll-control,
  html[data-print="template"] .table-shortcut-wrap,
  html[data-print="template"] #root header,
  html[data-print="template"] #root nav,
  html[data-print="template"] #root footer,
  html[data-print="template"] #root [data-course-filter],
  html[data-print="template"] .lab-template-actions,
  html[data-print="template"] #writeup-template,
  html[data-print="template"] textarea.lab-template {
    display: none !important;
  }
  html[data-print="template"] #root,
  html[data-print="template"] #root > div,
  html[data-print="template"] main,
  html[data-print="template"] #writeup,
  html[data-print="template"] .lab-template-card,
  html[data-print="template"] .lab-template-print,
  html[data-print="template"] .lab-template-print * {
    visibility: visible !important;
  }
  html[data-print="template"] .lab-template-print {
    display: block !important;
    position: static;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11pt;
    line-height: 1.45;
    color: #111;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #fff;
  }
  html[data-print="template"] .lab-template-card {
    display: block !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  html[data-print="template"] .lab-template-card > :not(.lab-template-print) {
    display: none !important;
  }
}

/* Success-criteria / I-can card: no centred text, including the heading and intro. */
@media (max-width: 640px) {
  #root #plans section[class*="bg-emerald"],
  #root #plans section[class*="bg-emerald"] p,
  #root #plans section[class*="bg-emerald"] h4,
  #root section:has(> div > label > input[type="checkbox"]) p,
  #root section:has(label:has(input[type="checkbox"])) p,
  #root section:has(label:has(input[type="checkbox"])) {
    text-align: left !important;
  }
}

/* Bulletproof: success-criteria heading + intro always left-aligned on phones. */
@media (max-width: 640px) {
  #root .text-emerald-800,
  #root .text-emerald-900,
  #root p.text-emerald-800,
  #root p.text-emerald-900,
  #root [class*="bg-emerald-50"] p,
  #root [class*="bg-emerald-50"] {
    text-align: left !important;
  }
}

/* SPI-17: real-phone overflow, font scale, chips, rail (24 Nov 2026). */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Apply through 900px so large-CSS-pixel Android phones (display size /
   text zoom) still get the phone layout, not sm/md two- and three-column grids. */
@media (max-width: 900px) {
  body { padding-right: 0 !important; }

  #root #home,
  #root #shorts > .grid,
  #root #student-go-pro .grid,
  #root #reels .grid,
  #root #plans .grid,
  #root #lab .grid,
  #root main [class*="sm:grid-cols"],
  #root main [class*="md:grid-cols"],
  #root main [class*="lg:grid-cols"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #root main,
  #root article,
  #root section,
  #root aside,
  #root #home > *,
  #root #flame-fume-progress,
  #root #flame-fume-progress > div,
  #root [data-course-filter],
  #root [class*="rounded-"] {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /* Flex/chip min-width:max-content was stretching cards and clipping text
     (Past-Paper, Baking Soda button, long pills). */
  #root button,
  #root .flex > button,
  #root a[class*="rounded"],
  #root [class*="w-full"] {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #root [data-course-pill],
  #root [data-course-badge],
  #root #compounds [aria-pressed],
  #root [aria-label="Choose your course"] button {
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
  }

  #root h1, #root h2, #root h3, #root h4,
  #root p, #root li, #root button, #root a, #root span {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }
  #root #home h2 {
    font-size: clamp(26px, 7.5vw, 36px) !important;
    line-height: 1.15 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    max-width: 100%;
  }

  /* Progress: compact horizontal pills, not tall ovals from 44px min-height
     plus rounded-full. */
  #root #flame-fume-progress span[class*="rounded-full"] {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    max-width: 100%;
    min-width: 0;
    height: 32px !important;
    border-radius: 999px !important;
    overflow: hidden;
  }
  #root #flame-fume-progress span[class*="rounded-full"] button,
  #root #flame-fume-progress button {
    min-height: 0 !important;
    height: 32px !important;
    padding: 0 10px !important;
    white-space: nowrap !important;
    line-height: 32px !important;
    box-sizing: border-box;
  }
  #root #flame-fume-progress a {
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  #root article,
  #root article p,
  #root article h3,
  #root article h4,
  #root article div,
  #root #student-go-pro article,
  #root #student-go-pro p,
  #root #student-go-pro h3 {
    overflow-wrap: break-word !important;
    word-break: normal !important;
    max-width: 100%;
    min-width: 0;
  }
  #root article .font-mono,
  #root #student-go-pro .font-mono {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  #root .search-hint-card { width: 100%; max-width: 100%; }
  #root .search-hint-list li {
    grid-template-columns: auto minmax(0, 1fr);
  }
  #root .search-hint-exp {
    overflow-wrap: break-word;
    word-break: normal;
  }

  #root #home .flex.items-center.gap-2 {
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
  }

  /* Success criteria: centre the heading and intro; rows stay left. */
  #root [class*="bg-emerald-50"] > p.text-xs,
  #root [class*="bg-emerald-50"] > p:first-child,
  #root [class*="bg-emerald-50"] > p:nth-child(2),
  #root p.text-emerald-800,
  #root p.text-emerald-900 {
    text-align: center !important;
  }
  #root label:has(input[type="checkbox"]),
  #root label:has(input[type="checkbox"]) span,
  #root label:has(input[type="checkbox"]) > *:not(input) {
    text-align: left !important;
  }

  #root [class*="overflow-x-auto"],
  #root .overflow-x-auto {
    max-width: 100%;
    min-width: 0;
  }

  /* Course filter: wrap pills instead of a sideways scroller that overflow-x-clip can cut. */
  #root [data-course-filter] .chem-scroll {
    overflow-x: visible !important;
    overflow-y: visible !important;
    max-width: 100%;
  }
  #root [data-course-filter] .chem-scroll > div,
  #root [data-course-filter] .flex.flex-nowrap,
  #root [data-course-filter] .w-max {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #root [data-course-filter] [data-course-pill] {
    white-space: normal !important;
    max-width: 100% !important;
    flex: 0 1 auto;
  }

  /* Don't let leftover nowrap labels (e.g. Learning options) poke past the viewport. */
  #root p.whitespace-nowrap,
  #root h1.whitespace-nowrap,
  #root h2.whitespace-nowrap,
  #root h3.whitespace-nowrap,
  #root h4.whitespace-nowrap {
    white-space: normal !important;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
  }
}

/* SPI-17 tables: smaller type, whole-word wrap, plan columns (24 Nov 2026). */
@media (max-width: 900px) {
  /* Never let inherited overflow-wrap:anywhere or min-width:0 crush table words. */
  #root table {
    font-size: 13px !important;
    line-height: 1.35;
    table-layout: auto;
    width: 100%;
    border-collapse: collapse;
  }
  #root table[class*="w-full"] {
    max-width: 100%;
  }
  #root th,
  #root td {
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
    white-space: normal !important;
    padding: 6px 8px !important;
  }
  #root th {
    font-size: 12px !important;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
  }
  #root td {
    font-size: 13px !important;
  }

  /* Tighter side padding on cards that hold a table. */
  #root :is(div, article, section):has(> table),
  #root :is(div, article, section):has(> [class*="overflow-x-auto"] > table) {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Bare tables (e.g. Chlorine family) scroll inside the card if a word still cannot fit. */
  #root :is(div, article, section):has(> table) {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
  }
  #root [class*="overflow-x-auto"]:has(> table) {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
  }

  /* Lab / particle tables keep a content min-width and scroll in their wrapper
     instead of shrinking mid-word (SPI-17 had zeroed min-width on .w-full). */
  #root table[class*="min-w-[520"] {
    min-width: 520px !important;
  }

  /* Plan comparison tables: feature column ~45%, tick columns narrow and centred.
     Drop the 620/640px min-width so they try to fit the phone first. */
  /* Only the FREE / Teacher Pro / Student Go Pro comparison tables
     (min-w 620/640). Do not restyle lesson-plan data tables in #plans. */
  #root #plans table[class*="min-w-[620"],
  #root #plans table[class*="min-w-[640"],
  #root #student-go-pro table[class*="min-w-"] {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  #root #plans table[class*="min-w-[620"] th,
  #root #plans table[class*="min-w-[620"] td,
  #root #plans table[class*="min-w-[640"] th,
  #root #plans table[class*="min-w-[640"] td,
  #root #student-go-pro table[class*="min-w-"] th,
  #root #student-go-pro table[class*="min-w-"] td {
    min-width: 0 !important;
  }
  #root #plans table[class*="min-w-[620"] th:first-child,
  #root #plans table[class*="min-w-[620"] td:first-child,
  #root #plans table[class*="min-w-[640"] th:first-child,
  #root #plans table[class*="min-w-[640"] td:first-child,
  #root #student-go-pro table[class*="min-w-"] th:first-child,
  #root #student-go-pro table[class*="min-w-"] td:first-child {
    width: 45%;
    text-align: left;
  }
  #root #plans table[class*="min-w-[620"] th:not(:first-child),
  #root #plans table[class*="min-w-[620"] td:not(:first-child),
  #root #plans table[class*="min-w-[640"] th:not(:first-child),
  #root #plans table[class*="min-w-[640"] td:not(:first-child),
  #root #student-go-pro table[class*="min-w-"] th:not(:first-child),
  #root #student-go-pro table[class*="min-w-"] td:not(:first-child) {
    width: auto;
    text-align: center !important;
    padding: 6px 4px !important;
    vertical-align: middle;
  }
  #root #plans table[class*="min-w-[620"] th:not(:first-child),
  #root #plans table[class*="min-w-[640"] th:not(:first-child),
  #root #student-go-pro table[class*="min-w-"] th:not(:first-child) {
    font-size: 11px !important;
    letter-spacing: -0.03em;
    line-height: 1.2;
  }
}

/* 6px bar on table cards that scroll themselves (same as other inner scrollers). */
#root :is(div, article, section):has(> table)::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
#root :is(div, article, section):has(> table)::-webkit-scrollbar-track {
  background: #dce3ec;
  border-radius: 99px;
}
#root :is(div, article, section):has(> table)::-webkit-scrollbar-thumb {
  background: #101d32;
  border-radius: 99px;
}
@supports not selector(::-webkit-scrollbar) {
  #root :is(div, article, section):has(> table) {
    scrollbar-width: thin;
    scrollbar-color: #101d32 #dce3ec;
  }
}

/* SPI-17 cards: full-width text-block cards, icon above heading (24 Nov 2026). */
@media (max-width: 900px) {
  /* Do not let section py-* or grid gap-* classes add extra side padding. */
  #root #home,
  #root #home > .grid,
  #root #home > div[class*="grid"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  #root #home > *,
  #root #home > .grid > *,
  #root #home [data-syllabus-id],
  #root #home [data-syllabus-status] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
  }

  /* Text-block cards: nearly full width, 14–16px inner padding. */
  #root #home [class*="rounded-"],
  #root #lab .safety-reminder,
  #root #bonding [class*="rounded-3xl"],
  #root #student-go-pro [class*="rounded-3xl"] {
    padding: 16px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Icon stacks above the heading; heading wraps between whole words only. */
  #root #home .flex.items-center.gap-2.font-black,
  #root .safety-reminder-copy {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    max-width: 100%;
    min-width: 0;
  }
  #root #home .flex.items-center.gap-2.font-black,
  #root #home .flex.items-center.gap-2.font-black + p,
  #root #home [class*="font-black"] {
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
    overflow: visible !important;
    max-width: 100%;
    min-width: 0;
  }
}

/* SPI-25 follow-up (25 Nov 2026): readable type on the injected FREE and PLANNED cards
   inside the dark What it is box. Scoped to those cards only. Amber accents kept. */
#root #student-go-pro .plan-message.bg-black {
  background: #101d32 !important;
  color: #e8e8e8 !important;
  border: 1px solid #101d32 !important;
}
#root #student-go-pro .plan-message.bg-black .free-message {
  background: #16332c;
  border: 1px solid #2a5a50;
}
#root #student-go-pro .plan-message.bg-black .pro-message {
  background: #2a1f0c;
  border: 1px solid #e6bd72;
}
#root #student-go-pro .plan-message.bg-black .plan-message-grid h4,
#root #student-go-pro .plan-message.bg-black .plan-message-grid p,
#root #student-go-pro .plan-message.bg-black .plan-message-note {
  color: #e8e8e8 !important;
}
#root #student-go-pro .plan-message.bg-black .free-message .plan-message-label {
  color: #8fd4c4 !important;
}
#root #student-go-pro .plan-message.bg-black .pro-message .plan-message-label {
  color: #f2a93b !important;
}
