:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --ink: #1f2a33;
  --muted: #5c6b76;
  --line: #e2e8ee;
  --brand: #3a6b8a;
  --brand-deep: #2b5169;
  --accent: #4a9d8e;
  --warn-bg: #fff7e8;
  --warn-line: #e8c983;
  --info-bg: #eef4f8;
  --crisis-bg: #f4efe6;
  --crisis-line: #d9b98a;
  --strong: #2f8a6f;
  --moderate: #b7791f;
  --limited: #7a8791;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31,42,51,.05), 0 4px 16px rgba(31,42,51,.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
.wrap { width: 100%; max-width: 780px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--brand-deep); text-decoration: none; font-size: 1.02rem; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.brand-right { display: inline-flex; align-items: center; gap: 14px; }
.brand-tag { color: var(--muted); font-size: .82rem; }
.mode-link { color: var(--muted); font-size: .82rem; text-decoration: none; border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.mode-link:hover { color: var(--brand-deep); border-color: var(--brand); }
@media (max-width: 520px) { .brand-tag { display: none; } }

.notice-strip { background: var(--info-bg); border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--brand-deep); }
.notice-strip .wrap { padding-top: 10px; padding-bottom: 10px; }

.main { padding: 30px 20px 60px; }

/* Intro */
.intro h1 { font-size: 1.6rem; line-height: 1.25; margin: .2em 0 .3em; color: var(--brand-deep); }
.lede { color: var(--muted); font-size: 1.02rem; margin: 0 0 24px; }

/* Panels & form */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.field-label { display: block; font-weight: 600; margin-bottom: 8px; }
textarea {
  width: 100%; resize: vertical; padding: 14px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; color: var(--ink); background: #fcfdfe;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.consent { margin: 14px 0 4px; font-size: .92rem; color: var(--muted); }
.consent input { margin-right: 8px; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.btn-primary {
  background: var(--brand); color: #fff; border: 0; padding: 11px 22px; border-radius: 999px;
  font: inherit; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.hint, .muted { color: var(--muted); }
.hint { font-size: .88rem; }
.small { font-size: .9rem; }

/* Pending / spinner */
.pending { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px 22px; text-align: center; box-shadow: var(--shadow); margin-top: 8px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pending-text { font-weight: 600; margin: 0 0 4px; }

/* Results */
.results { margin-top: 8px; }
.section-title { margin: 26px 0 4px; color: var(--brand-deep); }
.thesis { font-size: 1.05rem; }
h2 { font-size: 1.25rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin: 14px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 1.12rem; }
.badge { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 4px 10px; border-radius: 999px; color: #fff; white-space: nowrap; }
.badge-strong { background: var(--strong); }
.badge-moderate { background: var(--moderate); }
.badge-limited { background: var(--limited); }
.codes { color: var(--muted); font-size: .86rem; margin: 4px 0 8px; }

.criteria-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.criteria-grid h4 { margin: 0 0 6px; font-size: .92rem; color: var(--brand-deep); }
.criteria-grid ul { margin: 0; padding-left: 18px; font-size: .93rem; }
.ticks li { list-style: none; position: relative; padding-left: 20px; margin-bottom: 4px; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--strong); font-weight: 700; }
.qs li { margin-bottom: 4px; color: var(--muted); }

.cite-refs { margin-top: 12px; font-size: .82rem; color: var(--muted); }
.chip { background: var(--info-bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; display: inline-block; margin: 2px 2px 0 0; color: var(--brand-deep); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.two-col ul { padding-left: 18px; margin: 6px 0 0; }

/* Callouts */
.callout { border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; border: 1px solid var(--line); }
.callout-info { background: var(--info-bg); border-color: #cfe0eb; }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout-disclaimer { background: #fbfcfd; color: var(--muted); font-size: .9rem; }

/* Crisis */
.crisis { background: var(--crisis-bg); border: 1px solid var(--crisis-line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.crisis h2 { margin: 0 0 6px; color: #8a5a1f; font-size: 1.2rem; }
.crisis-list { list-style: none; padding: 0; margin: 10px 0 0; }
.crisis-list li { padding: 6px 0; border-top: 1px solid var(--crisis-line); }
.crisis-list li:first-child { border-top: 0; }
.region { display: inline-block; min-width: 92px; color: var(--muted); font-size: .84rem; }

.restart { margin-top: 24px; }
.restart a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; }
.site-footer .wrap { padding-top: 18px; padding-bottom: 26px; }
.site-footer p { font-size: .84rem; color: var(--muted); margin: 4px 0; }

@media (max-width: 560px) {
  .criteria-grid, .two-col { grid-template-columns: 1fr; }
  .intro h1 { font-size: 1.35rem; }
}

/* --- Structured case inputs + affected people (Mode 1) --- */
.block-title { font-size: 1.05rem; color: var(--brand-deep); margin: 0 0 14px; }
.block-subtitle { font-size: .95rem; color: var(--brand-deep); margin: 0; }
.field-label { margin-top: 12px; }
.affected { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.affected-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.btn-add { background: transparent; border: 1px solid var(--brand); color: var(--brand); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .85rem; cursor: pointer; }
.btn-add:hover { background: var(--brand); color: #fff; }
.people-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.people-empty { color: var(--muted); font-size: .88rem; margin: 6px 0; }
.person-card { position: relative; background: #fbfdfe; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 34px 10px 12px; }
.person-main { font-size: .95rem; }
.person-rel { color: var(--muted); font-size: .85rem; margin-left: 6px; }
.person-impact { color: var(--muted); font-size: .86rem; margin-top: 3px; line-height: 1.45; }
.person-remove { position: absolute; top: 6px; right: 8px; background: transparent; border: 0; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.person-remove:hover { color: #c0392b; }

/* --- Shared modal (theme-agnostic) --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,32,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; color: #1f2a33; border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.modal h3 { margin: 0 0 6px; }
.modal label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 5px; color: #33424f; }
.modal input, .modal textarea { width: 100%; box-sizing: border-box; border: 1px solid #d5dde4; border-radius: 9px; padding: 10px 12px; font: inherit; color: #1f2a33; background: #fff; }
.modal textarea { resize: vertical; }
.modal input:focus, .modal textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-cancel { background: transparent; border: 1px solid #ccd4db; color: #556; border-radius: 8px; padding: 9px 16px; font: inherit; cursor: pointer; }
.modal-save { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.modal-save:hover { background: var(--brand-deep); }

/* PII warning note (light base — Mode 1 pages and the modal) */
.pii-note { font-size: .8rem; color: #8a5a1f; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 7px 10px; margin: 6px 0 0; line-height: 1.4; }

/* PII gate alert (stronger than the advisory note) — light base */
.pii-alert { font-size: .85rem; color: #a11; background: #fdecec; border: 1px solid #f2b8b8; border-radius: 8px; padding: 8px 11px; margin: 8px 0 0; line-height: 1.4; }
.pii-override { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; font-weight: 600; cursor: pointer; }
.pii-override input { margin-top: 2px; flex: none; }

/* --- DSM citation viewer (side drawer) — shared by both modes --- */
.dsm-cite { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.chip.dsm-cite:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.dsm-cite:hover { text-decoration-style: solid; }

.pdfd-backdrop { position: fixed; inset: 0; background: rgba(10,15,20,.45); z-index: 999; opacity: 0; transition: opacity .25s ease; }
.pdfd-backdrop.show { opacity: 1; }
.pdfd-backdrop[hidden] { display: none; }

.pdfd-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(720px, 94vw);
  background: #fff; z-index: 1000; display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.35);
  transform: translateX(100%); transition: transform .26s ease;
}
.pdfd-drawer.open { transform: translateX(0); }
.pdfd-drawer[hidden] { display: none; }
.pdfd-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 12px; background: #1f2a33; color: #fff; }
.pdfd-title { font-weight: 650; font-size: .9rem; white-space: nowrap; }
.pdfd-actions { display: flex; align-items: center; gap: 8px; }
.pdfd-nav { background: rgba(255,255,255,.12); border: 0; color: #fff; font-size: 1.15rem; line-height: 1; cursor: pointer; border-radius: 6px; width: 30px; height: 30px; }
.pdfd-nav:hover { background: rgba(255,255,255,.25); }
.pdfd-pageno { font-size: .82rem; min-width: 44px; text-align: center; color: #cfe0eb; }
.pdfd-open { color: #cfe0eb; text-decoration: none; font-size: .8rem; white-space: nowrap; }
.pdfd-open:hover { color: #fff; }
.pdfd-close { background: transparent; border: 0; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.pdfd-body { flex: 1 1 auto; overflow: auto; background: #525659; position: relative; -webkit-overflow-scrolling: touch; }
.pdfd-img { display: block; width: 100%; height: auto; }
.pdfd-spin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.pdfd-spin .spinner-sm { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.pdfd-err { color: #fff; padding: 20px; text-align: center; }

/* Privacy information pill (public page, light theme) */
.privacy-pill { display: flex; gap: 12px; align-items: flex-start; background: var(--info-bg); border: 1px solid #cfe0eb; border-left: 4px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin: 0 0 20px; font-size: .92rem; line-height: 1.5; color: var(--ink); }
.privacy-pill .pp-icon { font-size: 1.2rem; line-height: 1.3; }
.privacy-pill strong { color: var(--brand-deep); }

/* Cross-tool (sibling app) links in the header */
.mode-link.app-link { border-color: var(--brand); color: var(--brand-deep); }
.mode-link.app-link:hover { border-color: var(--brand); color: var(--brand-deep); filter: brightness(1.05); }
