/* Forge cockpit UI — desktop composition (approved 16:9 reference).
   Left column: Job decision queue over the Job location map. Right column: the Job workspace, full height and always on screen.
   Density amendment: the queue keeps dense 27px rows (18–20+ visible at 2560×1440) instead of the reference's ~10 large rows. */
@media(min-width:981px),(min-width:761px) and (pointer:fine){
  /* Header: menu, brand, search, status cells, tools */
  header{display:flex;flex-wrap:nowrap;align-items:center;gap:10px;min-height:64px;padding:0 14px 0 6px;border-bottom:1px solid var(--forge-line-strong);box-shadow:0 8px 26px #0003}
  header .menu-btn{order:0;min-width:44px;min-height:44px}
  header .brand{order:1;display:flex;flex-direction:column;justify-content:center;padding:0 22px 0 14px;margin-right:6px;border-right:1px solid var(--forge-line);font:600 22px/1 var(--sans);letter-spacing:3.5px;white-space:nowrap}
  header .brand small{display:block;margin-top:6px;font:10.5px/1 var(--mono);letter-spacing:3.2px;color:var(--forge-dim)}
  header #crumb{order:2;font:10.5px var(--mono);letter-spacing:1.4px;color:var(--forge-faint);white-space:nowrap}
  header #search{order:3;flex:1 1 520px;max-width:640px;height:42px;font-size:14px}
  header .writer-identity{order:5;margin-left:auto}
  header .build-identity{order:4}
  header .hstat{order:6}
  header #compare-open,header #density-toggle,header #refresh{order:7;min-height:34px;padding:0 10px;font-size:11px;background:transparent;border-color:var(--forge-line);color:var(--forge-dim)}
  header #compare-open{margin-left:8px}
  header #bell{order:8;margin-left:6px;border-left:1px solid var(--forge-line);border-radius:0;padding-left:8px;min-width:46px}
  header #settings{order:9;min-width:38px;min-height:38px;border-color:transparent;background:transparent;font-size:19px}
  header #layout-toggle{order:10}
  /* P3: one refresh control (the countdown chip) and a header that fits at 1440: middle items shrink, bell and gear stay on screen */
  header #refresh,#rail .rail-foot button#rail-refresh{display:none!important}
  header .writer-identity,header .hstat,header #crumb{flex:0 1 auto;min-width:0;overflow:hidden}header .brand{flex:none}
  header #search{flex-shrink:50}   /* GUI 15: the search box gives up width before any header text clips */
  @media(min-width:1400px){header .brand,header .writer-identity,header .hstat,header [data-refresh-now]{flex:none}}
  header #search{min-width:140px}
  header #bell,header #settings,header .menu-btn{flex:none}
  header [data-refresh-now]{cursor:pointer;min-height:24px;border:0;background:transparent;color:inherit;text-transform:none}

  /* Rail: 96px, label under each icon; hover or the menu button opens the sub-items */
  #rail{width:96px}#rail .rail-in{width:96px;padding-top:6px;border-right:1px solid var(--forge-line-strong)}
  #rail.open .rail-in{width:268px}
  #rail .rail-brand{height:44px;justify-content:center;padding:0}
  #rail button{height:52px;padding:0 22px;gap:16px;font-size:13.5px}
  #rail:not(.open) .rail-brand .rl{display:none}
  @media(hover:hover){
    #rail:hover .rail-in{width:268px}
    #rail:hover .rail-brand .rl{display:inline}
  }

  /* Pipeline view: queue + map | workspace */
  #view-pipeline.on,#view-pipeline.on:has(#drawer.on){display:grid!important;grid-template-columns:minmax(0,1fr) clamp(520px,35%,900px)!important;grid-template-rows:auto minmax(0,1.12fr) minmax(0,1fr)!important;column-gap:10px;row-gap:0;padding:10px;overflow:hidden!important}
  #dash{display:contents!important}
  #queue-head{grid-column:1;grid-row:1}
  #worksplit{grid-column:1;grid-row:2;height:auto!important;min-height:0;border:1px solid var(--forge-line);border-top:0}
  #job-map-card{grid-column:1!important;grid-row:3!important;min-height:0!important;max-height:none!important;height:auto!important;margin-top:10px}
  #drawer{grid-column:2!important;grid-row:1/4!important;position:relative!important;inset:auto!important;width:auto!important;min-width:0!important;max-width:none!important;display:flex!important;background:var(--forge-panel)}
  #drawer.on{animation:forge-drawer-in 240ms var(--forge-ease) both}
  @keyframes forge-drawer-in{from{opacity:.2;transform:translateX(16px)}to{opacity:1;transform:none}}

  /* Map card: title top-left, legend bottom-left, controls stacked on the right */
  #job-map-card .map-head{left:14px;top:12px}
  #job-map-card .map-legend{display:flex!important;left:14px;bottom:12px;gap:18px;font:14px var(--sans)}
  #job-map-card .map-legend .map-dot{width:12px;height:12px}
  #job-map-card .map-zoom{display:flex;flex-direction:column-reverse;right:12px;top:12px;bottom:auto;gap:6px;border:0;background:transparent}
  #job-map-card .map-zoom button{min-width:46px;min-height:44px;border:1px solid var(--forge-line-strong);background:#060808;font-size:18px}
  #job-map-card .map-zoom #map-zoom-level{min-height:28px;font:11px var(--mono);color:var(--forge-dim)}
  #job-map-card .map-layers{position:absolute;right:12px;top:184px;z-index:5;min-width:46px;min-height:44px;border:1px solid var(--forge-line-strong);background:#060808}
  #job-map-card.layers-open #mapfilters{right:66px;top:12px;left:auto}
  #job-map-card .map-actions{right:70px;bottom:12px}

  /* Table density: at least 18 rows at 2560×1440 inside the queue panel */
  #gridwrap{scrollbar-color:#46504e #070909;scrollbar-width:thin;overscroll-behavior:contain}
  #grid{font-size:12px;line-height:1.05}
  #grid th,#grid td{height:27px;min-height:27px;padding:2px 9px;vertical-align:middle;border-bottom:1px solid #1a201f}
  #grid th{height:32px;font:10.5px var(--mono);letter-spacing:1.3px;color:#b5beba;box-shadow:0 1px 0 #303837}
  #grid td{font-size:13px}#grid td.mono{font-size:12px}
  /* row height comes from fitRows_(): 19 rows where the queue has room, else 16, else 15 (rows down to 20px on the shortest windows) */
  body:not([data-density=comfortable]) #grid td{height:var(--row-h,27px);font-size:var(--row-font,13px);padding-top:1px;padding-bottom:1px}
  body:not([data-density=comfortable]) #grid td .rowlink,body:not([data-density=comfortable]) #grid td .score-badge{vertical-align:middle}body:not([data-density=comfortable]) #grid td .rowlink{height:min(22px,calc(var(--row-h,27px) - 4px))}body:not([data-density=comfortable]) #grid td .row-select{width:min(18px,calc(var(--row-h,27px) - 6px));height:min(18px,calc(var(--row-h,27px) - 6px));margin:0;vertical-align:middle}
  header #search:focus{max-width:740px}
  body[data-density=comfortable] #grid td{height:36px;padding-top:6px;padding-bottom:6px}
}
/* Narrower desktops: the header sheds extras in steps (Refresh stays in the rail footer) */
@media(max-width:1599px) and (min-width:761px){
  header #crumb{display:none}
  header .brand{font-size:18px;letter-spacing:2.4px;padding:0 14px 0 10px}
  header .brand small{font-size:9px;letter-spacing:2.2px}
}
@media(max-width:1279px) and (min-width:761px){
  header #refresh{display:none}
  header .brand{font-size:15px;letter-spacing:1.6px}
  header .brand small{letter-spacing:1.4px}
  header .hcell,header .writer-badge{padding:0 9px}
}
@media(max-width:1279px) and (min-width:761px){
  #view-pipeline.on,#view-pipeline.on:has(#drawer.on){grid-template-columns:minmax(0,1fr) clamp(340px,38%,520px)!important}
}
@media(max-width:1023px) and (min-width:761px){
  header{gap:5px;padding-right:8px}
  header #search{min-width:80px}
  header #bell{display:none}
  /* cs-9755c866: at 768 the brand was flex-shrunk (min-width:0; overflow:hidden) to ~72px while
     PIPELINE EXPLORER needs ~101px, clipping to PIPELI / EXPLOF. Keep the type as-is; only stop the shrink. */
  header .brand{font-size:13px;letter-spacing:1px;padding:0 8px;flex:0 0 auto;min-width:max-content;overflow:visible}
  header .brand small{display:none}
  header #compare-open,header #density-toggle{padding:0 6px}
}
/* cs-b4c7432a: from 761 through 1199, Compact, Layout, Compare and the plain LAST SYNC cell leave the row; search keeps 150px and the queue / DATA AS OF readout never clips. */
@media(max-width:1199px) and (min-width:761px){
  header #compare-open,header #density-toggle,header #workspace-layout-toolbar,header .hcell.sync:not(.age):not(.bad){display:none}
  header{gap:3px}
  header .hcell{padding:0 4px}
}
@media(max-width:800px) and (min-width:761px){
  header .hcell:not(.sync) small{display:none}
}
@media(min-width:761px){
  header #search{min-width:150px}
  header .hstat{flex-shrink:0}
}
@media(min-width:2200px) and (min-height:1200px){
  #grid td{font-size:13.5px}
  #drawer .wh-title h2,#drawer #d-title{font-size:32px!important}
}

/* Job drawer body fills leftover height; the four decision buttons stay pinned at the bottom. */
@media(min-width:981px),(min-width:761px) and (pointer:fine){
  #drawer{min-height:0;overflow:hidden;flex-direction:column}
  /* cs-ca5b83da #4 (replaces the cs-9e5be547 #2 sibling rule, which landed on the last overview card and missed live): the scroll
     container itself reserves the sticky decide bar's height (50 px buttons + 8 + 4 padding) plus a 12 px gap, so any field,
     MY NOTE's #edit-note included, scrolls fully clear of the bar. */
  #drawer #d-body{flex:1 1 auto;min-height:0;overflow:auto;padding-bottom:calc(var(--pe-dec-h,50px) + 24px);scroll-padding-bottom:calc(var(--pe-dec-h,50px) + 24px)}
  #drawer .wh-top,#drawer .wh-chips,#drawer .wh-nav,#drawer .ws-score,#drawer #detail-tabs{flex-shrink:0}   /* GUI 13: only the body shrinks, so the tab strip never paints over the chips */
  #drawer #d-body>.wh-decide{position:sticky;bottom:0;z-index:3;flex:none;flex-wrap:nowrap;background:var(--pe-hull,#050707);padding:8px 0 4px;box-shadow:0 -1px 0 var(--pe-seam,var(--forge-line,#333))}
}

@media (max-height: 640px) and (min-width: 981px), (max-height: 640px) and (min-width: 761px) and (pointer: fine) {
  #drawer { overflow-y: auto; }
  #drawer #d-body { overflow: visible; }
}
