/* Sign Surveyor. Brand: green #ACCD24, black, white, gray #BDBFC1. Red is for alerts only.
   NOTE: design-system/on-top/MASTER.md was not available at build time. These tokens come
   from spec hard rule 7. Replace them with the MASTER.md tokens at deploy if they differ. */
:root {
  --green: #ACCD24;
  --black: #000;
  --white: #fff;
  --gray: #BDBFC1;
  --gray-light: #F3F4F4;
  --text-2: #55585B;
  --alert: #B3261E;
  --radius: 10px;
  --tap: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--white); color: var(--black);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
a { color: inherit; }

/* Top bar */
#bar { position: sticky; top: 0; z-index: 5; background: var(--black); color: var(--white); padding-top: env(safe-area-inset-top); border-bottom: 3px solid var(--green); }
.bar-top { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 14px; }
.bar-top h1 { font-size: 18px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 26px; text-decoration: none; min-width: 44px; min-height: 44px; display: grid; place-items: center; margin-left: -10px; }
.brand-mark { width: 18px; height: 18px; border: 3px solid var(--green); }
.net { font-size: 13px; color: var(--green); font-weight: 600; }
.steps { display: flex; }
.steps a { flex: 1; text-align: center; padding: 11px 0 9px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--gray); border-bottom: 3px solid transparent; margin-bottom: -3px; }
.steps a.on { color: var(--white); border-bottom-color: var(--white); }

#main { padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
#main > div > * + *, #main > * + * { margin-top: 14px; }

/* Cards and text */
.card { border: 1px solid var(--gray); border-radius: var(--radius); padding: 14px; }
.card > * + * { margin-top: 12px; }
.card h2, .list-title { font-size: 17px; font-weight: 700; }
.list-title { margin-top: 22px !important; }
.note { font-size: 14px; color: var(--text-2); }
.center { text-align: center; }
.empty { color: var(--text-2); text-align: center; padding: 18px 0; }
.step-help { font-size: 16px; }
.req { font-size: 12px; font-weight: 700; color: var(--alert); margin-left: 6px; text-transform: uppercase; letter-spacing: .03em; }
.tag { font-size: 11px; font-weight: 700; background: var(--black); color: var(--green); border-radius: 4px; padding: 1px 5px; margin-left: 4px; text-transform: uppercase; }
.card.alert { border: 2px solid var(--alert); }
.card.alert h2, .alert-text { color: var(--alert); }
.alert-text { font-size: 14px; font-weight: 600; }
.card.alert ul { margin: 8px 0 0; padding-left: 20px; }
.card.alert li { padding: 6px 0; }
ul.plain { margin: 0; padding-left: 20px; font-size: 15px; }
.card.waiting { background: var(--black); color: var(--white); border-color: var(--black); display: grid; gap: 2px; }
.card.waiting .note { color: var(--gray); margin: 0; }

/* Forms */
label, .field { display: block; font-size: 14px; font-weight: 600; }
.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=datetime-local], select, textarea {
  display: block; width: 100%; min-height: var(--tap); margin-top: 6px; padding: 10px 12px;
  font: inherit; font-size: 17px; font-weight: 400; color: var(--black); background: var(--white);
  border: 1.5px solid #8d8f91; border-radius: 8px; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #000 50%), linear-gradient(135deg, #000 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--green); outline-offset: 1px; border-color: var(--black); }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; font-size: 16px; }
label.check input { width: 24px; height: 24px; accent-color: var(--black); margin: 0; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > label, .row > .btn { flex: 1; min-width: 0; }
.row > * { margin-top: 0; }

/* A required box that flashes until the user types a value */
@keyframes must-flash { 0%, 49% { border-color: var(--alert); box-shadow: 0 0 0 4px rgba(179,38,30,.35); background: #FDECEA; } 50%, 100% { border-color: var(--alert); box-shadow: none; background: var(--white); } }
.must.flash input { border: 3px solid var(--alert); animation: must-flash 0.9s infinite; }
@media (prefers-reduced-motion: reduce) { .must.flash input { animation: none; background: #FDECEA; box-shadow: 0 0 0 4px rgba(179,38,30,.35); } }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--tap); padding: 10px 16px;
  font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
  color: var(--black); background: var(--white); border: 2px solid var(--black); border-radius: var(--radius); }
.btn.primary { background: var(--green); border-color: var(--green); }
.btn.big { min-height: 64px; font-size: 20px; }
.btn.small { min-height: 44px; font-size: 15px; padding: 6px 12px; width: auto; }
.btn.danger { background: var(--alert); border-color: var(--alert); color: var(--white); }
.btn:disabled { background: var(--gray-light); border-color: var(--gray); color: #8d8f91; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.link { background: none; border: 0; font: inherit; text-decoration: underline; padding: 10px 4px; color: inherit; cursor: pointer; }
.icon-btn { min-width: 48px; min-height: 48px; background: none; border: 0; font-size: 18px; color: var(--text-2); cursor: pointer; }
.stack { display: grid; gap: 10px; }

/* Segmented choice and stepper */
.seg { display: flex; border: 2px solid var(--black); border-radius: var(--radius); overflow: hidden; }
.seg button { flex: 1; min-height: 46px; font: inherit; font-weight: 600; background: var(--white); color: var(--black); border: 0; border-left: 2px solid var(--black); cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--black); color: var(--white); }
.stepper { display: flex; align-items: center; gap: 0; border: 2px solid var(--black); border-radius: var(--radius); width: max-content; overflow: hidden; }
.stepper button { width: 56px; min-height: 46px; font-size: 24px; font-weight: 700; background: var(--white); color: var(--black); border: 0; cursor: pointer; }
.stepper output { min-width: 56px; text-align: center; font-weight: 700; font-size: 18px; }

/* Lists */
.result { display: block; width: 100%; text-align: left; padding: 12px 14px; min-height: var(--tap); background: var(--white); color: var(--black);
  border: 1px solid var(--gray); border-radius: var(--radius); font: inherit; text-decoration: none; cursor: pointer; margin-top: 8px; }
.result b { display: block; }
.result span { display: block; font-size: 14px; color: var(--text-2); }
.result.on { border: 2px solid var(--black); }
.results:empty { display: none; }
.item-row { display: flex; align-items: center; gap: 4px; }
.item-row .result { flex: 1; }
.line { padding: 8px 0; border-top: 1px solid var(--gray-light); }
.line b { display: block; font-size: 15px; }
.line span { font-size: 14px; color: var(--text-2); }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; font-size: 15px; flex-wrap: wrap; }
.checklist li > .tick { flex: none; width: 24px; height: 24px; border: 2px solid var(--gray); border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.checklist li.done > .tick { background: var(--green); border-color: var(--green); }

/* Photos and surfaces */
.photo { display: flex; gap: 12px; border: 1px solid var(--gray); border-radius: var(--radius); padding: 10px; margin-top: 10px; }
.photo img, .gridthumb { width: 92px; height: 92px; object-fit: cover; border-radius: 6px; flex: none; background: var(--gray-light); }
.gridthumb { background-image: linear-gradient(var(--gray) 1px, transparent 1px), linear-gradient(90deg, var(--gray) 1px, transparent 1px); background-size: 15px 15px; border: 1px solid var(--gray); }
.grow { flex: 1; min-width: 0; display: grid; gap: 8px; align-content: start; }
.pick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pick img { width: 104px; height: 104px; object-fit: cover; border-radius: 8px; border: 2px solid var(--black); display: block; }

/* Canvas */
.canvas-wrap { display: flex; justify-content: center; background: var(--gray-light); border-radius: 6px; overflow: hidden; }
canvas { touch-action: none; display: block; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.draw-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.draw-head span { font-size: 14px; color: var(--text-2); }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--black); border: 2px solid var(--black); border-radius: var(--radius); overflow: hidden; }
.tools button { min-height: 46px; font: inherit; font-size: 15px; font-weight: 700; background: var(--white); color: var(--black); border: 0; cursor: pointer; padding: 0 2px; }
.tools button.on { background: var(--green); }
.tools button:first-child { grid-column: span 2; }
.pass-text { font-size: 14px; font-weight: 700; }
.pass-text::before { content: '\2713  '; }
details.card summary { min-height: 30px; cursor: pointer; }
ol.plain { margin: 0; padding-left: 22px; font-size: 15px; }
ol.plain li { padding: 3px 0; }
.editor { border: 2px solid var(--black); }

.viewrow { flex-wrap: nowrap; }
.viewrow .btn { flex: 1; font-size: 18px; }
.viewrow #dr-undo, .viewrow #dr-fit { flex: 2; font-size: 15px; }

/* Totals: shown at all times on the surface screens */
.totals { display: flex; background: var(--black); color: var(--white); border-radius: var(--radius); padding: 10px 6px; position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 3; }
.totals div { flex: 1; text-align: center; }
.totals b { display: block; font-size: 20px; color: var(--green); font-variant-numeric: tabular-nums; }
.totals span { font-size: 12px; color: var(--gray); }

/* Tape-measure keypad */
#keypad { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #111; display: grid; gap: 8px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
body.kp-open { padding-bottom: 460px; }
body.kp-open #toast { bottom: 410px; }
.kp-head { display: flex; justify-content: space-between; align-items: center; color: var(--gray); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.kp-abc { background: none; border: 1px solid #55585B; border-radius: 8px; color: var(--white); font: inherit; font-size: 12px; font-weight: 600; min-height: 32px; padding: 0 10px; cursor: pointer; text-transform: none; }
.kp-fracs { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: none; }
.kp-fracs::-webkit-scrollbar { display: none; }
.kp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kp-key { height: 50px; border: 0; border-radius: 10px; background: var(--white); color: var(--black); font: 700 24px -apple-system, system-ui, sans-serif; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.kp-key small { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); margin-top: -4px; }
.kp-key.alt { background: var(--gray); }
.kp-key.word { font-size: 15px; }
.kp-key.kp-frac { flex: none; height: 44px; min-width: 62px; padding: 0 8px; font-size: 18px; background: #2a2a2a; color: var(--white); }
.kp-key.kp-frac.common { color: var(--green); }
.kp-key:active, .kp-next:active { opacity: .7; }
.kp-next { height: 52px; border: 0; border-radius: 10px; background: var(--green); color: var(--black); font: 700 21px -apple-system, system-ui, sans-serif; cursor: pointer; touch-action: manipulation; }

/* Toast and dialog */
#toast { position: fixed; left: 14px; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30; background: var(--black); color: var(--white);
  padding: 14px 16px; border-radius: var(--radius); font-weight: 600; text-align: center; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .15s, transform .15s; }
#toast.show { opacity: 1; transform: none; }
#toast.alert { background: var(--alert); }
.dialog-back { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 18px; }
.dialog { background: var(--white); border-radius: 14px; padding: 18px; max-width: 420px; width: 100%; display: grid; gap: 12px; }
.dialog h2 { font-size: 19px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
