:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --bg: #F6F8F7;
  --card: #FFFFFF;
  --text: #13201C;
  --muted: #5B6B66;
  --line: #E1E7E4;
  --accent: #0E8A6A;
  --accent-soft: #E3F4EE;
  --quote: #F2F6F4;
  --good: #2E9E5B; --moderate: #E9B824; --sensitive: #F07B3F; --unhealthy: #E02D3C; --very: #8E3B9E; --unknown: #9AA5A1;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1412; --card: #161F1C; --text: #E8EFEC; --muted: #9AACA6; --line: #26332F;
    --accent: #3CC79C; --accent-soft: #15302A; --quote: #1C2723;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1412; --card: #161F1C; --text: #E8EFEC; --muted: #9AACA6; --line: #26332F;
  --accent: #3CC79C; --accent-soft: #15302A; --quote: #1C2723;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--accent); }
h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 28px 0 4px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }

.top { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 18px; }
.logo { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); position: relative; }
.logo::after { content: ""; position: absolute; left: 6px; right: 6px; top: 9px; height: 8px; border: 2.5px solid #fff; border-bottom: 0; border-radius: 10px 10px 0 0; }
.status { margin-left: auto; font-size: 12px; color: var(--muted); }
.status b { color: var(--accent); font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); }

.menu { position: fixed; right: 16px; top: 58px; z-index: 1003; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; display: flex; flex-direction: column; min-width: 220px; }
.menu button { text-align: left; background: none; border: 0; color: var(--text); font: inherit; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu button:hover, .menu-link:hover { background: var(--accent-soft); }
.menu-link { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; padding: 10px 12px; border-radius: 10px; }
.menu-lang { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 12px 6px; }
.menu-lang-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.lang-switch { display: flex; gap: 4px; background: var(--quote); border-radius: 10px; padding: 3px; }
.menu .lang-switch button { flex: 1; text-align: center; padding: 7px 6px; font-size: 13px; border-radius: 8px; }
.menu .lang-switch button[aria-pressed="true"] { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

main { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }

.ask { display: flex; gap: 10px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.ask:focus-within { border-color: var(--accent); }
.ask textarea { flex: 1; border: 0; resize: none; font: inherit; background: transparent; color: var(--text); outline: none; padding: 6px; min-width: 0; }
.ask button { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font: 600 15px var(--font); cursor: pointer; }
.ask button:disabled { opacity: .6; cursor: progress; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.chip { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 13px; font: 14px var(--font); cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--accent); }

.answer { margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.answer .text { font-size: 17px; white-space: pre-wrap; }
.answer sup a { text-decoration: none; font-weight: 600; font-size: 12px; padding: 0 2px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.meta .fast { color: var(--accent); font-weight: 600; }
.notfound { border-left: 4px solid var(--sensitive); }
/* Text arriving word by word, with a blinking caret */
.answer.streaming .text::after { content: ""; display: inline-block; width: 8px; height: 1.1em; margin-left: 2px; vertical-align: -2px;
  background: var(--accent); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .answer.streaming .text::after { animation: none; } }

.src { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--card); scroll-margin-top: 80px; }
.src.flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.src blockquote { margin: 0 0 8px; padding: 8px 12px; background: var(--quote); border-left: 3px solid var(--accent); border-radius: 6px; font-size: 15px; }
.src .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.src .n { font-weight: 700; color: var(--accent); }
.badge { font-size: 11px; font-weight: 600; letter-spacing: .04em; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.badge.live { background: var(--accent); color: #fff; border-color: var(--accent); }
.verified { color: var(--accent); font-weight: 600; }

.loading { margin-top: 22px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.good { background: var(--good); } .dot.moderate { background: var(--moderate); } .dot.sensitive { background: var(--sensitive); } .dot.unhealthy { background: var(--unhealthy); } .dot.very { background: var(--very); }
.small { font-size: 13px; margin: -4px 0 10px; }
/* Map markers: the PM2.5 value inside a coloured circle, like AAI's map */
.pm-pin { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; font: 700 12px var(--font);
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pm-pin.moderate { color: #3A2E00; }
.pm-icon { display: grid; place-items: center; }
.zoomed-out .pm-pin { width: 13px; height: 13px; font-size: 0; border-width: 1.5px; }
.map { height: min(65vh, 520px); border-radius: var(--radius); border: 1px solid var(--line); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat.models { grid-column: 1 / -1; }
.mbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 10px 0; background: var(--line); }
.mbar i { display: block; min-width: 4px; }
.mlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.mlist li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 14px; }
.mlist .mname { font-weight: 600; }
.mlist .mnum { color: var(--muted); margin-left: auto; }
ul.plain { padding-left: 18px; }
.sources-list { list-style: none; padding: 0; }
.sources-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.error { margin-top: 18px; color: var(--unhealthy); }

.providers { display: grid; gap: 10px; margin-bottom: 18px; }
.provider { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.provider:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.provider.off { opacity: .55; cursor: not-allowed; }
.provider input { margin-top: 4px; accent-color: var(--accent); }
.provider b { display: block; }
.provider small { color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 1px 6px; margin-left: 6px; background: var(--accent-soft); color: var(--accent); }
.field { display: block; font-weight: 600; margin-bottom: 18px; }
.field input { display: block; width: 100%; margin-top: 6px; font: 15px var(--font); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.field small { display: block; font-weight: 400; margin-top: 6px; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font: 600 15px var(--font); cursor: pointer; margin-right: 10px; }
.local-info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 10px; margin-bottom: 18px; }
.hw { width: 100%; border-collapse: collapse; font-size: 14px; }
.hw th, .hw td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hw th { color: var(--muted); font-weight: 600; }
/* Sensor details sheet */
.pm-icon { cursor: pointer; }
.sheet { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: center; padding: 16px; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 17, .45); }
.sheet-panel { position: relative; width: min(460px, 100%); max-height: min(86vh, 760px); overflow-y: auto; background: var(--bg);
  border-radius: 20px; padding: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.sheet-close { position: sticky; float: right; top: 0; margin: 4px 4px -38px 0; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.9); color: #13201C; display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.st-head { border-radius: 16px; padding: 18px; color: #fff; }
.st-head.moderate { color: #2E2400; }
.st-top { display: flex; justify-content: space-between; gap: 12px; padding-right: 30px; }
.st-name { font-size: 19px; font-weight: 700; line-height: 1.25; margin: 0; }
.st-sub { font-size: 13px; opacity: .85; margin-top: 4px; }
.st-trend { text-align: right; white-space: nowrap; font-size: 13px; opacity: .95; }
.st-trend b { display: block; font-size: 20px; }
.st-rule { border: 0; border-top: 1px solid currentColor; opacity: .25; margin: 14px 0 10px; }
.st-label { font-size: 13px; opacity: .85; }
.st-cat { font-weight: 700; font-size: 16px; }
.st-value { display: flex; align-items: flex-end; justify-content: space-between; }
.st-value b { font-size: 56px; line-height: 1; letter-spacing: -.02em; }
.st-value b small { font-size: 18px; font-weight: 500; opacity: .8; margin-left: 6px; }
.st-face { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; }
.st-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-top: 12px; }
.st-card h3 { font-size: 16px; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.st-card h3 span { font-size: 12px; font-weight: 400; color: var(--muted); }
.st-chart { width: 100%; height: 150px; display: block; }
.st-chart text { font: 11px var(--font); fill: var(--muted); }
.st-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.st-stats div { background: var(--quote); border-radius: 12px; padding: 8px; text-align: center; }
.st-stats span { display: block; font-size: 12px; color: var(--muted); }
.st-stats b { font-size: 20px; }
.st-extra { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.st-advice { margin: 0; padding-left: 18px; }
.st-advice li { margin: 4px 0; }
@media (max-width: 560px) {
  .sheet { place-items: end center; padding: 0; }
  .sheet-panel { width: 100%; border-radius: 20px 20px 0 0; max-height: 88vh; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .st-value b { font-size: 46px; }
}

/* Voice agent */
main { padding-bottom: 120px; }
.voice { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 1002; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.voice-btn { display: flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 14px 20px;
  font: 600 15px var(--font); cursor: pointer; box-shadow: 0 8px 24px rgba(14,138,106,.35); }
.voice-btn .stop { display: none; }
.voice.live .voice-btn { background: var(--unhealthy); box-shadow: 0 8px 24px rgba(214,69,69,.35); }
.voice.live .voice-btn .mic { display: none; } .voice.live .voice-btn .stop { display: block; }
.voice.live .voice-label { display: none; }
.voice-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; width: min(340px, calc(100vw - 32px));
  box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.voice-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); }
.voice[data-mode="listening"] .pulse { background: var(--accent); animation: beat 1.2s ease-in-out infinite; }
.voice[data-mode="speaking"] .pulse { background: var(--moderate); animation: beat .6s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.6); opacity: .5; } }
.voice-line { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-height: 4.5em; overflow: hidden; }
#ghost { position: fixed; left: 0; top: 0; z-index: 2000; pointer-events: none; opacity: 0; transform: translate(50vw, 80vh);
  transition: transform .6s cubic-bezier(.3,.7,.2,1), opacity .3s; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
#ghost.on { opacity: 1; }
#ghost.click::after { content: ""; position: absolute; left: -12px; top: -12px; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--accent); animation: ripple .4s ease-out forwards; }
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #ghost { transition: none; } .pulse { animation: none !important; } }

@media (max-width: 560px) {
  .hw { font-size: 13px; }
  .ask { flex-direction: column; align-items: stretch; }
  .status { display: none; }
  .top .icon-btn { margin-left: auto; }
  main { padding-top: 16px; }
  .voice-btn { padding: 14px; }
  .voice-label { display: none; }
  .menu { left: 16px; right: 16px; }
  .src .row { font-size: 12px; }
}

/* Accuracy test on the dashboard */
#evalBox h2 { margin-top: 28px; }
.evalcard { display: flex; gap: 18px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.evalcard p { margin: 0 0 6px; }
.evalscore { text-align: center; min-width: 110px; }
.evalscore b { display: block; font-size: 38px; color: var(--good); line-height: 1.1; }
.evalscore span { color: var(--muted); font-size: 13px; }
.evallist { margin-top: 10px; }
.evallist summary { cursor: pointer; color: var(--accent); }
.evallist ol { padding-left: 22px; font-size: 14px; }
.evallist li { margin: 4px 0; }
@media (max-width: 560px) { .evalcard { flex-direction: column; align-items: stretch; } }

/* Admin page: add research */
.admin { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
.small-switch button { padding: 4px 10px; font-size: 13px; }
.card-form { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card-form label { font-weight: 600; margin-top: 8px; }
.card-form input, .card-form select { width: 100%; font: 15px var(--font); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.card-form .primary { align-self: flex-start; margin-top: 14px; }
.card-form .primary:disabled { opacity: .6; cursor: wait; }
.card-form .error, .card-form .ok { margin: 8px 0 0; }
.ok { color: var(--good); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-docs li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-actions { display: flex; gap: 14px; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: var(--unhealthy); }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } .admin-docs li { flex-direction: column; align-items: flex-start; } }
a.primary { display: inline-block; text-decoration: none; }

/* Answer actions: feedback, share, policy brief */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.act { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 12px; font: 14px var(--font); cursor: pointer; }
.act:hover { border-color: var(--accent); }
.act[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.act-msg { font-size: 13px; color: var(--muted); word-break: break-all; }

/* Policy brief (one A4 page when printed) */
.brief-page { background: #E9EEEC; }
.brief-tools { max-width: 210mm; margin: 0 auto; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brief { max-width: 210mm; margin: 0 auto 40px; background: #fff; color: #13201C; padding: 14mm 14mm 10mm; box-shadow: 0 2px 16px rgba(0,0,0,.08); font-size: 12.5px; line-height: 1.45; }
.brief .muted { color: #5B6B66; }
.brief-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--accent); padding-bottom: 8px; margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }
.brief-head .logo { display: inline-block; vertical-align: middle; }
.brief-label { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; color: #5B6B66; margin: 6px 0 0; }
.brief h1 { font-size: 20px; margin: 2px 0 10px; }
.brief h2 { font-size: 14px; margin: 10px 0 6px; color: var(--accent); }
.brief h3 { font-size: 11.5px; margin: 10px 0 2px; color: #5B6B66; font-weight: 600; }
.brief-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }
.brief-findings { margin: 0; padding-left: 18px; }
.brief-findings li { margin: 0 0 6px; }
.brief sup { color: var(--accent); font-weight: 600; }
.kpis { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.kpi { border: 1px solid #E1E7E4; border-left: 4px solid var(--accent); border-radius: 8px; padding: 6px 8px; }
.kpi b { display: block; font-size: 16px; line-height: 1.2; }
.kpi span, .kpi small { display: block; font-size: 10.5px; color: #5B6B66; }
.brief svg { width: 100%; height: auto; display: block; }
.brief svg .lbl { font-size: 9px; fill: #5B6B66; }
.brief svg .val { font-size: 9px; fill: #13201C; font-weight: 600; }
.brief svg .ref { stroke: #5B6B66; stroke-dasharray: 3 3; stroke-width: .8; }
.brief-sources { margin: 0; padding-left: 18px; font-size: 11px; }
.brief-sources li { margin: 0 0 5px; }
.brief-sources q { display: block; color: #3b4a45; font-style: italic; }
.brief-sources a { color: var(--accent); word-break: break-all; }
.brief-foot { margin-top: 10px; padding-top: 6px; border-top: 1px solid #E1E7E4; font-size: 10px; color: #5B6B66; }
@media (max-width: 700px) { .brief { padding: 18px 16px; } .brief-grid, .kpis { grid-template-columns: 1fr; } }
@media print {
  @page { size: A4; margin: 0; }
  .no-print { display: none !important; }
  .brief-page { background: #fff; }
  .brief { box-shadow: none; margin: 0; max-width: none; font-size: 11.5px; }
  .brief-grid { grid-template-columns: 1.15fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* History */
.history-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.danger-act { color: var(--unhealthy); }
.hist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.hist summary { cursor: pointer; line-height: 1.4; }
.hist-body { margin-top: 10px; }
.hist-body p { margin: 0 0 8px; }
.hist-body ol { margin: 0 0 10px; padding-left: 20px; }
@media print {
  body.printing-history .top, body.printing-history .menu, body.printing-history .voice, body.printing-history .ghost,
  body.printing-history .view:not(#view-history), body.printing-history .no-print { display: none !important; }
  body.printing-history .hist { break-inside: avoid; border-color: #ccc; }
}

/* Schools ranking */
.school-list { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: sc; }
.school-list li { display: grid; grid-template-columns: 2.2fr 1.4fr 48px auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); counter-increment: sc; }
.school-list li.sc-note { display: block; border: 0; counter-increment: none; }
.sc-name::before { content: counter(sc) ". "; color: var(--muted); }
.sc-bar { height: 10px; background: var(--quote); border-radius: 6px; overflow: hidden; }
.sc-bar i { display: block; height: 100%; border-radius: 6px; }
.sc-val { text-align: right; }
.sc-map { padding: 4px 10px; font-size: 13px; }
@media (max-width: 560px) { .school-list li { grid-template-columns: 1fr 44px auto; } .sc-bar { grid-column: 1 / -1; grid-row: 2; } }

/* Chat widget (inside its frame on other websites) */
html.tw-html, .tw-page { background: transparent !important; margin: 0; overflow: hidden; height: 100%; }
.tw-launcher { position: fixed; bottom: 16px; right: 16px; width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #0E8A6A; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.22), inset 0 0 0 3px rgba(255,255,255,.35);
  transition: transform .15s ease; }
.tw-launcher:hover { transform: scale(1.06); }
.tw-launcher:focus-visible, .tw-icon:focus-visible, .tw-send:focus-visible, .tw-mic:focus-visible { outline: 3px solid #1f6feb; outline-offset: 2px; }
.tw-badge { position: absolute; top: -4px; right: -4px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: #fff; color: #13201C;
  font: 700 13px/26px var(--font); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.tw-launcher.tw-bad::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid currentColor; opacity: 0; animation: tw-ring 2.4s ease-out infinite; color: inherit; }
.tw-launcher.tw-bad { color: #fff; }
@keyframes tw-ring { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tw-launcher.tw-bad::after { animation: none; } .tw-launcher { transition: none; } }
.tw-left .tw-launcher, .tw-left .tw-nudge { right: auto; left: 16px; }

.tw-nudge { position: fixed; right: 16px; bottom: 92px; width: calc(100% - 32px); max-width: 290px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 12px 30px 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px; line-height: 1.4; }
.tw-nudge p { margin: 0 0 6px; }
.tw-x { position: absolute; top: 4px; right: 6px; background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
.tw-link { background: none; border: 0; padding: 0; color: var(--accent); font: 600 14px var(--font); cursor: pointer; }

.tw-panel { position: fixed; inset: 10px; display: flex; flex-direction: column; background: var(--card); color: var(--text); border-radius: 18px;
  border: 1px solid var(--line); box-shadow: 0 10px 34px rgba(0,0,0,.22); overflow: hidden; font-size: 14.5px; }
@media (max-width: 519px) { .tw-panel { inset: 0; border-radius: 0; border: 0; } }
.tw-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; background: var(--accent); color: #fff; }
.tw-head .logo { background: #fff; flex: none; }
.tw-head .logo::after { border-color: var(--accent); }
.tw-title { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.tw-title span { font-size: 12px; opacity: .9; }
.tw-icon { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.tw-icon:hover { background: rgba(255,255,255,.28); }
.tw-air { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; border-bottom: 1px solid var(--line); background: var(--quote); }
.tw-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.tw-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.tw-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; line-height: 1.45; word-wrap: break-word; }
.tw-bot { align-self: flex-start; background: var(--quote); border-bottom-left-radius: 4px; }
.tw-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.tw-err { color: var(--unhealthy); }
.tw-bot sup { color: var(--accent); font-weight: 700; }
.tw-spoken { align-self: flex-start; font-size: 12.5px; color: var(--muted); font-style: italic; max-width: 88%; }
.tw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tw-chips .chip { font-size: 13px; text-align: left; }
.tw-srcs { margin-top: 8px; font-size: 13px; }
.tw-srcs summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tw-srcs ol { padding-left: 18px; margin: 6px 0 0; }
.tw-srcs li { margin-bottom: 8px; }
.tw-srcs blockquote { margin: 0 0 3px; padding-left: 8px; border-left: 3px solid var(--accent); font-style: italic; }
.tw-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 13px; }
.tw-acts button { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; cursor: pointer; font-size: 13px; }
.tw-acts button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tw-typing i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: tw-dot 1s infinite; }
.tw-typing i:nth-child(2) { animation-delay: .15s; } .tw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tw-dot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.tw-voice { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 13px; color: var(--accent); border-top: 1px solid var(--line); }
.tw-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
.tw-compose input { flex: 1; min-width: 0; font: 15px var(--font); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.tw-send, .tw-mic { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; flex: none; }
.tw-send { background: var(--accent); color: #fff; }
.tw-send:disabled { opacity: .5; cursor: wait; }
.tw-mic { background: var(--accent-soft); color: var(--accent); }
.tw-mic .stop { display: none; }
.tw-mic.live { background: var(--unhealthy); color: #fff; }
.tw-mic.live .mic { display: none; } .tw-mic.live .stop { display: block; }
.tw-foot { padding: 0 12px 10px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* Widget page inside the platform: a pretend website with the widget in its corner */
.wd-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.wd-site { position: relative; isolation: isolate; height: 620px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.wd-bar { display: flex; gap: 6px; align-items: center; padding: 8px 12px; background: #EEF2F0; border-bottom: 1px solid #E1E7E4; font-size: 12px; color: #5B6B66; }
.wd-bar i { width: 10px; height: 10px; border-radius: 50%; background: #d0d7d4; }
.wd-fake { padding: 22px; color: #13201C; }
.wd-fake b { display: block; height: 14px; background: #E9EEEC; border-radius: 6px; margin: 10px 0; }
.wd-fake h3 { margin: 0 0 12px; }
.wd-copy { margin-top: 8px; }
.wd-langs { display: flex; gap: 8px; margin: 10px 0; }
@media (max-width: 760px) { .wd-grid { grid-template-columns: 1fr; } .wd-site { height: 560px; } }
.snippet { background: var(--quote); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 13px; }
.demo-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.wd-list { padding-left: 20px; } .wd-list li { margin-bottom: 6px; }

/* Widget views: tabs, map, sensor card, schools */
.tw-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--card); }
.tw-tabs button { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 4px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; }
.tw-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tw-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tw-view[hidden] { display: none !important; }
.tw-scroll { overflow-y: auto; overscroll-behavior: contain; display: block; }
.tw-map { flex: 1; min-height: 200px; }
.tw-note { margin: 0; padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.tw-pad { padding: 10px 14px; margin: 0; }
.tw-st-head { color: #fff; padding: 10px 14px 12px; }
.tw-st-head h3 { margin: 6px 0 2px; font-size: 16px; }
.tw-st-val b { font-size: 30px; }
.tw-back { background: rgba(255,255,255,.22); color: #fff; border: 0; border-radius: 8px; padding: 3px 9px; font: 600 12px var(--font); cursor: pointer; }
.tw-spark { width: 100%; height: auto; display: block; }
.tw-spark text { font-size: 10px; fill: var(--muted); }
.tw-sc { list-style: none; margin: 0; padding: 0 8px 10px; counter-reset: tsc; }
.tw-sc li { counter-increment: tsc; }
.tw-sc button { width: 100%; display: grid; grid-template-columns: 1.5fr 1fr 38px; gap: 8px; align-items: center; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 7px 6px; font: 13px var(--font); color: var(--text); text-align: left; cursor: pointer; }
.tw-sc button:hover { background: var(--quote); }
.tw-sc-name::before { content: counter(tsc) ". "; color: var(--muted); }
.tw-sc-bar { height: 8px; background: var(--quote); border-radius: 5px; overflow: hidden; }
.tw-sc-bar i { display: block; height: 100%; border-radius: 5px; }
.tw-sc b { text-align: right; }
.tw-linkmsg { align-self: flex-start; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; font-weight: 600; text-decoration: none; }
.tw-srcs li.flash { background: var(--accent-soft); border-radius: 6px; transition: background .3s; }

/* Time saved (the track's metric) */
.stat.saved { grid-column: 1 / -1; background: var(--accent-soft); border-color: var(--accent); }
.stat.saved b { font-size: 32px; color: var(--accent); }
.saved-line { margin: -4px 0 14px; font-weight: 600; color: var(--accent); }

/* Ask / Check a claim */
.mode-tabs { display: inline-flex; gap: 4px; background: var(--quote); border-radius: 999px; padding: 4px; margin: 6px 0 10px; }
.mode-tabs button { border: 0; background: none; border-radius: 999px; padding: 7px 14px; font: 600 14px var(--font); color: var(--muted); cursor: pointer; }
.mode-tabs button[aria-selected="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.verdict { display: inline-block; font-weight: 700; padding: 6px 12px; border-radius: 10px; margin-bottom: 10px; }
.v-supported { background: #E3F4EA; color: #1E7A45; }
.v-contradicted { background: #FCE4E6; color: #B4202D; }
.v-partly { background: #FDF0E2; color: #A9551A; }
.v-not-covered { background: var(--quote); color: var(--muted); }

/* Research gaps (AAI team) */
.gaps { margin-top: 26px; }
.small-act { font-size: 12px; padding: 3px 10px; vertical-align: middle; }
.gaps-list { padding-left: 22px; }
.gaps-list > li { margin-bottom: 14px; }
.gap-head { display: flex; justify-content: space-between; gap: 10px; }
.gap-bar { display: block; height: 7px; background: var(--quote); border-radius: 4px; margin: 5px 0; overflow: hidden; }
.gap-bar i { display: block; height: 100%; background: var(--sensitive); border-radius: 4px; }
.gaps-list ul { margin: 2px 0 0; padding-left: 16px; }
.differ { display: inline-block; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 10px; margin-bottom: 10px; background: #EEF0FB; color: #3B4A9A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .differ { background: #23284A; color: #B9C1F2; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400 !important; } .check input { width: auto !important; }

/* Automatic chart in answers */
.answer-chart { margin: 12px 0 4px; max-width: 420px; }
.answer-chart figcaption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.answer-chart svg { width: 100%; height: auto; display: block; }
.answer-chart .ch-l { font-size: 10px; fill: var(--muted); }
.answer-chart .ch-v { font-size: 10px; font-weight: 600; fill: var(--text); }

/* Source tools: quote card image and APA reference */
.src-tools { margin-left: auto; display: inline-flex; gap: 6px; }
.mini { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font: 600 12px var(--font); color: var(--muted); cursor: pointer; }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.cite-out { margin: 6px 0 0; word-break: break-word; }

/* Guided tour */
.tour-start { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 7px 16px; font: 600 14px var(--font); cursor: pointer; margin: 0 0 12px; }
.tour-start:hover { background: var(--accent); color: #fff; }
.tour-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 1004; width: min(720px, calc(100% - 24px)); background: rgba(19, 32, 28, .94); color: #fff;
  border-radius: 16px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.tour-caption { margin: 6px 0 10px; font-size: 16px; line-height: 1.45; }
.tour-dots { display: flex; gap: 4px; }
.tour-dots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); }
.tour-dots i.on { background: #3CC79C; }
.tour-ctrls { display: flex; gap: 8px; justify-content: flex-end; }
.tour-b { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font: 600 13px var(--font); cursor: pointer; }
.tour-b:hover { background: rgba(255,255,255,.22); }
.touring .voice { bottom: 150px; }
.tour-invite { position: fixed; left: 16px; bottom: 16px; z-index: 1003; display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--accent);
  border-radius: 999px; padding: 4px 6px 4px 4px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.tour-go { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font: 600 14px var(--font); cursor: pointer; }
.tour-invite .tour-x, .tour-bar .tour-x { background: none; border: 0; color: inherit; font-size: 16px; cursor: pointer; padding: 4px 8px; }
@media (max-width: 560px) { .tour-caption { font-size: 15px; } .tour-invite { right: 90px; } }
