/* Job Calc. Tape-measure yellow on jobsite charcoal, with a bright mode for sun. */
:root {
  --bg: #efece4; --panel: #ffffff; --panel2: #f6f3ec; --line: #d8d2c3;
  --text: #17171a; --muted: #6b675e; --key: #ffffff; --key2: #e9e5da; --keyp: #ddd7c8;
  --op: #1d1d20; --opt: #ffc414; --y: #ffc414; --yi: #1a1400; --yd: #e0a800;
  --red: #c4321f; --ok: #1f7a3a; --shadow: 0 1px 0 rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --num: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --panel: #1b1d20; --panel2: #16181b; --line: #2c2f34;
    --text: #f3f0e8; --muted: #9c998f; --key: #25282d; --key2: #1f2226; --keyp: #33373d;
    --op: #2f2a1a; --opt: #ffc414; --red: #ff6b57; --ok: #4fc277; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121315; --panel: #1b1d20; --panel2: #16181b; --line: #2c2f34;
  --text: #f3f0e8; --muted: #9c998f; --key: #25282d; --key2: #1f2226; --keyp: #33373d;
  --op: #2f2a1a; --opt: #ffc414; --red: #ff6b57; --ok: #4fc277; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 500 16px/1.3 var(--font);
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
u { text-decoration: none; color: var(--muted); font-weight: 600; }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 12px 6px; }
.brand .mark { display: block; width: 32px; height: 32px; border-radius: 8px; background: var(--y) url("icon-192.png") center/cover; }
.tabs { flex: 1; display: flex; background: var(--key2); border-radius: 12px; padding: 3px; gap: 3px; }
.tabs button { flex: 1; height: 42px; border-radius: 9px; font-weight: 700; font-size: 15px; line-height: 1.05; color: var(--muted); padding: 0 4px; }
.tabs button[aria-selected="true"] { background: var(--y); color: var(--yi); }
.gear { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.gear:active { background: var(--key2); }
.top .mic { margin-right: -6px; }
#say-text { width: 100%; font: 600 20px/1.35 var(--num); border-radius: 14px; border: 1px solid var(--line); background: var(--panel); padding: 12px; resize: none; -webkit-user-select: text; user-select: text; }
.sayrow { display: flex; gap: 8px; margin-top: 10px; }
.sayrow .btn { flex: 1; }
.saymsg { min-height: 22px; margin: 8px 2px; font-weight: 600; color: var(--muted); }
.saymsg.bad { color: var(--red); }
.sayex { display: flex; flex-wrap: wrap; gap: 6px; }
.sayex .chip { height: auto; min-height: 40px; white-space: normal; text-align: left; padding: 8px 12px; border-radius: 12px; }
body.es .tabs button { font-size: 13.5px; letter-spacing: -.01em; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* tape */
.tapewrap { flex: 1; min-height: 56px; display: flex; flex-direction: column; padding: 0 12px; }
.tapehead { display: flex; justify-content: space-between; align-items: center; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; height: 22px; }
.link { color: var(--muted); font-size: 13px; text-transform: none; letter-spacing: 0; text-decoration: underline; padding: 4px 0 4px 12px; }
.tape { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tape li:first-child { margin-top: auto; }
.tape li button { width: 100%; text-align: right; padding: 6px 4px; border-bottom: 1px dashed var(--line); font-family: var(--num); }
.tape li button:active { background: var(--key2); }
.tape .te { color: var(--muted); font-size: 15px; display: block; }
.tape .tr { font-size: 19px; font-weight: 700; }
.tape .hint { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 4px; margin-top: auto; }

/* display */
.display { margin: 4px 12px 8px; background: var(--panel); border-radius: 16px; padding: 8px 14px 10px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.expr { min-height: 22px; font: 600 17px/1.3 var(--num); color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.big { display: block; width: 100%; text-align: right; font: 700 46px/1.1 var(--num); letter-spacing: -.01em; min-height: 52px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.big.typing { color: var(--text); }
.big.answer::before { content: "= "; color: var(--yd); }
.big b { font-weight: 700; }
.big u, .tr u { text-decoration: none; color: var(--muted); font-weight: 600; margin-left: 1px; }
.big em { font-style: normal; font-size: .55em; color: var(--muted); font-weight: 600; }
.big .ph { color: var(--muted); opacity: .5; }
.fr { display: inline-flex; align-items: center; font-size: .62em; vertical-align: .12em; margin: 0 1px; }
.fr sup { vertical-align: .55em; font-size: 1em; line-height: 0; }
.fr sub { vertical-align: -.3em; font-size: 1em; line-height: 0; }
.fr i { font-style: normal; margin: 0 1px; opacity: .7; }
.sub { min-height: 20px; text-align: right; font: 600 16px/1.25 var(--num); color: var(--muted); }
.sub.err { color: var(--red); }
.sub .pv { color: var(--text); }
.approx { display: inline-block; font-size: 12px; font-weight: 700; color: var(--yi); background: var(--y); border-radius: 6px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.alts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; min-height: 26px; }
.alts span { font: 600 14px/24px var(--num); color: var(--muted); background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 0 7px; }

/* keypad */
.padwrap { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
.pad { display: grid; grid-template-columns: repeat(4, 1fr) 1.18fr; grid-auto-rows: 62px; gap: 7px; }
.k { border-radius: 14px; background: var(--key); font: 600 30px/1 var(--num); box-shadow: var(--shadow); border: 1px solid var(--line); display: grid; place-items: center; }
.k:active, .k.down { background: var(--keyp); transform: translateY(1px); }
.k.fn { font-size: 24px; color: var(--muted); background: var(--key2); }
.k.unit { background: var(--y); color: var(--yi); border-color: var(--yd); font-size: 28px; font-weight: 700; }
.k.unit:active { background: var(--yd); }
.k.op { background: var(--op); color: var(--opt); font-size: 34px; border-color: transparent; }
.k.eq { background: var(--y); color: var(--yi); font-size: 36px; border-color: var(--yd); }
.k.eq.done { font-size: 22px; font-weight: 700; }
.k.op.on { outline: 3px solid var(--y); outline-offset: -3px; }
.frhead { border-radius: 14px; background: var(--key2); border: 1px solid var(--line); font: 700 15px/1.1 var(--num); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.frhead small { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* the fraction column looks like a tape blade */
.fracs { grid-column: 5; grid-row: 2 / span 4; overflow-y: auto; border-radius: 14px; background: var(--y); border: 1px solid var(--yd); overscroll-behavior: contain; scrollbar-width: none; position: relative; }
.fracs::-webkit-scrollbar { display: none; }
.fk { display: flex; align-items: center; width: 100%; height: 50px; position: relative; color: var(--yi); border-bottom: 1px solid rgba(0,0,0,.14); }
.fracs.d32 .fk { height: 44px; }
.fk:active, .fk.down { background: rgba(0,0,0,.14); }
.fk .tick { position: absolute; left: 0; top: 50%; height: 3px; margin-top: -1.5px; background: var(--yi); border-radius: 0 2px 2px 0; }
.fk .t2 { width: 46%; height: 4px; } .fk .t4 { width: 34%; } .fk .t8 { width: 24%; } .fk .t16 { width: 15%; height: 2px; } .fk .t32 { width: 8%; height: 2px; }
.fk .fl { margin-left: auto; margin-right: 8px; font: 700 22px/1 var(--num); display: inline-flex; align-items: center; }
.fk .fl sup { font-size: 17px; vertical-align: 7px; }
.fk .fl sub { font-size: 17px; vertical-align: -5px; }
.fk .fl i { font-style: normal; margin: 0 1px; font-size: 18px; opacity: .75; }
.fk.d2 .fl { font-size: 24px; }

/* yards and tons */
.volscroll { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 12px calc(20px + env(safe-area-inset-bottom)); -webkit-user-select: text; user-select: text; }
.shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.shape { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; line-height: 1.1; text-align: center; min-height: 64px; color: var(--muted); }
.shape svg { width: 30px; height: 30px; color: var(--text); }
.shape[aria-checked="true"] { background: var(--y); border-color: var(--yd); color: var(--yi); }
.shape[aria-checked="true"] svg { color: var(--yi); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.frow { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 58px; border-bottom: 1px solid var(--line); text-align: left; gap: 10px; }
.frow:last-child { border-bottom: 0; }
.frow .fn { font-weight: 600; color: var(--muted); }
.frow .fv { font: 700 26px/1.1 var(--num); text-align: right; }
.frow .fv.empty { color: var(--muted); opacity: .55; font-size: 18px; font-weight: 600; }
.frow .fv u { text-decoration: none; color: var(--muted); font-weight: 600; }
.frow:active { background: var(--panel2); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.lbl { font-weight: 600; color: var(--muted); font-size: 15px; }
.seg { display: flex; background: var(--key2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { min-width: 50px; height: 38px; border-radius: 8px; font-weight: 700; color: var(--muted); padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.result { padding: 12px 14px; }
.result .yd { font: 700 44px/1 var(--num); }
.result .yd em { font-style: normal; font-size: 22px; color: var(--muted); }
.result .more { color: var(--muted); font: 600 16px/1.4 var(--num); margin-top: 4px; }
.result .none { color: var(--muted); padding: 6px 0; }
.result .order { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel2); font: 600 16px/1.4 var(--num); }
.result .order b { font-size: 19px; }
.mhead { display: flex; justify-content: space-between; align-items: baseline; padding-top: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 40px; padding: 0 14px; border-radius: 20px; background: var(--key2); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--y); color: var(--yi); border-color: var(--yd); }
.mline { display: flex; align-items: center; gap: 8px; padding: 6px 0 10px; flex-wrap: wrap; }
.mline input { width: 74px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); text-align: center; font: 700 20px var(--num); }
.mline .tons { margin-left: auto; font: 700 26px/1 var(--num); }
.mline .tons em { font-style: normal; font-size: 16px; color: var(--muted); }
.loads { font: 700 22px var(--num); margin-left: auto; }
.loads small { font-size: 14px; color: var(--muted); font-weight: 600; }
.btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 52px; border-radius: 14px; font-weight: 700; font-size: 17px; background: var(--key2); border: 1px solid var(--line); }
.btn.y { background: var(--y); color: var(--yi); border-color: var(--yd); }
.btn:active { filter: brightness(.94); }
.jl { list-style: none; margin: 0; padding: 0; }
.jl li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.jl .jn { flex: 1; min-width: 0; }
.jl .jn b { display: block; }
.jl .jn small { color: var(--muted); font-family: var(--num); font-size: 14px; }
.jl .jy { font: 700 20px var(--num); text-align: right; }
.jl .jy small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.x { width: 40px; height: 40px; border-radius: 10px; color: var(--muted); font-size: 20px; }
.x:active { background: var(--key2); }
.jtot { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0 6px; font-weight: 700; }
.jtot span:last-child { font: 700 26px var(--num); }
.jhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 2px; }
.fine { font-size: 13px; color: var(--muted); margin: 4px 4px 0; }
.card .pad-gap { height: 10px; }

/* tools */
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 2px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; min-height: 96px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left; font-weight: 700; font-size: 16px; line-height: 1.15; box-shadow: var(--shadow); }
.tcard svg { width: 34px; height: 34px; color: var(--text); }
.tcard:active { background: var(--panel2); }
.tback { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.tback button { height: 42px; padding: 0 14px 0 10px; border-radius: 12px; background: var(--key2); font-weight: 700; color: var(--muted); }
.tback h2 { margin: 0; font-size: 20px; }
.optrow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.optrow .fn { display: block; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.optrow .seg button { flex: 1; }
.optrow:last-child { border-bottom: 0; }
.titems { padding: 4px 0; }
.ti { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.ti:last-child { border-bottom: 0; }
.ti .tl { color: var(--muted); font-weight: 600; }
.ti .tv { font: 700 22px/1.15 var(--num); text-align: right; }
.ti.head { flex-direction: column; align-items: flex-start; gap: 0; }
.ti.head .tv { font-size: 44px; text-align: left; }
.ti.send .tv::after { content: " ›"; color: var(--muted); font-size: .7em; }
.ti .ok { color: var(--ok); } .ti .bad { color: var(--red); }
.ti.wide { flex-direction: column; align-items: stretch; }
.ti.wide .tv { font-size: 17px; text-align: left; font-weight: 600; }
.marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.marks > span { font: 600 15px/1.2 var(--num); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.marks > span small { color: var(--muted); }
.terr { color: var(--red); padding: 10px 0; font-weight: 600; }

/* sheets */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 20px 20px 0 0; max-height: 94dvh; display: flex; flex-direction: column; box-shadow: 0 -8px 30px rgba(0,0,0,.3); }
.sheet .sh { display: flex; align-items: center; padding: 10px 12px 4px; gap: 8px; }
.sheet .sh h2 { flex: 1; margin: 0; font-size: 19px; }
.sheet .close { height: 40px; padding: 0 14px; border-radius: 10px; color: var(--muted); font-weight: 600; background: var(--key2); }
.sheet .sbody { overflow-y: auto; padding: 4px 14px calc(16px + env(safe-area-inset-bottom)); -webkit-user-select: text; user-select: text; }
.sheet .display { margin: 4px 12px 8px; }
.sheet .padwrap { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.sheet .hintline { color: var(--muted); font-size: 13.5px; padding: 0 16px 6px; }
.set { margin: 6px 0 14px; }
.set .lbl { display: block; margin-bottom: 6px; }
.set .seg { width: 100%; }
.set .seg button { flex: 1; }
.help { font-size: 15px; line-height: 1.45; }
.help h3 { font-size: 16px; margin: 16px 0 4px; }
.help p { margin: 4px 0; }
.help kbd { font: 700 14px var(--num); background: var(--key2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.about { color: var(--muted); font-size: 13px; margin-top: 18px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; background: #1b1d20; color: #f3f0e8; border-radius: 14px; padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 12px; font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.toast button { color: var(--y); font-weight: 700; padding: 8px 10px; border-radius: 8px; }

/* short phones: smaller keys so it all fits */
@media (max-height: 700px) {
  .pad { grid-auto-rows: 52px; gap: 6px; }
  .big { font-size: 38px; min-height: 44px; }
  .fk { height: 42px; } .fracs.d32 .fk { height: 38px; }
}
@media (max-width: 400px) { .brand { display: none; } }
@media (min-width: 560px) {
  body { max-width: 520px; margin: 0 auto; }
  .sheet { max-width: 520px; margin: 0 auto; }
}
