:root {
  color-scheme: light;
  --fg: #16241a;
  --bg: #fbfbf7;
  --accent: #2f6b3c;
  --accent-dark: #204a29;
  --border: #d8dcd3;
  --danger: #a3312a;
  --warning: #8a5a12;
  --low: #1f5e2c;
  --focus: #0b5fff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 18px;
  line-height: 1.4;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.icon { width: 1.5em; height: 1.5em; fill: none; }
.icon-lg { width: 2em; height: 2em; }
.icon-xl { width: 4.5rem; height: 4.5rem; color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1.25rem;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
}
.panel[hidden] { display: none !important; }
.panel-full { padding: 0; position: relative; background: #000; color: #fff; }
.panel-message { max-width: 32rem; font-size: 1.15rem; }

/* ---------- home ---------- */
.panel-home { justify-content: space-between; padding-bottom: 3rem; padding-top: 4rem; }
.camera-fab {
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(47,107,60,.35);
}
.camera-fab:active { transform: scale(.97); }
.camera-fab .icon-xl { color: #fff; width: 5rem; height: 5rem; }

.home-secondary { display: flex; gap: 2.5rem; }
.icon-button {
  background: none; border: none; color: var(--fg); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  font-size: .95rem; min-width: 64px; min-height: 44px; padding: .5rem;
}
.icon-button .icon { color: var(--accent); width: 1.8rem; height: 1.8rem; }

/* ---------- buttons ---------- */
.big-button {
  min-height: 64px;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: #fff;
  color: var(--accent-dark);
  padding: .9rem 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  cursor: pointer;
  width: 100%;
  max-width: 26rem;
}
.big-button-primary { background: var(--accent); color: #fff; }
.big-button-secondary { background: #fff; }
.big-button:active { transform: scale(.98); }

.corner-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ---------- camera ---------- */
#camera-video, #review-image { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.overlay-caption {
  position: absolute; top: 1rem; left: 1rem; right: 4.5rem;
  background: rgba(0,0,0,.55); padding: .6rem 1rem; border-radius: 10px; font-size: 1.05rem;
}
.shutter-button {
  position: absolute; bottom: 2.5rem; left: 50%; transform: translateX(-50%);
  width: 84px; height: 84px; border-radius: 999px; background: #fff; border: 6px solid #ddd; cursor: pointer;
}
.shutter-button:active { background: #ddd; }
.review-actions {
  position: absolute; bottom: 2rem; left: 0; right: 0;
  display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; padding: 0 1rem;
}

/* ---------- processing ---------- */
.spinner {
  width: 64px; height: 64px; border-radius: 999px;
  border: 6px solid var(--border); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--border); border-right-color: var(--accent); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- result ---------- */
.result { max-width: 34rem; width: 100%; display: flex; flex-direction: column; align-items: center; gap: .9rem; padding: 2rem 1.25rem; text-align: center; }
.result-severity { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.result-severity .icon-xl { }
.severity-label { font-weight: 700; font-size: 1.2rem; text-transform: uppercase; letter-spacing: .03em; }
.severity-low .severity-label, .severity-low .icon { color: var(--low); }
.severity-moderate .severity-label, .severity-moderate .icon { color: var(--warning); }
.severity-high .severity-label, .severity-high .icon,
.severity-critical .severity-label, .severity-critical .icon { color: var(--danger); }
.severity-unknown .severity-label, .severity-unknown .icon { color: #555; }

.result-title { font-size: 1.7rem; margin: 0; }
.result-summary { font-size: 1.15rem; }

.listen-button {
  border: none; border-radius: 999px; background: var(--accent-dark); color: #fff;
  padding: 1rem 2rem; font-size: 1.15rem; font-weight: 700; display: inline-flex;
  align-items: center; gap: .6rem; cursor: pointer; min-height: 56px;
}

.result-secondary-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.text-toggle-button {
  border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--fg);
  padding: .5rem 1rem; font-size: .95rem; display: inline-flex; align-items: center; gap: .4rem;
  cursor: pointer; min-height: 44px;
}
.result-plaintext {
  width: 100%; max-width: 32rem; text-align: left; white-space: pre-wrap; word-wrap: break-word;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem;
  font-family: inherit; font-size: 1rem; line-height: 1.5;
}

.confidence { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.confidence-label { font-size: .95rem; opacity: .8; }
.confidence-dots { display: flex; gap: .4rem; }
.dot { width: 16px; height: 16px; border-radius: 999px; background: var(--border); }
.dot-filled { background: var(--accent); }

.result h2 { font-size: 1.1rem; align-self: flex-start; margin: .5rem 0 0; }
.evidence-list, .action-list, .action-list-plain, .alternatives-list { list-style: none; padding: 0; margin: 0; width: 100%; text-align: left; }
.evidence-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem 0; }
.evidence-list .icon { color: var(--accent); flex-shrink: 0; margin-top: .1rem; }
.action-list li { display: flex; gap: .8rem; align-items: flex-start; padding: .5rem 0; }
.action-number {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 999px; background: var(--accent);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.action-list-plain li, .alternatives-list li { padding: .35rem 0; border-bottom: 1px solid var(--border); }

.expert-callout {
  display: flex; gap: .6rem; align-items: center; background: #fdf1d6; border: 2px solid var(--warning);
  border-radius: 10px; padding: 1rem; color: #5c3d0d; text-align: left;
}
.expert-callout .icon { color: var(--warning); flex-shrink: 0; }

.result-error .icon-xl { color: var(--danger); }

/* ---------- questions ---------- */
.question-block { border: none; padding: 0; margin: 0 0 1.25rem; width: 100%; }
.question-block legend { font-size: 1.15rem; font-weight: 700; margin-bottom: .6rem; padding: 0; }
.answer-buttons { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }
.answer-buttons .big-button { flex: 1 1 8rem; }

/* ---------- language picker ---------- */
.language-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: .75rem; width: 100%; max-width: 30rem; }
.language-choice {
  border: 2px solid var(--border); background: #fff; border-radius: 12px; padding: 1rem .5rem;
  display: flex; flex-direction: column; align-items: center; gap: .4rem; cursor: pointer; font-size: 1rem;
  min-height: 64px;
}
.language-flag { font-size: 2rem; }

/* ---------- history ---------- */
.history-item { display: flex; gap: .75rem; align-items: center; width: 100%; max-width: 30rem; padding: .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.history-date { display: block; font-size: .85rem; opacity: .7; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 1rem; right: 1rem; bottom: 1.5rem; z-index: 50;
  background: var(--fg); color: #fff; padding: 1rem 1.25rem; border-radius: 12px; font-size: 1.05rem;
  text-align: center;
}

/* ---------- forms (shared with activation) ---------- */
.admin-form { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 26rem; }
.admin-form input {
  font-size: 1.2rem; padding: .9rem; border-radius: 10px; border: 2px solid var(--border); width: 100%;
}

.doc-page { text-align: left; align-items: flex-start; max-width: 40rem; margin: 0 auto; }
.doc-page ol { padding-left: 1.4rem; }
.doc-page li { margin-bottom: .5rem; }

.link-button { background: none; border: none; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
