/* Phone layout: one primary action, quiet metadata, and locally scrollable controls.
   Keep this after page styles so PJAX and direct loads share the same layout. */
.llm-filter-toggle { display: none; }
.llm-search-row { display: contents; }
@media (max-width: 700px) {
  body:not(.is-cover) { --collection-gutter: 16px; }
  body:not(.is-cover) .site-header__inner { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  body .site-content.reading-article, body .site-content.browse-page,
  body .site-content.standalone-page { padding-inline: 16px; }
  body .browse-page { padding-top: 22px; }
  body :is(.browse-page,.standalone-page) h1 { font-size: 28px; line-height: 1.25; }
  body .browse-toolbar { gap: 8px; margin-bottom: 20px; }
  body .browse-actions button { min-height: 44px; }
  body .browse-search input { font-size: 16px; min-height: 44px; }
  body .browse-group > summary { gap: 10px; padding-inline: 0; font-size: 15px; }
  body .browse-group-body { padding-left: 12px; }
  body .browse-tag-list a { min-height: 44px; }
  body .reading-header { margin-bottom: 20px; }
  body .reading-title-row h1 { font-size: 28px; line-height: 1.3; overflow-wrap: anywhere; }
  body .site-toc-mobile > summary { min-height: 44px; display: flex; align-items: center; }
  body .site-toc-mobile__nav a { min-height: 44px; display: flex; align-items: center; }
  body .site-pager { gap: 12px; }
  body .site-pager__link { min-width: 0; flex: 1; padding: 12px 0; }
  body .site-pager__title { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
  body .site-search__shortcut { display: none; }
  body .site-lang-banner { bottom: max(12px, env(safe-area-inset-bottom)); }
  body .site-lang-banner__inner { flex-wrap: wrap; gap: 4px 8px; padding: 8px 12px; }
  body .site-lang-banner__icon { display: none; }
  body .site-lang-banner__text { flex-basis: 100%; font-size: 13px; }
  body .site-lang-banner__actions { width: 100%; justify-content: space-between; }

  /* Reference: results first, with secondary filters behind an explicit control. */
  body .site-main.site-main--reference { padding: 20px 16px 40px; }
  body .reference-page :is(.lookup-hero,.hw-header,.llm-header,.at-header) { margin-bottom: 16px; gap: 12px; }
  body .reference-page :is(.lookup-hero,.hw-header,.llm-header,.at-header) h1 { font-size: 28px; line-height: 1.25; }
  body .reference-page :is(.lookup-lead,.hw-lead,.llm-lead,.at-lead) { font-size: 14px; line-height: 1.65; }
  body .reference-page :is(.hw-stamp,.llm-stamp,.at-stamp) { font-size: 11px; }
  body .reference-page :is(.hw-tabs,.hw-kinds,.llm-board-tabs,.at-categories) {
    flex-wrap: nowrap; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
  }
  body .reference-page :is(.hw-tabs,.hw-kinds,.llm-board-tabs,.at-categories) > a { flex-shrink: 0; min-height: 44px; }
  body .llm-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
  body .llm-search-row { display: flex; flex: 0 0 100%; min-width: 0; gap: 10px; }
  body .llm-toolbar .llm-query { flex: 1; min-width: 0; }
  body .llm-filter-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--reading-rule); border-radius: 6px; background: var(--reading-bg); color: var(--site-default-fg-color); font: inherit; font-size: 13px; cursor: pointer; }
  body .llm-filter-toggle::after { content: '+'; }
  body .llm-filter-toggle[aria-expanded=true]::after { content: '−'; }
  body .llm-app:not([data-filters-expanded]) :is(.llm-toolbar,.llm-filterline) > .llm-select { display: none; }
  body .llm-app[data-filters-expanded] .llm-toolbar > .llm-select { flex: 1 1 calc(50% - 10px); min-width: 0; }
  body .llm-filterline { gap: 10px; padding-bottom: 12px; }
  body .llm-filterline > .llm-unit { width: 100%; margin-left: 0; }
  body .at-filters { grid-template-columns: minmax(0,1fr) 124px; gap: 10px; }
  body .at-entry { padding-block: 16px; }
  body .at-entry h2 { font-size: 16px; overflow-wrap: anywhere; }
  body .at-entry > p { font-size: 14px; line-height: 1.65; }
  body .lookup-index { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
  body .lookup-index > li { margin-top: 0 !important; }

  /* Keep map controls reachable without growing its overlay into the graph. */
  body .graph-view-controls button { min-width: 44px; min-height: 44px; }
  body .graph-card__close { width: 44px; height: 44px; }
  body .graph-card__title { padding-right: 36px; }
  body .graph-legend { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  body .graph-legend__chip { white-space: nowrap; }
  body .graph-hud__title { max-width: calc(100vw - 184px); }
}

/* Mobile learning is a reading directory, with one category control and
   optional progress editing. These rules replace the old phone card layout. */
.learn-mobile-heading, .learn-mobile-label,
.learn-topic-toggle, .learn-edit-progress { display: none; }
@media (max-width: 1024px) {
  body .learning-shell :is(h1,h2,h3,p,button,summary,.learn-resume strong) { font-family: inherit; }
}
@media (max-width: 768px) {
  body .learning-shell { --mobile-ink: #233d35; --mobile-paper: #f0f4f1; --mobile-soft-ink: #66766d; --atlas-line: color-mix(in srgb, var(--atlas-ink) 10%, var(--atlas-bg)); }
  body .learning-shell .learn-workspace { padding: 20px 20px 48px; }
  body .learning-shell--explorer .learn-workspace { display: grid; row-gap: 12px; }
  body .learning-shell--explorer .learn-browser-bar { order: -1; display: block; margin: 0; }
  body .learn-mobile-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; min-height: 68px; padding: 2px 0 22px; }
  body .learn-mobile-heading h1 { flex: 0 0 auto; font-size: 32px; font-weight: 600; line-height: 1.3; letter-spacing: -.03em; }
  body .learn-mobile-category { display: none; position: relative; max-width: 62%; min-width: 0; }
  body [data-mobile-filter-ready] .learn-mobile-category { display: block; }
  body .learn-mobile-category select { appearance: none; width: 100%; min-height: 44px; padding: 8px 28px 8px 10px; border: 0; border-radius: 0; background: transparent; color: var(--atlas-muted); font: inherit; font-size: 16px; text-overflow: ellipsis; cursor: pointer; }
  body .learn-mobile-category svg { position: absolute; right: 8px; top: 12px; width: 20px; height: 20px; fill: none; stroke: var(--atlas-muted); stroke-width: 1.4; pointer-events: none; }
  body .learn-mobile-category select:focus-visible { outline: 2px solid var(--reading-accent); outline-offset: 3px; }
  body .learning-shell--explorer[data-mobile-filter-ready] .learn-filters { display: none; }
  body .learning-shell--explorer:not([data-mobile-filter-ready]) .learn-filters { display: none; }
  body .learning-shell--explorer .learn-grid { display: block; margin: 0; }
  body .learning-shell--explorer .explorer-field,
  body .learning-shell--explorer .explorer-section-grid { display: contents; }
  body .learning-shell--explorer .explorer-field-heading { display: none; }
  body .learning-shell--explorer .learn-card { position: relative; display: block; padding: 22px 0 22px 58px; margin: 0; min-height: 0; border: 0; border-top: 1px solid var(--atlas-line); border-radius: 0; background: transparent; box-shadow: none; }
  body .learning-shell--explorer .explorer-card-art { position: absolute; top: 22px; left: 0; display: grid; place-items: center; width: 40px; height: 44px; border-radius: 10px; background: var(--mobile-paper); color: var(--mobile-soft-ink); }
  body .learning-shell--explorer .explorer-card-art svg { width: 26px; height: 26px; }
  body .explorer-card-art::before, body .explorer-card-art::after, body .explorer-card-art-line { display: none; }
  body .learning-shell--explorer .explorer-card-copy { display: grid; grid-template-columns: minmax(0,1fr); gap: 7px; padding: 0; }
  body .learning-shell--explorer .explorer-card-copy h3 { grid-column: 1; grid-row: 1; padding-right: 0; font-size: 20px; font-weight: 600; line-height: 1.4; letter-spacing: 0; overflow-wrap: anywhere; }
  body .learning-shell--explorer .learn-card p { grid-column: 1; grid-row: 2; margin: 0; font-size: 14px; line-height: 1.75; color: var(--atlas-muted); }
  body .learning-shell--explorer .learn-card__foot { grid-column: 1; grid-row: 3; align-self: center; margin: 2px 0 0; padding: 0; font-size: 12px; line-height: 1.5; white-space: nowrap; }
  body .learning-shell--explorer .learn-card__enter { display: none; }
  body .learning-shell--explorer .learn-resume { padding: 16px; border-radius: 10px; gap: 12px; background: var(--reading-surface); border: 0; }
  body .learning-shell--explorer .learn-resume strong { font-size: 17px; font-weight: 500; line-height: 1.5; }
  body .learning-shell--explorer .learn-personal h2 { font-size: 14px; font-weight: 500; }

  body .learning-shell--path .learn-workspace { padding-top: 20px; }
  body .learning-shell--path .learn-hero--series { display: block; position: relative; padding: 0; border: 0; border-radius: 0; background: none; color: var(--atlas-ink); }
  body .learning-shell--path .learn-hero__copy { position: relative; }
  body .learning-shell--path .learn-eyebrow { display: block; position: absolute; right: 0; top: 0; width: 48px; height: 48px; margin: 0; font-size: 0; }
  body .learning-shell--path .learn-series-emblem { display: grid; position: static; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--mobile-paper); color: var(--mobile-soft-ink); opacity: 1; }
  body .learning-shell--path .learn-series-emblem svg { width: 30px; height: 30px; }
  body .learning-shell--path .learn-hero h1 { padding-right: 60px; min-height: 48px; display: flex; align-items: center; font-size: clamp(28px, 8vw, 34px); font-weight: 600; line-height: 1.2; letter-spacing: -.025em; text-wrap: initial; }
  body .learning-shell--path .learn-hero p { margin: 10px 0 0; max-width: none; color: var(--atlas-muted); font-size: 15px; font-weight: 400; line-height: 1.8; }
  body .path-reading-actions { margin-top: 18px; padding: 0; border: 0; }
  body .learning-shell--path .learn-hero__actions { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 12px; align-items: stretch; }
  body .learning-shell--path .learn-primary { display: flex; flex: 0 1 auto; min-width: 0; min-height: 44px; padding: 10px 16px; gap: 24px; border-radius: 8px; background: var(--mobile-paper); color: var(--atlas-ink); font-size: 15px!important; }
  body .learning-shell--path .learn-follow { display: flex; align-items: center; justify-content: center; gap: 0; flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; border: 1px solid var(--atlas-line); border-radius: 8px; }
  body .learning-shell--path .learn-follow__mark { width: 24px; height: 24px; border: 0; background: none; color: var(--atlas-ink); }
  body .learning-shell--path .learn-follow__mark svg { width: 20px; height: 20px; }
  body .learning-shell--path .learn-follow[aria-pressed=true] { background: var(--mobile-paper); border-color: var(--atlas-muted); }
  body .learning-shell--path .learn-follow[aria-pressed=true] .learn-follow__mark { background: none; border: 0; color: var(--atlas-ink); }
  body .learning-shell--path .learn-follow__copy { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  body .learning-shell--path .learn-series-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: none; min-height: 44px; margin: 0; color: var(--atlas-muted); }
  body .learning-shell--path .learn-series-progress [data-series-detail] { font-size: 12px; color: var(--atlas-muted); }
  body .learning-shell--path .learn-series-progress .learn-track { display: none; }
  body .learning-shell--path[data-learning-ready] .learn-edit-progress { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; font-size: 12px; color: var(--atlas-muted); }
  body .learn-edit-progress[aria-pressed=true] { color: var(--atlas-ink); }
  body .learning-shell--path .learn-section-heading { margin: 4px 0 0; padding: 16px 0 12px; border-top: 1px solid var(--atlas-line); align-items: center; }
  body .learning-shell--path .learn-section-heading h2 { font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; }
  body .learning-shell--path .learn-section-heading > span { font-size: 12px; }
  body .learn-desktop-label { display: none; }
  body .learn-mobile-label { display: inline; }
  body .learning-shell--path .learn-topics { display: block; }
  body .learning-shell--path .learn-topic { display: block; padding: 0; margin-bottom: 20px; border: 0; border-radius: 0; background: none; }
  body .learning-shell--path .learn-topic:has(.learn-topic-toggle[aria-expanded=true]) { background: none; border-color: transparent; }
  body .learning-shell--path .learn-topic > header { display: grid; grid-template-columns: 26px minmax(0,1fr); align-items: center; gap: 8px; padding: 0; }
  body .learning-shell--path .learn-topic__number { display: block; grid-row: auto; font-family: inherit; font-size: 14px; line-height: 1; font-weight: 500; letter-spacing: 0; color: var(--atlas-muted); opacity: 1; }
  body .learning-shell--path .learn-topic h3 { font-family: inherit; font-size: 18px; line-height: 1.5; font-weight: 600; letter-spacing: 0; }
  body .learning-shell--path .learn-topic-title { display: block; padding: 18px 0; }
  body .learning-shell--path[data-mobile-path-ready] .learn-topic-title { display: none; }
  body .learning-shell--path[data-mobile-path-ready] .learn-topic-toggle { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 12px 0; border: 0; background: none; color: inherit; text-align: start; font: inherit; }
  body .learn-topic-toggle > span:first-child { flex: 1; min-width: 0; }
  body .learn-topic-toggle .learn-topic-size { color: var(--atlas-muted); font-size: 12px; font-weight: 400; }
  body .learn-topic-toggle svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: var(--atlas-muted); stroke-width: 1.5; transition: transform .18s; }
  body .learn-topic-toggle[aria-expanded=false] svg { transform: rotate(-90deg); }
  body .learning-shell--path .learn-topic__progress { display: none; }
  body .learning-shell--path .learn-topic ol { display: grid; grid-template-columns: minmax(0,1fr); gap: 0; padding: 0 0 0 34px; }
  body .learning-shell--path .learn-lesson { border: 0; border-bottom: 1px solid var(--atlas-line); background: none; }
  body .learning-shell--path .learn-lesson > a { padding: 12px 0; min-height: 48px; gap: 8px; font-size: 16px; font-weight: 400; line-height: 1.65; color: var(--atlas-ink); }
  body .learning-shell--path :is(.learn-lesson__number,.learn-lesson__arrow) { display: none; }
  body .learning-shell--path .learn-check, body .learning-shell--path .learn-check[hidden] { display: none!important; }
  body .learning-shell--path[data-reading-editing] .learn-check:not([hidden]) { display: grid!important; width: 44px; min-height: 44px; }
  body .learning-shell--path .learn-lesson.is-complete > a { color: var(--atlas-ink); }
  body .learning-shell--path:not([data-reading-editing]) .learn-lesson.is-complete > a::after { content: '✓'; margin-left: auto; padding-left: 8px; color: var(--reading-accent); font-size: 12px; }
}
@media (max-width: 360px) {
  body .learning-shell .learn-workspace { padding-inline: 20px; }
  body .learning-shell--explorer .explorer-card-copy { column-gap: 10px; }
  body .learning-shell--explorer .explorer-card-copy h3 { font-size: 19px; }
  body .learning-shell--path .learn-hero--series { padding: 0; }
  body .learning-shell--path .learn-hero p { font-size: 14px; }
}

@media (max-width: 768px) {
  [data-theme=dark] body .learning-shell { --mobile-ink: #29463c; --mobile-paper: #1a2522; --mobile-soft-ink: #a0b5a9; }
}
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  [data-theme=auto] body .learning-shell { --mobile-ink: #29463c; --mobile-paper: #1a2522; --mobile-soft-ink: #a0b5a9; }
}
