/* Mech sheet (sheet.js, paperdoll-sheet.js), moved from mechlab.css. Linked by mechlab.html and library.html; sheet.js
   adds it on the other pages (deck). Phone / narrow layout at the end. */
.sh-dlg { width: min(1320px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); overflow: auto; padding: 0 16px 16px; }
.sh-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 10px; padding: 12px 0 8px; background: var(--surface-1); border-bottom: 1px solid var(--line); }
.sh-titles { flex: 1; min-width: 0; }
.sh-titles h2 { margin: 0; overflow-wrap: anywhere; }
.sh-titles p { margin: 2px 0 0; }
.sh-actions { display: flex; gap: 6px; }
.sh-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin: 10px 0; }
.sh-kpis div { background: var(--bg); border: 1px solid var(--line); padding: 6px 8px; min-width: 0; }
.sh-kpis b { display: block; font: 600 16px/1.3 var(--f-data); color: var(--text-strong); font-variant-numeric: tabular-nums; }
.sh-kpis span { color: var(--muted); font-size: 11px; }
.sh-dollside .sh-kpis { margin-top: 0; }
.sh-doll { display: block; width: 100%; height: auto; }
.sh-axis { fill: none; stroke: var(--line-strong); }
.sh-tick { font: 10px var(--f-data); fill: var(--text-faint); }
.sh-cockpitline { fill: none; stroke: #fff; stroke-width: 1; stroke-dasharray: 5 3; opacity: .8; }
.sh-cockpitval { font: 700 10px var(--f-data); fill: #fff; }
.sh-hit path { stroke-width: .5; stroke-linejoin: round; }
.sh-viewbar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.sh-viewname { min-width: 96px; text-align: center; font: 600 12px var(--f-data); color: var(--text-strong); }
.sh-turn { background: var(--bg); border: 1px solid var(--line); color: var(--text); font-size: 15px; line-height: 1; padding: 3px 9px; cursor: pointer; }
.sh-turn:hover { border-color: var(--line-strong); }
.sh-dollturn { cursor: pointer; }
.sh-dlg .k-ballistic { --kc: var(--k-ballistic); } .sh-dlg .k-energy { --kc: var(--k-energy); }
.sh-dlg .k-missile { --kc: var(--k-missile); } .sh-dlg .k-ams { --kc: var(--k-ams); }
.sh-muzzle { fill: var(--kc); }
.sh-wbox { fill: none; stroke: var(--kc); stroke-width: 1.2; }
.sh-wbox.arm { stroke-dasharray: 3 2; }
.sh-leader { fill: none; stroke: var(--kc); stroke-width: .9; opacity: .85; }
.sh-wlabel { fill: var(--kc); font: 600 10.5px var(--f-data); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
/* weapon summary, bottom right of the paperdoll */
.sh-wsum text { paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.sh-wsumtitle { font: 600 9.5px var(--f-data); letter-spacing: .08em; text-transform: uppercase; fill: var(--muted); }
.sh-wsumname { font: 600 11.5px var(--f-data); fill: var(--kc); }
.sh-wsumcount { font: 600 11.5px var(--f-data); fill: var(--text-strong); font-variant-numeric: tabular-nums; }
.sh-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font: 11px/1.4 var(--f-data); color: var(--muted); }
.sh-sw { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.sh-sw.line { width: 16px; height: 0; border-top: 1px dashed #fff; vertical-align: 3px; }
.sh-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.sh-table th { text-align: left; color: var(--muted); font: 500 10.5px/1.8 var(--f-data); letter-spacing: .06em; text-transform: uppercase; padding: 3px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sh-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sh-table td.n { text-align: right; font-family: var(--f-data); font-variant-numeric: tabular-nums; }
.sh-table b { color: var(--kc); }
.sh-table td.ok { color: var(--ok); } .sh-table td.mid { color: var(--accent); } .sh-table td.bad { color: var(--danger); }
.sh-note { font-size: 11px; margin: 6px 0 0; }
.sh-charts { columns: 300px 3; column-gap: 16px; margin-top: 12px; }
.sh-charts > * { break-inside: avoid; }
.sh-sechead { cursor: default; }
.sh-badge { display: inline-flex; align-items: center; height: 18px; margin-left: 8px; padding: 0 6px; border: 1px solid currentColor; vertical-align: 3px;
  font: 600 10.5px/1 var(--f-data); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sh-badge.role { color: var(--accent); background: var(--accent-soft); }
.sh-ctrls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sh-ctrls select { max-width: 100%; }
.sh-status { font-size: 12px; }
/* six key figures with their percentile in the reference */
.sh-kpi6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 10px 0 6px; }
.sh-kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 7px 9px 8px; background: var(--bg); border: 1px solid var(--line); }
.sh-kpi .lab { overflow: hidden; font: 600 10.5px/1.3 var(--f-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.sh-kpi .val { font: 600 20px/1.15 var(--f-data); color: var(--text-strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-kpi .val small { margin-left: 3px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.sh-kpi .val small.masc { margin-left: 5px; font-size: 14px; color: var(--text); }
.sh-kpi .sub { overflow: hidden; font: 11px/1.3 var(--f-data); color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.sh-kpi .sub b { font-weight: 600; color: var(--text); }
.sh-pp { display: flex; align-items: center; gap: 6px; min-height: 12px; margin-top: 3px; }
.sh-pct { position: relative; flex: 1; min-width: 40px; height: 10px; }
.sh-pct::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: var(--surface-3); }
.sh-pct::after { content: ""; position: absolute; left: 50%; top: 1px; width: 1px; height: 8px; background: var(--line-strong); }
.sh-pct i { position: absolute; top: 1px; left: calc(var(--p) * 1% - 4px); z-index: 1; width: 8px; height: 8px; background: var(--text-strong); transform: rotate(45deg); }
.sh-pct.lo i { background: var(--danger); } .sh-pct.hi i { background: var(--ok); }
.sh-pv { min-width: 28px; font: 600 11px/1 var(--f-data); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
/* alerts */
.sh-alerts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.sh-al { padding: 3px 8px; font-size: 12px; border: 1px solid var(--line); border-left-width: 3px; background: var(--surface-2); }
.sh-al.crit { border-left-color: var(--danger); background: var(--danger-soft); }
.sh-al.warn { border-left-color: var(--accent); background: var(--accent-soft); }
.sh-al.info { border-left-color: var(--blu); background: color-mix(in srgb, var(--blu) 12%, transparent); }
.sh-al.ok { border-left-color: var(--ok); color: var(--muted); }
/* three columns: sections, paperdoll, sections */
.sh-grid { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(250px, 300px); gap: 14px; align-items: start; }
.sh-col, .sh-center { min-width: 0; }
.sh-nsec { padding: 6px 0; border-top: 1px solid var(--line); }
.sh-nsec h3 { display: flex; align-items: baseline; gap: 6px; margin: 0 0 4px; font: 600 11px/1.3 var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.sh-nsec .ml-row { align-items: baseline; }
.sh-nsec .ml-row .v { white-space: nowrap; }
.sh-nsec .ml-row .v small { margin-left: 4px; font-size: 11px; color: var(--text-faint); }
.sh-nsec .ml-row.key .k { color: var(--text); }
.sh-nsec .ml-row.key .v { font-weight: 600; color: var(--text-strong); }
.sh-nsec .ml-row.warn .v { color: var(--accent); }
.sh-nsec .ml-row.bad .v { color: var(--danger); }
/* one-line value that scrolls back and forth when it is too long (sheet.js startScrollers) */
.sh-nsec .ml-row.sh-scroll .k { flex: none; white-space: nowrap; }
.sh-nsec .ml-row.sh-scroll .v { flex: 1; min-width: 0; overflow: hidden; }
.sh-scroll .mq { display: inline-block; }
.sh-scroll.run .mq { animation: sh-scroll 7s ease-in-out infinite alternate; }
@keyframes sh-scroll { 0%, 15% { transform: translateX(0); } 85%, 100% { transform: translateX(var(--mq-shift)); } }
@media (prefers-reduced-motion: reduce) { .sh-scroll.run .mq { animation: none; } }
.sh-dollcard { min-width: 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); }
.sh-dollcard .sh-legend { font-size: 10.5px; }
.sh-expo { margin-top: 8px; }
.sh-expofigs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sh-expofigs div { min-width: 0; padding-left: 8px; border-left: 2px solid var(--line-strong); }
.sh-expofigs b { display: block; font: 600 15px/1.2 var(--f-data); color: var(--text-strong); white-space: nowrap; }
.sh-expofigs b.ok { color: var(--ok); } .sh-expofigs b.mid { color: var(--accent); } .sh-expofigs b.bad { color: var(--danger); }
.sh-expofigs span { font-size: 11px; color: var(--muted); }
/* paperdoll legend, folded under the exposure figures */
.sh-legendbox { margin-top: 8px; border-top: 1px solid var(--line); }
.sh-legendbox > summary { padding: 6px 0 0; font: 600 11px/1.3 var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.sh-legendbox .sh-legend { margin-top: 4px; }
.sh-more { margin-top: 8px; padding: 0; border: 1px solid var(--line); background: var(--surface-1); }
.sh-more > summary { padding: 6px 10px; }
.sh-more > summary span { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-faint); }
.sh-more > .sh-dollside { padding: 4px 10px 10px; overflow-x: auto; }
/* exchange ratio */
.sh-card { margin-top: 8px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); }
.sh-card h4 { margin: 0 0 4px; font: 600 11px/1.3 var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sh-trade { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.sh-trade b { display: block; font: 600 18px/1.1 var(--f-data); color: var(--text-strong); font-variant-numeric: tabular-nums; }
.sh-trade span { font-size: 11px; color: var(--muted); }
.sh-ratio { padding: 4px 8px; text-align: center; border: 1px solid currentColor; }
.sh-ratio.good { color: var(--ok); } .sh-ratio.bad { color: var(--danger); } .sh-ratio.even { color: var(--muted); }
.sh-ratio b, .sh-ratio span { color: inherit; }
.sh-ttkbar { position: relative; height: 16px; margin: 6px 0 2px; }
.sh-ttkbar span { position: absolute; left: 0; height: 6px; }
.sh-ttkbar .d { top: 0; background: var(--viz-1); } .sh-ttkbar .t { top: 9px; background: var(--danger); opacity: .8; }
@media (max-width: 1180px) {
  .sh-kpi6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sh-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sh-grid .sh-center { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 760px) {
  .sh-dlg { width: calc(100vw - 16px); padding: 0 10px 12px; }
  .sh-grid { grid-template-columns: 1fr; }
  .sh-kpi6, .sh-expofigs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sh-kpi .val { font-size: 17px; }
}

/* ---------------------------------------------------------------- phones and Lab mobile mode (docs/specs/17-mobile.md)
   Here rather than in mechlab-mobile.css: the sheet also opens from My mechs and the deck. */
/* compact paperdoll (paperdoll-sheet.js COMPACT): a narrower figure with larger text, >= 11 px on a 360 px screen */
.sh-doll.compact { max-width: 460px; margin: 0 auto; overflow: visible; }
.sh-doll.compact .sh-wlabel { font-size: 14px; stroke-width: 4px; }
.sh-doll.compact .sh-wsumtitle { font-size: 12.5px; }
.sh-doll.compact .sh-wsumname, .sh-doll.compact .sh-wsumcount { font-size: 14px; }
@media (max-width: 899px) {
  /* full screen, sticky header with a 44 px close button */
  .sh-dlg, .cmp-dlg { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; overflow: auto; overscroll-behavior: contain;
    padding: 0 max(8px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .sh-head { flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: max(6px, env(safe-area-inset-top, 0px)) 0 6px; }
  .sh-titles h2 { font-size: 15px; }
  .sh-titles h2 .sh-badge { height: 16px; margin-left: 6px; }
  .sh-titles p { overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
  .sh-close { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; }
  .sh-actions { order: 3; flex-wrap: wrap; flex-basis: 100%; }
  .sh-actions:empty { display: none; }
  .sh-actions > .btn { min-height: 36px; }

  /* paperdoll first, then key figures, alerts, settings and the folded sections */
  .sh-body { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
  .sh-dollcard { padding: 6px 6px 8px; }
  .sh-more { margin-top: 6px; }
  .sh-kpi6 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
  .sh-kpi .lab, .sh-kpi .sub { overflow: visible; white-space: normal; text-overflow: clip; }
  .sh-kpi .lab { font-size: 11px; }
  .sh-kpi .sub { font-size: 12px; }
  .sh-kpi .val { font-size: 18px; white-space: normal; }
  .sh-alerts { margin: 0; }
  .sh-ctrls { padding: 6px 0; border-top: 1px solid var(--line); }
  .sh-ctrls > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .sh-fold { border: 1px solid var(--line); background: var(--surface-1); }
  .sh-fold > summary { padding: 10px; font: 600 12px/20px var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--text); cursor: pointer; }
  .sh-fold > .sh-col { padding: 0 10px 8px; }
  .sh-fold .sh-nsec .ml-row .v { white-space: normal; text-align: right; }
  .sh-fold > .sh-charts { columns: auto; margin: 0; padding: 0 10px 10px; }
  .sh-charts svg { max-width: 100%; height: auto; }

  /* comparisons: one column, the close button stays at the bottom of the screen */
  .cmp-dlg > form { display: flex; flex-direction: column; min-height: 100%; }
  .cmp-dlg h2 { padding-top: max(10px, env(safe-area-inset-top, 0px)); }
  .cmp-dlg .cmp-body { flex: 1; min-width: 0; }
  .cmp-dlg .dk-dlg-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom, 0px)); z-index: 2; margin: 10px 0 0;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface-1); border-top: 1px solid var(--line); }
  .cmp-main, .cmp-charts { grid-template-columns: minmax(0, 1fr); }
  .cmp-pick { width: 100%; }
  .cmp-charts svg { max-width: 100%; height: auto; }
}
@media (max-width: 899px) and (pointer: coarse) {
  .sh-turn { min-width: var(--touch); min-height: var(--touch); }
  /* 20 px line + 2 x 12 px = 44 px; summaries stay list items (keeps their marker) */
  .sh-fold > summary, .sh-more > summary, .sh-legendbox > summary { padding-top: 12px; padding-bottom: 12px; line-height: 20px; }
  .cmp-dlg .dk-dlg-actions button { min-height: var(--touch); }
  .sh-ctrls select, .an-seg button, .an-num { min-height: var(--touch); }
  .an-seg button { min-width: var(--touch); justify-content: center; }
}
/* decision 4: on phones the comparisons are read-only, the version comparison is not offered */
@media (max-width: 599px) {
  .sh-vercmp, .cmp-pick, .cmp-chip .dk-ibtn { display: none; }
}
