/* ---- StueveCast cockpit layout on top of the S2 base stylesheet ---- */
:root{ --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); --topbar-h: 88px; --side-w: 322px; --right-w: 302px; }
html{ -webkit-text-size-adjust:100%; }
html, body{ height:100%; }
body{ padding-top:var(--safe-t); overflow:hidden; }
.app{ max-width:none; padding:0; height:100%; display:flex; flex-direction:column; }
.dim{ color:var(--text-dim); font-weight:400; }

/* header: the S2 title block (eyebrow · title · subtitle) left, logo right */
header.topbar{ display:flex; flex-direction:row; align-items:center; justify-content:space-between; gap:16px; height:auto; padding:8px 14px 8px;
  border-bottom:1px solid var(--line); margin:0; flex-shrink:0; }
.title-block{ min-width:0; }
.title-block .eyebrow{ margin-bottom:3px; }
.title-block h1{ font-size:22px; }
.title-block p{ margin:3px 0 0; font-family:var(--mono); font-size:11.5px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.header-logo{ height:46px; flex-shrink:0; }
.print-only{ display:none; }

/* workspace: three columns */
#workspace{ display:grid; grid-template-columns:var(--side-w) 14px minmax(0,1fr) var(--right-w); flex:1; min-height:0; overflow:hidden; }
body.side-collapsed #workspace{ grid-template-columns:0 14px minmax(0,1fr) var(--right-w); }
body.side-collapsed #sidePanel{ display:none; }
#sidePanel{ overflow-y:auto; overflow-x:hidden; border-right:1px solid var(--line); padding:6px 10px 24px; min-width:0; }
#sideHandle{ display:flex; align-items:center; justify-content:center; cursor:pointer; background:var(--panel-2); border-right:1px solid var(--line);
  color:var(--text-dim); user-select:none; -webkit-user-select:none; touch-action:manipulation; }
#sideHandle span{ font-size:18px; line-height:1; }
#sideHandle:hover{ color:var(--text-strong); background:var(--panel); }
#centerCol{ overflow-y:auto; overflow-x:hidden; padding:6px 10px 14px; position:relative; min-width:0; display:flex; flex-direction:column; }
#rightCol{ overflow-y:auto; overflow-x:hidden; border-left:1px solid var(--line); padding:4px 8px 20px; min-width:0; }

/* generic controls */
.icon-btn{ width:36px; height:36px; padding:0; font-size:16px; flex-shrink:0; }
.icon-btn.tiny{ width:26px; height:26px; font-size:14px; }
.icon-btn.on{ background:var(--amber); color:#1a1200; border-color:var(--amber); }
.primary-btn{ background:var(--amber); border:1px solid var(--amber); color:#1a1200; font-family:var(--mono); font-weight:700;
  font-size:13px; height:40px; padding:0 18px; border-radius:8px; cursor:pointer; }
.primary-btn.small{ height:32px; padding:0 12px; font-size:12px; }
.primary-btn:disabled{ opacity:.45; cursor:not-allowed; }
.primary-btn:hover:not(:disabled){ filter:brightness(1.08); }
.primary-btn.attention{ box-shadow:0 0 0 3px rgba(240,166,61,.35); }
.reset-btn.mini{ height:26px; padding:0 9px; font-size:11px; }
.chip-row{ display:flex; flex-wrap:wrap; gap:5px; margin:4px 0; }
.chip-row.scroll{ flex-wrap:nowrap; overflow-x:auto; padding-bottom:3px; -webkit-overflow-scrolling:touch; scrollbar-width:thin; }
.chip{ flex-shrink:0; display:inline-flex; align-items:center; gap:5px; background:var(--panel-2); border:1px solid var(--line); color:var(--text);
  font-family:var(--mono); font-size:11.5px; padding:0 10px; height:28px; border-radius:14px; cursor:pointer; white-space:nowrap; }
.chip.sel, .chip.primary{ background:var(--amber); border-color:var(--amber); color:#1a1200; font-weight:700; }
.chip.model-chip.comp{ font-weight:600; }
.chip.model-chip.avail{ color:var(--text-dim); border-style:dashed; }
.chip .x{ opacity:.75; font-size:12px; padding-left:2px; }
.chip .x:hover{ opacity:1; }

/* left column */
.sp-section{ padding:4px 0 8px; border-bottom:1px solid var(--line); }
.sp-section:last-child{ border-bottom:none; }
.sp-section .section-title{ margin:6px 0 4px; font-size:9.5px; }
.loc-toolbar{ display:flex; gap:6px; align-items:center; margin:2px 0 4px; }
.search-wrap{ position:relative; flex:1; min-width:0; }
#searchInput{ width:100%; height:34px; box-sizing:border-box; background:var(--panel-2); border:1px solid var(--line); color:var(--text);
  font-family:var(--mono); font-size:12.5px; padding:0 10px; border-radius:7px; -webkit-appearance:none; appearance:none; }
#searchInput:focus{ outline:none; border-color:var(--amber); }
.search-results{ position:absolute; z-index:1200; left:0; right:0; top:38px; background:var(--panel-2); border:1px solid var(--line);
  border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.3); max-height:260px; overflow-y:auto; }
.sr-item{ display:flex; flex-direction:column; align-items:flex-start; width:100%; background:transparent; border:none; border-bottom:1px solid var(--line);
  color:var(--text); font-family:var(--mono); font-size:12px; padding:7px 10px; cursor:pointer; text-align:left; }
.sr-item:hover{ background:var(--panel); }
.sr-sub, .sr-empty{ font-size:10.5px; color:var(--text-dim); }
.sr-empty{ padding:8px 10px; }
.map-wrap{ position:relative; height:clamp(170px, 27vh, 320px); border:1px solid var(--line); border-radius:8px; overflow:hidden; background:var(--panel-2); }
#pickMap{ position:absolute; inset:0; }
.crosshair{ position:absolute; left:50%; top:50%; width:52px; height:52px; margin:-26px 0 0 -26px; pointer-events:none; z-index:800; }
.place-card{ display:flex; align-items:center; gap:6px; background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:5px 6px 5px 9px; margin-top:6px; }
.place-main{ flex:1; min-width:0; }
.place-name{ font-family:var(--mono); font-size:12.5px; font-weight:600; color:var(--text-strong); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.place-coords, .place-status{ font-family:var(--mono); font-size:10px; color:var(--text-dim); margin-top:1px; }
.time-readout{ display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; font-family:var(--mono); position:relative; margin-bottom:2px; }
.time-main{ background:none; border:none; padding:0; font-family:var(--mono); font-size:13px; font-weight:700; color:var(--text-strong); cursor:pointer;
  text-decoration:underline dotted var(--text-dim); text-underline-offset:3px; }
.time-readout .lead{ font-size:11px; color:var(--amber); }
.time-readout .utc{ font-size:10.5px; color:var(--text-dim); }
.time-picker{ position:absolute; left:0; top:0; width:1px; height:1px; opacity:0; pointer-events:none; }
.time-row{ display:flex; align-items:center; gap:3px; }
.time-row .icon-btn.tiny{ width:24px; height:24px; font-size:13px; }
.time-slider-wrap{ flex:1; position:relative; padding-bottom:14px; min-width:0; }
#timeSlider{ width:100%; margin:0; accent-color:var(--amber); height:30px; }
.time-ticks{ position:absolute; left:8px; right:8px; bottom:0; height:13px; pointer-events:none; }
.time-ticks span{ position:absolute; transform:translateX(-50%); font-family:var(--mono); font-size:8.5px; color:var(--text-dim); white-space:nowrap; }
.time-ticks span i{ display:block; width:1px; height:4px; background:var(--text-dim); margin:0 auto 1px; }
.model-list{ display:flex; flex-direction:column; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:var(--panel); }
.model-row{ display:flex; gap:8px; align-items:center; padding:4px 6px 4px 8px; border-bottom:1px solid var(--line); }
.model-row:last-child{ border-bottom:none; }
.model-row.off{ opacity:.45; }
.model-row.later{ opacity:.6; }
.model-row input[type=checkbox]{ width:17px; height:17px; margin:0; accent-color:var(--amber); flex-shrink:0; }
.mr-body{ display:flex; flex-direction:column; gap:1px; min-width:0; flex:1; cursor:pointer; }
.mr-name{ font-family:var(--mono); font-size:12px; font-weight:600; color:var(--text-strong); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mr-meta{ font-family:var(--mono); font-size:9.5px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mr-star{ background:none; border:none; font-size:16px; color:var(--text-dim); cursor:pointer; padding:0 3px; line-height:1; }
.mr-star.on{ color:var(--amber); }
.badge{ display:inline-block; border:1px solid var(--amber); color:var(--amber); border-radius:4px; padding:0 5px; font-size:9px; margin-left:4px; vertical-align:middle; }
.model-foot{ font-family:var(--mono); font-size:9.5px; color:var(--text-dim); margin:6px 0 0; line-height:1.45; }

/* centre column */
.toolbar{ display:flex; align-items:center; gap:8px; margin-bottom:4px; flex-shrink:0; }
.toolbar{ align-items:flex-start; }
#modelChips{ flex:1; min-width:0; margin:0; flex-wrap:wrap; gap:4px; }
.head-actions{ display:flex; gap:5px; flex-shrink:0; margin-left:auto; }
.chip.avg{ border-style:dotted; border-color:var(--amber); color:var(--amber); font-weight:700; }
.chip.avg.primary{ border-style:solid; }
.menu-wrap{ position:relative; }
.menu{ position:absolute; right:0; top:40px; width:296px; background:var(--panel-2); border:1px solid var(--line); border-radius:8px;
  box-shadow:0 10px 30px rgba(0,0,0,.35); z-index:1200; padding:4px 0; }
.menu-row{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:3px 10px; font-family:var(--mono); font-size:11px; color:var(--text); min-height:30px; }
.menu-row > span:first-child{ flex:1; min-width:0; }
.menu-row select, .menu-row input[type=number], .menu-row input[type=text]{ background:var(--bg); border:1px solid var(--line); color:var(--text);
  font-family:var(--mono); font-size:11px; height:26px; padding:0 6px; border-radius:5px; box-sizing:border-box; }
.menu-row select{ width:112px; }
.menu-row input[type=text]{ width:130px; }
.menu-row input[type=number]{ width:58px; text-align:center; }
.menu-row.ta-row{ cursor:pointer; }
.ta-link{ color:var(--amber); text-decoration:underline; }
.diagram-controls{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:5px; flex-shrink:0; }
.seg{ display:inline-flex; align-items:stretch; border:1px solid var(--line); border-radius:6px; overflow:hidden; background:var(--panel-2); }
.seg label{ position:relative; display:inline-flex; }
.seg input{ position:absolute; opacity:0; width:0; height:0; margin:0; }
.seg span{ display:inline-block; padding:0 10px; height:26px; line-height:26px; font-family:var(--mono); font-size:11.5px; color:var(--text-dim); cursor:pointer;
  border-right:1px solid var(--line); }
.seg label:last-child span{ border-right:none; }
.seg input:checked + span{ background:var(--amber); color:#1a1200; font-weight:700; }
.seg input:focus-visible + span{ outline:2px solid var(--amber); outline-offset:-2px; }
.seg-label{ padding:0 8px; font-family:var(--mono); font-size:10px; letter-spacing:.06em; text-transform:uppercase; color:var(--text-dim); line-height:26px; border-right:1px solid var(--line); }
.time-strip{ margin-left:auto; display:flex; align-items:center; gap:4px; font-family:var(--mono); font-size:12px; font-weight:600; color:var(--text-strong); white-space:nowrap; }
.notice{ font-family:var(--mono); font-size:11px; color:var(--text); background:var(--panel-2); border:1px solid var(--line); border-radius:7px; padding:6px 10px; margin-bottom:6px; flex-shrink:0; }
.notice.error{ border-color:#e0554a; }
.empty-state{ margin:28px auto; max-width:520px; background:var(--panel); border:1px dashed var(--line); border-radius:10px; padding:16px 20px;
  font-family:var(--mono); font-size:12px; color:var(--text-dim); line-height:1.6; }
.empty-title{ font-size:13px; font-weight:600; color:var(--text-strong); margin-bottom:6px; }
.loading{ position:absolute; inset:0; z-index:900; background:rgba(11,16,23,.6); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px;
  font-family:var(--mono); font-size:13px; color:#e3e9f2; text-align:center; padding:24px; }
.spinner{ width:34px; height:34px; border:3px solid rgba(255,255,255,.25); border-top-color:var(--amber); border-radius:50%; animation:sc-spin .9s linear infinite; }
@keyframes sc-spin{ to{ transform:rotate(360deg); } }
.chart-card{ padding:8px 6px 4px; }
.chart-row{ display:flex; gap:6px; }
#altRangeCol{ display:flex; flex-direction:column; align-items:center; gap:4px; width:28px; flex-shrink:0; }
.zoom-label{ font-family:var(--mono); font-size:8px; color:var(--text-dim); writing-mode:vertical-rl; text-orientation:mixed; transform:rotate(180deg); }
#altRangeReset{ width:24px; height:24px; padding:0; font-size:11px; flex-shrink:0; position:relative; z-index:3; }
#altRangeTrack{ position:relative; flex:1; width:100%; display:flex; justify-content:center; }
.alt-track-line{ position:absolute; top:0; bottom:0; width:4px; border-radius:2px; background:var(--line); }
#altRangeFill{ position:absolute; width:4px; border-radius:2px; background:var(--amber); opacity:.5; left:50%; transform:translateX(-50%); }
#chart{ touch-action:pan-y; }
#windPanelHandle{ position:absolute; width:22px; margin-left:-11px; cursor:ew-resize; display:none; align-items:center; justify-content:center; z-index:6; touch-action:none; }
#windPanelHandle .grip{ width:6px; height:44px; border-radius:3px; background:var(--amber); opacity:.8; box-shadow:0 0 0 3px var(--panel-2); }
#windPanelHandle:hover .grip{ opacity:1; width:7px; }
#exportPngBtn{ position:absolute; top:2px; right:6px; z-index:5; }
.legend{ font-size:9.5px; gap:3px 10px; padding:4px 2px 0; }
#panelsRow{ display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
#panelsRow > div{ flex:1; min-width:200px; background:var(--panel-2); border:1px solid var(--line); border-radius:8px; padding:8px; }
.panel-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:4px; }
.panel-title{ font-family:var(--mono); font-size:9.5px; color:var(--text-dim); letter-spacing:.06em; text-transform:uppercase; }

/* right column: dense */
#rightCol .section-title{ margin:6px 0 3px; font-size:9px; }
#rightCol .stat-strip{ grid-template-columns:repeat(2,1fr) !important; gap:1px; margin-bottom:5px; border-radius:6px; }
#rightCol .stat{ padding:3px 6px 4px; }
#rightCol .stat .k{ font-size:7.5px; letter-spacing:.05em; }
#rightCol .stat .v{ font-size:10.5px; margin-top:1px; line-height:1.3; }
#rightCol .stat-info-btn{ width:11px; height:11px; font-size:7px; top:3px; right:3px; }
#rightCol #analyticalComments{ padding:6px 10px 6px 10px; font-size:10.5px; margin-bottom:6px; line-height:1.45; }
#analyticalComments{ background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:12px 16px; margin-bottom:12px; font-family:var(--mono); font-size:12px; position:relative; }
#analyticalCommentsList{ display:flex; flex-direction:column; gap:5px; }
.attribution{ font-family:var(--mono); font-size:8.5px; color:var(--text-dim); line-height:1.5; margin-top:8px; }
.attribution a{ color:var(--text-dim); }

/* modals */
.modal-overlay{ position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:1100; align-items:center; justify-content:center; padding:20px; }
.modal-box{ background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:18px 20px; font-family:var(--mono); color:var(--text);
  max-width:420px; width:100%; box-shadow:0 12px 40px rgba(0,0,0,.4); max-height:90vh; overflow-y:auto; }
.modal-box.about{ max-width:640px; }
.modal-title{ font-size:13px; font-weight:600; margin-bottom:10px; color:var(--text-strong); }
.modal-text{ font-size:11.5px; color:var(--text-dim); line-height:1.55; margin-bottom:14px; }
.modal-text p{ margin:0 0 10px; }
.modal-field{ display:flex; align-items:center; gap:8px; margin-bottom:16px; font-size:11px; color:var(--text-dim); }
.modal-field input{ width:100px; background:var(--bg); border:1px solid var(--line); color:var(--text); font-family:var(--mono); font-size:12px; padding:6px 8px; border-radius:5px; }
.modal-actions{ display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.share-row{ display:flex; gap:8px; margin-bottom:12px; }
#shareUrl{ flex:1; min-width:0; background:var(--bg); border:1px solid var(--line); color:var(--text); font-family:var(--mono); font-size:11px; padding:6px 8px; border-radius:5px; }
.share-qr{ display:flex; justify-content:center; background:#fff; border-radius:6px; padding:8px; margin-bottom:12px; }
.share-qr:empty{ display:none; }

/* touch ergonomics */
@media (pointer: coarse){
  .vslider::-webkit-slider-thumb{ width:24px; height:24px; }
  .vslider::-moz-range-thumb{ width:24px; height:24px; }
  .vslider{ width:24px; }
  .stat-info-btn{ width:18px; height:18px; font-size:10px; }
  #rightCol .stat-info-btn{ width:16px; height:16px; font-size:9px; }
}

/* narrow screens: stacked layout, left panel as a drawer */
@media (max-width: 999px){
  body{ overflow:auto; }
  .app{ height:auto; display:block; }
  #workspace{ display:block; height:auto; overflow:visible; }
  #sidePanel{ position:fixed; left:0; top:calc(var(--topbar-h) + var(--safe-t)); bottom:0; width:min(380px, 92vw); z-index:950; background:var(--bg);
    transform:translateX(-100%); transition:transform .2s ease; box-shadow:4px 0 24px rgba(0,0,0,.3); display:block !important; border-right:1px solid var(--line); }
  body.side-open #sidePanel{ transform:none; }
  #sideHandle{ position:fixed; left:0; top:50%; transform:translateY(-50%); width:22px; height:64px; z-index:951; border:1px solid var(--line); border-left:none; border-radius:0 8px 8px 0; transition:left .2s ease; }
  body.side-open #sideHandle{ left:min(380px, 92vw); }
  #centerCol{ overflow:visible; padding:6px 8px 6px 20px; }
  #rightCol{ border-left:none; overflow:visible; padding:4px 8px 24px; }
  .map-wrap{ height:40vh; }
  .time-strip{ margin-left:0; }
}

/* print: one A4 page, single column (chart, panels, then the right-column blocks) */
@media print{
  html, body{ overflow:visible !important; height:auto !important; }
  .app{ display:block !important; height:auto !important; padding:0 !important; }
  header.topbar{ height:auto !important; padding:0 0 4px !important; margin-bottom:6px !important; }
  .title-block h1{ font-size:14px; }
  .title-block p{ font-size:8.5px; white-space:normal; }
  .print-only{ display:inline; font-size:7.5px; color:#555; word-break:break-all; }
  .header-logo{ height:30px; }
  #workspace{ display:block !important; height:auto !important; overflow:visible !important; }
  #sidePanel, #sideHandle, .toolbar, .diagram-controls, #profileNotice, #emptyState, #loadingOverlay, .attribution, .menu, #windPanelHandle, #exportPngBtn, .panel-export-btn, .modal-overlay{ display:none !important; }
  #centerCol, #rightCol{ display:block !important; overflow:visible !important; border:none !important; padding:0 !important; height:auto !important; }
  #dataView{ display:block !important; }
  .chart-card{ padding:4px 4px 2px !important; }
  .legend{ font-size:7px; gap:2px 8px; padding:2px 2px 0; }
  #panelsRow{ display:grid !important; grid-template-columns:1fr 1fr 1fr !important; gap:4px !important; margin-top:4px !important; }
  #panelsRow > div{ padding:3px !important; min-width:0 !important; }
  html.print-no-panels #panelsRow{ display:none !important; }
  #rightCol .section-title{ margin:4px 0 2px; font-size:7.5px; }
  #rightCol .stat-strip{ grid-template-columns:repeat(5,1fr) !important; margin-bottom:3px; page-break-inside:avoid; }
  #rightCol .stat{ padding:2px 5px 3px; }
  #rightCol .stat .k{ font-size:6.5px; }
  #rightCol .stat .v{ font-size:9px; }
  #rightCol #analyticalComments{ padding:4px 8px !important; font-size:8px !important; margin-bottom:0 !important; page-break-inside:avoid; }
  #analyticalCommentsList{ gap:2px; }
}

/* map attribution compact */
.leaflet-container .leaflet-control-attribution{ font-size:8px; padding:1px 4px; background:rgba(255,255,255,.75); }
