:root {
  --bg: #f6f1e9;
  --surface: #fffaf3;
  --text: #1f1a16;
  --muted: #5b5048;
  --border: #6b5d52;
  --accent: #923000;
  --accent-text: #ffffff;
  --danger: #b00020;
  --listen-text: #fff;
  --warn-bg: #fde3cf;
  --focus: #0b4fd6;
  --ok: #1d6b2f;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --surface: #241e18;
    --text: #f7efe6;
    --muted: #c9bcae;
    --border: #a8998b;
    --accent: #ff8c3a;
    --accent-text: #17130f;
    --danger: #ff6b6b;
    --listen-text: #17130f;
    --warn-bg: #4a2a12;
    --focus: #8fb8ff;
    --ok: #7fd68f;
  }
}
* { box-sizing: border-box; }
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.wrap { max-width: 40rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
header { border-top: 0.5rem solid var(--accent); padding-top: 1.25rem; }
h1 { font-size: 2.2rem; line-height: 1.1; margin: 0 0 0.4rem; }
h2 { font-size: 1.5rem; margin: 0 0 0.75rem; }
.sub { margin: 0; font-size: 1.15rem; color: var(--muted); }
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
}
label { font-weight: 700; display: block; margin-bottom: 0.4rem; }
.hint { color: var(--muted); margin: 0; }
input, textarea, select {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.8rem 0.9rem;
  min-height: 3.2rem;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
select option { color: var(--text); background: var(--bg); }
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 0.4rem;
}
button {
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  min-height: 3.4rem;
  width: 100%;
  border-radius: 0.75rem;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.7rem 1.2rem;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
/* Busy controls keep readable text; aria-disabled and status text convey state. */
button:disabled, button[aria-disabled="true"], input:disabled, select:disabled,
input[type="file"][aria-disabled="true"] { opacity: 1; cursor: wait; -webkit-text-fill-color: currentColor; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.big { font-size: 1.45rem; min-height: 4.5rem; }
.status { font-weight: 700; margin: 0; }
.status:empty { display: none; }
.error { color: var(--danger); font-weight: 700; margin: 0; }
.error:empty { display: none; }
.ok { color: var(--ok); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.camera-file { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; min-height: 1px; padding: 0; overflow: hidden; }

/* talk area */
.talk { position: relative; display: flex; flex-direction: column; gap: 1rem; }
.talk textarea { min-height: 18rem; font-size: 1.2rem; }
.mic {
  width: 9.5rem; height: 9.5rem; min-height: 0;
  border-radius: 50%;
  padding: 0.5rem;
  font-size: 1.2rem; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
  box-shadow: 0 6px 0 rgba(0,0,0,0.25);
}
.mic svg { width: 3rem; height: 3rem; flex-shrink: 0; }
#micLabel { display: block; max-width: 8rem; font-weight: 700; text-align: center; }
.talk.empty .mic {
  position: absolute; left: 50%; top: 9rem;
  transform: translate(-50%, -50%);
}
.talk:not(.empty) .mic { align-self: center; }
.mic.listening { background: var(--danger); border-color: var(--danger); color: var(--listen-text); }
@media (prefers-reduced-motion: no-preference) {
  .mic.listening { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--border); } }
.trial { margin: 0; font-size: 1.05rem; }

/* report */
.report-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.report-list li { border-left: 0.35rem solid var(--accent); padding-left: 0.8rem; }
.report-list .k { display: block; font-weight: 700; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.report-list .v { display: block; font-size: 1.15rem; white-space: pre-wrap; }
.missing { font-style: italic; color: var(--muted); }
.warn { font-weight: 700; color: var(--danger); background: var(--warn-bg); padding: 0.3rem 0.5rem; border-radius: 0.4rem; }
.test { margin: 0; padding: 0.6rem; border: 2px dashed var(--border); border-radius: 0.5rem; }

/* admin codes */
.codes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.codes li { border: 2px solid var(--border); border-radius: 0.75rem; padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.codes p { margin: 0; }
.company-name { font-weight: 700; }
.codes .code { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.06em; word-break: break-all; }
.newcode { font-family: ui-monospace, Menlo, monospace; font-size: 2.2rem; font-weight: 700; letter-spacing: 0.08em; text-align: center; padding: 1rem; border: 3px solid var(--accent); border-radius: 0.75rem; word-break: break-all; margin: 0; }
footer { color: var(--muted); font-size: 1rem; border-top: 2px solid var(--border); padding-top: 1rem; }
.mt { margin-top: 1rem; }
.panel { display: flex; flex-direction: column; gap: 1.5rem; }

/* options, location, photos */
.group { display: flex; flex-direction: column; gap: 0.75rem; border-top: 2px solid var(--border); padding-top: 1rem; }
h3 { font-size: 1.25rem; margin: 0; }
.status-plain { margin: 0; font-weight: 700; }
input[type="file"] { padding: 0.7rem; }
.photo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.photo-list li { border: 2px solid var(--border); border-left: 0.35rem solid var(--accent); border-radius: 0.75rem; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.75rem; }
.photo-list figure { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.photo-list img { display: block; width: 100%; height: auto; max-height: 22rem; object-fit: contain; background: var(--bg); border-radius: 0.5rem; }
.photo-list figcaption { font-size: 1.15rem; white-space: pre-wrap; }
.photo-list textarea { min-height: 6rem; font-size: 1.2rem; }

.tagline { margin: 0 0 0.3rem; font-size: 1.2rem; font-weight: 700; }
.profile-form { display: flex; flex-direction: column; gap: 0.75rem; border-top: 2px solid var(--border); padding-top: 1rem; margin-top: 0.5rem; }
.profile-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.profile-form legend { font-weight: 700; font-size: 1.2rem; padding: 0; margin-bottom: 0.5rem; }
.logo-preview { display: block; max-width: 100%; max-height: 10rem; background: #fffaf3; border: 2px solid var(--border); border-radius: 0.5rem; padding: 0.4rem; }
.save-status { margin: 0; padding: 0.6rem 0.9rem; border-left: 0.35rem solid var(--accent); background: var(--surface); font-weight: 700; }
.warnbox { border-color: var(--danger); background: var(--warn-bg); }
.archive-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.archive-item { width: 100%; text-align: left; }
.report-list textarea { min-height: 3.2rem; }
.photo-upload { margin: 0.25rem 0; font-weight: 700; }
.optional-details { border: 2px dashed var(--border); border-radius: 0.75rem; padding: 0.75rem 1rem; }
.optional-details summary { font-weight: 700; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.optional-details[open] summary { margin-bottom: 0.75rem; }

/* Company theme: set only through CSS custom properties from company-ui.js. Text, surfaces, focus and errors stay high contrast. */
header { display: flex; flex-direction: column; gap: 0.5rem; }
header h1, header .tagline, header .sub { margin-bottom: 0; }
.brand-logo { display: block; max-width: 14rem; max-height: 6rem; width: auto; height: auto; object-fit: contain; background: #fffaf3; border: 2px solid var(--border); border-radius: 0.5rem; padding: 0.4rem; }
.feedback-open { margin-top: 0.5rem; }
html.branded { --accent: var(--brand); --accent-text: var(--brand-text); }
html.branded body { background: var(--bg); background: color-mix(in srgb, var(--brand) 14%, var(--bg)); border-top: 0.75rem solid var(--brand); }
html.branded header { background: var(--brand); color: var(--brand-text); border-top: 0; border-radius: 1rem; padding: 1.25rem; }
html.branded header .sub { color: var(--brand-text); }
html.branded header button.secondary { background: var(--surface); color: var(--text); border-color: var(--brand-text); }
html.branded header .status { background: var(--surface); color: var(--ok); padding: 0.4rem 0.7rem; border-radius: 0.5rem; }
html.branded .card, html.branded .save-status, html.branded footer { background: var(--surface); }
html.branded footer { padding: 1rem; border-radius: 0.75rem; border: 2px solid var(--border); }
@media (forced-colors: active) {
  html.branded header, html.branded body { background: Canvas; color: CanvasText; border-color: CanvasText; }
  .brand-logo { forced-color-adjust: none; }
}

/* Feedback dialog */
.feedback-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; padding: 1.25rem; background: var(--surface); color: var(--text); border: 3px solid var(--border); border-radius: 1rem; }
.feedback-dialog::backdrop { background: rgba(23, 19, 15, 0.6); }
.feedback-dialog form { display: flex; flex-direction: column; gap: 0.9rem; }
.feedback-dialog label { margin-bottom: 0; }
button.listening { background: var(--danger); border-color: var(--danger); color: var(--listen-text); }

/* Admin code type */
.choice { border: 2px solid var(--border); border-radius: 0.75rem; padding: 0.75rem 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.choice legend { font-weight: 700; padding: 0 0.3rem; }
label.radio { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; margin: 0; font-weight: 700; }
label.radio input { width: 1.6rem; height: 1.6rem; min-height: 0; margin: 0; accent-color: var(--accent); }
.feedback-note { white-space: pre-wrap; }
/* Text placed directly on the tinted page sits on a solid surface, and focus inside the brand header uses the brand foreground. */
html.branded .wrap > p:not(.sr-only):not([hidden]) { background: var(--surface); padding: 0.6rem 0.9rem; border-radius: 0.6rem; }
html.branded header :focus-visible { outline-color: var(--brand-text); }
.report-company { margin: 0.5rem 0 1rem; }
.report-company p { margin: 0.1rem 0; }
.report-company .report-company-name { font-weight: 700; font-size: 1.15em; }
.report-logo { display: block; max-width: 12rem; max-height: 5rem; width: auto; height: auto; object-fit: contain; margin-bottom: 0.4rem; }
