/* RESPOND PI Questionnaire — palette from PLAN §10.
   System font stack only: the CSP forbids external font requests. */

:root {
  --accent: #23bde0;
  --accent-dark: #22b5d7;
  --text: #424242;
  --muted: #666666;
  --danger: #d51923;
  --success: #5ec232;
  --warning: #fdce3e;
  --border: #ebebeb;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
}

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

body {
  margin: 0;
  background: var(--surface-alt);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--surface); padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- header / footer ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.logo { height: 42px; width: auto; }
.header-right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.header-right a { color: var(--muted); text-decoration: none; }
.header-right a:hover { color: var(--accent-dark); }
.who { color: var(--text); font-weight: 600; }
.role-chip {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 8px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
}
.inline-form { display: inline; margin: 0; }

.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 20px 0; background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; flex-wrap: wrap; }

/* ---------- PHI callout (modal only) ---------- */

.phi-callout {
  color: var(--danger); font-size: 14px; font-weight: 600;
  background: #fdecec; border: 1px solid #f5c2c5; border-radius: var(--radius);
  padding: 10px 14px; margin: 12px 0; display: flex; gap: 8px; align-items: baseline;
}
.phi-callout::before { content: "▲"; font-size: 11px; }
.modal-label { display: block; font-weight: 600; margin: 16px 0 6px; }

/* ---------- landing ---------- */

.landing { max-width: 560px; margin: 48px auto; text-align: center; }
.landing h1 { font-size: 28px; margin-bottom: 8px; }
.lede { color: var(--muted); margin-bottom: 28px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.code-card { text-align: left; }
.code-card label { display: block; font-weight: 600; margin-bottom: 8px; }

.code-input {
  width: 100%; padding: 14px 16px; font-size: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.code-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.staff-link { margin-top: 28px; font-size: 14px; }
.staff-link a { color: var(--muted); }

/* ---------- generic ---------- */

.help { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; margin: 12px 0 0; }

.notice {
  border-left: 4px solid var(--warning); background: #fffbf0;
  padding: 12px 16px; border-radius: var(--radius); margin: 16px 0;
}
.submitted-notice { border-left-color: var(--success); background: #f4fbf0; }

.btn {
  display: inline-block; border: none; border-radius: var(--radius);
  padding: 11px 20px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.subtle { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.subtle:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 13px; text-decoration: underline;
}
.linklike:hover { color: var(--accent-dark); }
.linklike.danger { color: var(--danger); }

/* ---------- page head + toc ---------- */

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin: 28px 0 16px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 26px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.progress-pill {
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 5px 14px; font-size: 13px; font-weight: 600;
}

/* ---------- two-column layout: sticky sidebar + content ---------- */

.q-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 28px; align-items: start; }
.q-main { min-width: 0; }

.sidenav {
  position: sticky; top: 20px; align-self: start;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.sidenav-progress {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.progress-label { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.progress-label span { color: var(--accent-dark); font-size: 18px; }

.bar.big { height: 10px; width: 100%; }
.sidenav nav { display: flex; flex-direction: column; gap: 4px; }

.toc-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px;
  text-decoration: none; color: var(--text); font-size: 13px; line-height: 1.3;
}
.toc-item:hover { border-color: var(--accent); }
.toc-item.active { background: #f2fbfd; border-color: var(--accent); }
.toc-item.partial { border-left-color: var(--warning); }
.toc-item.done { border-left-color: var(--success); }
.toc-title { min-width: 0; }
.toc-meta { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.toc-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.cmt-badge {
  background: #e7f7fb; color: var(--accent-dark); border-radius: 999px;
  padding: 1px 7px; font-size: 11px; font-weight: 700;
}

/* ---------- respondent name ---------- */

.respondent { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.respondent label { font-size: 13px; color: var(--muted); font-weight: 600; }
.respondent-input {
  padding: 6px 10px; font: inherit; font-size: 14px; min-width: 240px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.respondent-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

@media (max-width: 820px) {
  .q-layout { grid-template-columns: 1fr; }
  .sidenav { position: static; max-height: none; }
  .sidenav nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ---------- sections + questions ---------- */

.section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 28px; margin-bottom: 24px;
}
.section h2 {
  margin: 0 0 4px; font-size: 19px; color: var(--accent-dark);
  padding-bottom: 10px; border-bottom: 2px solid var(--border);
}
.section-desc { color: var(--muted); font-size: 14px; margin: 12px 0 0; }

.question { padding: 20px 0; border-bottom: 1px solid var(--border); }
.question:last-child { border-bottom: none; padding-bottom: 4px; }
.question[hidden] { display: none; }

.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.q-label { font-weight: 600; }

.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-state.saved { color: var(--success); }
.save-state.error { color: var(--danger); font-weight: 600; }

.group-label {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: .1em; margin: 4px 0; text-transform: uppercase;
}
.group-label::before, .group-label::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.text-input, .text-area, .option-text, .comment-input {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.text-input:focus, .text-area:focus, .option-text:focus, .comment-input:focus {
  outline: 2px solid var(--accent); border-color: var(--accent);
}
.text-area { resize: vertical; min-height: 88px; }
.text-input:disabled, .text-area:disabled { background: var(--surface-alt); color: var(--muted); }
.counter { text-align: right; font-size: 11px; color: var(--muted); margin-top: 3px; }

.radio-row { display: flex; align-items: center; gap: 20px; margin-top: 8px; }
.radio, .checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.radio input, .checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }

.checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px 20px; margin-top: 10px;
}
.checkbox-cell { display: flex; flex-direction: column; gap: 6px; }
.option-text[hidden] { display: none; }

/* ---------- uploads ---------- */

.uploads { margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.upload-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px;
}
.upload-row a { color: var(--accent-dark); }
.upload-row .muted { margin-left: auto; font-size: 12px; }
.file-btn { display: inline-block; cursor: pointer; }

/* ---------- dropzones ---------- */

.slot-drop { display: flex; align-items: center; gap: 12px; padding: 6px; border: 1px dashed transparent; border-radius: var(--radius); }
.slot-drop.drag { border-color: var(--accent); background: #f2fbfd; }
.slot-drop-hint { font-size: 12px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-alt); padding: 22px; text-align: center; cursor: pointer;
  transition: border-color .12s, background .12s; margin-bottom: 14px;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: #f2fbfd; }
.dropzone-inner { display: flex; flex-direction: column; gap: 4px; }
.dz-browse { color: var(--accent-dark); text-decoration: underline; }
.inline-warn { color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 4px; }
.dz-state { font-size: 12px; color: var(--muted); margin-top: 8px; }
.dz-state.error { color: var(--danger); font-weight: 600; }

/* ---------- consolidated document list ---------- */

.doc-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.doc-list-head, .doc-row {
  display: grid; grid-template-columns: 2fr 1.4fr auto auto; gap: 12px;
  align-items: center; padding: 9px 14px;
}
.doc-list-head {
  background: var(--surface-alt); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 600;
}
.doc-row { border-top: 1px solid var(--border); font-size: 14px; }
.doc-row a { color: var(--accent-dark); word-break: break-word; }
.doc-slot { color: var(--muted); font-size: 13px; }
.doc-empty { padding: 16px 14px; }

/* ---------- attachments (thumbnails + file chips) ---------- */

.attach-block { margin-top: 10px; }
.attach-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.attach { position: relative; }
.attach.is-img img {
  width: 120px; height: 90px; object-fit: cover; display: block;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.attach.is-file {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
}
.attach.is-file a { color: var(--accent-dark); }
.attach-remove {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: var(--danger); color: #fff;
  cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.attach.is-file .attach-remove { position: static; width: auto; height: auto; background: none; color: var(--danger); }

.dropzone.slim { padding: 14px; }
.section-docs { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.section-docs-title { font-size: 14px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

.attach-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.paste-btn { padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.paste-ico { font-size: 14px; }
.attach-hint { font-size: 12px; }
.attach-hint kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px;
}

/* ---------- RESPOND comments ---------- */

.comments { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.comment {
  background: #f2fbfd; border: 1px solid #cfeef6;
  border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 10px 14px;
}
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment-brand {
  color: var(--accent-dark); font-weight: 700; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
}
.comment-head .muted { font-size: 12px; }
.comment-head .danger { margin-left: auto; }
.comment-body { white-space: pre-wrap; font-size: 14px; }
.comment-add { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 32px; max-width: 560px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.modal h2 { margin-top: 0; }

/* ---------- submit bar ---------- */

.submit-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px; flex-wrap: wrap;
}

/* ---------- tables (staff) ---------- */

.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tbody tr:hover { background: var(--surface-alt); }
.table a { color: var(--accent-dark); }

.bar { background: var(--border); border-radius: 999px; height: 7px; width: 120px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.status-chip {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 9px; border-radius: 999px;
}
.status-active { background: #e7f7fb; color: var(--accent-dark); }
.status-submitted { background: #eef9e7; color: #3f8a1f; }
.status-disabled { background: #f3f3f3; color: var(--muted); }

.code-reveal {
  background: #fffbe8; border: 1px solid var(--warning);
  border-radius: var(--radius); padding: 16px 20px; margin: 16px 0;
}
.code-reveal code {
  font-size: 22px; letter-spacing: .08em; font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.form-grid { display: grid; gap: 12px; max-width: 460px; }
.form-grid label { font-weight: 600; font-size: 14px; }

/* ---------- print (PLAN §10) ---------- */

@media print {
  .no-print, .site-header, .site-footer, .save-state, .submit-bar,
  .file-btn, .comment-add, .linklike, .modal-backdrop, .skip-link, .sidenav { display: none !important; }

  body { background: #fff; font-size: 11pt; }
  .wrap { max-width: none; padding: 0; }
  .q-layout { display: block; }

  .section {
    box-shadow: none; border: none; border-top: 1.5pt solid #000;
    padding: 0; margin: 0 0 14pt; break-inside: avoid;
  }
  .section h2 { color: #000; border-bottom: none; }
  .question { break-inside: avoid; padding: 6pt 0; }
  .question[hidden] { display: none !important; }
  .comment { border: 1pt solid #999; background: #fff; }
  .text-area, .text-input { border: 1pt solid #999; }
  a { text-decoration: none; color: #000; }
}
