:root {
  color-scheme: light;
  --ink: #173132;
  --muted: #5b6d6b;
  --paper: #f6f3ea;
  --surface: #fffdfa;
  --primary: #0b625b;
  --primary-dark: #074640;
  --primary-soft: #dff1eb;
  --amber: #ef9f32;
  --amber-soft: #fff0cf;
  --danger: #b73632;
  --danger-soft: #fde9e6;
  --border: #d9ddd5;
  --shadow: 0 14px 36px rgba(28, 59, 55, 0.1);
  --font-scale: 1;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: calc(16px * var(--font-scale));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(239, 159, 50, 0.13), transparent 28rem),
    var(--paper);
  line-height: 1.65;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

html.large-text {
  --font-scale: 1.2;
}

body.high-contrast {
  --ink: #000;
  --muted: #202020;
  --paper: #fff;
  --surface: #fff;
  --primary: #004d40;
  --primary-dark: #002e26;
  --primary-soft: #e2f4ef;
  --amber: #a85a00;
  --amber-soft: #fff1bf;
  --danger: #980e0e;
  --danger-soft: #ffe6e6;
  --border: #626262;
  background: #fff;
}

body.independent-role {
  padding-bottom: 2rem;
}

button,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 4px solid #2b78d0;
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  background: #fff;
  color: #000;
  padding: 0.75rem 1rem;
  border: 2px solid #000;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem max(1rem, calc((100vw - 1120px) / 2));
  background: rgba(255, 253, 250, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.brand {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-align: left;
  min-height: 52px;
  cursor: pointer;
  text-decoration: none;
}

.brand img {
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(11, 98, 91, 0.2);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.2rem;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.12rem;
}

.accessibility-tools {
  display: flex;
  gap: 0.45rem;
}

.tool-button {
  min-height: 44px;
  min-width: 62px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.tool-button[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.safety-strip {
  padding: 0.55rem 1rem;
  background: var(--amber-soft);
  border-bottom: 1px solid #eccd91;
  text-align: center;
  font-size: 0.94rem;
}

.safety-strip span {
  color: var(--danger);
  margin-right: 0.45rem;
}

main {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.page {
  padding: 1.25rem 0 3rem;
  animation: enter 180ms ease-out;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 2rem;
  align-items: center;
  padding: 0.65rem 0 1.2rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.2rem 0.75rem;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.5rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
  margin: 0.8rem 0 1rem;
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin-bottom: 0.65rem;
}

h3 {
  line-height: 1.35;
}

.lead {
  color: var(--muted);
  font-size: 1.16rem;
  max-width: 42rem;
}

.hero-figure {
  min-height: 230px;
  border-radius: 32px;
  background: linear-gradient(150deg, var(--primary) 0%, #0e8175 100%);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
}

.hero-figure::before,
.hero-figure::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
}

.hero-figure::before {
  width: 230px;
  height: 230px;
  right: -70px;
  top: -60px;
}

.hero-figure::after {
  width: 110px;
  height: 110px;
  left: -35px;
  bottom: -30px;
}

.avatar {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 20px;
  margin-bottom: 0.8rem;
  position: relative;
  z-index: 1;
}

.avatar img {
  display: block;
  width: 88px;
  height: 88px;
}

.hero-figure blockquote {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.hero-figure p {
  margin: 0.45rem 0 0;
  color: rgba(255, 255, 255, 0.86);
  position: relative;
  z-index: 1;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin: 0.6rem 0;
}

.section-heading p {
  color: var(--muted);
  margin: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.action-card {
  border: 2px solid transparent;
  border-radius: 24px;
  min-height: 165px;
  padding: 1rem;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(30, 56, 52, 0.08);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.action-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.action-card.primary-action {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.action-card.primary-action .icon {
  background: var(--amber-soft);
  color: #754000;
}

.action-card.primary-action span:last-child {
  color: rgba(255, 255, 255, 0.88);
}

.action-card .icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.65rem;
  font-weight: 900;
  margin-bottom: 1.1rem;
}

.action-card:nth-child(2) .icon,
.action-card:nth-child(4) .icon {
  background: var(--amber-soft);
  color: #8a4b00;
}

.action-card strong,
.action-card span {
  display: block;
}

.action-card strong {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.action-card span {
  color: var(--muted);
}

.evidence-row {
  margin-top: 1.3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.evidence-item {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.evidence-item strong,
.evidence-item span {
  display: block;
}

.evidence-item strong {
  font-size: 1.45rem;
  color: var(--primary-dark);
}

.evidence-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.page-header {
  max-width: 780px;
  margin-bottom: 1.5rem;
}

.back-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  padding: 0.6rem 0;
  min-height: 48px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.role-portal {
  max-width: 940px;
  margin: 0 auto;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.role-card {
  display: grid;
  align-content: start;
  min-height: 250px;
  padding: 1.4rem;
  border: 2px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(30, 56, 52, 0.08);
}

.role-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
}

.role-card.elder {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.role-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 1.2rem;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 900;
}

.role-card strong,
.role-card > span:last-child {
  display: block;
}

.role-card strong {
  margin-bottom: 0.45rem;
  font-size: 1.35rem;
}

.role-card > span:last-child {
  color: var(--muted);
}

.portal-note {
  margin-top: 1rem;
  color: var(--muted);
}

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--amber);
  border-radius: 16px;
  background: var(--amber-soft);
}

.offline-banner strong,
.offline-banner span {
  display: block;
}

.offline-banner span {
  margin-top: 0.2rem;
  color: #6c4606;
}

.offline-banner .secondary-button {
  flex: 0 0 auto;
  min-height: 46px;
  background: #fff;
}

.demo-launch,
.demo-runbook {
  margin-top: 1rem;
}

.demo-qr-block {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
}

.demo-qr-block img {
  width: 220px;
  height: 220px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.demo-qr-block h2 {
  margin: 0.55rem 0 0.35rem;
}

.demo-qr-block p {
  margin: 0.65rem 0 0.8rem;
  color: var(--muted);
}

.demo-url {
  color: var(--primary-dark);
  font-weight: 900;
  overflow-wrap: anywhere;
  text-underline-offset: 4px;
}

.demo-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.demo-status {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.demo-status > span {
  color: #14805e;
}

.demo-status.warning > span {
  color: var(--amber);
}

.demo-status strong,
.demo-status small {
  display: block;
}

.demo-status small {
  margin-top: 0.18rem;
  color: var(--muted);
}

.demo-runbook .section-toolbar h2 {
  margin: 0.55rem 0 0;
}

.demo-steps {
  display: grid;
  gap: 0.75rem;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
}

.demo-steps li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #fff;
}

.demo-steps li > span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.demo-steps strong,
.demo-steps p {
  display: block;
}

.demo-steps p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.demo-steps a {
  min-height: 44px;
  color: var(--primary-dark);
  font-weight: 900;
  white-space: nowrap;
}

.demo-step-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.demo-step-actions .text-button,
.demo-step-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: clamp(1rem, 3vw, 1.7rem);
  box-shadow: 0 8px 26px rgba(31, 60, 56, 0.07);
}

.form-label {
  display: block;
  font-weight: 900;
  font-size: 1.08rem;
  margin-bottom: 0.55rem;
}

.form-hint {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin: -0.3rem 0 0.8rem;
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  line-height: 1.7;
}

textarea:focus {
  border-color: var(--primary);
}

.form-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.primary-button,
.secondary-button,
.voice-button,
.danger-button {
  min-height: 54px;
  border-radius: 15px;
  padding: 0.7rem 1.15rem;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 2px solid var(--primary);
  background: var(--primary);
  color: white;
}

.primary-button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.secondary-button,
.voice-button {
  border: 2px solid var(--primary);
  background: var(--surface);
  color: var(--primary-dark);
}

.voice-button.listening {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.danger-button {
  border: 2px solid var(--danger);
  background: var(--danger);
  color: white;
}

.button-link,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.text-link {
  min-height: 44px;
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.check-line {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1rem;
  padding: 0.8rem;
  border-radius: 14px;
  background: var(--primary-soft);
}

.check-line input,
.signal-option input {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  margin-top: 0.18rem;
  accent-color: var(--primary);
}

.signals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.signal-option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: #fff;
}

.result-card {
  margin-top: 1rem;
  border-radius: 22px;
  padding: 1.35rem;
  border: 2px solid var(--border);
  background: #fff;
}

.result-card.high {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.result-card.medium {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.result-card.low {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.risk-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-weight: 900;
  background: var(--surface);
  border: 1px solid currentColor;
  margin-bottom: 0.8rem;
}

.result-card h3 {
  margin-bottom: 0.45rem;
  font-size: 1.4rem;
}

.result-card ul,
.help-list,
.source-list {
  padding-left: 1.35rem;
}

.result-card li,
.help-list li,
.source-list li {
  margin: 0.45rem 0;
}

.disclaimer {
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.structured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.structured-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem;
  background: #fff;
}

.structured-item strong,
.structured-item span {
  display: block;
}

.structured-item strong {
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.structured-item ul {
  margin: 0;
  padding-left: 1.25rem;
}

.structured-item li + li {
  margin-top: 0.35rem;
}

.structured-item.full {
  grid-column: 1 / -1;
}

.conclusion-boundary,
.follow-up-panel,
.story-sources {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  background: var(--surface);
}

.conclusion-boundary {
  border-left: 5px solid var(--amber);
}

.follow-up-panel {
  background: var(--amber-soft);
}

.follow-up-panel h4,
.follow-up-panel p {
  margin-top: 0;
}

.follow-up-panel textarea {
  min-height: 100px;
  margin-bottom: 0.75rem;
}

.story-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
}

.story-sources strong {
  width: 100%;
}

.story-grid,
.lesson-grid,
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.story-card,
.lesson-card,
.help-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.25rem;
  background: var(--surface);
  box-shadow: 0 7px 20px rgba(31, 60, 56, 0.06);
}

.story-card h3,
.lesson-card h3,
.help-card h3 {
  font-size: 1.25rem;
  margin: 0.6rem 0 0.45rem;
}

.card-tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.story-card p,
.lesson-card p,
.help-card p {
  color: var(--muted);
}

.lesson-question {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 18px;
  background: var(--primary-soft);
}

.lesson-question-label {
  display: inline-block;
  color: var(--primary-dark);
  font-size: 0.88rem;
  font-weight: 900;
}

.lesson-question > p {
  margin: 0.35rem 0 0.85rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.lesson-answer-toggle {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--primary);
  border-radius: 14px;
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 900;
  cursor: pointer;
}

.lesson-answer-icon {
  flex: 0 0 auto;
  font-size: 1.5rem;
  line-height: 1;
}

.lesson-answer {
  margin-top: 0.8rem;
  padding: 0.9rem 1rem;
  border-left: 5px solid var(--amber);
  border-radius: 12px;
  background: var(--surface);
}

.lesson-answer[hidden] {
  display: none;
}

.lesson-answer strong {
  color: var(--primary-dark);
}

.lesson-answer p {
  margin: 0.3rem 0 0.2rem;
  color: var(--ink);
}

.story-card footer,
.lesson-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  min-height: 44px;
  padding: 0.4rem;
  font-weight: 900;
  cursor: pointer;
}

.source-link {
  color: var(--primary-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.help-card.urgent {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
}

.number-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.number-link:last-child {
  border-bottom: 0;
}

.number-link strong {
  color: var(--primary-dark);
  font-size: 1.25rem;
}

.flow-steps {
  counter-reset: steps;
  display: grid;
  gap: 0.75rem;
  margin: 1.2rem 0 0;
}

.flow-step {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0.8rem;
  align-items: start;
}

.flow-step::before {
  content: counter(steps);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.flow-step strong,
.flow-step span {
  display: block;
}

.flow-step span {
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(0.7rem, env(safe-area-inset-bottom));
  width: min(620px, calc(100% - 1.3rem));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0.45rem;
  border: 1px solid rgba(11, 98, 91, 0.25);
  border-radius: 22px;
  background: rgba(255, 253, 250, 0.96);
  box-shadow: 0 14px 40px rgba(13, 61, 55, 0.18);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 58px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.bottom-nav span {
  display: block;
  font-size: 1.2rem;
  line-height: 1.05;
}

.bottom-nav button.active {
  color: #fff;
  background: var(--primary);
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.agent-status span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.agent-status.online span {
  background: #14805e;
}

.agent-status.offline span {
  background: var(--danger);
}

.quick-prompts {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.8rem;
  scrollbar-width: thin;
}

.quick-prompts button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
}

.chat-shell {
  padding: 0;
  overflow: hidden;
}

.demo-sample-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e2bd66;
  border-radius: 18px;
  background: linear-gradient(120deg, #fff8df, #fffdf8);
}

.demo-sample-bar div,
.demo-sample-bar strong,
.demo-sample-bar small {
  display: block;
}

.demo-sample-bar span {
  color: #7b4c00;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.demo-sample-bar strong {
  margin-top: 0.18rem;
  color: var(--ink);
}

.demo-sample-bar small {
  margin-top: 0.16rem;
  color: var(--muted);
}

.demo-sample-bar .secondary-button {
  flex: 0 0 auto;
}

.chat-messages {
  min-height: 340px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 1.2rem;
  background: linear-gradient(180deg, rgba(223, 241, 235, 0.5), rgba(255, 253, 250, 0.2));
}

.chat-message {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  margin-bottom: 1rem;
}

.chat-message.user {
  grid-template-columns: minmax(0, 1fr) 50px;
}

.chat-message.user .chat-speaker {
  grid-column: 2;
  grid-row: 1;
  background: var(--amber-soft);
  color: #754000;
}

.chat-message.user .chat-bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.chat-speaker {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.chat-bubble {
  width: min(100%, 720px);
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  background: #fff;
}

.chat-message.user .chat-bubble {
  border-radius: 18px 4px 18px 18px;
}

.chat-text {
  white-space: pre-wrap;
}

.processing-line,
.processing-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.processing-line p,
.processing-card p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.processing-card {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--primary);
  border-radius: 18px;
  background: var(--primary-soft);
}

.processing-dots {
  display: inline-flex;
  gap: 0.28rem;
  flex: 0 0 auto;
}

.processing-dots i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--primary);
  animation: processing-pulse 1.1s ease-in-out infinite;
}

.processing-dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.processing-dots i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes processing-pulse {
  0%, 70%, 100% { opacity: 0.3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

.answer-meta,
.analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.answer-status,
.answer-mode,
.analysis-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.answer-status.high {
  border-color: #b83232;
  background: #fff0f0;
  color: #8b1d1d;
}

.answer-status.medium {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: #754000;
}

.chat-notice {
  margin: 0.75rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid currentColor;
  opacity: 0.78;
  font-size: 0.86rem;
}

.chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.chat-sources strong {
  width: 100%;
}

.chat-composer {
  padding: 1rem 1.2rem 1.2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-composer textarea {
  min-height: 110px;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.privacy-consent {
  font-size: 0.9rem;
}

.family-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.3rem;
  background: linear-gradient(135deg, var(--surface), var(--primary-soft));
}

.family-promo h2 {
  margin: 0.7rem 0 0.35rem;
}

.family-promo p,
.section-toolbar p,
.connection-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.guardian-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.guardian-entry h2 {
  margin: 0.55rem 0 0.3rem;
}

.guardian-entry p {
  margin-bottom: 0;
  color: var(--muted);
}

.consent-summary {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--primary-soft);
}

.consent-summary .status-pill {
  width: fit-content;
}

.permission-form fieldset {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  border: 0;
  margin: 0 0 1rem;
}

.permission-form legend {
  margin-bottom: 0.8rem;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
}

.permission-option {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
}

.permission-option.selected,
.permission-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.permission-option input {
  width: 24px;
  height: 24px;
  margin-top: 0.1rem;
  accent-color: var(--primary);
}

.permission-option strong,
.permission-option small {
  display: block;
}

.permission-option small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.permission-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.2rem;
  border: 2px solid var(--primary);
  border-radius: 20px;
  background: var(--primary-soft);
}

.permission-result p,
.permission-result span {
  color: var(--muted);
}

.permission-result.muted-result {
  display: grid;
  border-color: var(--border);
  background: var(--surface);
}

.guardian-actions {
  display: grid;
  gap: 0.65rem;
  min-width: 240px;
}

.binding-card {
  max-width: 620px;
  margin: 1rem auto 0;
}

.binding-card .primary-button,
.binding-card .text-link {
  width: 100%;
  margin-top: 0.8rem;
}

.code-input {
  width: 100%;
  min-height: 64px;
  padding: 0.65rem 1rem;
  border: 2px solid var(--border);
  border-radius: 15px;
  color: var(--primary-dark);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-align: center;
}

.code-input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(11, 111, 100, 0.16);
}

.role-entry-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.demo-banner {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #eccd91;
  border-radius: 14px;
  background: var(--amber-soft);
}

.demo-banner strong {
  flex: 0 0 auto;
}

.family-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, 0.75fr);
  gap: 1rem;
}

.family-lower {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.family-section {
  margin-top: 1rem;
}

.section-toolbar,
.alert-topline,
.alert-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.section-toolbar h2,
.section-toolbar p,
.alert-topline .risk-badge {
  margin-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 900;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.metric-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.metric-card strong,
.metric-card span {
  display: block;
}

.metric-card strong {
  color: var(--primary-dark);
  font-size: 1.9rem;
  line-height: 1.2;
}

.metric-card span {
  color: var(--muted);
  margin-top: 0.25rem;
}

.metric-card.danger strong {
  color: var(--danger);
}

.privacy-note {
  margin: 1rem 0 0;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.9rem;
}

.connection-panel {
  text-align: center;
}

.connection-code {
  margin: 0.8rem 0 0.45rem;
  color: var(--primary-dark);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.connection-panel .secondary-button {
  width: 100%;
  margin-top: 1rem;
}

.family-alert-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.family-alert {
  padding: 1rem;
  border: 1px solid var(--amber);
  border-left: 7px solid var(--amber);
  border-radius: 16px;
  background: var(--amber-soft);
}

.family-alert.high {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.family-alert.read {
  border-color: var(--border);
  background: var(--surface);
}

.family-alert h3 {
  margin: 0.7rem 0 0.35rem;
}

.family-alert p {
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.family-alert time,
.alert-actions span {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.family-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.family-profile-grid input {
  width: 100%;
  min-height: 50px;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
}

.family-profile-grid input:focus {
  border-color: var(--primary);
}

.assistance-card.active {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
}

.admin-metrics {
  margin-bottom: 1rem;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.65fr);
  gap: 1rem;
  align-items: start;
}

.review-queue {
  position: sticky;
  top: 100px;
}

.review-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.review-list-item {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  min-height: 100px;
  padding: 0.85rem;
  border: 2px solid var(--border);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.review-list-item.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.review-list-item > span:last-child,
.review-item-top time {
  color: var(--muted);
  font-size: 0.84rem;
}

.review-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.status-chip {
  display: inline-flex;
  width: fit-content;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #754000;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-chip.returned {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip.published {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.review-detail .section-toolbar h2 {
  margin: 0.45rem 0 0;
}

.review-fields {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0 1.3rem;
}

.review-fields div {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.review-fields dt {
  color: var(--primary-dark);
  font-weight: 900;
}

.review-fields dd {
  margin: 0.25rem 0 0;
}

.review-checklist {
  display: grid;
  gap: 0.65rem;
}

.review-check {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--amber-soft);
}

.review-check > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  font-weight: 900;
}

.review-check.done {
  background: var(--primary-soft);
}

.review-check.done > span {
  background: var(--primary);
}

.review-check strong,
.review-check small {
  display: block;
}

.review-check small {
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
  bottom: 7rem;
  max-width: calc(100% - 2rem);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: #173132;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

body.high-contrast .site-header,
body.high-contrast .bottom-nav {
  background: #fff;
  border-color: #000;
  backdrop-filter: none;
}

body.high-contrast .panel,
body.high-contrast .action-card,
body.high-contrast .story-card,
body.high-contrast .lesson-card,
body.high-contrast .lesson-question,
body.high-contrast .lesson-answer,
body.high-contrast .help-card,
body.high-contrast .role-card,
body.high-contrast .structured-item,
body.high-contrast textarea,
body.high-contrast input,
body.high-contrast .signal-option,
body.high-contrast .chat-bubble,
body.high-contrast .metric-card,
body.high-contrast .review-list-item,
body.high-contrast .review-fields div,
body.high-contrast .demo-status,
body.high-contrast .demo-steps li,
body.high-contrast .demo-qr-block img,
body.high-contrast .offline-banner {
  border-color: #000;
  box-shadow: none;
}

body.high-contrast .hero-figure,
body.high-contrast .action-card.primary-action,
body.high-contrast .bottom-nav button.active {
  background: #003f36;
}

body.high-contrast .action-card.primary-action {
  border-color: #000;
}

body.high-contrast .answer-status,
body.high-contrast .answer-mode,
body.high-contrast .analysis-meta span,
body.high-contrast .risk-badge {
  border-width: 2px;
}

body.high-contrast .toast {
  background: #000;
  border: 2px solid #fff;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-figure {
    min-height: 230px;
  }
}

@media (max-width: 680px) {
  .site-header {
    align-items: center;
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .brand {
    width: 100%;
  }

  .accessibility-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.3rem;
  }

  .tool-button {
    min-width: 0;
    padding: 0.35rem;
    font-size: 0.9rem;
  }

  main {
    width: min(100% - 1rem, 1120px);
  }

  .page {
    padding-top: 1.3rem;
  }

  .hero {
    gap: 0.8rem;
    padding: 0.4rem 0 1rem;
  }

  .hero-figure {
    display: none;
  }

  .hero > div > .lead,
  .hero > div > .primary-button {
    display: none;
  }

  .evidence-row,
  .story-grid,
  .lesson-grid,
  .help-grid,
  .family-dashboard,
  .family-lower,
  .family-profile-grid,
  .metric-grid,
  .admin-workspace,
  .structured-grid,
  .signals {
    grid-template-columns: 1fr;
  }

  .action-grid,
  .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .family-promo,
  .guardian-entry,
  .permission-result,
  .offline-banner,
  .demo-banner,
  .demo-sample-bar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .demo-sample-bar .secondary-button {
    width: 100%;
  }

  .review-queue {
    position: static;
  }

  .review-check {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .review-check .text-button,
  .review-check .source-link {
    grid-column: 2;
    justify-self: start;
  }

  .guardian-actions {
    width: 100%;
    min-width: 0;
  }

  .demo-qr-block,
  .demo-status-grid {
    grid-template-columns: 1fr;
  }

  .demo-qr-block img {
    width: min(220px, 100%);
    height: auto;
    justify-self: center;
  }

  .demo-steps li {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .demo-step-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .action-card {
    min-height: 138px;
    padding: 0.9rem;
  }

  .action-card .icon {
    width: 46px;
    height: 46px;
    margin-bottom: 0.65rem;
    border-radius: 14px;
    font-size: 1.3rem;
  }

  .action-card strong {
    font-size: 1.08rem;
  }

  .action-card span:last-child {
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .role-card {
    min-height: 210px;
    padding: 1rem;
  }

  .structured-item.full {
    grid-column: auto;
  }

  .safety-strip {
    text-align: left;
  }

  .chat-message,
  .chat-message.user {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .chat-message.user {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .chat-speaker {
    font-size: 0.72rem;
  }
}

@media (max-width: 460px) {
  html.large-text .action-grid,
  html.large-text .role-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 1rem;
    padding-top: 0.6rem;
  }

  .hero-figure {
    min-height: 210px;
    padding: 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
