:root {
  /* USF / CUTR brand palette */
  --green: #006747;
  --green-dark: #024c36;
  --gold: #cfc493;
  --gold-dark: #8c8049;
  --bg: #f4f6f4;
  --card: #fff;
  --line: #dde3dd;
  --red: #b42318;
  --amber: #a9832a;
  --text: #1a2620;
  --muted: #5c6b62;
  /* radius scale - controls tight, containers softer, no uniform bubbles */
  --r-sm: 6px;
  --r-md: 8px;
}
* { box-sizing: border-box; }
/* the hidden attribute must beat class display:flex (capflag, feedback, fb-form) */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: 'Public Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
h1, h2, h3 { text-wrap: balance; }

header {
  background: #fff;
  border-bottom: 3px solid var(--green);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
header .logo { height: 40px; width: auto; }
header button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--green);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--r-sm);
}
.subbar {
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 8px 16px;
  border-bottom: 2px solid var(--gold);
}
/* Demo mode has to be unmistakable. A small badge was not enough: a CUTR reviewer entered
   the demo code, could not clear the sample serial, and reasonably read the canned result
   as the app being broken. */
.demo-banner {
  background: #fff8e1;
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #6b5415;
}
.demo-banner strong { color: #4d3c0c; }
.demo-banner button {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--amber);
  color: #fff;
}
body.demo .subbar::after {
  content: 'Demo';
  float: right;
  background: var(--gold);
  color: var(--green-dark);
  font-weight: 700;
  padding: 0 8px;
  border-radius: 4px;
}

.screen { padding: 16px; max-width: 560px; margin: 0 auto; }
.sub { color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; font-size: 14px; }

input[type=email], input[type=password], input[type=text], input[type=tel], input[type=number], textarea {
  width: 100%;
  padding: 13px 14px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
}
input:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
textarea { resize: vertical; }

button {
  border: none;
  border-radius: var(--r-sm);
  padding: 14px 18px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary { width: 100%; background: var(--green); color: #fff; margin: 8px 0; }
button.primary:hover { background: var(--green-dark); }
button.secondary { width: 100%; background: #eef1ee; color: var(--text); margin-top: 20px; }
button:disabled { opacity: .55; cursor: not-allowed; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.thumb { position: relative; }
.thumb img { width: 88px; height: 88px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; }
.thumb-x {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; padding: 0;
  border-radius: 50%; background: var(--red); color: #fff; border: 2px solid #fff;
  font-size: 15px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.verdict {
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 16px;
  border-radius: var(--r-md);
  text-align: center;
  color: #fff;
  background: var(--amber);
}
.verdict.legal { background: var(--green); }
.verdict.illegal { background: var(--red); }
.verdict.needs_review { background: var(--amber); }

.capflag {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #fbe9e7;
  border: 1px solid var(--red);
  color: var(--red);
  font-weight: 600;
}
.capflag .tag {
  flex: none;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

h3.section {
  margin: 20px 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--green-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 5px;
}
#r-label { margin: 14px 0 2px; font-size: 22px; }
#r-speed { font-variant-numeric: tabular-nums; }
.sp-over { color: var(--red); font-weight: 700; }
/* Link to the page a spec figure came from, shown next to the figure itself. */
.sp-src { font-size: 13px; font-weight: 600; color: var(--green); margin-left: 6px; white-space: nowrap; }
#r-points { padding-left: 18px; }
#r-points li { margin-bottom: 6px; }
.markings { margin: 10px 0; font-size: 14px; color: var(--muted); }
details { margin: 14px 0; }
details summary { cursor: pointer; color: var(--green); font-weight: 600; }

.field-label { display: block; margin: 14px 0 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.field-row { display: flex; gap: 12px; }
.field-row > div { flex: 1; }
.field-row input, .field-row select { width: 100%; }
/* Manufacturer + model: an alternative or a supplement to photos, so it sits right under them. */
.makemodel { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); padding: 4px 14px 8px; margin: 4px 0 0; min-width: 0; }
.makemodel legend { font-size: 13px; font-weight: 700; color: var(--green-dark); padding: 0 6px; margin-left: -6px; }
.makemodel p { margin: 2px 0 0; }
.makemodel .field-label { margin-top: 10px; }
.makemodel .field-row > div { min-width: 0; }
.idsource { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.idsource strong { color: var(--text); }
.loc-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; flex-wrap: wrap; }
.loc-btn { width: auto; background: #eef1ee; color: var(--green-dark); border: 1px solid var(--line); padding: 10px 16px; font-size: 14px; }
#gps-status { font-size: 13px; }

.research { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin: 10px 0; }
.research p { margin: 0 0 8px; }
.research dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; }
.research dt { color: var(--muted); font-size: 13px; }
.research dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.research .warn { color: var(--red); font-weight: 600; margin: 10px 0 0; }

.help-id { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.help-id .chatrow { margin-top: 8px; }
.help-id input { margin: 0; }

.sources { font-size: 13px; margin: 14px 0; }
.sources ul { padding-left: 18px; margin: 4px 0; }
.sources a { color: var(--green); word-break: break-word; }

.feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.feedback .fb-q { font-weight: 600; margin-right: 4px; }
.fb {
  width: auto;
  padding: 8px 14px;
  font-size: 14px;
  background: var(--green);
  color: #fff;
  border-radius: var(--r-sm);
}
.fb.ghost { background: transparent; border: 1px solid var(--line); color: var(--green); }
.fb-done { color: var(--green); font-weight: 700; }
.fb-form { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fb-form select, .fb-form input { margin: 0; flex: 1; min-width: 140px; }
select {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}

.chatlog { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.bubble { padding: 10px 13px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 3px; }
.bubble.model { align-self: flex-start; background: #eef1ee; border-bottom-left-radius: 3px; }
.bubble .cite { margin-top: 6px; padding-top: 6px; border-top: 1px solid #d3dad3; font-size: 12px; color: var(--muted); }
.bubble .cite a { color: var(--green); }
.chatrow { display: flex; gap: 8px; }
.chatrow input { flex: 1; margin: 0; }
.chatrow button { background: var(--green); color: #fff; }

.report-actions { display: flex; gap: 10px; margin-top: 18px; }
.report-actions .secondary { margin: 0; flex: 1; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 22px 16px 28px;
}

/* Printable / PDF report (browser print → Save as PDF; works on iOS Safari) */
#printable { display: none; }
@media print {
  body > *:not(#printable) { display: none !important; }
  #printable {
    display: block !important;
    font-family: 'Public Sans', Arial, sans-serif;
    color: #111; padding: 8px 4px; max-width: 100%;
  }
  #printable .pr-head { display: flex; justify-content: space-between; align-items: flex-start;
    border-bottom: 2px solid var(--green); padding-bottom: 8px; margin-bottom: 14px; }
  #printable .pr-org { font-size: 9px; letter-spacing: 1px; color: var(--green-dark); font-weight: 700; }
  #printable .pr-title { font-size: 18px; font-weight: 800; color: var(--green); }
  #printable .pr-meta { font-size: 10px; color: #555; text-align: right; }
  #printable .pr-verdict { color: #fff; background: var(--amber); font-weight: 800; letter-spacing: 1px;
    padding: 8px 12px; border-radius: 6px; margin: 6px 0 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printable .pr-legal { background: var(--green); }
  #printable .pr-illegal { background: var(--red); }
  #printable .pr-needs_review { background: var(--amber); }
  #printable h2 { font-size: 15px; margin: 4px 0 8px; }
  #printable h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--green-dark);
    border-bottom: 1px solid var(--gold); padding-bottom: 3px; margin: 14px 0 6px; }
  #printable table { width: 100%; border-collapse: collapse; font-size: 11px; }
  #printable th { text-align: left; color: #555; font-weight: 600; width: 34%; padding: 2px 8px 2px 0; vertical-align: top; }
  #printable td { padding: 2px 0; font-weight: 600; }
  #printable ul { margin: 4px 0; padding-left: 16px; font-size: 11px; line-height: 1.5; }
  #printable .pr-flag { background: #fbe9e7; border: 1px solid var(--red); color: var(--red);
    padding: 6px 10px; border-radius: 5px; font-size: 11px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printable .pr-narr { font-size: 11px; line-height: 1.55; }
  #printable .pr-foot { margin-top: 16px; font-size: 8.5px; color: #777; border-top: 1px solid #ddd; padding-top: 6px; }
  @page { margin: 12mm; }
}

/* ---- Accounts: sign-in, header, People ---- */
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.whoami { font-size: 13px; font-weight: 600; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install-tip { background: #fff8e1; border: 1px solid #e8d49a; color: #4d3c0c; border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; }
.demo-entry { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); }
.demo-entry .secondary { margin-top: 0; }
button.linklike { background: none; border: 0; color: var(--green); padding: 6px 0; font-weight: 600; text-decoration: underline; }
.small { font-size: 13px; }
.admin-h { margin: 4px 0 0; font-size: 20px; }
.invite-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md, 10px); padding: 4px 14px 10px; margin: 12px 0; }
.invite-form input, .invite-form select { width: 100%; }
.invite-msg { font-size: 14px; color: var(--green-dark); min-height: 1.2em; margin: 4px 0 0; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.person { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; }
.person.disabled { opacity: .6; }
.person-main { min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.person-actions button { background: #eef1ee; color: var(--green-dark); border: 1px solid var(--line); padding: 6px 10px; font-size: 13px; }
.pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--green); color: #fff; border-radius: 999px; padding: 2px 7px; vertical-align: middle; }

/* ---- Passkeys ---- */
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0 4px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.passkey-offer { background: #eef6f2; border: 1px solid #b9d8c9; border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 14px; }
.passkey-offer p { margin: 6px 0; font-size: 14px; }
.passkey-actions { display: flex; align-items: center; gap: 14px; }
.passkey-actions .primary { width: auto; padding-left: 20px; padding-right: 20px; }
