/* =====================================================================
   Phone layer (approved 19 October 2026: direction A "Quiet list",
   plus the stepped Draft). Spec: design-options/app-revamp/phone.html
   and system.html#phone. Applies up to 760 px, where the sidebar
   becomes a sheet. Loaded last; desktop and tablet are untouched.
   ===================================================================== */
#sidebarTheme{display:none}
@media(max-width:760px){
  /* ---------- shell: gutter, top bar ---------- */
  main,#main{padding:20px 16px 40px}
  header{height:52px;padding:0 4px;gap:0}
  #menu{width:44px;height:44px;flex:none}
  #crumb{padding:0 4px;font:600 15px/1.2 var(--sans);color:var(--ink)}
  #crumb .crumb-root,#crumb .crumb-sep,#crumb .crumb-mid{display:none}
  #crumb .crumb-leaf{font-weight:600}
  .search-trigger{width:44px;height:44px;padding:0;justify-content:center;box-shadow:none;background:none;color:var(--ink);font-size:0;gap:0}
  .search-trigger kbd{display:none}
  .search-trigger .icon,.search-trigger svg{width:20px;height:20px;margin:0}
  #theme{display:none}
  #sidebarTheme{display:flex}

  /* ---------- type scale ---------- */
  .page-heading h1,.documents-lead h1,.source-intro h1,.matter-intro h1,.verification-lead h1,.ph-row h1,.home-head h1,.course-lead h1,.legal-page h1{font:400 24px/1.2 var(--display);letter-spacing:-.02em}
  .page-heading .page-description,.documents-lead>p,.source-intro p,.matter-intro p,.ph-row p,.home-head p,.course-lead p{font-size:14px;line-height:1.5;margin-top:6px}
  .page-heading,.documents-lead,.source-intro,.ph-row,.home-head,.course-lead{margin-bottom:16px}
  h2{font-size:18px}
  .kick,.eyebrow{font-size:10px}

  /* ---------- buttons and inputs ---------- */
  .button{min-height:44px;padding:0 16px;font-size:15px}
  .button.sm{min-height:40px;padding:0 12px;font-size:14px}
  .button.icon,.button.icon.sm{width:44px;min-width:44px;height:44px;min-height:44px;padding:0}
  input[type=text],input[type=search],input[type=email],input[type=password],input[type=date],input[type=number],input:not([type]),select,textarea{font-size:16px}
  input[type=text],input[type=search],input[type=email],input[type=password],input[type=date],input[type=number],input:not([type]),select{min-height:48px}

  /* One action row under a page title: the buttons share the width, primary first. */
  .ph-row{display:block}
  .ph-row .acts,.home-head-actions,.template-head-actions{display:flex;flex-wrap:nowrap;gap:8px;width:100%;margin:16px 0 0}
  .ph-row .acts>.button,.home-head-actions>.button,.template-head-actions>.button{flex:1}
  .ph-row .acts>.button.primary,.home-head-actions>.button.primary{order:-1}

  /* ---------- cards, banners ---------- */
  /* Banners: icon, one sentence, the report link inline at the end. */
  .legal-banner{display:block;position:relative;padding:10px 12px 10px 48px;font-size:13px;line-height:1.5}
  .legal-banner>.icon{position:absolute;left:10px;top:9px;margin:0}
  .legal-banner>p{display:inline;margin:0}
  .legal-banner .legal-report-btn{display:inline;min-height:0;height:auto;padding:0;margin:0 0 0 4px;border:0;background:none;font:600 13px/1.5 var(--sans);color:var(--ink);text-decoration:underline;text-underline-offset:3px;white-space:normal}
  .legal-banner .legal-report-btn .icon{display:none}

  /* ---------- lesson guide: a bottom sheet ---------- */
  .lesson-outline{inset:auto 0 0 0!important;width:100%!important;height:auto!important;max-height:78vh;border-radius:16px 16px 0 0;border:0;box-shadow:var(--e3);transform:translateY(100%)}
  .lesson-guide-open .lesson-outline{transform:translateY(0)}
  .lesson-outline::before{content:"";display:block;width:36px;height:5px;margin:8px auto 0;border-radius:3px;background:var(--line-strong);flex:none}
  .lesson-guide-header{min-height:52px;padding:6px 8px 4px 16px}
  .lesson-guide-backdrop:not([hidden]){inset:0!important}
  .lesson-outline-link{min-height:44px}
}
@media(max-width:760px){
  #sidebarTheme{width:100%;height:44px;align-items:center;gap:14px;padding:0 10px;border:0;border-radius:var(--r-md);background:transparent;color:var(--ink-2);font:400 14px/1 var(--sans)}
  #sidebarTheme .icon{width:18px;height:18px;color:var(--muted)}
}

/* ---------- Home ---------- */
@media(max-width:760px){
  .home-head-actions>.button.secondary{flex:none;width:44px;padding:0;font-size:0;gap:0}
  .home-head-actions>.button.secondary .icon{width:18px;height:18px;margin:0}
  .home-tasks{display:block;gap:0;border-radius:var(--r-lg);box-shadow:var(--e1);background:var(--surface);overflow:hidden}
  .home-tasks>a.home-task{border-radius:0;box-shadow:none;border:0;min-height:60px;padding:12px 14px 12px 16px;margin:0}
  .home-tasks>a.home-task+a.home-task{border-top:1px solid var(--line)}
  .home-route{margin-bottom:26px}
  .home-route-more{margin-top:12px}
  .home-grid{gap:26px}
  .home-side{gap:26px}
  .home-recent .card-h{padding:12px 8px 12px 16px;flex-wrap:nowrap}
  .home-recent .card-h h2{white-space:nowrap;font-size:15px}
  .home-recent .card-h .button{min-height:44px;white-space:nowrap}
  .home-doc{min-height:60px;padding:10px 16px}
  .home-doc .badge{display:none}
  .home-course h2{font-size:18px}
}

/* ---------- Lesson ---------- */
@media(max-width:760px){
  /* The top bar names the subject (a link back); the in-page back link would repeat it. */
  #crumb:has(.crumb-mid) .crumb-mid{display:block;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
  #crumb:has(.crumb-mid) .crumb-leaf{display:none}
  #crumb a.crumb-mid::before{content:"← "}
  .lesson-course-back{display:none}
  .lesson-guide-toolbar{margin-bottom:10px}
  #lessonGuideToggle{width:44px;height:44px;padding:0;justify-content:center}
  #lessonGuideToggle span{display:none}
  .lesson-main h1{font:400 26px/1.18 var(--display);letter-spacing:-.02em}
  .lesson-objective{font-size:16px;line-height:1.55}
}
@media(max-width:760px){
  .home-recent .card-h{justify-content:space-between}
  .home-recent .card-h .card-h-end{margin-left:auto}
  #lessonGuideToggle,#lessonGuideToggle[aria-expanded=true]{border:0;background:none}
}

/* ---------- Draft (template): stepped fields, bottom bar, preview behind an eye ---------- */
.draft-stepbar,.tpl-preview-toggle,.draft-step-head,.ed-fmt-toggle{display:none}
@media(max-width:760px){
  .template-page-heading{display:block;margin-bottom:20px}
  .template-page-icon{display:none}
  .template-head-actions [data-start-draft]{display:none}
  .template-head-actions:has(.tpl-preview-toggle){position:absolute;top:12px;right:0;width:auto;margin:0}
  .template-page-heading{position:relative}
  .template-page-heading:has(.tpl-preview-toggle) .page-heading{padding-right:56px}
  .tpl-preview-toggle{display:inline-flex;flex:none!important}
  .tpl-preview-toggle[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
  .template-layout{margin-top:0}
  .template-fields{padding:0}
  .template-fields.stepped .fields-head h2{font:600 12.5px/1.3 var(--sans);color:var(--muted)}
  .template-fields.stepped>.quiet{margin:8px 0 20px;font-size:13px}
  .template-fields .fields-scroll{display:grid;grid-template-columns:1fr;gap:16px;max-height:none;overflow:visible;margin:0;padding:0}
  .template-fields .fields-scroll label{display:grid;gap:6px;margin:0;font:600 14px/1.3 var(--sans);color:var(--ink-2)}
  .template-fields .fields-scroll .field-group label{display:grid;width:auto;margin:0 0 16px}
  .template-fields input{margin:0;background:var(--surface)}
  .template-fields.stepped .fields-scroll>[data-step]:not(.on){display:none}
  .template-fields.stepped .field-group{margin:0;padding:0;border:0}
  .template-fields.stepped .field-group>summary{display:none}
  .draft-step-head{display:block;margin:0 0 16px}
  .draft-step-head h2{margin:4px 0 0;font:400 18px/1.3 var(--display)}
  .template-fields.stepped>details{margin-top:20px}
  .template-layout:has(.stepped):not(.preview-on) .template-preview{display:none}
  .template-layout.preview-on .template-fields{display:none}
  .template-layout.preview-on .template-preview{display:block;margin-inline:-16px;padding:12px 0 0}
  .template-preview .document-paper{border-radius:0;box-shadow:none;padding:24px 16px;font-size:15px}
  main:has(.draft-stepbar:not([hidden])){padding-bottom:96px}
  .draft-stepbar:not([hidden]){display:flex;gap:8px;position:fixed;left:0;right:0;bottom:0;z-index:30;padding:10px 16px calc(10px + env(safe-area-inset-bottom));background:var(--bg);border-top:1px solid var(--line)}
  .draft-stepbar .button{flex:1}
  .draft-stepbar .button.tertiary{flex:none;padding:0 18px}
}

/* ---------- Editor: title row, full-bleed paper, bottom bar with views and Aa ---------- */
@media(max-width:760px){
  .ed-top{flex-wrap:nowrap;gap:4px;padding:10px 8px 10px 16px}
  .ed-title{flex:1 1 auto;flex-basis:auto}
  .ed-title input{font-size:18px}
  .ed-meta{font-size:12px}
  .ed-meta>span+span{display:none}
  .ed-acts{width:auto;gap:4px}
  .ed-acts #docxExport{flex:none;width:44px;min-width:44px;padding:0;gap:0;font-size:0}
  .ed-acts #docxExport span{display:none}
  .ed-acts #docxExport .icon{margin:0;width:18px;height:18px}
  .ed-acts #exportMore{border:0;background:none;box-shadow:none}
  .ed-acts .export-menu{left:auto;right:0}
  .ed-shell{padding-bottom:68px}
  .ed-tools{position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;flex-wrap:nowrap;gap:8px;padding:8px 16px calc(8px + env(safe-area-inset-bottom));border-top:1px solid var(--line);border-bottom:0;background:var(--bg)}
  .ed-views{order:0;flex:1;width:auto;margin:0;display:flex}
  .ed-views button{flex:1;min-height:44px;font-size:14px}
  .ed-views [data-doc-view=notes]{display:none}
  .ed-fmt-toggle{display:inline-flex;flex:none}
  .ed-shell.fmt-open .ed-fmt-toggle{background:var(--ink);color:var(--bg);border-color:var(--ink)}
  .ed-format{position:fixed;left:0;right:0;bottom:calc(61px + env(safe-area-inset-bottom));z-index:29;display:none;flex-wrap:wrap;justify-content:center;gap:4px;padding:12px 12px 10px;border-radius:16px 16px 0 0;background:var(--surface);box-shadow:var(--e3);overflow:visible}
  .ed-shell.fmt-open .ed-format{display:flex}
  .ed-format .button.icon.sm{width:44px;min-width:44px;height:44px}
  .ed-format select{height:44px;font-size:15px}
  .ed-format .ed-sep{display:none}
  .ed-find{padding:8px 16px}
  .ed-canvas,.ed-shell[data-view=compare] .ed-canvas{padding:0;background:var(--surface)}
  .ed-shell[data-view=compare] .ed-col,.ed-shell[data-view=notes] .ed-col{padding:0}
  .ed-paper.document-paper,.ed-shell[data-view=compare] .ed-paper{padding:24px 16px 32px;border-radius:0;box-shadow:none;font-size:16px;line-height:1.7}
  .ed-paper:focus{box-shadow:none}
  .ed-paper:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--signal) 35%,transparent)}
  .ed-col-h{margin:0;padding:12px 16px 0}
  .ed-foot{display:none}
  /* Compare: one column with inline redline; the change count is a pill that opens the list */
  .ed-shell[data-view=compare] .ed-side{position:fixed;left:0;right:0;bottom:calc(61px + env(safe-area-inset-bottom));z-index:29;max-height:60vh;overflow:auto;border:0;background:transparent;pointer-events:none}
  .ed-shell[data-view=compare] .ed-side>*{pointer-events:auto}
  .ed-shell[data-view=compare] .ed-side .ed-chg-head{display:inline-flex;align-items:center;gap:8px;margin:0 0 12px 16px;padding:0 16px;min-height:40px;border:0;border-radius:999px;background:var(--ink);color:var(--bg);box-shadow:var(--e3);cursor:pointer}
  .ed-shell[data-view=compare] .ed-side .ed-chg-head h2{font-size:14px;color:inherit}
  .ed-shell[data-view=compare] .ed-side .ed-chg-head span{display:none}
  .ed-shell[data-view=compare] .ed-side:not(.open)>:not(.ed-chg-head){display:none}
  .ed-shell[data-view=compare] .ed-side.open{background:var(--surface);border-radius:16px 16px 0 0;box-shadow:var(--e3);padding-top:12px}
  .ed-shell[data-view=compare] .ed-side.open .ed-chg-head{background:var(--sunken);color:var(--ink);box-shadow:none}
}

/* ---------- Lists and secondary pages ---------- */
@media(max-width:760px){
  /* Draft a document: compact cards, small icon beside the kicker, card titles at 18 */
  .featured-document{padding:16px;gap:6px;min-height:0}
  .featured-document .featured-icon{position:absolute;top:12px;right:12px;width:36px;height:36px}
  .featured-document .featured-icon .draft-icon{width:18px;height:18px}
  .featured-document{position:relative}
  .featured-document h2{margin:10px 48px 0 0;font:400 18px/1.3 var(--display)}
  .featured-document p{margin:4px 0 8px;font-size:14px}
  .featured-link{min-height:44px;display:inline-flex;align-items:center}
  /* A back action in a header reads as a link, not a full-width button */
  .desk-page .ph-row .acts>a.button.secondary[href="#review"]:only-child{flex:none;min-height:44px;padding:0;margin-left:-2px;border:0;background:none;box-shadow:none;font-weight:500;color:var(--muted)}
  /* Glossary letters: one swipeable row at full gutter, 36 px targets */
  .gloss-rail{margin-inline:-16px;padding-inline:16px}
  .gloss-rail>*{width:36px;height:36px;flex:none}
  .gloss-letter-head{font-size:22px}
  /* Playbook: section titles on the 18 scale */
  .pb-when h2,.pb-steps-head h2,.pb-head~* h2{font:400 18px/1.3 var(--display)}
  /* Rows of page actions: primary on its own line, the rest share the next */
  .actions:has(#exportWorkspace),.actions:has(#exportLearningReport){display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .actions:has(#exportWorkspace)>.button,.actions:has(#exportLearningReport)>.button{width:100%;margin:0;justify-content:center;white-space:normal;text-align:center}
  .actions:has(#exportWorkspace)>.button.primary,#exportLearningReport{grid-column:1/-1}
  .revision-next h2{font:400 18px/1.3 var(--display)}
  .revision-next{padding:16px}
}
@media(max-width:760px){
  .documents-lead{padding-bottom:0}
  .document-feature{margin-top:0;padding-top:20px}
  .course-next h2{font:400 18px/1.3 var(--display)}
  .prose.narrow h2{font-size:20px;line-height:1.3}
  .upd-body h2{font-size:18px}
}

/* ---------- Dialogs, search, toasts ---------- */
@media(max-width:760px){
  /* Sign-in and account: a bottom sheet the width of the screen */
  #accountDialog[open]{width:100%;max-width:none;max-height:calc(100dvh - 24px);margin:auto 0 0;border-radius:16px 16px 0 0;padding-bottom:env(safe-area-inset-bottom)}
  #accountDialog .account-close{width:44px;height:44px}
  #accountDialog .account-tabs button{min-height:40px;font-size:14px}
  #accountDialog .account-show{min-height:44px;padding:0 12px}
  #accountDialog .account-wide{min-height:48px}
  /* Search: full screen, one swipeable row of scopes, no keyboard hints */
  #search[open]{width:100%;max-width:none;height:100dvh;max-height:none;margin:0;border-radius:0;display:flex;flex-direction:column}
  #search .dialog-top{min-height:56px;padding:4px 4px 4px 16px}
  #search .dialog-top button{width:44px;height:44px}
  #search #searchInput{font-size:16px}
  #search .scope-chips{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;padding-inline:16px}
  #search .scope-chips::-webkit-scrollbar{display:none}
  #search .scope-chips button{flex:none;min-height:36px;padding:0 14px;font-size:14px}
  #search #searchResults{flex:1;max-height:none}
  #searchFoot{display:none}
  /* Toast: full width above the bottom edge */
  #toast{left:16px;right:16px;max-width:none;width:auto;transform:translate(0,140%);justify-content:flex-start;bottom:calc(16px + env(safe-area-inset-bottom));font-size:14px;line-height:1.4}
  #toast.show{transform:translate(0,0)}
  body:has(.draft-stepbar:not([hidden]),.ed-tools) #toast{bottom:calc(76px + env(safe-area-inset-bottom))}
  /* Assessment: the top bar already links back to the subject */
  body:has(#crumb .crumb-mid) #main>a.back{display:none}
  #main>a.back+* h2,.prose h2{font-size:20px;line-height:1.3}
  .content-tabs button,.legal-tabs a,.legal-tabs button{min-height:44px}
  #reader [data-close]{width:44px;height:44px}
}

/* ---------- Library filters: a bottom sheet ---------- */
.filter-sheet-head,.filter-sheet-foot,.filter-sheet-backdrop{display:none}
@media(max-width:760px){
  .source-filter-drawer>summary{height:44px}
  .source-filter-drawer[open]>summary{margin-bottom:0}
  .source-filter-drawer[open] .filter-sheet-backdrop{display:block;position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.4)}
  .source-filter-drawer[open] .filter-sheet{position:fixed;left:0;right:0;bottom:0;z-index:61;display:flex;flex-direction:column;max-height:82dvh;border-radius:16px 16px 0 0;background:var(--surface);box-shadow:var(--e3)}
  .filter-sheet::before{content:"";display:block;width:36px;height:5px;margin:8px auto 0;border-radius:3px;background:var(--line-strong);flex:none}
  .source-filter-drawer[open] .filter-sheet-head{display:flex;align-items:center;justify-content:space-between;min-height:52px;padding:0 8px 0 16px;border-bottom:1px solid var(--line)}
  .filter-sheet-head h2{margin:0;font:400 18px/1.3 var(--display)}
  .filter-sheet .facets{flex:1;overflow:auto;padding:16px;gap:22px;grid-template-columns:1fr;font-size:15px}
  .filter-sheet .facet-group>legend{font-size:12.5px}
  .filter-sheet .facet-opt{min-height:44px;padding:0}
  .filter-sheet .facet-opt input{width:20px;height:20px}
  .filter-sheet .facet-n{font-size:12px}
  .filter-sheet .seg{display:flex;width:100%}
  .filter-sheet .seg button{flex:1;min-height:44px;font-size:14px}
  .source-filter-drawer[open] .filter-sheet-foot{display:block;padding:12px 16px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--line)}
  .filter-sheet-foot .button{width:100%;min-height:48px}
  body:has(.source-filter-drawer[open]){overflow:hidden}
}
