/* ============================================================================
 * screens-v6.css — APP SHELL + INDEX SCREENS  (Home · Crane · File · Manuals ·
 * Search · Settings). Loaded after styles.css + styles/app-v6.css.
 *
 * Contract: compose the v6 tokens/components from app-v6.css. No new tokens, no
 * re-declared colours, no font-size below 12px, nothing that hides a safety
 * line. Class prefixes owned here: .scr-*, .segctl, .setrow, .register.
 * ==========================================================================*/

/* ---------------------------------------------------------- 1. SHELL / A11Y */
/* Class rules like .linkbtn{display:block} beat the UA [hidden] rule, so
 * hidden affordances were rendering (measured: "Remove offline pack" showed on
 * a crane with no pack). Enforce the attribute. */
[hidden]{display:none!important}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
/* AUDIT P1: pull-to-refresh reloaded mid-thread; double-tap zoom fought taps. */
html,body{overscroll-behavior-y:contain}
body{touch-action:manipulation}
/* Clearance for the floating chat FAB so it never covers the last row. */
.scr-pad{height:calc(var(--tap) + var(--s5))}
@media (min-width:700px){.scr-pad{height:var(--s5)}}
/* The Ask FAB (chat.js) duplicated the always-visible Ask tab on the index
 * routes and sat on the rows' primary actions (critic P1: Manuals Save,
 * Settings Download, File/Crane chevrons). It stays inside a thread only. */
body[data-route="file"] #chatfab,
body[data-route="manuals"] #chatfab,
body[data-route="settings"] #chatfab,
body[data-route="crane"] #chatfab{display:none}

/* ------------------------------------------------------- 2. HERO / SECTIONS */
.scr-hero{padding:var(--s5) 0 var(--s3)}
.scr-hero h1{margin:0}
.scr-hero .hsub{margin:var(--s2) 0 0}
.scr-hero .hsub .off{color:var(--danger-ink);font-weight:600}
.scr-hero .badges{margin:var(--s3) 0 0}
.badges>*+*::before{content:none}
.sechead{display:flex;align-items:baseline;gap:var(--s3);justify-content:space-between;
  margin:var(--s5) 0 var(--s2);padding:0}
.sechead .sec{margin:0;padding:0}
.seccount{font-size:12px;line-height:16px;color:var(--dim);font-weight:600;
  font-variant-numeric:tabular-nums;white-space:nowrap;flex:none}
.inset{background:var(--surface);border:1px solid var(--hair);border-radius:var(--r-card);
  padding:0 var(--gutter);box-shadow:var(--e1)}
.inset .row{border-bottom:1px solid var(--hair)}
.inset>.row:last-child,.inset>*:last-child .row:last-child{border-bottom:0}

/* ------------------------------------------------------------ 3. HOME */
.scr-cont{margin:0 0 var(--s5)}
.contcard{grid-template-columns:1fr auto;align-items:center;row-gap:0;
  text-decoration:none;color:var(--txt)}
.contcard .contlead{grid-column:1;font-size:12px;line-height:16px;font-weight:600;
  letter-spacing:.06em;text-transform:uppercase;color:var(--acc-ink)}
.contcard .conttitle{grid-column:1;font-size:20px;line-height:26px;font-weight:600;
  letter-spacing:-.015em;overflow-wrap:anywhere}
.contcard .contsub{grid-column:1}
.contcard .chev{grid-column:2;grid-row:1/4;align-self:center}
.contacts{display:grid;grid-template-columns:1fr 1fr;gap:var(--s2);margin:var(--s2) 0 0}
.contacts .btn{font-size:15px}
.sicon{position:absolute;left:var(--s4);top:50%;transform:translateY(-50%);
  width:20px;height:20px;color:var(--mut);pointer-events:none}
.sicon svg{width:20px;height:20px;display:block}
.searchbar .srow{position:relative}
.searchbar .srow input{padding-left:calc(var(--s4) + 26px)}
.scopechips{margin:var(--s2) 0 0}
/* Equal tile height: the meta is a 2-line slot so 9-section and 1-section
 * cranes do not produce two different tile rhythms. */
.tile .meta{min-height:36px}
.tile .ring{background:var(--surface);border-width:2px}
/* not-downloaded is the DEFAULT, not an error: neutral ring, never red. */
.tile .ring.off{border-color:var(--n-300)}
.tile .ring.mid{border-color:var(--acc)}
.tile .ring.half{border-color:var(--acc);border-style:dashed}
.tile .foot:empty{display:none}
.scr-offline-line{margin:0 0 var(--s2);font-size:13px;line-height:18px;color:var(--mut)}
.scr-offline-line.warn{color:var(--warn-ink)}
.scopechips .chip{min-height:44px;font-size:13px;padding:0 var(--s3);flex:0 0 auto}
.scr-sec .sechead{margin-top:var(--s5)}
.scr-foot{margin:var(--s6) 0 0;padding-bottom:var(--s4)}
.scr-foot a{display:inline-flex;align-items:center;min-height:44px;color:var(--acc-ink);
  font-weight:600;text-decoration:none}
.scr-empty{border:1px dashed var(--hair-2);border-radius:var(--r-card);
  padding:var(--s6) var(--s5);margin:var(--s2) 0 0}
.empty .eicon{color:var(--dim);margin-bottom:var(--s1)}
.empty .eicon svg{width:34px;height:34px;display:block}
.empty .row{display:flex;gap:var(--s2);width:100%;margin-top:var(--s3)}
.empty .row .btn{flex:1}

/* -------------------------------------------------------- 4. SEGMENTED CTRL */
.segctl{display:flex;gap:0;padding:2px;margin:var(--s2) 0 var(--s4);
  background:var(--surface-3);border:1px solid var(--hair);border-radius:var(--r-sm)}
.segctl button{flex:1 1 0;min-width:0;min-height:44px;padding:8px var(--s2);
  background:transparent;border:0;border-radius:calc(var(--r-sm) - 2px);
  color:var(--mut);font-size:15px;font-weight:600;cursor:pointer;
  transition:transform var(--dur-1) var(--spring),background var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease)}
.segctl button[aria-selected="true"]{background:var(--surface);color:var(--txt);
  box-shadow:var(--e1)}
.segctl button:active{transform:scale(.97)}
.panel{padding-bottom:var(--s2)}

/* ------------------------------------------------------------ 5. CRANE */
.skhero{display:flex;flex-direction:column;gap:var(--s2);padding:var(--s5) 0 var(--s3)}
.skeleton-list .skrow{display:flex;align-items:center;gap:var(--s3);
  border-bottom:1px solid var(--hair);padding:10px 0}
.skeleton-list .skrow .skl{margin:0;height:14px}
.scr-offline{padding:var(--s4)}
.offhead{display:flex;align-items:center;gap:var(--s3);margin-bottom:var(--s4)}
.ringwrap{flex:none;width:52px;height:52px;display:block}
.ringwrap.small{width:36px;height:36px}
.progring{width:100%;height:100%;display:block}
.offtxt{min-width:0}
.offtxt b{display:block;font-size:17px;line-height:22px;font-weight:600;
  letter-spacing:-.015em}
.offtxt small{display:block;color:var(--mut);font-size:13px;line-height:18px;
  font-variant-numeric:tabular-nums;margin-top:1px}
#storline{margin:var(--s2) 0 0}
#delpack{margin-top:var(--s1)}

/* ------------------------------------------------- 6. FILE (sheet register) */
.scr-filehead{position:sticky;top:calc(var(--topbar-h) + env(safe-area-inset-top));
  z-index:4;background:var(--bg);padding:var(--s2) 0 var(--s2);margin:0 0 var(--s1)}
.scr-filehead .sechead{margin:0 0 var(--s2)}
.filetools{display:grid;grid-template-columns:1fr;gap:var(--s2)}
@media (min-width:420px){.filetools{grid-template-columns:1fr 132px}}
.filetools .fixin{min-height:44px;font-size:15px;padding:0 var(--s3);
  border-color:var(--hair);background:var(--surface)}
.filetools .fjump{font-family:var(--f-mono);font-variant-numeric:tabular-nums;
  text-align:center}
/* .row already draws a chevron span; .sheetrow adds ::after — keep ONE. */
.row.sheetrow::after{content:none}
.register{list-style:none;margin:0;padding:0}
.register li{--reg-w:52px}
.regrow{min-height:60px;gap:var(--s3);align-items:center}
.reg{flex:none;width:var(--reg-w);font-family:var(--f-mono);
  font-variant-numeric:tabular-nums;font-size:13px;font-weight:700;color:var(--acc-ink)}
.regrow .rtxt b{font-size:17px;line-height:22px}
.regrow .rtxt small{font-size:13px;line-height:18px;color:var(--mut)}
.locchip{flex:none;font-family:var(--f-mono);font-variant-numeric:tabular-nums;
  font-size:12px;font-weight:600;color:var(--mut);background:var(--surface-2);
  border-radius:var(--r-xs);padding:3px var(--s2);min-height:22px;display:inline-flex;
  align-items:center}
.register li.hit{background:var(--acc-weak);border-radius:var(--r-sm)}
.register li.hit .reg{color:var(--acc-ink)}
.register li[hidden]{display:none}

/* ---------------------------------------------------------- 7. MANUALS */
.scr-toolbar{display:flex;align-items:center;justify-content:space-between;gap:var(--s3);
  margin:var(--s3) 0 var(--s1)}
.scr-toolbar .chip{min-height:44px}
.scr-mrow{display:flex;align-items:stretch;border-bottom:1px solid var(--hair);
  background:var(--surface);transition:background var(--dur-1) var(--ease-out)}
.scr-mrow:last-child{border-bottom:0}
.scr-mrow[hidden]{display:none}
.scr-mrow-main{flex:1;min-width:0;display:flex;align-items:center;gap:var(--s3);
  min-height:64px;padding:10px 0;color:var(--txt);text-decoration:none}
.scr-mrow-main .rtxt{flex:1;min-width:0}
.scr-mrow-main .rtxt b{display:block;font-size:17px;line-height:22px;font-weight:600;
  letter-spacing:-.015em;overflow-wrap:anywhere}
.scr-mrow-main .rtxt small{display:block;color:var(--mut);font-size:13px;line-height:18px;
  margin-top:1px}
/* Document numbers sit INSIDE the meta line (mono, tabular). A separate
 * trailing cell collided with wrapped titles at 320-390px. */
.docno{font-family:var(--f-mono);font-variant-numeric:tabular-nums;
  font-size:12px;font-weight:600;color:var(--dim)}
.scr-mrow-act{flex:none;align-self:center;min-width:64px;min-height:44px;padding:0 var(--s2);
  background:transparent;border:0;border-radius:var(--r-sm);color:var(--acc-ink);
  font-size:15px;font-weight:600;cursor:pointer;
  transition:transform var(--dur-1) var(--spring),background var(--dur-1) var(--ease)}
.scr-mrow-act:active{background:var(--surface-2);transform:scale(.97)}
.scr-mrow-act.on{color:var(--ok-ink);font-weight:700}
.scr-mrow-act:disabled{opacity:1;cursor:default}
.scr-mrow:active{background:var(--surface-2)}

/* ----------------------------------------------------------- 8. SEARCH */
.result{padding:0;overflow:hidden}
.result .rhit{display:block;padding:12px var(--s4);color:var(--txt);text-decoration:none}
.result .rhit:active{background:var(--surface-2)}
.result .rhead{display:flex;align-items:baseline;gap:var(--s2);min-width:0}
.result .rhead .tag{margin:0;flex:none}
.result .rnum{font-family:var(--f-mono);font-variant-numeric:tabular-nums;
  font-size:15px;font-weight:700;color:var(--acc-ink);flex:none}
.result .rmeta{font-size:12px;line-height:16px;color:var(--mut);
  font-variant-numeric:tabular-nums;margin-left:auto;flex:none;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.result .t{display:block;margin-top:2px}
.result .m,.result .s,.result .why{display:block}
.result .why{color:var(--mut);font-size:12px;line-height:16px;margin-top:var(--s1);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.racts{display:flex;gap:var(--s2);padding:0 var(--s4) var(--s3)}
.racts .chip{min-height:44px;font-size:13px;padding:0 var(--s3);gap:6px;
  color:var(--acc-ink);background:var(--acc-weak);border-color:transparent}
.racts .chip svg{width:16px;height:16px;flex:none}
.scr-progress{background:var(--surface);border:1px solid var(--hair);
  border-radius:var(--r-card);padding:var(--s3) var(--s4);box-shadow:var(--e1)}
.pgrow{display:flex;align-items:center;justify-content:space-between;gap:var(--s3);
  margin-bottom:var(--s2)}
.pgtext{font-size:15px;font-weight:600;color:var(--txt)}
.scr-progressline{display:flex;align-items:center;gap:var(--s3);justify-content:space-between;
  font-size:13px;line-height:18px;color:var(--mut);margin:var(--s2) 0 0}
.scr-progressline .chip{min-height:44px;flex:none}
.scr-progress .chip{min-height:44px}

/* Sheet action row (P0, critic): `.btn{width:100%}` inside the flex setrow
 * gave the button a 100% flex-basis and squeezed `.stxt` to 0 width, so the
 * label broke one character per line and Cancel fell below the fold. */
.sheet .setrow{align-items:center}
.sheet .setrow .stxt{flex:1 1 auto;min-width:0}
.sheet .setrow .btn{width:auto;flex:0 0 auto;min-width:112px}
.sheet .btn.ghost{width:100%}

/* ---------------------------------------------------------- 9. SETTINGS */
.setrow{display:flex;align-items:center;gap:var(--s3);min-height:52px;
  padding:10px var(--gutter);border-bottom:1px solid var(--hair);
  color:var(--txt);text-decoration:none}
.inset>.setrow:last-child{border-bottom:0}
.setrow .stxt{flex:1;min-width:0}
.setrow .stxt b{display:block;font-size:17px;line-height:22px;font-weight:600;
  letter-spacing:-.015em;overflow-wrap:anywhere}
.setrow .stxt small{display:block;color:var(--mut);font-size:13px;line-height:18px;margin-top:1px}
.setval{flex:none;color:var(--mut);font-size:15px;font-weight:600;text-align:right;
  max-width:46%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.setval.wrap{white-space:normal;overflow-wrap:anywhere;max-width:52%;font-size:13px;
  line-height:18px}
.setrow:active{background:var(--surface-2)}
.segmini{flex:none;display:flex;padding:2px;background:var(--surface-2);
  border-radius:var(--r-sm);gap:0}
.segmini button{min-width:64px;min-height:44px;padding:0 var(--s2);border:0;
  border-radius:calc(var(--r-sm) - 2px);background:transparent;color:var(--mut);
  font-size:15px;font-weight:600;cursor:pointer;
  transition:background var(--dur-2) var(--ease),color var(--dur-2) var(--ease)}
.segmini button[aria-pressed="true"]{background:var(--surface);color:var(--txt);
  box-shadow:var(--e1)}
.segmini button:active{transform:scale(.97)}
.swbtn{flex:none;width:56px;height:44px;display:flex;align-items:center;
  justify-content:flex-end;background:transparent;border:0;padding:0;cursor:pointer}
.swbtn .sw{width:46px;height:28px;border-radius:var(--r-pill);background:var(--surface-3);
  position:relative;transition:background var(--dur-2) var(--ease)}
.swbtn .sw::after{content:"";position:absolute;top:2px;left:2px;width:24px;height:24px;
  border-radius:50%;background:var(--surface);box-shadow:var(--e1);
  transition:transform var(--dur-2) var(--spring)}
.swbtn[aria-checked="true"] .sw{background:var(--ok-ink)}
.swbtn[aria-checked="true"] .sw::after{transform:translateX(18px)}
.swbtn:active .sw{transform:scale(.95)}
.offrow .stxt b{font-size:17px}
/* Shimmer: the v6 pair (surface-2 → surface-3) is a ~1.6% step on the light
 * canvas, i.e. invisible (critic). One darker stop reads as a loading block. */
.skl,.skeleton{
  background:linear-gradient(90deg,var(--surface-3) 25%,
    color-mix(in srgb,var(--txt) 9%,var(--surface-3)) 37%,var(--surface-3) 63%);
  background-size:400% 100%}
body.contrast .skl,body.contrast .skeleton{background:#333}
.scr-plate{margin:var(--s2) 0 var(--s3);line-height:1.6}
.warnplate{border-left:3px solid var(--warn);font-family:var(--f);font-size:13px;
  line-height:1.5;color:var(--txt)}
.warnplate b{font-size:15px}
.scr-sup{overflow-wrap:anywhere;user-select:all;margin:var(--s2) 0 0}
#dlall{margin:var(--s3) 0 0}
#offhint{margin:var(--s2) 0 0}

/* ------------------------------------------------------- 10. STATES/A11Y */
/* Text size = Large must step EVERY route (critic: Manuals/Settings changed one
 * 12px header, elsewhere <=1px). app-v6's ramp re-values the --fs-* tokens and
 * the rules that use them; these are the screens layer's hardcoded sizes. */
body.bigtype .scr-hero h1{font-size:38px;line-height:44px}
body.bigtype .scr-hero .hsub{font-size:18px;line-height:26px}
body.bigtype .seccount{font-size:14px;line-height:20px}
body.bigtype .tile .code{font-size:32px;line-height:38px}
body.bigtype .tile .meta{font-size:16px;line-height:22px;min-height:44px}
body.bigtype .tile .badge{font-size:14px}
body.bigtype .contcard .contlead{font-size:14px;line-height:20px}
body.bigtype .contcard .conttitle{font-size:24px;line-height:30px}
body.bigtype .contcard .contsub{font-size:16px;line-height:22px}
body.bigtype .segctl button,body.bigtype .segmini button{font-size:17px}
body.bigtype .scopechips .chip{font-size:15px}
body.bigtype .searchbar input,body.bigtype .srow input,body.bigtype .fixin{font-size:19px}
body.bigtype .reg{font-size:16px;width:var(--reg-w)}
body.bigtype .register li{--reg-w:64px}
body.bigtype .regrow .rtxt b,body.bigtype .scr-mrow-main .rtxt b,
body.bigtype .setrow .stxt b{font-size:20px;line-height:26px}
body.bigtype .regrow .rtxt small,body.bigtype .scr-mrow-main .rtxt small,
body.bigtype .setrow .stxt small{font-size:16px;line-height:22px}
body.bigtype .locchip,body.bigtype .docno{font-size:14px}
body.bigtype .scr-mrow-act{font-size:17px;min-width:72px}
body.bigtype .setval{font-size:17px}
body.bigtype .result .rnum{font-size:17px}
body.bigtype .result .rmeta,body.bigtype .result .why{font-size:14px;line-height:20px}
body.bigtype .racts .chip{font-size:15px}
body.bigtype .pgtext{font-size:17px}
body.bigtype #tabbar a{font-size:14px}
body.bigtype .scr-offline-line{font-size:15px;line-height:22px}
body.bigtype .offtxt b{font-size:20px;line-height:26px}
body.bigtype .offtxt small{font-size:16px;line-height:22px}
@media (prefers-reduced-motion:reduce){
  .segctl button,.scr-mrow-act,.scopechips .chip{transition:none}
}
/* Big type: keep the register column from colliding with long titles. */
body.bigtype .register li{--reg-w:64px}
body.bigtype .segmini button{min-width:72px}
/* Maximum contrast: everything opaque, no wash. */
body.contrast .inset,body.contrast .scr-offline,body.contrast .scr-progress,
body.contrast .scr-mrow,body.contrast .setrow,body.contrast .scr-empty{
  background:#000;border-color:#fff;box-shadow:none}
body.contrast .scr-mrow-act,body.contrast .segctl,body.contrast .segmini,
body.contrast .locchip,body.contrast .racts .chip{background:#000;color:#ff0;border-color:#fff}
body.contrast .reg,body.contrast .result .rnum,body.contrast .docno{color:#ff0}
body.contrast .tile .ring{border-color:#fff}
body.contrast .tile .ring.on{border-color:#0f0}
body.contrast .scopechips .chip[aria-pressed="true"],
body.contrast .segctl button[aria-selected="true"],
body.contrast .segmini button[aria-pressed="true"]{background:#ff0;color:#000}
body.contrast .scr-filehead{background:#000}
body.contrast .swbtn .sw{background:#000;border:1px solid #fff}
body.contrast .swbtn .sw::after{background:#fff}
body.contrast .swbtn[aria-checked="true"] .sw{background:#ff0}
body.contrast .swbtn[aria-checked="true"] .sw::after{background:#000}

/* --------------------------------------------------------- 11. RESPONSIVE */
/* P1 (critic): app-v6 reserves a 340px right rail for the chat dock in EVERY
 * short landscape viewport, leaving a 472px content column on all routes. This
 * file loads later, so re-scope it to the thread that actually has the dock. */
@media (min-width:600px) and (max-height:520px){
  #view{padding-right:var(--gutter)}
  body.inchat #view{padding-right:calc(340px + var(--gutter))}
  #tabbar{padding-right:var(--s2)}
  body.inchat #tabbar{padding-right:calc(340px + var(--gutter))}
  #chatfab{right:max(var(--s4),calc(50vw - 380px + var(--s4)))}
  body.inchat #chatfab{right:calc(340px + var(--gutter))}
  .chatmenu{right:max(var(--s4),calc(50vw - 380px + var(--s4)))}
  body.inchat .chatmenu{right:calc(340px + var(--gutter))}
  #toast{left:50%}
  body.inchat #toast{left:calc(50% - 170px)}
}
/* Short viewports (landscape phone / keyboard open): the large title must not
 * eat the whole screen — app-v6 already compacts the chrome at <=520px. */
@media (max-height:520px){
  .scr-hero{padding:var(--s2) 0 var(--s1)}
  .scr-hero h1{font-size:24px;line-height:30px}
  .scr-hero .hsub{margin-top:2px;font-size:13px;line-height:18px}
  .scr-hero .badges{margin-top:var(--s2)}
  .scr-cont{margin-bottom:var(--s3)}
  .segctl{margin:var(--s1) 0 var(--s2)}
  .scopechips{margin-top:var(--s1)}
  .sechead{margin:var(--s3) 0 var(--s1)}
  .scr-filehead{padding:var(--s1) 0}
  .scr-filehead .sechead{margin-bottom:var(--s1)}
  .tile .meta{min-height:0}
  .scr-hero,.panel{padding-bottom:var(--s1)}
}
@media (max-width:359px){
  /* Settings rows: give the label the full width and let the control wrap. */
  .setrow{flex-wrap:wrap;row-gap:var(--s2)}
  .setrow .stxt{flex:1 1 100%}
  .segmini,.swbtn{margin-left:auto}
  .scr-hero{padding-top:var(--s4)}
  .contacts{grid-template-columns:1fr}
  .register li{--reg-w:46px}
  .docno{display:none}
  .setrow{padding-left:var(--s3);padding-right:var(--s3)}
  .inset{padding:0 var(--s3)}
}
@media (min-width:700px){
  .scopechips .chip{min-height:44px;font-size:15px}
  .racts .chip{min-height:44px}
  .filetools{grid-template-columns:1fr 160px}
}
