:root{color-scheme:light;--bg:#e4e4e4;--panel:#f7f7f7;--input:#fff;--text:#202020;--muted:#606060;--border:#b6b6b6;--accent:#006cb7;--error:#aa231c;--total:#d0d0d0}
body.dark{color-scheme:dark;--bg:#1e1e1e;--panel:#252525;--input:#2c2c2c;--text:#e6e6e6;--muted:#aaa;--border:#515151;--accent:#83c2ff;--error:#ffaaa3;--total:#373737}
*{box-sizing:border-box}body{margin:0;padding:36px 24px;font:15px Arial,sans-serif;background:var(--bg);color:var(--text)}main{max-width:1160px;margin:auto}header{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-bottom:32px}h1{font-size:30px;line-height:1.2;margin:0 0 3px}.byline{font-size:16px}.version{font-size:12px;color:var(--muted);margin-left:12px}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.byline a{color:inherit}sup{font-size:9px}nav{display:flex;flex-wrap:wrap;gap:5px;padding-top:4px}button,select,input{font:inherit;color:inherit;background:var(--input);border:1px solid var(--border);border-radius:5px}button{cursor:pointer;padding:7px 11px}button:hover{filter:brightness(1.15)}button:disabled{opacity:.4;cursor:default}button:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.reset{color:var(--error)}select{padding:7px;max-width:100%}.settings{display:flex;flex-wrap:wrap;gap:18px;background:var(--panel);padding:18px;border:1px solid var(--border);border-radius:7px}.settings label{display:flex;flex-direction:column;gap:7px;font-size:12px;font-weight:bold}.help{color:var(--muted);font-size:13px;line-height:1.5;min-height:20px;margin:14px 0 20px}.sheet-head,.data-row,.total-row{display:grid;grid-template-columns:minmax(140px,1fr) 110px minmax(170px,1fr) minmax(170px,1fr);gap:16px;align-items:start}.sheet-head{font-size:13px;font-weight:bold;align-items:center;margin-bottom:12px}.sheet-head .operations{display:flex;gap:4px}.sheet-head button{padding:3px 12px}.data-row{padding:5px 0}.label-wrap{display:flex;gap:4px}.label-input{width:100%;min-width:0;padding:10px;height:40px}.label-style{width:62px;font-size:12px;padding:4px}.row-controls{display:flex;align-items:center;gap:5px;height:40px}.drag-handle{padding:6px 2px;cursor:grab;color:var(--muted);touch-action:none;user-select:none}.operator{width:32px;height:32px;padding:0;font-size:18px}.operator.selected{background:#007acc;color:white;border-color:#007acc}.include{width:16px;height:16px;accent-color:#007acc}.delete{padding:2px 5px;background:none;border:0;color:var(--muted);font-size:19px}.timecode{width:100%;padding:8px 10px;height:40px;font:18px ui-monospace,SFMono-Regular,Consolas,monospace;font-variant-numeric:tabular-nums}.converted{background:var(--total)}.input-wrap{min-width:0}.error{font-size:12px;color:var(--error);line-height:1.4;margin-top:4px}.data-row.excluded .input-wrap,.data-row.excluded .label-wrap{opacity:.4}.data-row.dragging{opacity:.35}.data-row.drop-target{box-shadow:0 -2px 0 var(--accent)}.total-row{border-top:1px solid var(--border);margin-top:14px;padding-top:18px;font-weight:bold}.total-row output{font:22px ui-monospace,SFMono-Regular,Consolas,monospace;display:block;padding:10px;background:var(--total);border-radius:5px;overflow-wrap:anywhere}.runtime{font-size:12px;font-weight:normal;color:var(--muted);padding:7px 0;line-height:1.4}#status{color:var(--error);font-size:13px;min-height:18px}.bottom-controls{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:15px 0 28px}.bottom-controls span{font-size:12px;color:var(--muted)}details{border-top:1px solid var(--border);padding-top:15px;font-size:13px;line-height:1.6;color:var(--muted)}summary{cursor:pointer;color:var(--text)}footer{text-align:center;font-size:12px;color:var(--muted);line-height:2;margin-top:36px}.no-labels .label-cell{display:none}.no-labels .sheet-head,.no-labels .data-row,.no-labels .total-row{grid-template-columns:110px minmax(170px,1fr) minmax(170px,1fr)}body.simple .converted-cell,body.simple .conversion-setting{display:none}body.simple .sheet-head,body.simple .data-row,body.simple .total-row{grid-template-columns:minmax(140px,1fr) 110px minmax(170px,1fr)}body.simple .no-labels .sheet-head,body.simple .no-labels .data-row,body.simple .no-labels .total-row{grid-template-columns:110px minmax(170px,1fr)}
@media(max-width:850px){body{padding:24px 16px}header{flex-direction:column;gap:15px}.sheet-head,.data-row,.total-row{gap:10px;grid-template-columns:minmax(100px,1fr) 176px minmax(155px,1fr) minmax(155px,1fr)}.sheet{overflow-x:auto}.sheet-head,.data-row,.total-row{min-width:660px}.sheet.no-labels .sheet-head,.sheet.no-labels .data-row,.sheet.no-labels .total-row{min-width:490px}body.simple .sheet-head,body.simple .data-row,body.simple .total-row{min-width:480px}body.simple .no-labels .sheet-head,body.simple .no-labels .data-row,body.simple .no-labels .total-row{min-width:330px;grid-template-columns:155px minmax(145px,1fr)}.settings{gap:14px;padding:14px}.timecode{font-size:16px}.total-row output{font-size:18px}}
@media print{@page{size:portrait;margin:12mm}body{padding:0;--bg:#fff;--text:#000;--muted:#333;--input:#fff;--total:#fff;--border:#999;color:#000!important;background:#fff!important}nav,.bottom-controls,details,footer,.drag-handle,.delete,.label-style,#status{display:none}.settings{background:white;color:black}.sheet{overflow:visible}.sheet-head,.data-row,.total-row{break-inside:avoid}.timecode,.label-input{color:black;background:white;border:none}.operator{color:black!important;background:white!important;border:none}.operator:not(.selected){visibility:hidden}.include{pointer-events:none}.data-row.excluded{display:none}.runtime,.help{color:#333}.total-row output{background:white;color:black}.sheet-head .operations{visibility:hidden}}

dialog{background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:24px;max-width:calc(100vw - 32px)}dialog::backdrop{background:#0008}dialog h2{font-size:18px;margin:0 0 18px}.move-actions{display:flex;gap:8px}

.label-style{width:76px;flex-shrink:0}@media print{select{background:#fff!important;color:#000!important;color-scheme:light}input:focus-visible{outline:none}dialog{display:none}}

.sheet-head{align-items:start;margin-bottom:16px}
.sheet-head>.label-cell,.sheet-head>.operations{align-self:end;padding-bottom:6px}
.column-controls{display:flex;flex-direction:column;gap:10px;min-width:0}
.column-controls>span{margin-bottom:2px}
.rate-control{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:normal;flex-wrap:wrap}
.rate-control select{font-size:13px}
.conversion-control,.rounding-control{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:normal;color:var(--muted)}
.conversion-control select,.rounding-control select{width:100%;font-size:13px;color:var(--text)}
.rounding-control{margin-top:10px}
.total-row .help{font-size:12px;font-weight:normal;margin:8px 0 0;min-height:0}
@media(max-width:850px){.rate-control{align-items:flex-start;flex-direction:column;gap:6px}.conversion-control select,.rounding-control select{font-size:12px}}
@media print{.column-controls label,.rounding-control{color:#333}.conversion-control select,.rounding-control select{color:#000}.total-row .help{color:#333}}

.conversion-toolbar{margin-bottom:24px}
.conversion-toolbar .conversion-control{display:flex;flex-direction:row;align-items:center;gap:10px;width:max-content;max-width:100%;color:var(--text)}
.conversion-toolbar .conversion-control select{width:auto}
.conversion-toolbar .help{margin:10px 0 0;min-height:0;font-size:12px}
.sheet-head{margin-bottom:8px}
.advanced-options{border-top:0;padding-top:8px;font-size:12px;font-weight:normal}
.advanced-options summary{color:var(--muted)}
.advanced-options p{margin:8px 0 0}

.sheet-head{font-size:16px;line-height:20px;font-weight:700;align-items:center}
.sheet-head>.label-cell{align-self:center;padding:0}
.sheet-head .rate-control{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;gap:8px;min-height:40px;font-size:16px;font-weight:700;line-height:20px}
.sheet-head .rate-control>span{white-space:nowrap}
.sheet-head .rate-control select{width:110px;max-width:110px;min-width:0;flex-shrink:1}
.sheet-head .rate-control select{font-size:13px;font-weight:400;line-height:normal}
.advanced-options .conversion-control{margin-top:12px}
.advanced-options .help{margin:8px 0 14px}

.row-controls,.sheet-head .operations{display:grid;grid-template-columns:18px 32px 32px 16px 20px;gap:5px;align-items:center;height:40px}
.sheet-head>.operations{padding:0;align-self:center}
.sheet-head .operations #allAdd{grid-column:2}
.sheet-head .operations #allSubtract{grid-column:3}
.sheet-head .operations .operator{padding:0;font-size:18px;width:32px;height:32px}
.row-controls .drag-handle{width:18px;text-align:center}

@media(max-width:850px){.sheet-head,.sheet-head .rate-control{font-size:14px}.sheet-head .rate-control select{font-size:12px;flex:1}.sheet-head .rate-control{gap:6px}}

.timecode{width:calc(var(--tc-chars,12) * 1ch + 22px);max-width:100%}
.total-row output{width:calc(var(--tc-chars,12) * 1ch + 20px);max-width:100%}

.sheet-head .column-controls{width:calc(12ch + 22px);max-width:100%;font:18px ui-monospace,SFMono-Regular,Consolas,monospace;align-items:center}
.sheet-head .rate-control{width:max-content;justify-content:center;font-family:Arial,sans-serif}
.sheet-head .rate-control select{flex:none;width:110px}
.total-row>div:nth-child(2){font-size:16px;line-height:26px;padding-top:10px}
@media(max-width:850px){.sheet-head .column-controls{font-size:16px}.sheet-head .rate-control select{width:90px}.total-row>div:nth-child(2){line-height:22px}}

.footer-link{border:0;background:none;color:var(--accent);padding:0;font:inherit;cursor:pointer}.footer-link:hover{text-decoration:underline}
.about-dialog{width:740px;max-width:calc(100vw - 32px);max-height:85vh;max-height:85dvh;padding:0;overflow:auto;line-height:1.6}
.about-header{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:20px 28px;border-bottom:1px solid var(--border);background:var(--panel);position:sticky;top:0;z-index:1}
.about-header h2{font-size:22px;line-height:1.3;margin:0 0 3px}.about-header span{font-size:12px;color:var(--muted)}
.about-close{font-size:24px;padding:0;width:34px;height:34px;flex-shrink:0}
.about-content{padding:6px 28px 28px;font-size:14px}.about-intro{font-size:16px}.about-content h3{font-size:16px;margin:24px 0 8px}.about-content p{margin:10px 0}.about-content ul,.about-content ol{padding-left:22px}.about-content li{margin:9px 0}.about-content code{font-size:13px;overflow-wrap:anywhere}.about-support{border-top:1px solid var(--border);padding-top:18px;color:var(--muted)}.about-content #backToCalculator{margin-top:12px}
@media(max-width:600px){.about-header{padding:18px}.about-content{padding:4px 18px 22px}.about-header h2{font-size:20px}}


.advanced-cleanup{margin-top:14px}

.print-rate{display:none}
@media print{
  .sheet-head .rate-control{flex-direction:column;width:100%;gap:4px;min-height:0;text-align:center}
  .sheet-head .rate-control select{display:none}
  .sheet-head .rate-control .print-rate{display:block;font-size:14px;font-weight:400;line-height:20px;color:#000}
}

.save-share{position:relative;border:0;padding:0;color:inherit;font:inherit;line-height:normal}
.save-share>summary{list-style:none;padding:7px 11px;background:var(--input);border:1px solid var(--border);border-radius:5px;cursor:pointer}
.save-share>summary::-webkit-details-marker{display:none}
.save-share-menu{position:absolute;right:0;top:calc(100% + 6px);z-index:10;min-width:220px;padding:5px;background:var(--panel);border:1px solid var(--border);border-radius:6px;box-shadow:0 8px 24px #0004;display:flex;flex-direction:column;gap:3px}
.save-share-menu button{text-align:left;border:0;background:transparent;padding:10px;color:var(--text)}
.save-share-menu button:hover{background:var(--input)}
.save-share-menu small{display:block;font-size:11px;color:var(--muted);margin-top:5px}
@media(max-width:600px){.save-share-menu{right:auto;left:0}}

.runsheet-heading{display:flex;flex-direction:column;gap:7px;margin:0 0 24px;max-width:520px}
.runsheet-heading label{font-size:12px;color:var(--muted)}
.runsheet-heading input{padding:9px 12px;font-size:18px;width:100%}
.print-runsheet-title{display:none}
.hide-labels .runsheet-heading,.hide-labels .print-runsheet-title{display:none}
@media print{
  .runsheet-heading{display:none}
  .print-runsheet-title{display:block;font-size:22px;line-height:1.3;margin:0 0 20px;overflow-wrap:anywhere}
  header{margin-bottom:18px}
  .sheet{--print-columns:minmax(140px,280px) 36px 185px 185px}
  .sheet.no-labels{--print-columns:36px 185px 185px}
  body.simple .sheet{--print-columns:minmax(140px,280px) 36px 185px}
  body.simple .sheet.no-labels{--print-columns:36px 185px}
  .sheet-head,.data-row,.total-row{grid-template-columns:var(--print-columns)!important;min-width:0!important;gap:12px}
  .row-controls{display:flex;justify-content:center;gap:0}
  .row-controls .operator:not(.selected),.row-controls .include{display:none}
  .sheet-head .operations{overflow:hidden}
}

.calculator-brand{display:flex;align-items:center;gap:16px;flex-shrink:0}
.brand-logo{display:block;flex-shrink:0;line-height:0}
.brand-logo img{width:80px;height:auto;filter:none}
.brand-logo .brand-logo-white{display:none}.brand-logo .brand-logo-black{display:block}
body.dark .brand-logo .brand-logo-white{display:block}body.dark .brand-logo .brand-logo-black{display:none}
@media(max-width:600px){.calculator-brand{gap:12px;flex-shrink:1}.brand-logo img{width:60px}.calculator-brand h1{font-size:26px}}
@media print{.brand-logo img,body.dark .brand-logo img{width:70px;filter:none!important}.brand-logo .brand-logo-white,body.dark .brand-logo .brand-logo-white{display:none!important}.brand-logo .brand-logo-black,body.dark .brand-logo .brand-logo-black{display:block!important}}

.touch-entry-actions{display:none}
@media screen and (pointer:coarse){.input-wrap:focus-within>.touch-entry-actions{display:flex;gap:6px;margin-top:6px;width:calc(var(--tc-chars,12) * 1ch + 22px);max-width:100%}.touch-next{min-height:44px;flex:1;padding:8px 6px;font-size:16px}}

/* Collaboration preview */
[hidden]{display:none!important}
.live-banner{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:12px 16px;margin-bottom:20px;background:var(--panel);border:1px solid var(--border);border-radius:7px}
.live-banner>div{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
#liveStatus{font-size:13px;color:var(--muted)}
.live-dialog{width:640px;line-height:1.5}.live-dialog label{display:block;margin-top:16px;font-weight:bold}.live-dialog input{display:block;width:100%;padding:10px;font-size:13px;margin:6px 0;cursor:text}
.chat-panel{position:fixed;right:16px;top:16px;bottom:16px;width:310px;z-index:15;display:flex;flex-direction:column;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:16px;box-shadow:0 8px 24px #0004}
body.chat-open main{margin-right:340px;max-width:none}
.chat-heading{display:flex;justify-content:space-between;align-items:center}.chat-heading h2{font-size:18px;margin:0}.chat-heading button{font-size:20px;padding:0 10px}
.chat-note{font-size:12px;color:var(--muted);line-height:1.4}
.chat-messages{flex:1;min-height:80px;overflow:auto;border-top:1px solid var(--border);padding-top:12px}
.chat-message{font-size:14px;line-height:1.4;padding:9px 0;border-bottom:1px solid var(--border);overflow-wrap:anywhere}.chat-message p{margin:4px 0;white-space:pre-wrap}.chat-message small{display:block;color:var(--muted);font-size:11px}
#chatForm{padding-top:12px}#chatForm label{display:block;font-size:12px;margin:8px 0}#chatForm input,#chatForm textarea{display:block;width:100%;padding:8px;margin-top:4px;background:var(--input);color:var(--text);border:1px solid var(--border);border-radius:5px;font:16px Arial,sans-serif}#chatStatus{font-size:12px;color:var(--muted);min-height:16px}
.shared-viewer .row-controls .delete,.shared-viewer .row-controls .drag-handle,.shared-viewer .touch-entry-actions{visibility:hidden}
@media(max-width:1100px){body.chat-open main{margin-right:0}.chat-panel{width:min(340px,calc(100vw - 24px));right:12px}}
@media print{.live-banner,.chat-panel{display:none!important}body.chat-open main{margin-right:0}}

.target-controls{display:flex;flex-direction:column;align-items:flex-start;gap:6px;margin-top:12px;font-weight:normal}
.target-controls label{font-size:13px;font-weight:bold}.target-comparison{font-size:14px;font-weight:bold;line-height:1.5;overflow-wrap:anywhere}.target-comparison[data-state="over"],.target-comparison[data-state="invalid"]{color:var(--error)}.target-comparison[data-state="under"]{color:var(--accent)}
@media print{.target-comparison{color:#000!important}.target-controls .timecode{border:none;background:#fff}}

.runsheet-title-row{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:24px}
.runsheet-title-row .runsheet-heading{flex:1;min-width:0;margin-bottom:0}
.runsheet-title-row .reset{margin-left:auto;flex-shrink:0;min-height:42px}
@media print{.runsheet-title-row{display:none}}

/* Opaque print artwork avoids SVG soft-mask incompatibilities in PDF viewers. */
.brand-logo .brand-logo-print{display:none}
@media print{.brand-logo .brand-logo-black,body.dark .brand-logo .brand-logo-black{display:none!important}.brand-logo .brand-logo-print,body.dark .brand-logo .brand-logo-print{display:block!important}}

/* Preview: keep the runtime goal with runsheet setup, and its difference with totals. */
.runsheet-title-row{align-items:flex-start}
.runsheet-title-row .runsheet-heading input{height:42px}
.runtime-target-heading{display:flex;flex-direction:column;gap:7px;flex-shrink:0}
.runtime-target-heading label{font-size:12px;color:var(--muted)}
.runtime-target-heading #targetRateHint{white-space:nowrap}
.runtime-target-heading .timecode{height:42px}
.runtime-target-heading .error{max-width:230px;margin-top:0}
.runtime-target-heading .error:empty{display:none}
.runsheet-title-row .reset{margin-top:21px}
.print-runtime-target{display:none}
@media(max-width:650px){.runsheet-title-row{flex-wrap:wrap}.runsheet-title-row .runsheet-heading{flex-basis:100%;max-width:none}}
@media print{.print-runtime-target:not([hidden]){display:block;font-size:14px;margin:0 0 20px}.print-runsheet-title:not(:empty)+.print-runtime-target:not([hidden]){margin-top:-12px}}

/* Match the runsheet grid so the target and input values share an exact edge. */
.runsheet-title-row{display:grid;grid-template-columns:minmax(140px,1fr) 110px minmax(170px,1fr) minmax(170px,1fr);gap:16px;position:relative;isolation:isolate;padding:18px 0;margin-bottom:30px}
.runsheet-title-row::before{content:"";position:absolute;inset:0 -16px;z-index:-1;background:var(--panel);border:1px solid var(--border);border-radius:7px}
.runsheet-title-row .runsheet-heading{grid-column:1 / 3;max-width:none}
.runtime-target-heading{grid-column:3;grid-row:1;min-width:0}
.runsheet-title-row .reset{grid-column:4;grid-row:1;justify-self:end;margin-left:0}
body.simple .runsheet-title-row{grid-template-columns:minmax(140px,1fr) 110px minmax(170px,1fr)}
body.simple .runsheet-title-row .reset{grid-column:3}
.hide-labels .runtime-target-heading,.hide-labels .target-controls,.hide-labels .print-runtime-target{display:none!important}
.hide-labels .runsheet-title-row{display:flex;padding:0;justify-content:flex-end;margin-bottom:24px}
.hide-labels .runsheet-title-row::before{display:none}
.hide-labels .runsheet-title-row .reset{margin-top:0}
@media(max-width:650px){.runsheet-title-row,body.simple .runsheet-title-row{grid-template-columns:1fr auto;gap:16px}.runsheet-title-row .runsheet-heading{grid-column:1 / -1;grid-row:1}.runtime-target-heading{grid-column:1;grid-row:2}.runsheet-title-row .reset,body.simple .runsheet-title-row .reset{grid-column:2;grid-row:2}}
@media print{.runsheet-title-row,.hide-labels .runsheet-title-row{display:none}}

/* End the setup panel at the target field, leaving Reset outside its border. */
.runsheet-title-row::before{display:none}
.runsheet-title-row .runsheet-heading,.runtime-target-heading{position:relative;align-self:stretch}
.runtime-target-heading{justify-self:start;width:max-content;max-width:100%}
.runsheet-title-row .runsheet-heading::before,.runtime-target-heading::before{content:"";position:absolute;inset:-18px -16px;z-index:-1;background:var(--panel);border-top:1px solid var(--border);border-bottom:1px solid var(--border)}
.runsheet-title-row .runsheet-heading::before{border-left:1px solid var(--border);border-radius:7px 0 0 7px}
.runtime-target-heading::before{border-right:1px solid var(--border);border-radius:0 7px 7px 0}
@media(max-width:650px){.runsheet-title-row .runsheet-heading::before{border:1px solid var(--border);border-bottom:0;border-radius:7px 7px 0 0}.runtime-target-heading::before{border:1px solid var(--border);border-top:0;border-radius:0 0 7px 7px}}

/* Tighten the rate columns while preserving shared heading/row/total tracks. */
@media screen and (min-width:851px){
  .sheet-head,.data-row,.total-row,.runsheet-title-row{grid-template-columns:minmax(140px,1fr) 110px 230px minmax(170px,1fr)}
  .no-labels .sheet-head,.no-labels .data-row,.no-labels .total-row{grid-template-columns:110px 230px minmax(170px,1fr)}
  body.simple .sheet-head,body.simple .data-row,body.simple .total-row,body.simple .runsheet-title-row{grid-template-columns:minmax(140px,1fr) 110px minmax(170px,1fr)}
  body.simple .no-labels .sheet-head,body.simple .no-labels .data-row,body.simple .no-labels .total-row{grid-template-columns:110px minmax(170px,1fr)}
  .runtime-target-heading::before{right:calc(-1 * var(--target-panel-overhang,16px))}
}

/* Keep row creation and reset outside the title/target panel. */
.runsheet-actions{grid-column:4;grid-row:1;justify-self:end;display:flex;align-items:center;gap:10px;margin-top:21px}
.runsheet-actions button{min-height:42px;white-space:nowrap}
.runsheet-title-row .runsheet-actions .reset{margin:0}
body.simple .runsheet-actions{grid-column:3}
.hide-labels .runsheet-actions{margin-top:0}
@media(max-width:650px){.runsheet-actions,body.simple .runsheet-actions{grid-column:2;grid-row:2}}

/* Preserve label space in narrower desktop windows before allowing sheet scrolling. */
@media screen and (max-width:1100px){
  .sheet{overflow-x:auto;padding:2px 0}
  .sheet-head,.data-row,.total-row{grid-template-columns:minmax(236px,1fr) 110px 205px 205px;gap:16px;min-width:804px}
  .sheet.no-labels .sheet-head,.sheet.no-labels .data-row,.sheet.no-labels .total-row{grid-template-columns:110px 205px 205px;min-width:552px}
  body.simple .sheet-head,body.simple .data-row,body.simple .total-row{grid-template-columns:minmax(236px,1fr) 110px 205px;min-width:583px}
  body.simple .sheet.no-labels .sheet-head,body.simple .sheet.no-labels .data-row,body.simple .sheet.no-labels .total-row{grid-template-columns:110px 205px;min-width:331px}
}
@media screen and (min-width:951px) and (max-width:1100px){
  .runsheet-title-row{grid-template-columns:minmax(236px,1fr) 110px 205px 205px}
  body.simple .runsheet-title-row{grid-template-columns:minmax(236px,1fr) 110px 205px}
  body.simple .runsheet-actions{grid-column:3;grid-row:2;margin-top:8px}
}
@media screen and (max-width:950px){
  .runsheet-title-row,body.simple .runsheet-title-row{grid-template-columns:minmax(0,1fr) 152px 166px;gap:16px}
  .runsheet-title-row .runsheet-heading{grid-column:1;grid-row:1}
  .runtime-target-heading{grid-column:2;grid-row:1}
  .runsheet-actions,body.simple .runsheet-actions{grid-column:3;grid-row:1}
  .runtime-target-heading::before{right:-16px}
}
@media screen and (max-width:850px){
  .sheet-head,.data-row,.total-row{grid-template-columns:minmax(236px,1fr) 110px 185px 185px;gap:10px;min-width:746px}
  .sheet.no-labels .sheet-head,.sheet.no-labels .data-row,.sheet.no-labels .total-row{grid-template-columns:110px 185px 185px;min-width:500px}
  body.simple .sheet-head,body.simple .data-row,body.simple .total-row{grid-template-columns:minmax(236px,1fr) 110px 185px;min-width:551px}
  body.simple .sheet.no-labels .sheet-head,body.simple .sheet.no-labels .data-row,body.simple .sheet.no-labels .total-row{grid-template-columns:110px 185px;min-width:305px}
  .sheet-head .rate-control select{flex:none}
}
@media screen and (max-width:650px){
  .runsheet-title-row,body.simple .runsheet-title-row{grid-template-columns:minmax(0,1fr) auto}
  .runsheet-title-row .runsheet-heading{grid-column:1 / -1;grid-row:1}
  .runtime-target-heading{grid-column:1;grid-row:2}
  .runsheet-actions,body.simple .runsheet-actions{grid-column:2;grid-row:2}
  .runsheet-title-row .runsheet-heading::before{border:1px solid var(--border);border-radius:7px;inset:-10px -8px}
  .runtime-target-heading::before{border:1px solid var(--border);border-radius:7px;inset:-10px -8px}
  .runsheet-title-row{row-gap:28px}
}

@media screen and (min-width:840px) and (max-width:950px){
  .sheet-head,.data-row,.total-row,.runsheet-title-row{grid-template-columns:minmax(236px,1fr) 110px 185px 185px;gap:10px;min-width:746px}
  .runsheet-title-row .runsheet-heading{grid-column:1 / 3}
  .runtime-target-heading{grid-column:3}
  .runsheet-actions,body.simple .runsheet-actions{grid-column:4}
  .sheet-head .rate-control{font-size:14px;gap:6px}
  .sheet-head .rate-control select{width:90px;font-size:12px;flex:none}
  .sheet-head .column-controls,.timecode{font-size:16px}
  .total-row output{font-size:18px}
  .runtime-target-heading::before{right:calc(-1 * var(--target-panel-overhang,16px))}
  body.simple .runsheet-title-row{grid-template-columns:minmax(236px,1fr) 110px 185px;min-width:551px}
  body.simple .runsheet-actions{grid-column:3;grid-row:2;margin-top:8px}
}

/* Sharing remains visible and its banner follows the setup panel's footprint. */
.live-share-button{display:inline-flex;align-items:center;justify-content:center;gap:7px;margin-left:8px;color:var(--accent);border-color:var(--accent);background:transparent;min-height:35px}
.live-share-button[data-state="active"]{color:#167443;border-color:#167443}
body.dark .live-share-button[data-state="active"]{color:#7edda6;border-color:#7edda6}
.live-share-button[data-state="paused"],.live-share-button[data-state="reconnecting"]{color:#8a5a00;border-color:#8a5a00}
body.dark .live-share-button[data-state="paused"],body.dark .live-share-button[data-state="reconnecting"]{color:#ffd079;border-color:#ffd079}
.live-share-button[data-state="active"] svg,.live-share-button[data-state="paused"] svg,.live-share-button[data-state="reconnecting"] svg{display:none}
.live-banner{width:var(--setup-panel-width,100%);max-width:calc(100% + 32px);margin-left:-16px;flex-wrap:wrap;gap:10px 16px}
.live-banner>div:first-child{flex:1 1 220px;min-width:0}
.live-banner>div:last-child{display:flex;flex-wrap:wrap;gap:6px}
#liveStatus{overflow-wrap:anywhere}
.hide-labels .live-banner{width:max-content;max-width:100%;margin-left:0}
@media(max-width:650px){.live-banner{width:100%;max-width:100%;margin-left:0}.live-share-button{margin-left:0}}
.runtime-target-heading .error{width:100%;max-width:100%;overflow-wrap:anywhere}

/* Keep connection status directly beneath its sharing control. */
.header-tools{display:flex;flex-direction:column;align-items:flex-end;flex:0 1 auto;min-width:0;max-width:100%}
.header-tools nav{justify-content:flex-end}
#liveBanner{position:relative;width:320px;max-width:100%;margin:12px 0 0 auto;padding:12px;flex-direction:column;align-items:stretch;gap:10px;font-size:13px}
#liveBanner::before{content:"";position:absolute;top:-6px;right:40px;width:10px;height:10px;background:var(--panel);border-left:1px solid var(--border);border-top:1px solid var(--border);transform:rotate(45deg)}
#liveBanner>div:first-child{flex:0 1 auto;flex-direction:column;align-items:flex-start;gap:4px}
#liveBanner>div:last-child{justify-content:flex-end}
#liveBanner button{font-size:13px}
@media(max-width:850px){.header-tools{width:100%}}

/* A shallow status strip leaves more room for the runsheet. */
#liveBanner{width:440px;padding:7px 10px;flex-direction:row;align-items:center;gap:8px 14px}
#liveBanner>div:first-child{flex:1 1 200px;gap:2px}
#liveBanner>div:last-child{flex:0 0 auto;gap:6px}
#liveBanner button{padding:6px 9px}
@media(max-width:480px){#liveBanner{flex-wrap:wrap}#liveBanner>div:first-child{flex-basis:100%}#liveBanner>div:last-child{margin-left:auto}}

/* Align the actions with the setup panel's lower border. */
.runsheet-actions{align-self:end;margin-top:0;transform:translateY(18px)}
.hide-labels .runsheet-actions{transform:none}
#liveBanner{width:310px;gap:8px;padding:6px 9px}
#liveBanner>div:first-child{flex:1 1 120px}
#liveBanner>div:last-child{gap:5px}
#liveBanner button{padding:6px 8px}
@media screen and (min-width:1101px){
  .header-tools{position:relative}
  #liveBanner{position:absolute;right:0;top:calc(100% + 8px);margin:0;z-index:2}
}
@media screen and (min-width:840px) and (max-width:1100px){body.simple .runsheet-actions{transform:none}}
@media screen and (max-width:650px){.runsheet-actions{transform:translateY(10px)}}

/* Room for Chat, Share Links and Stop sharing on the same compact strip. */
#liveBanner{width:400px}

.footer-actions{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:18px;margin-top:12px;font-size:14px}.support-tool{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--border);border-radius:5px;padding:5px 12px;color:var(--accent);line-height:1.5}.support-tool:hover{background:var(--panel);text-decoration:none;border-color:var(--accent)}.support-tool:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.support-note{margin:8px 0 0;font-size:12px;line-height:1.5;color:var(--muted)}

.tip-invitation{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;margin-top:20px;font-size:13px;line-height:1.5;color:var(--muted)}.tip-invitation .support-tool{font-size:14px}

.official-coffee-button{display:flex;align-items:center}.official-coffee-button .bmc-btn{zoom:.75}

.chat-control{padding:10px 0;border-bottom:1px solid var(--border)}.chat-control p{font-size:13px;line-height:1.4;margin:8px 0}.chat-control #controlDecision{display:flex;gap:8px}.chat-control #controlDecision[hidden]{display:none}

.chat-keyboard-hint{font-size:12px;color:var(--muted);line-height:1.4;margin:0 0 10px}.chat-message p{white-space:pre-wrap;overflow-wrap:anywhere}

/* v2.1.2: checkbox-sized operation indicators with a larger invisible hit area. */
@media screen {
  .row-controls,.sheet-head .operations{grid-template-columns:18px 16px 16px 16px 20px;gap:6px}
  .row-controls .operator,.sheet-head .operations .operator{position:relative;width:16px;height:16px;min-width:0;min-height:0;padding:0;border-radius:3px;font-size:14px;font-weight:700;line-height:14px;display:inline-flex;align-items:center;justify-content:center}
  .row-controls .operator::before,.sheet-head .operations .operator::before{content:"";position:absolute;inset:-10px -3px}
  .row-controls .include{margin:0}
  .row-controls .delete{width:20px;padding:2px 0}
}

/* Compact formatting picker; the popover escapes the scrolling sheet. */
.label-style-wrap{flex:0 0 42px}
.label-style{width:42px;height:40px;padding:0 5px;display:flex;align-items:center;justify-content:space-between;gap:3px;font-size:15px}
.style-symbol{display:inline-block;min-width:19px;text-align:center;line-height:1}
.style-chevron{font:12px Arial,sans-serif;color:var(--muted)}
.label-style-menu{position:fixed;inset:auto;margin:0;width:150px;max-height:calc(100dvh - 16px);overflow-y:auto;padding:5px;background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:7px;box-shadow:0 8px 24px #0005}
.style-option{display:flex;align-items:center;gap:10px;width:100%;height:44px;padding:8px;border:0;background:transparent;text-align:left;font-size:14px}
.style-option[aria-checked="true"]{background:var(--input);box-shadow:inset 3px 0 var(--accent)}
@media print{.label-style-wrap,.label-style-menu{display:none!important}}

/* Font choice and color are independent, for labels and the runsheet title. */
.label-style{position:relative}
.label-style-menu{width:170px}
.style-menu-heading{font-size:11px;font-weight:700;color:var(--muted);padding:5px 8px 2px}
.style-option{height:40px}
.style-check{margin-left:auto;visibility:hidden;color:var(--accent)}
.style-option[aria-checked="true"] .style-check{visibility:visible}
.style-menu-hint{font-size:11px;line-height:1.3;color:var(--muted);padding:6px 8px}
.title-input-wrap{display:flex;gap:4px;align-items:stretch;min-width:0}
.title-input-wrap input{flex:1;min-width:0}
.title-input-wrap .label-style{height:100%;min-height:40px}

/* Bright accents on dark screens, readable inks on white paper. */
body:not(.dark) [data-text-color="red"]{color:#b12d26!important}
body:not(.dark) [data-text-color="green"]{color:#226d43!important}
body:not(.dark) [data-text-color="blue"]{color:#1c5ba6!important}
body:not(.dark) [data-text-color="yellow"]{color:#806900!important}
@media print{
  .label-input,.print-runsheet-title{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  [data-text-color="red"]{color:#b12d26!important}
  [data-text-color="green"]{color:#226d43!important}
  [data-text-color="blue"]{color:#1c5ba6!important}
  [data-text-color="yellow"]{color:#806900!important}
}

/* Let the runsheet title lead the printed page. */
@media print {
  header{margin-bottom:14px;align-items:center}
  .calculator-brand{gap:8px}
  .calculator-brand h1{font-size:14px;line-height:1.2;margin-bottom:2px}
  .calculator-brand .byline{font-size:10px;line-height:1.3}
  .calculator-brand .version{font-size:8px;margin-left:6px}
  .calculator-brand sup{font-size:7px}
  .brand-logo img,body.dark .brand-logo img{width:32px}
  .print-runsheet-title{font-size:26px;line-height:1.25;margin-bottom:18px}
}

@media print {
}

.print-target-summary{display:none}
@media print{
  .total-row .print-target-summary{display:block;padding-top:10px;font-size:11px;font-weight:400;line-height:1.4;color:#333}
  .print-target-summary .print-runtime-target:not([hidden]){display:block;font-size:11px;margin:0 0 3px}
  .print-target-summary #printTargetDifference{margin:0;font-size:11px;font-weight:700;color:#000}
  .print-target-summary:has(.print-runtime-target[hidden]){display:none}
  .total-row .target-controls{display:none}
}

/* A restrained print grid separates entries without competing with their text. */
@media print {
  .sheet-head{border-bottom:1px solid #bbb;padding-bottom:6px;margin-bottom:0}
  .data-row{border-bottom:.5pt solid #ddd;padding:5px 0}
  .data-row>div:not(:first-child){border-left:.5pt solid #e2e2e2;padding-left:6px}
  .data-row .label-input{padding-left:4px}
  .total-row{border-top:1px solid #888;margin-top:10px}
}

/* Continuous vertical rules complete the print grid. */
@media print {
  .sheet-head,.data-row,.total-row{column-gap:0}
  .sheet-head{padding-bottom:0;align-items:stretch;border-top:.5pt solid #ccc}
  .data-row{padding:0;align-items:stretch}
  .sheet-head>div,.data-row>div{padding:6px;border-left:.5pt solid #ccc}
  .sheet-head>div:last-child,.data-row>div:last-child{border-right:.5pt solid #ccc}
  .data-row>div:not(:first-child){border-left:.5pt solid #ccc;padding-left:6px}
  .sheet-head .operations{visibility:visible}
  .sheet-head .operations .operator{visibility:hidden}
  .sheet-head .column-controls{width:auto;max-width:none}
  .sheet-head .rate-control{margin:auto}
  .data-row .row-controls{height:auto;min-height:52px;align-items:center}
  .data-row .input-wrap{display:flex;flex-direction:column;justify-content:center}
  .data-row .label-wrap{align-items:center}
  body.simple .sheet-head>div:nth-child(3),body.simple .data-row>div:nth-child(3){border-right:.5pt solid #ccc}
}

@media print {
  .sheet{--print-columns:minmax(140px,1fr) 36px 185px 185px}
  body.simple .sheet{--print-columns:minmax(140px,1fr) 36px 185px}
  .sheet.no-labels{--print-columns:36px 185px 185px}
  body.simple .sheet.no-labels{--print-columns:36px 185px}
}

@media print {
  header{display:flex;flex-direction:row;justify-content:flex-start;align-items:center}
  .sheet-head>.operations{align-self:stretch;height:auto;padding:6px}
  .sheet-head>.label-cell{display:flex;align-self:stretch;align-items:center;padding:6px}
}

.sheet-head{position:relative}
.swap-rates{position:absolute;transform:translate(-50%,-50%);width:26px;height:26px;padding:0;font-size:20px;line-height:1;background:transparent;border-color:var(--border);z-index:2}
.swap-rates::before{content:"";position:absolute;inset:-7px 0}
body.simple .swap-rates{display:none}
@media print{.swap-rates{display:none!important}}

#swapDialog{width:460px;max-width:calc(100vw - 32px);line-height:1.5}
#swapDialog h2{font-size:20px;margin-top:0}
#swapRateSummary{font-size:13px;color:var(--muted)}
.swap-dialog-actions{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-top:20px}
@media screen and (max-width:950px){.swap-rates{width:18px;height:24px;font-size:16px}}
.sheet-head>.swap-rates{padding:0;min-width:0}
