/* PASS 5 — MOBILE-FIRST INVESTIGATION EXPERIENCE
   Purpose: make the phone build feel like the primary product rather than a compressed desktop interface. */

:root{
  --p5-ink:#171c1e;
  --p5-ink-2:#202729;
  --p5-ink-3:#2b3335;
  --p5-paper:#ece6d8;
  --p5-paper-2:#f4efe4;
  --p5-paper-deep:#d8d1c3;
  --p5-rule:#aaa294;
  --p5-rule-dark:#767068;
  --p5-accent:#bd9e57;
  --p5-accent-deep:#74612f;
  --p5-safe:#708b77;
  --p5-danger:#8b4c4e;
  --p5-touch:48px;
  --p5-bottom-nav:72px;
}

/* Smoothness and touch ergonomics */
html{scroll-behavior:smooth}
button,[role="button"],select,input,textarea{-webkit-tap-highlight-color:transparent}
.workspace{-webkit-overflow-scrolling:touch;overscroll-behavior-y:contain}
.document-desk,.document-inspector,.search-panel,.media-panel,.compare-panel{-webkit-overflow-scrolling:touch}
@media (pointer:coarse){button,.filter-button,.notebook-tab,.dossier-jumpbar button{min-height:44px}}

/* Workspace entrance feels deliberate but very fast. */
@keyframes p5-view-in{from{opacity:.01;transform:translateY(5px)}to{opacity:1;transform:none}}
@keyframes p5-sheet-in{from{transform:translateY(105%)}to{transform:translateY(0)}}
@keyframes p5-fade{from{opacity:0}to{opacity:1}}
body.pass5-view-transition #workspace>*{animation:p5-view-in .15s cubic-bezier(.2,.7,.2,1) both}
body.reduced-motion #workspace>*,body.reduced-motion .pass5-more-sheet,body.reduced-motion .pass5-sheet-backdrop{animation:none!important}

/* Pass 5 mobile header */
.pass5-mobile-context{display:none}
.pass5-mobile-context__case{font:800 .48rem var(--font-mono);letter-spacing:.12em;color:#8f9898;text-transform:uppercase;white-space:nowrap}
.pass5-mobile-context__view{font:720 .86rem var(--font-ui);color:#eee9dc;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:210px}
.pass5-mobile-context__status{display:flex;gap:5px;align-items:center;font:650 .44rem var(--font-mono);color:#8f9996;white-space:nowrap}
.pass5-mobile-context__status i{width:5px;height:5px;border-radius:50%;background:#77917d}

/* More sheet */
.pass5-sheet-backdrop{position:fixed;inset:0;background:rgba(10,13,14,.58);z-index:170;animation:p5-fade .14s ease both}
.pass5-more-sheet{position:fixed;z-index:171;left:0;right:0;bottom:0;background:#e6e0d4;border-top:1px solid #7f786d;box-shadow:0 -24px 70px rgba(0,0,0,.38);max-height:min(84vh,720px);overflow:auto;padding:8px 14px calc(18px + env(safe-area-inset-bottom));animation:p5-sheet-in .19s cubic-bezier(.2,.72,.2,1) both}
.pass5-sheet-grip{width:38px;height:4px;border-radius:5px;background:#aaa396;margin:3px auto 12px}
.pass5-more-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:4px 2px 13px;border-bottom:1px solid #b9b1a4}
.pass5-more-head span{display:block;font:800 .46rem var(--font-mono);letter-spacing:.1em;color:#70736f;text-transform:uppercase}
.pass5-more-head h2{font:500 1.65rem/1.05 var(--font-doc);margin:4px 0 0;color:#1c2223}
.pass5-more-close{width:42px;height:42px;border:1px solid #aaa296;background:#eee8dc;font:700 1rem var(--font-ui)}
.pass5-case-progress{padding:13px 2px 12px;border-bottom:1px solid #bbb3a6}
.pass5-case-progress__top{display:flex;justify-content:space-between;gap:10px;align-items:end}
.pass5-case-progress__top span{font:800 .48rem var(--font-mono);letter-spacing:.08em;color:#666d6b;text-transform:uppercase}
.pass5-case-progress__top strong{font:800 .84rem var(--font-mono);color:#202829}
.pass5-case-progress__track{height:4px;background:#c9c1b4;margin-top:8px;overflow:hidden}
.pass5-case-progress__track i{display:block;height:100%;background:#52645f;width:0}
.pass5-more-grid{display:grid;grid-template-columns:1fr 1fr;margin:12px 0;border:1px solid #a79f91;background:#f1ebdf}
.pass5-more-item{min-height:76px;border:0;border-right:1px solid #b9b1a3;border-bottom:1px solid #b9b1a3;background:transparent;text-align:left;padding:11px 12px;display:grid;grid-template-columns:30px 1fr auto;gap:8px;align-items:center}
.pass5-more-item:nth-child(2n){border-right:0}.pass5-more-item:nth-last-child(-n+2){border-bottom:0}
.pass5-more-item svg{width:22px;height:22px;stroke:#586564;fill:none;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}
.pass5-more-item strong{font-size:.76rem}.pass5-more-item small{display:block;font:650 .43rem var(--font-mono);letter-spacing:.06em;color:#787b75;margin-top:3px;text-transform:uppercase}
.pass5-more-item>em{font:800 .48rem var(--font-mono);font-style:normal;color:#6f746f;align-self:start;margin-top:2px}
.pass5-more-item.active{background:#dce1da;box-shadow:inset 3px 0 #5f7666}
.pass5-more-utilities{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.pass5-utility{min-height:48px;border:1px solid #aaa295;background:#eee8dc;text-align:left;padding:8px 10px;font-weight:760;font-size:.7rem}.pass5-utility small{display:block;font:600 .42rem var(--font-mono);color:#787b76;margin-top:2px}

/* Quick controls injected into content screens */
.pass5-quick-rail{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;padding:0 0 9px;margin:0 -1px}.pass5-quick-rail::-webkit-scrollbar{display:none}
.pass5-quick-chip{flex:0 0 auto;min-height:35px!important;border:1px solid #aaa295;background:#e7e1d5;padding:7px 10px;font:760 .62rem var(--font-ui);color:#4d5554;white-space:nowrap}
.pass5-quick-chip span{font:700 .46rem var(--font-mono);color:#777c78;margin-left:4px}.pass5-quick-chip.active{background:#222a2c;color:#f0ebde;border-color:#222a2c}.pass5-quick-chip.active span{color:#b7c0bd}
.pass5-result-count{font:700 .47rem var(--font-mono);letter-spacing:.06em;color:#737873;text-transform:uppercase;padding:2px 0 8px}

/* Desk */
.pass5-desk-quick{display:grid;grid-template-columns:repeat(3,1fr);border:1px solid #9e978b;background:#ded8cb;margin-top:10px}
.pass5-desk-quick button{border:0;border-right:1px solid #aea699;background:transparent;min-height:58px;padding:8px 5px;text-align:center}.pass5-desk-quick button:last-child{border-right:0}
.pass5-desk-quick svg{width:19px;height:19px;margin:0 auto 5px;stroke:#566361;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.pass5-desk-quick strong{display:block;font-size:.64rem}.pass5-desk-quick small{display:block;font:650 .39rem var(--font-mono);color:#787c77;margin-top:2px;text-transform:uppercase}
.pass5-progress-line{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:center;margin:10px 0 0;padding:8px 0 0;border-top:1px solid #bcb4a7}.pass5-progress-line>div{height:3px;background:#c4bdb1;overflow:hidden}.pass5-progress-line i{display:block;height:100%;background:#64776b}.pass5-progress-line strong{font:750 .48rem var(--font-mono);color:#6a6f6b}

/* Documents */
.pass5-files-tools{margin:0 0 8px}
.archive-row.pass5-filtered{display:none!important}
.pass5-file-state{display:inline-flex;align-items:center;gap:4px;font:700 .43rem var(--font-mono);letter-spacing:.04em;color:#6d716d;text-transform:uppercase}.pass5-file-state i{width:5px;height:5px;border-radius:50%;background:#9a9386}.archive-row.reviewed .pass5-file-state i{background:#6e8b75}

/* People */
.person-file.pass5-filtered{display:none!important}
.pass5-people-tools{margin:0 0 9px}

/* Notebook capture strip */
.pass5-note-capture{display:grid;grid-template-columns:1fr auto;margin:0 0 10px;border:1px solid #938a77;background:#dfd5b7}
.pass5-note-capture__copy{padding:9px 11px}.pass5-note-capture__copy span{display:block;font:800 .43rem var(--font-mono);letter-spacing:.08em;color:#6d675b}.pass5-note-capture__copy strong{display:block;font-size:.72rem;margin-top:2px}.pass5-note-capture__actions{display:flex;border-left:1px solid #a79d87}.pass5-note-capture button{width:44px;border:0;border-left:1px solid #b7ac94;background:rgba(255,255,255,.16);font:800 .64rem var(--font-mono)}.pass5-note-capture button:first-child{border-left:0}
.pass5-note-capture button:active{background:rgba(255,255,255,.5)}

/* Document reader reading progress and context */
.pass5-reading-progress{position:absolute;left:0;right:0;top:52px;height:2px;background:transparent;z-index:8;pointer-events:none}.pass5-reading-progress i{display:block;width:0;height:100%;background:#c4a45a;transition:width .06s linear}
.pass5-doc-position{display:none;font:750 .45rem var(--font-mono);letter-spacing:.06em;color:#87918f;white-space:nowrap}
.pass5-inspector-close{display:none}
.dossier-jumpbar button.pass5-active{background:#283032;color:#f0eadc;border-color:#283032}

/* Better feedback without game-like popups */
.pass5-toast-region{position:fixed;z-index:220;left:50%;top:calc(64px + env(safe-area-inset-top));transform:translateX(-50%);display:grid;gap:6px;pointer-events:none;width:min(90vw,380px)}
.pass5-toast{background:#1d2425;color:#eee9dd;border:1px solid #4d5656;box-shadow:0 8px 28px rgba(0,0,0,.28);padding:9px 11px;font-size:.67rem;line-height:1.35;animation:p5-view-in .14s ease both}.pass5-toast small{display:block;font:650 .41rem var(--font-mono);color:#9da6a3;margin-top:2px;text-transform:uppercase;letter-spacing:.05em}

/* Mobile system */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  :root{--p5-bottom-nav:70px}
  body{background:#c5c0b5}
  #app-shell{grid-template-rows:56px minmax(0,1fr)}
  .topbar{height:56px;grid-template-columns:minmax(0,1fr) auto;padding:0 10px 0 13px;background:#181f21;border-bottom-color:#0b0f10;box-shadow:0 1px rgba(255,255,255,.04) inset}
  .topbar__left{min-width:0}.case-mark{min-width:0}.case-mark__seal,.case-mark__copy{display:none!important}.pass5-mobile-context{display:grid;gap:1px;min-width:0}
  #nav-toggle{display:none!important}.top-actions{gap:6px}.top-actions #settings-open,.top-actions .save-state{display:none!important}
  .top-actions .command-button{width:40px!important;height:40px!important;border:1px solid #444e50!important;background:#222a2c!important;border-radius:3px!important}
  .top-actions .command-button::before{font-size:1rem!important}.topbar .icon-button{width:40px;height:40px}

  .workspace-grid{display:block;min-height:0;height:100%}.workspace{height:100%;padding:0 10px calc(var(--p5-bottom-nav) + 24px + env(safe-area-inset-bottom));background:#c8c3b8;overflow:auto}.workspace::before{display:none}
  .sidebar{display:none!important}

  /* New primary nav: four direct destinations + a complete More surface. */
  .mobile-bottom-nav{height:calc(var(--p5-bottom-nav) + env(safe-area-inset-bottom));padding:3px 5px env(safe-area-inset-bottom);background:#171e20;border-top:1px solid #374043;box-shadow:0 -8px 26px rgba(11,14,15,.18);grid-template-columns:repeat(5,1fr);z-index:90}
  .mobile-bottom-nav button{position:relative;min-height:60px;border:0;background:transparent;color:#88928f;display:grid;place-items:center;align-content:center;gap:3px;padding:5px 2px;font-size:.52rem;font-weight:720}
  .mobile-bottom-nav button::after{content:"";position:absolute;top:3px;width:18px;height:2px;background:transparent}
  .mobile-bottom-nav button.active{color:#f1ebdd}.mobile-bottom-nav button.active::after{background:#c1a25a}
  .mobile-bottom-nav svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}.mobile-bottom-nav .mobile-nav-code{display:none!important}
  .mobile-bottom-nav button span:last-child{font-size:.52rem;letter-spacing:.01em}

  /* Mobile pages read like a case system, not desktop panels. */
  .page-header,.archive-head,.people-head{margin:0 -10px 10px;padding:16px 14px 12px;background:#d8d2c7;border-bottom:1px solid #a8a195}.page-header h2,.archive-head h1,.people-head h1{font-size:1.72rem;line-height:1.02;margin:4px 0 5px}.page-header p,.archive-head p,.people-head p{font-size:.7rem;line-height:1.45;max-width:38rem}.page-header__action{margin-top:9px}.archive-search-trigger{display:none!important}

  /* Desk feels like opening a working folder, with less dead space. */
  .mobile-case-desk{margin:0 -10px;padding:8px 10px 0}
  .desk-classification{padding:2px 2px 8px;font-size:.44rem;letter-spacing:.1em;color:#5a5f5c}
  .desk-file-cover{margin:18px 0 0;background:#5b584f;padding:8px;border-color:#4c4a43;position:relative}
  .desk-file-tab{position:absolute;top:-18px;left:10px;background:#c2b99e;border:1px solid #7f7869;border-bottom:1px solid #c2b99e;border-radius:3px 3px 0 0;font-size:.48rem;font-weight:700;letter-spacing:.08em;color:#2c2822;padding:3px 9px;z-index:2;line-height:1}
  .desk-file-body{padding:24px 16px 16px;min-height:0;position:relative}
  .desk-file-body h1{font-size:2.05rem;line-height:1;margin:8px 0 6px}
  .desk-file-body>p{font-size:.86rem;line-height:1.38;margin-bottom:14px}
  .desk-file-meta{margin:0 0 14px}
  .desk-file-meta span{padding:7px 0}
  .desk-primary{min-height:48px;margin-top:1px}
  .desk-status-strip{grid-template-columns:repeat(4,1fr);margin:0;background:#222a2c}
  .desk-status-strip div{padding:7px 5px}
  .desk-status-strip span{font-size:.35rem}
  .desk-status-strip strong{font-size:.72rem}
  .desk-section{margin:10px 0 0;padding:12px;background:#dad4c8;border:1px solid #b5ada0}.desk-section__head h2{font-size:1.35rem}.desk-section__head button{min-height:40px}.recent-file{padding:10px 12px;min-height:70px}.recent-file strong{font-size:.77rem}.recent-file small{font-size:.54rem}.case-question-list li{grid-template-columns:30px 1fr;padding:8px 0}.case-question-list p{font-size:.7rem;line-height:1.45}

  /* Archive */
  .archive-control-sheet{position:sticky;top:0;z-index:11;margin:0 -10px 8px;padding:8px 10px 7px;background:#c8c3b8;border-top:0;border-bottom:1px solid #a8a195;box-shadow:0 4px 10px rgba(50,47,41,.06)}
  .archive-filter-rail{margin:0;padding:0 0 6px}.filter-button{min-height:34px!important;padding:6px 9px;font-size:.59rem}.archive-sort-row{grid-template-columns:minmax(0,1fr) 94px;gap:6px}.archive-sort-row input,.archive-sort-row select{min-height:41px;font-size:.68rem;padding:.55rem .6rem}.archive-registry-head{display:none}.archive-table{display:grid;gap:7px;background:transparent;border:0}.archive-row{grid-template-columns:52px minmax(0,1fr) 50px;min-height:92px;border:1px solid #aaa294!important;background:#e3ddd1;box-shadow:0 1px 0 rgba(255,255,255,.35) inset}.archive-row.reviewed{background:#d9ded8}.archive-row__thumb{background:#d2ccc0;border-right:1px solid #b5ad9f}.archive-row__thumb small{font-size:.38rem}.archive-row__main{padding:10px 9px}.archive-row__main .kicker{font-size:.42rem}.archive-row__main h3{font-size:.94rem;line-height:1.14;margin:3px 0 4px}.archive-row__main p{font-size:.62rem;line-height:1.35}.archive-mobile-meta{font-size:.48rem;margin-top:5px}.archive-cell.action{background:rgba(255,255,255,.14);border-left:1px solid #bbb3a5}.record-state{font-size:.4rem}.record-mark{font-size:.36rem}

  /* People: shorter, stronger, easier to scan. */
  .people-ledger{display:grid;gap:8px;background:transparent;border:0}.person-file{grid-template-columns:96px minmax(0,1fr);border:1px solid #a89f91!important;background:#e1dbcf;min-height:142px}.person-file__photo{margin:8px;padding:4px;background:#f0eadf;border-color:#9f978a;align-self:start}.person-file__body{padding:9px 11px 9px 0}.person-file__control{font-size:.36rem;line-height:1.25}.person-file__body h2{font-size:1.23rem;line-height:1;margin:4px 0 2px}.person-file__role{font-size:.58rem;line-height:1.28}.poi-factline{font-size:.48rem}.person-file dl{margin:6px 0}.person-file dt{font-size:.35rem}.person-file dd{font-size:.59rem;line-height:1.25}.poi-question{font-size:.56rem;line-height:1.3;padding:6px 0}.person-file__footer select{min-height:34px;font-size:.55rem}.person-file__footer>span{display:none}

  /* Document / dossier reader */
  .document-modal{grid-template-rows:52px minmax(0,1fr) 66px;background:#303534}.document-modal.dossier-mode{grid-template-rows:52px minmax(0,1fr)}
  .document-modal__toolbar{height:52px;padding:5px 8px;gap:7px}.document-modal__toolbar-left{gap:7px}.document-modal__toolbar .icon-button{width:40px;height:40px;background:#262d2f;border-color:#50595b;color:#e8e3d7}.document-modal__identity span{font-size:.39rem}.document-modal__identity strong{font-size:.69rem;max-width:188px}.pass5-doc-position{display:block;margin-left:auto;padding-right:2px}.document-modal__tools{display:none!important}
  .pass5-reading-progress{display:block}
  .document-desk{padding:10px 6px 40px;background:#4c4b46;scrollbar-width:thin}.paper-document{padding:36px 17px 46px;min-height:calc(100vh - 142px);border-color:#c9c1b3;box-shadow:0 8px 24px rgba(0,0,0,.29)}.paper-document p{font-size:.79rem;line-height:1.6}.paper-document .document-letterhead h1{font-size:1.45rem}.document-record-strip div{min-height:41px}.document-record-strip div span{font-size:.38rem}.document-record-strip div strong{font-size:.53rem}.document-mobile-actions{height:66px;padding:3px 4px calc(4px + env(safe-area-inset-bottom));background:#171e20;border-color:#384143}.document-mobile-actions button{min-height:56px!important;color:#929c99}.document-mobile-actions button span{font-size:.9rem}.document-mobile-actions button small{font-size:.48rem}.document-mobile-actions button.active{color:#e1c679}
  .document-inspector{z-index:155;max-height:82vh;padding:6px 12px calc(18px + env(safe-area-inset-bottom));background:#e3ddd2;border-color:#777168;border-radius:0}.document-inspector__grip{margin:3px auto 6px}.pass5-inspector-close{display:block;position:sticky;top:0;z-index:2;width:100%;height:42px;border:0;border-bottom:1px solid #b4ac9f;background:#e3ddd2;text-align:right;font-weight:780;font-size:.66rem}.document-inspector__section{margin-top:8px}

  /* Dossier */
  .dossier{background:#e8e2d6}.dossier-cover{grid-template-columns:102px 1fr;padding:11px;gap:10px}.realism-dossier-photo{padding:4px}.dossier-title h1{font-size:1.45rem;line-height:1}.dossier-title .dossier-subline{font-size:.61rem}.dossier-title p.small{font-size:.58rem;line-height:1.25;margin:.35rem 0}.dossier-status-line{margin-top:7px;padding:5px 0}.dossier-jumpbar{position:sticky;top:0;z-index:12;margin:0;display:flex;overflow:auto;background:#d1cabf;border-top:1px solid #9d9588;border-bottom:1px solid #91897d;scrollbar-width:none}.dossier-jumpbar::-webkit-scrollbar{display:none}.dossier-jumpbar button{flex:0 0 auto;min-height:40px!important;padding:8px 10px;border:0;border-right:1px solid #aca497;background:transparent;font-size:.42rem}.dossier-body{padding:0 12px 28px}.dossier-section{scroll-margin-top:44px;padding:12px 0}.dossier-section-head h2{font-size:.5rem}.dossier-grid{gap:0}.dossier-field{padding:7px 0;font-size:.68rem}.dossier-field span{font-size:.38rem}.dossier-relevance{padding:8px}.evidence-status-grid{gap:7px}.evidence-status-card{padding:9px}.evidence-status-card span{font-size:.4rem}.evidence-status-card li{font-size:.62rem;line-height:1.4}.movement-ledger-row{grid-template-columns:68px minmax(0,1fr)}.movement-ledger-row p{font-size:.61rem}.statement-change__pair p{font-size:.61rem}.dossier-media-grid{grid-template-columns:repeat(3,1fr);gap:5px}.dossier-media-card figcaption{padding:5px}.dossier-media-card figcaption strong{font-size:.52rem}.dossier-media-card figcaption small{font-size:.39rem;line-height:1.3}

  /* Notebook */
  .notebook-shell{margin:0;border-color:#8e846d}.notebook-tabs{top:0;padding:0;background:#68604f}.notebook-tab{min-height:43px!important;padding:8px 10px;font-size:.6rem}.notebook-page{padding:15px 11px 20px;min-height:calc(100vh - 190px)}.notebook-page h3{font-size:1.25rem}.page-instruction{font-size:.66rem;line-height:1.45}.reference-strip{padding:8px;margin-bottom:10px}.reference-chip{min-height:34px!important;font-size:.5rem}.notebook-textarea{min-height:48vh;font-size:.84rem;line-height:1.88!important;background-size:auto 30px!important}.suspect-note-card__head{gap:6px}.suspect-note-card textarea{min-height:120px}.contradiction-form textarea{min-height:110px}.theory-grid textarea{min-height:100px}

  /* Search and auxiliary surfaces */
  .search-panel{inset:56px 0 var(--p5-bottom-nav);background:#e2dcd1}.search-panel__header{padding:8px 10px;background:#d4cec3;border-bottom:1px solid #aaa296}.search-input-wrap input{min-height:42px}.search-result{grid-template-columns:minmax(96px,auto) 1fr!important;padding:10px;border-bottom-color:#bab2a5}.search-result .kicker{white-space:nowrap;font-family:var(--font-mono);font-size:.56rem;font-weight:700}.search-result button{font-size:.76rem}.settings-panel{z-index:180;background:#e6e0d5}.compare-panel{z-index:160}.media-panel{z-index:165;background:#1d2324}.media-panel__header{min-height:52px;padding:7px 9px}.media-panel__header h2{font-size:.9rem}.media-panel__tools{padding:6px}.media-panel__toolset{display:flex;flex-wrap:wrap;overflow:visible;gap:5px}.media-tool{min-height:36px!important;flex:1 1 auto;padding:4px 8px;font-size:.62rem}.media-tool#media-zoom-out,.media-tool#media-zoom-reset,.media-tool#media-zoom-in{flex:0 0 auto;min-width:36px}.media-panel__stage{grid-template-columns:1fr;grid-template-rows:minmax(0,1fr) auto}.media-panel__stage aside{max-height:34vh;overflow:auto;border-left:0;border-top:1px solid #394240}

  /* Compare tray no longer blocks navigation. */
  .evidence-tray{bottom:calc(var(--p5-bottom-nav) + 7px + env(safe-area-inset-bottom));left:7px;right:7px;border-radius:0}.evidence-tray__label{font-size:.37rem}.evidence-tray__item{font-size:.51rem}.evidence-tray__compare{min-height:38px}

  /* Accusation and utility forms */
  .accusation-shell,.timeline-layout,.board-layout,.puzzle-list,.envelope-list{margin-bottom:6px}.accusation-form input,.accusation-form select,.accusation-form textarea{font-size:.74rem;min-height:44px}.primary-button,.quiet-button{min-height:42px}
}

@media(max-width:380px){
  .pass5-mobile-context__view{max-width:176px}.desk-file-body h1{font-size:1.9rem}.archive-row{grid-template-columns:48px minmax(0,1fr) 46px}.person-file{grid-template-columns:88px minmax(0,1fr)}.document-modal__identity strong{max-width:157px}.dossier-cover{grid-template-columns:92px 1fr}.dossier-media-grid{grid-template-columns:1fr 1fr}.dossier-media-card:last-child{grid-column:1/-1;max-width:52%}.pass5-more-item{grid-template-columns:26px 1fr auto;padding:10px 9px}
}

@media(min-width:761px){
  .pass5-sheet-backdrop,.pass5-more-sheet,.pass5-toast-region{display:none!important}
}

/* Pass 5 QA refinements */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .dossier-jumpbar button{color:#525956!important;background:#d1cabf!important;font-weight:780}
  .dossier-jumpbar button.pass5-active{background:#283032!important;color:#f0eadc!important;box-shadow:inset 0 -2px #c3a45c}
  [data-case-view="notebook"] .page-header{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end}
  [data-case-view="notebook"] .page-header__action{margin:0;align-self:end}
  [data-case-view="notebook"] .page-header__action .quiet-button{min-height:40px;padding:.5rem .65rem;font-size:.62rem;white-space:nowrap}
  [data-case-view="notebook"] .page-header>div:first-child p{margin-bottom:0}
  .pass5-note-capture__actions button{width:48px;font-size:.52rem}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;animation-duration:.001ms!important;transition-duration:.001ms!important}
}

/* Pass 5 performance and custom action icon refinements */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .archive-row,.person-file,.dossier-section{content-visibility:auto}
  .archive-row{contain-intrinsic-size:92px}.person-file{contain-intrinsic-size:150px}.dossier-section{contain-intrinsic-size:320px}
  .document-mobile-actions button svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
  .document-mobile-actions button>span{display:none}
}

/* Pass 5 board and overlay QA corrections */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .board-layout{display:block}
  .evidence-board{min-height:220px!important;padding:12px!important;box-shadow:inset 0 0 28px rgba(0,0,0,.06)!important}
  .evidence-board .empty-state{min-height:124px;display:grid;align-content:center;color:#d9d5ca!important;border-color:#817d73!important;background:rgba(255,255,255,.035)!important;font-size:.72rem;line-height:1.5}
  .evidence-board .empty-state strong{color:#f1ecdf}
  .board-toolbar{align-items:flex-start}.board-toolbar .tag{max-width:148px;text-align:center;justify-content:center;line-height:1.2}
  .board-layout>aside{margin-top:9px}.connection-form{padding:10px}.connection-form textarea{min-height:96px}
  .connection-list .empty-state{min-height:76px}
  .document-modal:not(.hidden),.media-panel:not(.hidden),.compare-panel:not(.hidden),.search-panel:not(.hidden){animation:p5-view-in .13s cubic-bezier(.2,.7,.2,1) both}
}

/* PASS 5.1 — PRODUCTION HARDENING
   Target: remove small-touch, microtype, focus, overlay, and state-feedback defects
   without changing the Pass 5 information architecture. */
.form-feedback{min-height:1.05rem;margin-top:.42rem;font:650 .56rem/1.35 var(--font-ui);color:#6d4e35}
.form-feedback:empty{min-height:0;margin-top:0}
#save-state.save-error,.pass5-mobile-context__status.save-error{color:#d09a91!important}
#save-state.save-error i,.pass5-mobile-context__status.save-error i{background:#b86a6d!important;box-shadow:0 0 0 2px rgba(184,106,109,.14)}
.media-panel__image-wrap img.is-zoomed{cursor:grab;touch-action:none}
.media-panel__image-wrap img.is-zoomed:active{cursor:grabbing}
.document-modal,.search-panel,.settings-panel,.compare-panel,.media-panel,.document-inspector,.pass5-more-sheet{overscroll-behavior:contain}
body.case-overlay-open .pass5-bottom-nav{filter:saturate(.82) brightness(.82)}

@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  /* Touch targets: smart interfaces should never require precision tapping. */
  .filter-button,.pass5-quick-chip,.reference-chip,.person-file__footer select,.evidence-tray__compare,
  .primary-button,.quiet-button,.media-tool,.dossier-jumpbar button{min-height:44px!important}
  .filter-button{padding:8px 10px;font-size:.64rem}
  .pass5-quick-chip{padding:8px 11px;font-size:.64rem}
  .pass5-quick-chip span{font-size:.5rem}
  .person-file__footer select{font-size:.61rem;padding-inline:.5rem}
  .dossier-jumpbar button{padding:9px 12px;font-size:.5rem}
  .media-tool{padding:7px 11px;font-size:.54rem}

  /* Eliminate microtype that looked polished but was too small to read reliably. */
  .archive-row__thumb small{font-size:.46rem}
  .archive-row__main .kicker{font-size:.49rem;line-height:1.25}
  .archive-mobile-meta{font-size:.54rem;line-height:1.35}
  .record-state{font-size:.46rem}.record-mark{font-size:.43rem}
  .person-file__control{font-size:.46rem;line-height:1.35}
  .person-file__role{font-size:.63rem}
  .poi-factline{font-size:.55rem;line-height:1.35}
  .person-file dt{font-size:.44rem;line-height:1.25}
  .person-file dd{font-size:.64rem;line-height:1.32}
  .poi-question{font-size:.61rem;line-height:1.4}
  .dossier-title .dossier-subline{font-size:.66rem}
  .dossier-title p.small{font-size:.63rem;line-height:1.35}
  .dossier-section-head h2{font-size:.58rem}
  .dossier-field{font-size:.72rem;line-height:1.45}
  .dossier-field span{font-size:.46rem;line-height:1.25}
  .evidence-status-card span{font-size:.47rem}
  .evidence-status-card li{font-size:.66rem}
  .dossier-media-card figcaption strong{font-size:.58rem}
  .dossier-media-card figcaption small{font-size:.46rem;line-height:1.35}
  .document-record-strip div span{font-size:.44rem}
  .document-record-strip div strong{font-size:.58rem}
  .document-modal__identity span{font-size:.44rem}
  .document-modal__identity strong{font-size:.73rem}
  .document-mobile-actions button small{font-size:.52rem}
  .evidence-tray__label{font-size:.44rem}
  .evidence-tray__item{font-size:.56rem}

  /* Audio: put the transport controls on their own comfortable row so the waveform
     remains usable instead of becoming a narrow strip beside tiny controls. */
  .audio-evidence-transport{grid-template-columns:1fr!important;grid-template-rows:auto auto auto;gap:8px;padding:11px 9px 9px}
  .audio-primary-controls{grid-row:auto;grid-column:1;justify-content:flex-start;gap:8px}
  .audio-jump{width:44px;height:44px;font-size:.52rem}
  .audio-primary-controls .audio-play{width:46px;height:46px;flex:0 0 46px;font-size:.78rem}
  .audio-wave{grid-column:1;height:58px;min-width:0}
  .audio-review-controls{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px}
  .audio-review-controls label{font-size:.52rem;display:inline-flex;align-items:center;gap:6px}
  .audio-review-controls select{min-height:38px;font-size:.59rem}
  .audio-note-current{min-height:38px;padding:6px 12px;background:#2b3433;color:#dfdcd3;border:1px solid #505c58;border-radius:3px;font:600 .54rem var(--font-mono);cursor:pointer}
  .audio-note-current:active{background:#3c4847}
  .audio-review-controls>span{width:100%;text-align:left;font-size:.48rem;color:#8c9893}
  .audio-event-row{min-height:44px;grid-template-columns:28px 62px 1fr;padding:8px}
  .audio-event-row span{font-size:.47rem}.audio-event-row strong{font-size:.52rem}.audio-event-row em{font-size:.61rem}
  .audio-transcript-row{min-height:44px;grid-template-columns:56px 52px minmax(0,1fr);padding:8px}
  .audio-transcript-row time{font-size:.51rem}.audio-transcript-row strong{font-size:.49rem}.audio-transcript-row span{font-size:.61rem}

  /* Clear focused states on dark evidence surfaces. */
  .document-modal button:focus-visible,.media-panel button:focus-visible,.compare-panel button:focus-visible,
  .pass5-bottom-nav button:focus-visible,.pass5-more-sheet button:focus-visible{outline:2px solid #e6cc87;outline-offset:2px}

  /* Large text mode should remain usable without creating sideways scrolling. */
  body.large-text .archive-row{grid-template-columns:56px minmax(0,1fr) 52px}
  body.large-text .person-file{grid-template-columns:96px minmax(0,1fr)}
  body.large-text .dossier-cover{grid-template-columns:96px minmax(0,1fr)}
  body.large-text .document-modal__identity strong{max-width:150px}
}

/* High contrast must also cover Pass 5 hardcoded surfaces, not just global tokens. */
body.high-contrast .pass5-more-sheet,
body.high-contrast .search-panel,
body.high-contrast .settings-panel,
body.high-contrast .document-inspector{background:#fff;color:#000;border-color:#000}
body.high-contrast .archive-row,
body.high-contrast .person-file,
body.high-contrast .notebook-page,
body.high-contrast .connection-form{background:#fff!important;color:#000!important;border-color:#000!important}
body.high-contrast .pass5-quick-chip,
body.high-contrast .filter-button,
body.high-contrast .dossier-jumpbar button{background:#fff!important;color:#000!important;border-color:#000!important}
body.high-contrast .pass5-quick-chip.active,
body.high-contrast .filter-button.active,
body.high-contrast .dossier-jumpbar button.pass5-active{background:#000!important;color:#fff!important}
body.high-contrast .form-feedback{color:#000;font-weight:800}

/* PASS 5.2 — VISUAL CERTIFICATION / SEMANTIC POLISH */
.evidence-tray__slot{display:grid;grid-template-columns:minmax(0,1fr) 38px;min-width:0;border:1px solid #4c5355;background:#2b3335}
.evidence-tray__slot .evidence-tray__item{border:0;background:transparent;width:100%;min-width:0;padding:7px 8px;color:#e8e3d7}
.evidence-tray__remove{border:0;border-left:1px solid #4c5355;background:#252d2f;color:#c6cecb;font:700 1rem var(--font-ui);display:grid;place-items:center;min-width:38px}
.evidence-tray__remove:hover,.evidence-tray__remove:focus-visible{background:#343d3f;color:#fff}

@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  /* Horizontal rails should read as deliberate, swipeable controls rather than clipped layouts. */
  .pass5-quick-rail,.archive-filter-rail,.notebook-tabs,.dossier-jumpbar{scroll-snap-type:x proximity;overscroll-behavior-x:contain}
  .pass5-quick-rail>* ,.archive-filter-rail>* ,.notebook-tabs>* ,.dossier-jumpbar>*{scroll-snap-align:start}
  .pass5-quick-rail,.archive-filter-rail{padding-right:22px}
  .pass5-quick-rail{-webkit-mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 20px),transparent 100%);mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 20px),transparent 100%)}
  .archive-filter-rail{-webkit-mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 18px),transparent 100%);mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 18px),transparent 100%)}
  .notebook-tabs,.dossier-jumpbar{-webkit-mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 14px),transparent 100%);mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 14px),transparent 100%)}
  .pass5-quick-chip{min-width:44px}
  .notebook-tab{min-height:44px!important}

  /* Evidence reader details sheet: make dismissal unmistakably touch-safe. */
  .pass5-inspector-close{height:48px;min-height:48px!important;padding:0 8px;font-size:.7rem;letter-spacing:.01em;border-bottom:1px solid #aaa295}
  .pass5-inspector-close::after{content:"";display:inline-block;width:7px;height:7px;margin-left:7px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-2px)}

  /* Compare tray uses adjacent controls, never an interactive element nested in another control. */
  .evidence-tray__items{display:flex;gap:4px}
  .evidence-tray__slot{flex:1;min-width:0;grid-template-columns:minmax(0,1fr) 42px}
  .evidence-tray__slot .evidence-tray__item{font-size:.56rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:6px}
  .evidence-tray__slot .evidence-tray__item span{font-size:.4rem}
  .evidence-tray__remove{min-width:42px;min-height:44px;font-size:1.05rem}

  /* Avoid visual collision between persistent tray and primary navigation. */
  .evidence-tray{box-shadow:0 11px 34px rgba(0,0,0,.34);border-color:#596164}

  /* Small status labels remain secondary but readable on a phone. */
  .pass5-result-count{font-size:.5rem}
  .pass5-mobile-context__status{font-size:.46rem}

  /* Provide breathing room around the compact record counter. */
  .pass5-doc-position{font-size:.48rem;letter-spacing:.045em;max-width:92px;text-align:right;line-height:1.2}
}

@media(max-width:360px){
  .pass5-doc-position{max-width:76px;font-size:.44rem}
  .document-modal__identity strong{max-width:145px}
}

body.high-contrast .evidence-tray__slot,
body.high-contrast .evidence-tray__remove{border-color:#fff!important}
body.high-contrast .evidence-tray__remove{background:#000!important;color:#fff!important}

/* Mobile comparison is an A/B review surface, not a long stacked imitation of desktop split view. */
.compare-mobile-switch{display:none}
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .compare-mobile-switch{position:sticky;top:0;z-index:8;display:grid;grid-template-columns:1fr 1fr;background:#151b1d;border-bottom:1px solid #4b5455;padding:6px;gap:5px}
  .compare-mobile-switch button{min-height:44px;border:1px solid #4a5354;background:#242c2e;color:#aeb8b4;text-align:left;padding:6px 9px;font:700 .52rem var(--font-mono);letter-spacing:.035em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .compare-mobile-switch button span{display:inline-grid;place-items:center;width:21px;height:21px;margin-right:6px;border:1px solid #5d6667;color:#d8d2c5}
  .compare-mobile-switch button.active{background:#ede6d8;color:#202627;border-color:#b9a66f;box-shadow:inset 0 -2px #b99d53}
  .compare-mobile-switch button.active span{border-color:#8c7740;color:#5c4b20}
  .compare-column.compare-mobile-hidden{display:none!important}
  .compare-column__label{top:56px}
}

/* Final finger-target certification */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .document-inspector button{min-height:44px}
  .media-tool{min-width:44px!important;padding-left:10px;padding-right:10px}
  .toggle-row{min-height:56px;cursor:pointer}
  .toggle-row input[type="checkbox"]{width:22px;height:22px;min-width:22px;accent-color:#263032}
}


/* PASS 5.3 — DEEP DEFECT HARDENING
   These rules repair interaction defects found under repeated-use, small-screen,
   keyboard, accessibility and long-session stress testing. */

/* Overlay/view transitions must never expose the workspace underneath as a flash. */
@keyframes p53-view-in{from{opacity:.94;transform:translateY(3px)}to{opacity:1;transform:none}}
body.pass5-view-transition #workspace>*{animation:p53-view-in .11s cubic-bezier(.2,.7,.2,1) both}
.document-modal:not(.hidden),.media-panel:not(.hidden),.compare-panel:not(.hidden),.search-panel:not(.hidden),.settings-panel:not(.hidden){animation:p53-view-in .1s cubic-bezier(.2,.7,.2,1) both}

/* Query filtering happens in place. This avoids rebuilding the entire registry while typing. */
.archive-row.archive-query-filtered{display:none!important}

/* A class intended for phone-only UI must stay hidden above the mobile breakpoint even
   when a later component rule sets display. */
@media(min-width:761px){.mobile-only{display:none!important}}

/* Consistent keyboard visibility without adding a permanent "selected" ring after touch. */
button:focus:not(:focus-visible),[role="button"]:focus:not(:focus-visible){outline:none}
button,[role="button"],[data-open-doc],[data-open-suspect]{touch-action:manipulation}

@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  /* Do not use content-visibility on long dossier sections. Their real heights drive
     the sticky section spy, scroll restoration and jump navigation. */
  .dossier-section{content-visibility:visible!important;contain-intrinsic-size:auto!important}

  /* All task-critical text/actions use an actual finger-safe hit area. */
  .desk-principle button,.desk-section__head button,.incoming-return button,
  .timeline-open,.hint-reveal,.related-evidence button,.movement-ledger-row button,
  .statement-change header button,.corroboration-chip,.audio-note-current,
  .inspector-file,.search-result button{min-height:44px!important}
  .timeline-open,.hint-reveal,.related-evidence button,.movement-ledger-row button,
  .statement-change header button{display:inline-flex;align-items:center;padding:8px 6px!important;line-height:1.25}
  .corroboration-chip{padding-top:8px!important;padding-bottom:8px!important}
  .dossier-status-select,.suspect-status-select{min-height:44px!important}
  .audio-note-current{padding:8px 10px!important}

  /* The waveform marker looks like a precise line while retaining a usable hit target. */
  .audio-marker{width:44px!important;margin-left:-22px!important;background:transparent!important;border:0!important;top:-3px!important;bottom:-4px!important}
  .audio-marker::before{content:"";position:absolute;left:calc(50% - .5px);top:0;bottom:0;width:1px;background:#b29a64}
  .audio-marker::after{left:calc(50% - 3.5px)!important;top:-3px!important}
  .audio-marker span{left:calc(50% + 5px)!important}

  /* Horizontal control rails are intentionally swipeable and have usable trailing room. */
  .pass5-quick-rail,.archive-filter-rail,.notebook-tabs,.dossier-jumpbar{scroll-padding-inline:8px 34px;padding-right:30px!important}

  /* Board controls communicate unavailable actions instead of presenting dead controls. */
  #clear-board-selection:disabled,#save-connection:disabled{opacity:.46;cursor:not-allowed}

  /* Safe-area support on notched devices and landscape phones. */
  .topbar{padding-left:max(10px,env(safe-area-inset-left));padding-right:max(10px,env(safe-area-inset-right))}
  .workspace{padding-left:max(10px,env(safe-area-inset-left));padding-right:max(10px,env(safe-area-inset-right))}
  .mobile-bottom-nav{padding-left:max(5px,env(safe-area-inset-left));padding-right:max(5px,env(safe-area-inset-right))}
  .pass5-more-sheet{padding-left:max(14px,env(safe-area-inset-left));padding-right:max(14px,env(safe-area-inset-right))}

  /* Text entry surfaces must not be visually ambiguous or cramped. */
  .connection-form textarea,.annotation-box,#dossier-note,.suspect-note-card textarea,
  .contradiction-form textarea,.notebook-textarea{font-size:max(.76rem,16px);line-height:1.5}
}

body.high-contrast .timeline-open,
body.high-contrast .hint-reveal,
body.high-contrast .movement-ledger-row button,
body.high-contrast .related-evidence button,
body.high-contrast .statement-change header button{color:#000!important;text-decoration:underline;text-underline-offset:3px}


/* PASS 5.3B — MOBILE INPUT, DETAILS, AND VIEWPORT HARDENING */
#document-inspector[aria-modal="true"]{box-shadow:0 -24px 64px rgba(0,0,0,.46)}
@supports(height:100dvh){#app-shell{height:100dvh}.paper-document{min-height:calc(100dvh - 142px)}.notebook-page{min-height:calc(100dvh - 190px)}}
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  /* Prevent iOS from zooming the whole interface when a detective focuses a small field. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),select,textarea{font-size:16px!important}
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),select{min-height:44px}
  #dossier-status-select{min-height:44px!important;font-size:16px!important}
  .accusation-form .filter-row .tag{min-height:44px;display:inline-flex;align-items:center;gap:7px;padding:7px 9px}
  .accusation-form .filter-row input[type="checkbox"]{width:22px;height:22px;min-width:22px;accent-color:#263032}
  body.pass5-keyboard-open .mobile-bottom-nav,body.pass5-keyboard-open .evidence-tray{transform:translateY(120%);pointer-events:none}
  body.pass5-keyboard-open .workspace{padding-bottom:14px}
  body.pass5-keyboard-open .search-panel{bottom:0}
  body.pass5-keyboard-open .pass5-toast-region{bottom:12px}
  .mobile-bottom-nav,.evidence-tray{transition:transform .12s ease}
}

/* Coarse-pointer phone landscape stays in the mobile product instead of falling into desktop chrome. */
@media (pointer:coarse) and (max-height:520px) and (max-width:980px){
  .mobile-only{display:inline-grid!important}
  .desktop-only{display:none!important}
  #nav-toggle{display:none!important}
  .pass5-more-sheet,.pass5-sheet-backdrop,.pass5-toast-region{display:block}
  .pass5-sheet-backdrop.hidden,.pass5-more-sheet.hidden{display:none!important}
}


/* PASS 5.3C — SAFE-AREA / SYSTEM-UI CERTIFICATION */
@media (max-width:760px), (pointer:coarse) and (max-height:520px) and (max-width:980px){
  #app-shell{grid-template-rows:calc(56px + env(safe-area-inset-top)) minmax(0,1fr)}
  .topbar{height:calc(56px + env(safe-area-inset-top));padding-top:env(safe-area-inset-top)}
  .search-panel{top:calc(56px + env(safe-area-inset-top));bottom:calc(var(--p5-bottom-nav) + env(safe-area-inset-bottom))}
  .settings-panel{top:calc(56px + env(safe-area-inset-top))}
  .document-modal{grid-template-rows:calc(52px + env(safe-area-inset-top)) minmax(0,1fr) calc(66px + env(safe-area-inset-bottom))}
  .document-modal.dossier-mode{grid-template-rows:calc(52px + env(safe-area-inset-top)) minmax(0,1fr)}
  .document-modal__toolbar{height:calc(52px + env(safe-area-inset-top));padding-top:calc(5px + env(safe-area-inset-top))}
  .pass5-reading-progress{top:calc(52px + env(safe-area-inset-top))}
  .document-mobile-actions{height:calc(66px + env(safe-area-inset-bottom))}
  .media-panel__header,.compare-panel__header{padding-top:calc(7px + env(safe-area-inset-top));min-height:calc(52px + env(safe-area-inset-top))}
  body.pass5-keyboard-open .search-panel{bottom:0}
}
