:root {
  /* Type scale */
  --t0: 0.875rem; /* 14 */
  --t1: 1rem;     /* 16 */
  --t2: 1.125rem; /* 18 */
  --t3: 1.25rem;  /* 20 */
  --t4: 1.5rem;   /* 24 */
  --t5: 1.75rem;  /* 28 */

  /* Font roles */
  --title-font: Georgia, "Times New Roman", Times, serif;
  --ui-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  --mono-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;

  --bg: #ffffff;
  --fg: #222222;
  --muted: #666666;

  /* HIG-ish gutters: never tight, respects notch safe areas */
  --gutter-min: 1.25rem;             /* ~20px */
  --gutter-ideal: 4vw;               /* scales a bit */
  --gutter-max: 2.25rem;             /* ~36px */
  --gutter: clamp(var(--gutter-min), var(--gutter-ideal), var(--gutter-max));

  /* Keep list indent modest and proportional */
  --list-indent: 1.5rem;

  --top-pad: 2rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  font-family: var(--ui-font);
  font-size: var(--t2);
  line-height: 1.85;
  font-kerning: normal;
  font-variant-ligatures: none;
  text-align: left;
}

main, header, article, section, nav, .content, .post-article {
  text-align: left;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono-font);
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 0.5rem;
}
.skip:focus {
  left: calc(var(--gutter) + env(safe-area-inset-left));
}

.site-header {
  padding: var(--top-pad) 0 0 0;
}

.site-title {
  margin: 0;
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  font-family: var(--ui-font);
  font-weight: 500;
  font-size: var(--t1);         /* 16px label */
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--muted);          /* "scurry off" */
}

.site-title a {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
  font-size: inherit;
}

.content {
  padding: 2.2rem 0 4rem 0;
}

.post-list {
  list-style: none;
  margin: 0;
  padding-left: calc(var(--gutter) + var(--list-indent) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
  font-family: var(--ui-font);
  font-size: var(--t3);
  line-height: 1.75;
}

.post-item + .post-item {
  margin-top: 0.75rem;
}

.post-link {
  display: inline-flex;
  align-items: baseline;
  gap: 1.1rem;
  color: inherit;
  text-decoration: none;
}

.post-link:hover .post-title {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.post-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 6px;
  border-radius: 0.25rem;
}

.post-date {
  font-size: var(--t1);
  color: var(--muted);
  white-space: nowrap;
}

.post-meta {
  font-size: var(--t1);
}

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

/* Mobile: keep the same feel, just reduce indent + size */
@media (max-width: 600px) {
  :root {
    --list-indent: 1.75rem;
    --top-pad: 1.5rem;
  }

  body {
    font-size: var(--t1);
  }


  .post-list {
    font-size: var(--t2);
  }

  .post-h1 {
    font-size: var(--t3);
  }

  .post-body {
    font-size: var(--t1);
  }

  .post-date,
  .post-meta {
    font-size: var(--t0);
  }
}

/* --- Post page --- */

/* On post pages, treat site title as a breadcrumb */
.post .site-title {
  font-size: var(--t0);   /* 14px */
  letter-spacing: 0.03em;
  opacity: 0.7;
  color: var(--fg);
}

.post {
  padding-top: 1.25rem;
}

.post-article {
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
  max-width: 76ch;
}

.post-header {
  margin-bottom: 1.75rem;
}

.post-h1 {
  margin: 0 0 1rem 0;
  font-family: var(--ui-font);
  font-weight: 500;
  font-size: var(--t4); /* keep 24px */
  line-height: 1.25;
  letter-spacing: 0;
}

.post-meta {
  margin: 0;
  padding: 0;
  font-family: var(--ui-font);
  color: var(--muted);
}

/* On post pages, treat the header context as body copy */
.post-header .post-meta {
  color: var(--fg);
  font-size: var(--t2);
  line-height: 1.85;
  border-left: 3px solid #e6e6e6;
  padding-left: 1rem;
  margin-top: 1.25rem;
}

.post-meta .dot {
  margin: 0 0.5rem;
}

/* Make post-meta work as labeled rows (no new colors/fonts) */
.post-meta .meta-row {
  margin: 0 0 1rem 0;
}

.post-meta dt {
  display: block;
  font-weight: 600;
}

.post-meta dt::after {
  content: "";
}

.post-meta dd {
  display: block;
  margin: 0.25rem 0 0 0;
}

.post-body {
  font-family: var(--ui-font);
  font-size: var(--t2);
  line-height: 1.85;
  overflow-wrap: anywhere; /* long URLs, case IDs */
}

.post-body p {
  margin: 0 0 1.25rem 0;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.6rem 0;
  padding-left: var(--list-indent);
}

.post-body li {
  margin: 0.25rem 0;
}

.post-body h3 {
  margin: 3rem 0 0.75rem 0;
  font-size: var(--t2);   /* 18px */
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
}

.post-body h4 {
  margin: 2.2rem 0 0.5rem 0;
  font-size: var(--t1);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
}

.post-body a {
  color: #0000ee;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.post-body a:visited {
  color: #551a8b;
}

.post-body a:hover {
  text-decoration-thickness: 2px;
}

.post-body blockquote {
  margin: 1.6rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--fg);
}

.post-body blockquote p {
  margin: 0;
}

.post-body hr {
  border: 0;
  border-top: 1px solid #e6e6e6;
  margin: 3rem 0 1.75rem 0;
}

.post-body code {
  font-family: var(--mono-font);
  font-size: 0.95em;
  background: #f6f6f6;
  border-radius: 0.25rem;
  padding: 0.12em 0.32em;
}

.post-body pre {
  margin: 1.4rem 0;
  padding: 1rem;
  border: 1px solid #e6e6e6;
  border-radius: 0;
  overflow-x: auto;
  font-family: var(--mono-font);
  font-size: var(--t1);
  line-height: 1.6;
}

.post-body pre code {
  background: transparent;
  padding: 0;
}

.post-body table {
  display: block;
  width: 100%;
  margin: 1.4rem 0;
  border: 1px solid #e6e6e6;
  border-radius: 0;
  border-collapse: collapse;
  overflow-x: auto;
  font-size: var(--t1);
  line-height: 1.6;
}

.post-body th,
.post-body td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e6e6e6;
  vertical-align: top;
}

.post-body tr:last-child td {
  border-bottom: 0;
}

.post-body th {
  text-align: left;
  font-weight: 600;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.post-nav-link {
  font-family: var(--mono-font);
  text-decoration: none;
}

.post-nav-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.post-nav-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 6px;
  border-radius: 0.25rem;
}

@media (max-width: 600px) {
  .post-article {
    padding-left: calc(var(--gutter) + env(safe-area-inset-left));
    padding-right: calc(var(--gutter) + env(safe-area-inset-right));
    max-width: 100%;
  }

  .post-nav {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Footer --- */

.site-footer {
  padding: 2rem 0 2.5rem 0;
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
}

.footer-line {
  margin: 0;
  font-family: var(--ui-font);
  font-size: calc(var(--t0) / 2);     /* half of t0 */
  line-height: 1.6;
  color: var(--muted);
}

.footer-line a {
  color: inherit;           /* boring */
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.footer-line a:hover {
  text-decoration-thickness: 2px;
}

.footer-line .sep {
  margin: 0 0.5rem;
}

/* --- Clinician form --- */

.form {
  margin-top: 1.25rem;
}

.form-section {
  margin: 2.5rem 0;
}

.form-h2 {
  margin: 0 0 0.75rem 0;
  font-size: var(--t2);
  font-weight: 500;
}

.scale-list {
  margin: 0;
  padding-left: var(--list-indent);
}

.incident {
  padding: 1.75rem 0;
}

.incident + .incident {
  border-top: 1px solid #e6e6e6;
}

.incident-header {
  margin-bottom: 0.85rem;
}

.incident-title {
  margin: 0;
  font-size: var(--t2);
  font-weight: 600;
  line-height: 1.35;
}

.incident-meta {
  margin: 0.25rem 0 0 0;
  color: var(--muted);
  font-size: var(--t1);
  line-height: 1.6;
}

.incident-meta .dot {
  margin: 0 0.5rem;
}

.incident-summary {
  margin: 1rem 0 1.4rem 0;
}

.form hr {
  border: 0;
  border-top: 1px solid #e6e6e6;
  margin: 2.2rem 0 1.5rem 0;
}

.likert {
  border: 0;
  border-top: 1px solid #e6e6e6;
  border-radius: 0;
  padding: 0.9rem 0 0 0;
  margin: 0.75rem 0 0 0;
}

.likert-legend {
  font-family: var(--ui-font);
  font-weight: 600;
  font-size: var(--t1);
  padding: 0;
}

.hint {
  margin: 0.35rem 0 0.75rem 0;
  color: var(--muted);
  font-size: var(--t1);
  line-height: 1.6;
}

/* Form instructions should read as body copy (keep status as UI) */
.form .hint {
  color: var(--fg);
  font-size: inherit;
  line-height: inherit;
}

.form-actions .hint {
  color: var(--muted);
  font-size: var(--t1);
  line-height: 1.6;
}

.likert-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.likert-opt {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.1rem 0;
  border-radius: 0;
  border: 0;
}

.likert-opt input {
  margin-top: 0.25rem;
}

/* Radios: use native controls (removes “designed/app” feel) */
.form input[type="radio"] {
  appearance: auto;
  -webkit-appearance: auto;
  accent-color: var(--fg);
  width: auto;
  height: auto;
  border: 0;
  background: transparent;
  display: inline-block;
}

.form input[type="radio"]::before {
  content: none;
}

.form input[type="radio"]:checked::before {
  transform: none;
}

.form input[type="radio"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.likert-opt:focus-within {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin-top: 0.5rem;
}

.check input {
  margin-top: 0.35rem;
}

.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.05rem;
  height: 1.05rem;
  border: 1.5px solid var(--fg);
  border-radius: 0;
  background: transparent;
  display: inline-grid;
  place-content: center;
  flex: 0 0 auto;
}

.check input[type="checkbox"]::before {
  content: "";
  width: 0.35rem;
  height: 0.65rem;
  border-right: 2px solid var(--bg);
  border-bottom: 2px solid var(--bg);
  transform: rotate(45deg) scale(0);
}

.check input[type="checkbox"]:checked {
  background: var(--fg);
}

.check input[type="checkbox"]:checked::before {
  transform: rotate(45deg) scale(1);
}

.check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.form-actions {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid #e6e6e6;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono-font);
  font-size: var(--t1);
  line-height: 1.2;
  padding: 0.65rem 0.85rem;
  border-radius: 0;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.96);
}

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

.btn-quiet {
  background: transparent;
  color: var(--fg);
}

.form input[type="password"],
.form input[type="text"] {
  appearance: none;
  -webkit-appearance: none;
  width: min(28rem, 100%);
  padding: 0.6rem 0.7rem;
  border: 1px solid #e6e6e6;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono-font);
  font-size: var(--t1);
  line-height: 1.2;
}

.form input[type="password"]:focus-visible,
.form input[type="text"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.result {
  margin-top: 1.25rem;
  border: 1px solid #e6e6e6;
  border-radius: 0;
  padding: 0.75rem;
}

.result summary {
  font-family: var(--mono-font);
  cursor: pointer;
}

/* Wider screens: show 2x2 Likert options */
@media (min-width: 720px) {
  .likert-grid {
    grid-template-columns: 1fr 1fr;
  }
}
