/* OSS Cut List - phone and tablet styles. Owens Software & Systems. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/Inter-Bold.woff2") format("woff2"); }
:root {
  --navy: #0E1A26; --cyan: #2BC4F0; --blue: #0B6FAA; --blue-dark: #095A8A; --blue-light: #E7F3FA;
  --bg: #F5F6F8; --card: #FFFFFF; --ink: #14202C; --muted: #677382; --line: #DDE2E8; --field: #C7D0DA;
  --err: #B3261E; --err-bg: #FDECEA; --ok: #1E7D4F; --btn: #EDF0F3; --btn-h: #E0E6EC; --zebra: #F8FAFB; --thead: #F0F3F6;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --pad: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(96px + var(--safe-b));
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 21; display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff; height: calc(56px + var(--safe-t)); padding: var(--safe-t) var(--pad) 0;
  border-bottom: 2px solid var(--cyan);
}
.top .mark { display: block; width: 70px; height: auto; }
.top h1 {
  position: absolute; left: 50%; top: calc(50% + var(--safe-t) / 2); transform: translate(-50%, -50%);
  margin: 0; font-size: 21px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
}
.top .ver { color: #8FA3B8; font-size: 13px; }

/* toolbar */
.bar {
  display: flex; align-items: center; gap: 8px; background: #fff; border-bottom: 1px solid var(--line);
  padding: 6px 10px 6px 6px; position: sticky; top: calc(56px + var(--safe-t)); z-index: 20;
}
.file-btn {
  display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 auto; height: 44px; padding: 0 10px;
  border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer;
}
.file-btn:active, .file-btn[aria-expanded="true"] { background: var(--btn); }
.file-btn svg { width: 12px; height: 12px; flex: none; color: var(--muted); }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dirty { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); font-size: 0; overflow: hidden; }
.units { display: flex; align-items: center; gap: 6px; flex: none; }
.seg { display: inline-flex; background: var(--btn); border-radius: 9px; padding: 3px; }
.seg button {
  border: 0; background: none; height: 40px; padding: 0 12px; border-radius: 7px; font-size: 15px; font-weight: 600;
  color: #48525F; cursor: pointer; min-width: 44px;
}
.seg button[aria-checked="true"] { background: var(--blue); color: #fff; }
#metricUnit { height: 44px; border: 1px solid var(--field); border-radius: 8px; background: #fff; padding: 0 8px; font-size: 16px; }
.menu {
  position: fixed; z-index: 40; left: 8px; min-width: 210px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(14, 26, 38, .18); padding: 6px; display: flex; flex-direction: column;
}
.menu button { height: 48px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 8px; font-size: 16px; cursor: pointer; }
.menu button:active, .menu button:hover { background: var(--btn); }

/* cards */
.page { max-width: 980px; margin: 0 auto; padding: 10px 10px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.card-hint { margin: 4px 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.ref-strip {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; background: var(--blue-light); color: var(--blue-dark);
  border-radius: 8px; padding: 8px 10px; margin: 10px 0 14px; font-size: 13.5px;
}
.ref-strip b { font-weight: 600; color: var(--blue-dark); }
.field { margin: 0 0 12px; min-width: 0; }
.lbl { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 5px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.shown { min-height: 20px; margin-top: 5px; font-size: 14px; color: var(--ok); white-space: pre-wrap; }
.shown.err { color: var(--err); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.two .lbl { min-height: 2.7em; }
input.num, input.text, select {
  width: 100%; height: 48px; border: 1px solid var(--field); border-radius: 9px; background: #fff;
  padding: 0 12px; font-size: 17px; outline: none; appearance: none; -webkit-appearance: none;
}
input.num { text-align: right; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23677382' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px; padding-right: 32px;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 111, 170, .18); }
input.bad, select.bad { border-color: var(--err); background: var(--err-bg); }
.len-boxes { display: flex; gap: 10px; }
.unit-in { flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.unit-in span { color: var(--muted); font-size: 15px; min-width: 20px; }
body.metric .unit-in.imp, body:not(.metric) .unit-in.met { display: none; }
.dims { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.dims .wide { grid-column: 1 / -1; }

/* part rows */
.parts { display: flex; flex-direction: column; gap: 10px; }
.prow { border: 1px solid var(--line); border-radius: 10px; padding: 10px 10px 4px; background: #fff; }
.prow-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 6px; }
.prow-num { font-weight: 600; color: var(--muted); min-width: 24px; }
.prow-shown { flex: 1; font-size: 14px; color: var(--ok); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow-shown.err { color: var(--err); }
.rm {
  width: 44px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 8px; font-size: 20px; cursor: pointer;
  margin-right: -6px;
}
.rm:active { background: var(--btn); color: var(--err); }
.pgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 8px; }
.pgrid .c-ft { grid-column: span 2; } .pgrid .c-in { grid-column: span 2; } .pgrid .c-m { grid-column: span 4; }
.pgrid .c-qty { grid-column: span 2; }
.pgrid .c-a1, .pgrid .c-a2 { grid-column: span 2; } .pgrid .c-ref { grid-column: span 2; }
body.metric .pgrid .c-ft, body.metric .pgrid .c-in, body:not(.metric) .pgrid .c-m { display: none; }
.pgrid .lbl { font-size: 12.5px; margin-bottom: 3px; white-space: nowrap; }
.pgrid input.num { padding: 0 6px; font-size: 16px; }
.pgrid .field { margin-bottom: 8px; }
.refseg { display: flex; height: 48px; border: 1px solid var(--field); border-radius: 9px; overflow: hidden; background: #fff; }
.refseg button { flex: 1; border: 0; background: none; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; padding: 0; min-width: 0; }
.refseg button + button { border-left: 1px solid var(--field); }
.refseg button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.refseg.fixed { background: var(--btn); border-color: var(--line); }
.refseg.fixed button, .refseg.fixed button[aria-pressed="true"] { background: none; color: var(--ink); cursor: default; font-weight: 500; opacity: 1; }
.row-btns { display: flex; gap: 10px; margin-top: 12px; }

/* buttons */
.btn {
  height: 48px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--btn); color: var(--ink);
  font-size: 16px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:active { background: var(--btn-h); }
.btn.link { background: var(--blue-light); color: var(--blue-dark); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-dark); }
.btn.primary:disabled { background: #7FA9C6; }
.btn.big { height: 54px; font-size: 18px; width: 100%; }
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff;
  border-top: 1px solid var(--line); padding: 10px 12px calc(26px + var(--safe-b));
}
.actions.res { display: flex; flex-direction: column; gap: 8px; }
.actions.res .mini { display: flex; gap: 8px; }
.actions.res .mini .btn { flex: 1 1 0; min-width: 0; height: 44px; padding: 0 6px; font-size: 15px; }
.actions.res .main { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.actions.res .status { min-height: 0; font-size: 13.5px; color: var(--ok); text-align: center; }
.actions.res .status:empty { display: none; }
.actions.res .status.err { color: var(--err); }
.company {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 26; text-align: center; font-size: 11.5px; color: var(--muted);
  padding: 0 0 calc(7px + var(--safe-b)); pointer-events: none;
}
body.typing .actions, body.typing .company { display: none; }
.msg { white-space: pre-wrap; font-size: 14.5px; margin: 0 2px 10px; }
.msg.err { color: var(--err); background: var(--err-bg); border-radius: 10px; padding: 12px 14px; }
.msg.note { color: var(--blue-dark); background: var(--blue-light); border-radius: 10px; padding: 12px 14px; }
.msg.busy { color: var(--muted); padding: 4px 2px; }
.spacer { height: calc(var(--actions-h, 110px) + 12px); }

/* fraction keys over the keyboard */
.keys {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #D9DEE4; border-top: 1px solid #C3CAD3;
  padding: 6px 6px; will-change: transform; display: flex; gap: 6px;
}
.keys-fixed { display: flex; gap: 6px; flex: none; }
.keys-row { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.keys-row::-webkit-scrollbar { display: none; }
.keys button {
  flex: none; height: 42px; min-width: 46px; padding: 0 10px; border: 0; border-radius: 7px; background: #fff;
  font-size: 16px; font-weight: 600; color: var(--ink); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); cursor: pointer;
}
.keys button.k-frac { font-weight: 500; }
.keys button.k-alt { background: #C2CAD4; }
.keys button.k-done { background: var(--blue); color: #fff; }
.keys button:active { background: #BAC3CE; }

/* results */
.sum-inputs { color: var(--muted); font-size: 13.5px; margin: 4px 0 12px; line-height: 1.5; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { border: 1px solid var(--line); border-top: 3px solid var(--cyan); border-radius: 8px; padding: 10px 12px 11px; min-width: 0; }
.tile:first-child { border-top-color: var(--blue); }
.tile .v.long { font-size: clamp(15px, 4.7vw, 19px); }
.tile .v { font-size: clamp(16px, 5.3vw, 22px); font-weight: 700; letter-spacing: -0.2px; line-height: 1.2; }
.tile .n { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; }
.tile .d { font-size: 12.5px; color: var(--muted); }
.equation { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.best { margin-top: 10px; font-size: 13.5px; color: var(--ink); background: #FFF6E0; border-radius: 8px; padding: 9px 11px; }
.pat { border-top: 1px solid var(--line); padding: 12px 0 10px; }
.pat:first-of-type { border-top: 0; padding-top: 4px; }
.pat-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.pat-letter { font-weight: 700; font-size: 20px; color: var(--blue); min-width: 22px; }
.pat-count { font-weight: 700; font-size: 16px; }
.pat-count small { font-weight: 400; color: var(--muted); font-size: 13.5px; margin-left: 4px; }
.pat-left { margin-left: auto; font-size: 13.5px; color: var(--muted); text-align: right; }
.pat-left b { color: var(--ink); font-weight: 600; }
.cuts { list-style: none; margin: 0; padding: 0 0 0 34px; counter-reset: cut; }
.cuts li { position: relative; padding: 3px 0; font-size: 15.5px; }
.cuts li::before { counter-increment: cut; content: counter(cut); position: absolute; left: -26px; width: 18px; text-align: right; color: var(--muted); font-size: 12.5px; top: 5px; }
table.parts-t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.parts-t th { text-align: left; font-weight: 500; color: var(--muted); background: var(--thead); padding: 8px; font-size: 13px; }
.parts-t td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.parts-t tr:nth-child(even) td { background: var(--zebra); }
.parts-t td.q { font-weight: 700; width: 44px; }
.parts-t td .alt { color: var(--muted); font-size: 13px; display: block; }
.parts-t td .meas { color: var(--muted); font-size: 13px; display: block; }
.parts-t tr.total td { font-weight: 600; background: #fff; }
.note-p { color: var(--muted); font-size: 13px; margin: 10px 0 0; line-height: 1.5; }

/* dialogs */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(14, 26, 38, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 20px 18px calc(16px + var(--safe-b));
  max-height: 85vh; overflow: auto;
}
.sheet h3 { margin: 0 0 8px; font-size: 18px; }
.modal-body { white-space: pre-wrap; color: var(--ink); font-size: 15px; line-height: 1.45; }
.modal-body input { margin-top: 10px; }
.modal-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.modal-btns .btn { width: 100%; }

/* tablets and wider */

@media (max-width: 370px) {
  .seg button { padding: 0 8px; font-size: 14px; }
  #metricUnit { padding: 0 4px; }
  .file-btn { padding: 0 6px; }
}
@media (min-width: 720px) {
  :root { --pad: 22px; }
  .page { padding: 16px 20px 0; }
  .card { padding: 20px 22px; border-radius: 10px; }
  .two { grid-template-columns: repeat(2, minmax(0, 240px)); }
  .len-boxes { max-width: 360px; }
  .dims { grid-template-columns: repeat(3, minmax(0, 200px)); }
  .pgrid { grid-template-columns: 110px 130px 90px 90px 90px 120px; }
  .pgrid > * { grid-column: auto !important; }
  body.metric .pgrid { grid-template-columns: 248px 90px 90px 90px 120px; }
  .prow { display: grid; grid-template-columns: 34px 1fr 46px; align-items: center; padding: 8px 10px 0; }
  .prow-head { display: contents; }
  .prow-shown { grid-column: 2; grid-row: 2; padding: 0 0 8px; }
  .prow .pgrid { grid-column: 2; grid-row: 1; }
  .prow .rm { grid-column: 3; grid-row: 1; }
  .prow-num { grid-row: 1; align-self: center; padding-top: 18px; }
  .rm { align-self: center; margin-top: 16px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .actions { padding-left: max(20px, calc(50% - 470px)); padding-right: max(20px, calc(50% - 470px)); }
  .actions:not(.res) { display: flex; justify-content: flex-end; }
  .actions:not(.res) .btn.big { width: 240px; }
  .actions.res { flex-direction: row; align-items: center; }
  .actions.res .status { order: 2; flex: 1; text-align: left; }
  .actions.res .status:empty { display: block; }
  .actions.res .mini { order: 3; }
  .actions.res .mini .btn { flex: none; height: 48px; padding: 0 16px; }
  .actions.res .main { display: contents; }
  .actions.res #backBtn { order: 1; }
  .actions.res #printBtn { order: 4; padding: 0 22px; }
  .modal { align-items: center; }
  .sheet { border-radius: 14px; }
}

/* print: results only, OSS header, company line on every page */
.print-head, .print-foot { display: none; }
@media print {
  @page { margin: 14mm 12mm 16mm; }
  body { background: #fff; padding: 0; font-size: 10.5pt; }
  .top, .bar, .menu, .actions, .company, .keys, .modal, #inputPage, .spacer { display: none !important; }
  #resultPage { display: block !important; max-width: none; padding: 0; }
  .print-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5pt solid var(--navy); padding-bottom: 6pt; margin-bottom: 10pt; }
  .print-head img { height: 22pt; width: auto; }
  .print-title { text-align: right; }
  .print-title b { display: block; font-size: 14pt; }
  .print-title span { color: var(--muted); font-size: 9pt; }
  .print-foot { display: block; position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 8pt; color: #677382; }
  .card { border: 0; padding: 0; margin: 0 0 12pt; border-radius: 0; }
  .card h2 { font-size: 12.5pt; margin-bottom: 4pt; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile { break-inside: avoid; }
  .tile .v { font-size: 14pt; }
  .pat { break-inside: avoid; padding: 6pt 0; }
  .parts-t tr { break-inside: avoid; }
  .best { border: 1px solid #E8D9A8; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* new version available */
.update { position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 8px); z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--navy); color: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(14,26,38,.25); font-size: 15px; }
.update .btn { min-height: 40px; background: var(--cyan); color: var(--navy); border: 0; }
@media print { .update { display: none !important; } }

@media (max-width: 400px) {
  .seg button { padding: 0 10px; font-size: 14.5px; }
  .bar { gap: 6px; }
}

/* tabular figures only where numbers line up (Inter's tnum also widens the hyphen) */
input.num, .tile .v, .cuts, .parts-t, .pat-head, .prow-shown, .shown { font-feature-settings: "tnum" 1; }

/* messages sit right above Calculate, like the desktop */
.actions .msg { margin: 0 0 8px; max-height: 34vh; overflow-y: auto; }
.actions .msg:empty { display: none; }
.actions .msg.busy { text-align: center; padding: 0; }

/* license / paywall */
.license-note { margin: 0 2px 8px; font-size: 13px; color: var(--muted); text-align: center; }
.license-note:empty { display: none; }
.modal-body p { margin: 0 0 10px; white-space: normal; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-btns a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
.modal-btns a.btn.primary { color: #fff; }
.btn[disabled], .btn.is-soon { opacity: .65; cursor: not-allowed; }
.modal-body .text { width: 100%; }
.soon-label {
  display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px;
  background: rgba(255,255,255,.25); font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; vertical-align: middle;
}
.btn:not(.primary) .soon-label { background: rgba(14,26,38,.08); color: var(--muted); }

.btn.is-soon { white-space: normal; height: auto; min-height: 48px; padding: 10px 16px; line-height: 1.3; }
