/* OP Field — mobile-first field ergonomics (F2; re-tinted by the UX-2 design pass).
 * Dark by default (poor light: mechanical rooms, stairwells — contrast over subtlety);
 * tap targets >= 56px (glove-plausible); primary actions in thumb reach at the BOTTOM.
 * Colors come ONLY from tokens.css vars (html[data-theme=dark]); the local aliases below
 * keep the F2/F3 class vocabulary stable. Semantic custody colors are frozen meaning:
 * amber pill = queued on device, green = saved to server, red = alarm — always worded. */
:root {
  --bg: var(--surface); --card: var(--surface-raised); --line: var(--border);
  --fg: var(--text); --muted: var(--text-muted);
  --go: var(--primary); --go-fg: var(--on-primary);
  --warn: var(--queued); --bad: var(--alarm);
  --tap: 56px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
#topbar {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .9rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
#brand { font-weight: 700; letter-spacing: .02em; }
#who { margin-left: auto; font-size: .8rem; }
#view { padding: .9rem; max-width: 640px; margin: 0 auto; }
h1 { font-size: 1.3rem; margin: .2rem 0 .7rem; }
h2 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); font-size: .9rem; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: .9rem; margin: .7rem 0;
}
.pill {
  display: inline-block; padding: .1rem .6rem; border-radius: 999px;
  font-size: .78rem; border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--saved); border-color: var(--saved); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }

button, .btn {
  display: block; width: 100%; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--fg);
  font: inherit; font-size: 1.05rem; font-weight: 600;
  padding: .7rem 1rem; margin: .45rem 0; text-align: center;
  touch-action: manipulation;
}
button:active { transform: scale(.985); }
/* the GO button is BRAND primary (blue) — green now belongs exclusively to "saved" */
button.go { background: var(--go); color: var(--go-fg); border-color: var(--go); font-size: 1.15rem; }
button.quiet { font-weight: 400; color: var(--muted); min-height: 44px; }
button.danger { border-color: var(--bad); color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.grid2 button { margin: 0; min-height: 76px; }

input, select, textarea {
  width: 100%; min-height: var(--tap); font: inherit;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px;
  padding: .6rem .8rem; margin: .3rem 0 .7rem;
}
label { font-size: .9rem; color: var(--muted); display: block; margin-top: .5rem; }

.bottom { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%);
          padding-top: .8rem; }

#scanwrap { position: relative; border-radius: 14px; overflow: hidden;
            background: var(--surface); }
#scanwrap video { width: 100%; display: block; max-height: 62vh; object-fit: cover; }
#scanbox {
  position: absolute; inset: 12% 15%; border: 3px solid var(--accent);
  border-radius: 12px; opacity: .85; pointer-events: none;
}
#timing { font-variant-numeric: tabular-nums; }

.err {
  background: var(--alarm-soft-bg); border: 1px solid var(--alarm-soft-border);
  color: var(--alarm-soft-text);
  border-radius: 12px; padding: .7rem .9rem; margin: .6rem 0;
}
.okbox {
  background: var(--saved-soft-bg); border: 1px solid var(--saved-soft-border);
  color: var(--saved-soft-text);
  border-radius: 12px; padding: .7rem .9rem; margin: .6rem 0;
}
#toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); color: var(--fg);
  padding: .6rem 1rem; border-radius: 12px; z-index: 20; max-width: 92vw;
}
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
td, th { padding: .35rem .3rem; border-bottom: 1px solid var(--line); text-align: left; }
code { word-break: break-all; }

/* F3: sticky honesty banners (eviction, clock skew) + the queue badge */
#banner {
  padding: .7rem .9rem; margin: 0; border-radius: 0; font-size: .92rem;
  position: sticky; top: 0; z-index: 15;
}
#banner.warn { background: var(--restricted-bg); border-bottom: 1px solid var(--warn);
               color: var(--restricted-text); }
#banner.bad { background: var(--alarm-soft-bg); border-bottom: 1px solid var(--bad);
              color: var(--alarm-soft-text); }
#banner button { display: inline; width: auto; min-height: 0; margin-left: .5rem;
                 padding: .2rem .6rem; }
#queuebadge { cursor: pointer; }

/* UX-1.3: app chrome — back chevron, screen title (in #brand), overflow menu. Header
 * buttons are INLINE (the global full-width button rule is for content, not chrome). */
#topbar button.chrome {
  display: inline-block; width: auto; min-height: 44px; min-width: 44px;
  margin: 0; padding: 0 .55rem; border: 0; background: transparent;
  color: var(--fg); font-size: 1.5rem; line-height: 1;
}
#navback { font-size: 1.9rem; margin-left: -.4rem; }
#brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
#menu {
  position: fixed; right: .5rem; top: 3.4rem; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: .3rem; min-width: 13rem; box-shadow: var(--shadow);
}
#menu button { border: 0; background: transparent; text-align: left; margin: 0; }

/* UX-2: sign-in brand line (same mark as the web wordmark / app icon) */
.brandline { font-weight: 700; font-size: 1.15rem; margin: .8rem 0 1.4rem; }
.brandmark {
  display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -.18em;
  margin-right: .45em; border: .15em solid var(--primary); border-radius: .22em;
  border-right-width: .36em;
}

/* accessibility: visible focus (WCAG 2.4.7) */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
