:root {
  --ivory: #f5f0e6;
  --paper: #fffdf7;
  --parchment: #eee4cf;
  --gold: #c3a15b;
  --gold-dark: #95702e;
  --gold-light: #dfcb96;
  --bronze: #74551f;
  --indigo: #324866;
  --indigo-deep: #273b56;
  --indigo-soft: #e8edf2;
  --charcoal: #3b4b63;
  --ink: #4a5668;
  --muted: #747d8a;
  --line: #d9cfbc;
  --sage: #e9eee8;
  --rose: #f2e8df;
  --success: #40683d;
  --danger: #9f3d2e;
  --reader-font: 18px;
  --shadow: 0 16px 42px rgba(28, 42, 62, 0.1);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ivory); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 8%, rgba(195, 161, 91, 0.13), transparent 28rem),
    radial-gradient(circle at 92% 92%, rgba(36, 52, 75, 0.08), transparent 32rem),
    var(--ivory);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("/comprehend/brand/wm.webp") no-repeat center 48%;
  background-size: min(58vw, 520px);
  opacity: 0.018;
  pointer-events: none;
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(195, 161, 91, 0.42);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--charcoal); font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { font-size: clamp(1.75rem, 4vw, 2.65rem); line-height: 1.17; margin-bottom: 0.75rem; letter-spacing: -0.018em; }
h2 { font-size: clamp(1.25rem, 2.4vw, 1.65rem); margin-bottom: 0.45rem; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Chronicles strip: the same Back and Home as every other page in the book */
.chron {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1080px, calc(100% - 22px));
  margin: 10px auto 0;
  font-family: Georgia, "Times New Roman", serif;
}
.chron .brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.chron .brand img { height: 34px; width: auto; }
.chron .brand b { display: block; font: italic 500 19px/1 Georgia, "Times New Roman", serif; color: var(--bronze); }
.chron .brand small { display: block; margin-top: 4px; font: 500 9.5px/1 "Avenir Next", Avenir, -apple-system, sans-serif; letter-spacing: .3em; color: var(--gold); }
.chron .btns { display: flex; gap: 8px; }
.chron .btn {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid rgba(168, 121, 46, .45); border-radius: 999px; background: rgba(243,235,227, .7);
  font: 500 11px/1 "Avenir Next", Avenir, -apple-system, sans-serif; letter-spacing: .22em; text-transform: uppercase; color: var(--bronze); text-decoration: none;
  transition: background .3s, color .3s;
}
.chron .btn:hover { background: var(--bronze); color: var(--paper); }
.chron .btn.home { border-color: var(--gold); color: var(--indigo); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(1080px, calc(100% - 22px));
  margin: 0 auto;
  padding: 9px 16px;
  border: 0;
  border-bottom: 1px solid rgba(195, 161, 91, 0.55);
  border-radius: 0;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 4px 18px rgba(28, 42, 62, 0.045);
  backdrop-filter: blur(10px);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.brand-button img { width: auto; height: 42px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.03; }
.brand-copy small { color: var(--gold-dark); font-size: 0.52rem; letter-spacing: 0.15em; text-transform: uppercase; }
.brand-copy strong { color: var(--indigo); font-family: Georgia, serif; font-size: 1.28rem; font-style: italic; }
.brand-copy > span { color: var(--muted); font-size: 0.56rem; letter-spacing: 0.14em; text-transform: uppercase; }

.trial-badge, .source-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--parchment);
  color: var(--bronze);
  font-size: 0.76rem;
  font-weight: 700;
}

.patient-controls { display: flex; align-items: center; gap: 7px; }
.language-control { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.75rem; color: var(--muted); }
.language-control select, .speech-row select {
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.shell { position: relative; z-index: 1; width: min(1120px, calc(100% - 28px)); margin: 24px auto 60px; }
.view.narrow { width: min(520px, 100%); margin-inline: auto; }

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 14px 38px rgba(28, 42, 62, 0.065);
}

.hero { display: flex; flex-direction: column; padding: 0; overflow: hidden; border-top: 2px solid var(--gold); background: linear-gradient(180deg, rgba(255, 253, 247, 0.99), rgba(249, 244, 234, 0.98)); text-align: center; }
.hero-brand { display: grid; place-items: center; padding: 38px 24px 6px; background: transparent; }
.hero-brand img { width: min(162px, 46vw); height: auto; filter: drop-shadow(0 7px 15px rgba(116, 85, 31, 0.14)); }
.hero-content { padding: 10px clamp(26px, 7vw, 84px) clamp(38px, 6vw, 68px); }
.hero-content > p:not(.eyebrow) { width: min(690px, 100%); margin: 0 auto 34px; color: var(--muted); font-size: 1.04rem; }
.eyebrow { margin-bottom: 0.45rem; color: var(--gold-dark); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.quiet-centre { max-width: 680px; margin: 18px auto; color: var(--muted); font-size: 0.85rem; text-align: center; }

.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; width: min(720px, 100%); margin: 0 auto; }
.role-card {
  min-height: 148px;
  padding: 25px 22px;
  border: 0;
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 253, 247, 0.45);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.role-card:hover { transform: translateY(-2px); border-color: var(--gold-dark); background: var(--paper); box-shadow: 0 10px 24px rgba(28, 42, 62, 0.07); }
.role-icon { display: block; margin-bottom: 12px; color: var(--gold-dark); font-family: Georgia, serif; font-size: 0.68rem; font-style: italic; letter-spacing: 0.14em; }
.role-card strong { display: block; margin-bottom: 8px; color: var(--indigo); font-family: Georgia, serif; font-size: 1.24rem; font-weight: 400; }
.role-card > span:last-child { display: block; color: var(--muted); font-size: 0.9rem; }

.login-card { padding: 28px; }
.login-card form { display: grid; gap: 12px; }
.login-logo { display: block; width: 96px; height: auto; margin: -8px auto 6px; filter: drop-shadow(0 5px 11px rgba(116, 85, 31, 0.11)); }
.text-back { margin: -6px 0 22px; padding: 4px 0; border: 0; background: transparent; color: var(--bronze); cursor: pointer; }

label { display: grid; gap: 5px; color: var(--ink); font-size: 0.84rem; font-weight: 700; }
label b { color: var(--danger); }
input, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }

.primary-button, .secondary-button {
  min-height: 43px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--indigo); background: var(--indigo); color: #fff; box-shadow: none; }
.primary-button:hover { background: var(--indigo-deep); }
.secondary-button { border: 1px solid var(--gold-light); background: #fff; color: var(--indigo); }
.compact { min-height: 36px; padding: 7px 12px; font-size: 0.84rem; }
.icon-button {
  min-width: 37px;
  height: 37px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}
.button-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 12px; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
option:disabled, option.translation-only-option { color: #9b948b; }
.form-status, .record-status { min-height: 1.35em; margin: 9px 0 0; color: var(--muted); font-size: 0.82rem; }
.form-status.error, .record-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }

.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin: 8px 2px 18px; }
.section-heading p { margin-bottom: 0; color: var(--muted); }
.form-section, .patient-section { margin-bottom: 15px; padding: 24px; }
.step-title { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.step-title > span {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: transparent;
  color: var(--indigo);
  font-size: 0.78rem;
  font-weight: 800;
}
.step-title h2 { margin: 0; }
.step-title.plain { margin-bottom: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 18px; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.upload-card { display: grid; gap: 11px; padding: 17px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.document-number { color: var(--gold-dark); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.file-picker { display: block; padding: 10px 13px; border: 1px dashed var(--gold); border-radius: 11px; color: var(--bronze); text-align: center; cursor: pointer; }
.upload-status { min-height: 2.4em; margin: 0; color: var(--muted); font-size: 0.79rem; }
.upload-status.ready { color: var(--success); }
.note-strip { margin: 14px 0 0; padding: 10px 13px; border-radius: 12px; background: var(--sage); color: #4d543e; font-size: 0.82rem; }
.share-result { margin-top: 16px; padding: 18px; border: 1px solid #bfd0b9; border-radius: 16px; background: #edf4e9; }
.share-result label { margin-top: 10px; }
.success-label { margin-bottom: 4px; color: var(--success); font-weight: 900; }
.package-list { display: grid; gap: 9px; }
.package-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.package-row strong, .package-row span { display: block; }
.package-row span { color: var(--muted); font-size: 0.78rem; }

.patient-welcome { padding: clamp(26px, 5vw, 46px); text-align: center; }
.patient-welcome > p:not(.eyebrow) { width: min(680px, 100%); margin: 0 auto 18px; }
.coordinator-card { display: inline-block; max-width: 620px; padding: 12px 20px; border-radius: 14px; background: var(--parchment); color: var(--ink); font-size: 0.86rem; }
.section-title-row { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 13px; }
.section-title-row h2, .section-title-row p { margin-bottom: 0; }
.patient-documents { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.patient-document {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 96px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.patient-document .document-icon { font-size: 1.55rem; }
.patient-document strong, .patient-document small { display: block; }
.patient-document small { color: var(--muted); }
.patient-document .open-arrow { margin-left: auto; color: var(--gold); font-weight: 900; }
.capability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.capability-grid span { display: grid; gap: 2px; padding: 12px 14px; border-left: 2px solid var(--gold); border-radius: 0; background: rgba(232, 237, 242, 0.62); color: var(--indigo); font-size: 0.82rem; }
.capability-grid b { font-family: Georgia, serif; font-size: 0.96rem; }
.capability-grid small { color: var(--muted); }

.record-field { position: relative; }
.record-field textarea { padding-right: 57px; }
.microphone-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid var(--gold-light);
  border-radius: 50%;
  background: #fff8e8;
  color: var(--bronze);
  cursor: pointer;
}
.microphone-button.large { width: 46px; height: 46px; font-size: 1.1rem; }
.microphone-button.recording { border-color: var(--danger); background: #f9dfdb; color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(159, 61, 46, 0.08); } }
.notes-list { display: grid; gap: 8px; margin-top: 14px; }
.note-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.note-item div { flex: 1; }
.note-item small { display: block; margin-top: 3px; color: var(--muted); }
.note-item button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.reader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--ivory);
}
.reader-header { position: relative; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--paper); }
.reader-title { display: flex; flex: 1; min-width: 170px; flex-direction: column; line-height: 1.2; }
.reader-title strong { color: var(--charcoal); }
.reader-title span { color: var(--muted); font-size: 0.75rem; }
.page-controls, .view-controls, .reader-accessibility { display: flex; align-items: center; gap: 5px; }
.page-controls span { min-width: 78px; color: var(--muted); font-size: 0.8rem; text-align: center; }
.reader-accessibility select { max-width: 185px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 0.78rem; }
.view-button { padding: 7px 9px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; font-size: 0.77rem; }
.view-button:first-child { border-radius: 9px 0 0 9px; }
.view-button:last-child { border-radius: 0 9px 9px 0; }
.view-button + .view-button { margin-left: -6px; }
.view-button.active { position: relative; z-index: 1; border-color: var(--indigo); background: var(--indigo-soft); color: var(--indigo); font-weight: 800; }
.reader-progress { height: 3px; background: var(--parchment); }
.reader-progress span { display: block; width: 0; height: 100%; background: var(--gold); transition: width 0.2s ease; }
.reader-scroll { flex: 1; overflow: auto; padding: 15px 12px 180px; }
.pdf-stage { text-align: center; }
#pdfCanvas { max-width: 100%; border-radius: 4px; background: #fff; box-shadow: 0 4px 20px rgba(50, 35, 15, 0.15); }
.reading-stage { width: min(830px, 100%); margin: 0 auto; font-size: var(--reader-font); }
.reading-paragraph { margin-bottom: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; white-space: pre-wrap; transition: background 0.15s ease, border-color 0.15s ease; }
.bilingual-stage { width: min(1120px, 100%); margin: 0 auto; overflow-x: auto; }
.bilingual-head, .bilingual-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; min-width: 560px; }
.bilingual-head { position: sticky; top: -15px; z-index: 2; padding: 8px 0; background: var(--ivory); color: var(--bronze); font-size: 0.76rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.bilingual-row { margin-bottom: 10px; }
.bilingual-cell { min-height: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: var(--reader-font); white-space: pre-wrap; transition: background 0.15s ease, border-color 0.15s ease; }
.bilingual-cell.translation { background: var(--paper); }
.reading-active { border-color: var(--gold) !important; background: #f4e5b9 !important; box-shadow: 0 0 0 2px rgba(180, 135, 62, 0.12); }
.loading-card { padding: 30px; color: var(--muted); text-align: center; }

.reader-footer { position: fixed; right: 0; bottom: 0; left: 0; z-index: 106; border-top: 1px solid var(--line); background: rgba(255, 250, 240, 0.98); box-shadow: 0 -6px 22px rgba(50, 35, 15, 0.08); }
.speech-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; padding: 8px 11px; border-bottom: 1px solid var(--line); }
.control-label { color: var(--muted); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.round-button { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); cursor: pointer; }
.round-button.play { width: 42px; height: 42px; border-color: var(--indigo); background: var(--indigo); color: #fff; }
.audio-availability { flex-basis: 100%; min-height: 0; color: var(--muted); font-size: 0.74rem; text-align: center; }
.reader-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; width: min(650px, 100%); margin: 0 auto; padding: 7px 11px calc(7px + env(safe-area-inset-bottom)); }
.tool-button { min-height: 42px; border: 0; border-radius: 11px; font-weight: 900; cursor: pointer; }
.tool-button.translate { background: var(--parchment); color: #765717; }
.tool-button.explain { background: var(--sage); color: #4d543e; }
.tool-button.ask { background: var(--rose); color: #85502d; }

.assistant-panel {
  position: fixed;
  top: 11%;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 130;
  display: flex;
  flex-direction: column;
  width: min(860px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -8px 35px rgba(40, 30, 15, 0.24);
}
.assistant-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.assistant-panel header h2, .assistant-panel header p { margin-bottom: 0; }
.assistant-body { flex: 1; overflow: auto; padding: 18px; }
.assistant-question { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.assistant-question .primary-button { width: 100%; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.answer-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.answer-card h3 { margin-bottom: 7px; font-size: 1rem; }
.answer-card ul { margin: 8px 0 0; padding-left: 20px; }
.evidence-list { display: grid; gap: 9px; margin-top: 16px; }
.evidence-item { padding: 11px 13px; border-left: 4px solid var(--gold); border-radius: 0 11px 11px 0; background: var(--parchment); }
.evidence-item blockquote { margin: 5px 0 8px; font-style: italic; }
.evidence-item button { border: 0; background: transparent; color: var(--bronze); cursor: pointer; font-weight: 800; padding: 0; }
.grounded-note { padding: 9px 12px; border-radius: 11px; background: #edf4e9; color: var(--success); font-size: 0.82rem; }
.unsupported-note { padding: 13px; border-radius: 12px; background: #f8e4df; color: #823629; }

.toast { position: fixed; right: 16px; bottom: 18px; z-index: 300; max-width: min(420px, calc(100% - 32px)); padding: 11px 15px; border-radius: 12px; background: var(--charcoal); color: #fff; box-shadow: var(--shadow); font-size: 0.84rem; }

@media (max-width: 760px) {
  .hero-brand { padding: 28px 18px 4px; }
  .hero-brand img { width: 132px; }
  .hero-content { padding: 8px 24px 38px; }
  .app-header { align-items: flex-start; flex-wrap: wrap; }
  .patient-controls { flex-basis: 100%; justify-content: flex-end; }
  .language-control { flex: 1; }
  .language-control select { flex: 1; max-width: none; }
  .role-grid, .form-grid, .upload-grid, .patient-documents { grid-template-columns: 1fr; }
  .section-heading, .section-title-row { align-items: flex-start; flex-direction: column; }
  .source-pill { align-self: flex-start; }
  .capability-grid { grid-template-columns: 1fr; }
  .reader-header { align-items: flex-start; }
  .reader-title { order: -1; flex-basis: calc(100% - 115px); }
  .reader-accessibility { flex: 1; justify-content: flex-end; }
  .view-controls { flex-basis: 100%; }
  .view-button { flex: 1; }
  .answer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .chron { width: calc(100% - 20px); }
  .chron .brand small { display: none; }
  .chron .btn { padding: 0 10px; letter-spacing: .14em; }
  .shell { width: min(100% - 18px, 1040px); margin-top: 11px; }
  .app-header { width: 100%; border-radius: 0; }
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 1.12rem; }
  .brand-copy > span { font-size: 0.49rem; }
  .trial-badge { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero, .form-section, .patient-section, .login-card { padding: 19px; }
  .role-card { min-height: 140px; }
  .bilingual-head, .bilingual-row { min-width: 510px; gap: 6px; }
  .bilingual-cell { padding: 10px; font-size: calc(var(--reader-font) * 0.83); }
  .speech-row { gap: 5px; }
  .speech-row select { max-width: 128px; padding-inline: 6px; }
  .control-label { display: none; }
  .reader-actions { gap: 5px; }
  .tool-button { font-size: 0.82rem; }
  .assistant-panel { top: 5%; }
}

@media print {
  body::before, .app-header, .reader, .assistant-panel, button, .record-status { display: none !important; }
  .shell { width: 100%; margin: 0; }
  .card { border: 0; box-shadow: none; }
  .view { display: none !important; }
  #patientView { display: block !important; }
  #patientView > section:not(:has(#notesList)) { display: none !important; }
}

/* Master copy additions */
.microphone-button svg.mic { width: 18px; height: 18px; fill: currentColor; display: block; margin: auto; }
.microphone-button.large svg.mic { width: 21px; height: 21px; }
.tool-button { font-weight: 600; letter-spacing: 0.02em; }
.document-icon { font-family: Georgia, serif; font-style: italic; letter-spacing: 0.12em; color: var(--gold-dark); }
.patient-document .document-icon { font-size: 1rem; }
@media (max-width: 760px) {
  .patient-controls, .language-control { min-width: 0; }
  .language-control select { min-width: 0; width: 100%; }
}

/* ===== Soft beige layer, Oct 2026: Chronicles beige, italic serif, no boxes, gentle fades ===== */
:root {
  --ivory: #ebdcce;          /* Chronicles beige ground */
  --paper: #f6eee6;          /* soft surface */
  --parchment: #efe3d6;
  --line: rgba(176, 141, 87, .28);
  --gold: #b08d57;
  --gold-dark: #8a6a3c;
  --bronze: #7a5c38;
  --charcoal: #5b4a3a;       /* warm, never black */
  --ink: #5f5043;
  --muted: #8d7b69;
  --indigo: #4f5b7a;
  --indigo-deep: #434e6b;
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --shadow: 0 18px 50px rgba(122, 92, 56, .08);
}
html, body { background: var(--ivory); }
body { font-family: var(--serif); font-size: 18px; color: var(--ink); }
body::before { display: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--charcoal); letter-spacing: 0; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); font-weight: 300; }
h1 em, h2 em { font-style: italic; color: var(--gold-dark); }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.5rem); font-style: italic; }
.eyebrow { font-family: var(--serif); font-weight: 500; font-size: .78rem; letter-spacing: .28em; color: var(--gold); }
label { font-weight: 400; font-size: .95rem; color: var(--ink); }
label b, .file-picker b { color: var(--gold-dark); font-weight: 400; }

/* fades */
@keyframes softIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view:not(.hidden), .reader:not(.hidden), .assistant-panel:not(.hidden) { animation: softIn .8s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) { .view, .reader, .assistant-panel { animation: none !important; } }

/* one logo: the card carries the mark on the opening page */
body[data-view="roleView"] .chron .brand { visibility: hidden; }
.app-header { background: rgba(243, 235, 227, .9); border-bottom: 1px solid var(--line); box-shadow: none; }
.brand-copy strong { font-family: var(--serif); font-weight: 400; font-style: italic; color: var(--gold-dark); font-size: 1.45rem; }
.brand-copy > span { font-family: var(--serif); font-style: italic; letter-spacing: .04em; text-transform: none; font-size: .82rem; color: var(--muted); }
body[data-view="roleView"] .app-header { display: none; }
.chron .btn { background: transparent; border-color: rgba(176,141,87,.4); font-family: var(--serif); font-weight: 500; }

/* no square boxes anywhere: soft, borderless surfaces */
.card { border: 0; border-radius: 28px; background: rgba(246, 238, 230, .72); box-shadow: var(--shadow); }
.hero { border: 0; background: transparent; box-shadow: none; }

/* opening page: the graphic card, fading into the words */
.hero-art { position: relative; margin: 0 auto; width: min(1000px, 100%); }
.hero-art img { display: block; width: 100%; height: auto; border-radius: 6px; animation: cardIn 1.6s ease both; }
.hero-art::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 22%; background: linear-gradient(to bottom, rgba(235,220,206,0), var(--ivory)); pointer-events: none; }
@keyframes cardIn { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: none; } }
.hero-content { text-align: center; padding: 6px 20px 10px; animation: softIn 1.2s .5s both; }
.hero-content h1 { margin-bottom: .5rem; }
.hero-content .lede { margin: 0 auto 26px; width: min(560px, 100%); font-style: italic; color: var(--muted); font-size: 1.12rem; }
.trust { width: min(620px, 100%); margin: 0 auto 30px; padding: 22px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.trust p { margin: 0 0 10px; color: var(--ink); font-size: 1.08rem; line-height: 1.6; }
.trust p:last-child { margin: 0; color: var(--muted); font-style: italic; }
.trust em { color: var(--gold-dark); }
.role-links { display: flex; justify-content: center; gap: clamp(24px, 6vw, 70px); flex-wrap: wrap; }
.role-link { background: none; border: 0; padding: 6px 4px 10px; cursor: pointer; font-family: var(--serif); color: var(--charcoal); text-align: center; position: relative; }
.role-link span { display: block; font-size: 1.35rem; font-style: italic; }
.role-link small { display: block; color: var(--muted); font-size: .9rem; margin-top: 2px; }
.role-link::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 0; height: 1px; background: var(--gold); transform: scaleX(.3); opacity: .5; transition: transform .6s ease, opacity .6s ease; }
.role-link:hover::after, .role-link:focus-visible::after { transform: scaleX(1); opacity: 1; }
.quiet-centre { font-style: italic; color: var(--muted); font-size: .92rem; }

/* sign-in pages */
.login-card { text-align: center; padding: 34px 30px; }
.login-card form { text-align: left; }
.text-back { font-family: var(--serif); font-style: italic; color: var(--gold-dark); }

/* inputs and buttons: soft, rounded, light */
input, textarea, select { border: 1px solid var(--line) !important; border-radius: 14px !important; background: rgba(255,251,246,.75) !important; color: var(--ink); font-family: var(--serif); font-size: 1rem; }
input:focus, textarea:focus, select:focus { border-color: var(--gold) !important; }
.primary-button, .secondary-button { border-radius: 999px; font-family: var(--serif); font-weight: 500; letter-spacing: .06em; transition: background .4s, color .4s, border-color .4s; }
.primary-button { background: var(--gold-dark); border-color: var(--gold-dark); color: #fbf6ef; }
.primary-button:hover { background: var(--bronze); }
.secondary-button { background: transparent; border-color: var(--line); color: var(--bronze); }
.icon-button, .round-button { border-color: var(--line) !important; background: transparent !important; color: var(--bronze) !important; }
.round-button.play { background: var(--gold-dark) !important; color: #fbf6ef !important; border-color: var(--gold-dark) !important; }

/* coordinator: calm and balanced */
.section-heading { align-items: flex-end; margin-bottom: 18px; }
.section-heading h1 { font-size: clamp(1.45rem, 2.6vw, 1.85rem); margin-bottom: .3rem; }
.section-heading p { font-style: italic; font-size: .98rem; }
.form-section, .patient-section { padding: 26px clamp(20px, 4vw, 38px); margin-bottom: 18px; }
.step-title { gap: 12px; margin-bottom: 16px; }
.step-title > span { width: 30px; height: 30px; border: 1px solid var(--gold) !important; background: transparent !important; color: var(--gold-dark) !important; font-family: var(--serif); font-style: italic; font-weight: 400 !important; border-radius: 50% !important; }
.step-title h2 { font-size: 1.25rem; }
.form-grid { gap: 14px 26px; align-items: end; }
.upload-card { border: 0; border-radius: 22px; background: rgba(239,227,214,.6); padding: 18px 20px; }
.document-number { font-weight: 500; font-style: italic; letter-spacing: .12em; }
.file-picker { border-radius: 999px; border-style: solid; border-color: var(--line); text-align: center; color: var(--bronze); font-style: italic; }
.note-strip { background: transparent; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0 0; font-style: italic; color: var(--muted); }
.share-result { border: 0; background: rgba(239,227,214,.7); border-radius: 22px; }
.package-row { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; background: transparent !important; }

/* patient pages */
.trial-badge, .source-pill { background: transparent; border: 1px solid var(--line); font-weight: 400; font-style: italic; color: var(--gold-dark); }
.patient-welcome h1 { font-style: italic; }
.coordinator-card { background: transparent; border-top: 1px solid var(--line); border-radius: 0; font-style: italic; }
.patient-document { border: 0 !important; border-radius: 22px !important; background: rgba(239,227,214,.65) !important; box-shadow: none !important; transition: background .5s, transform .5s; }
.patient-document:hover { background: rgba(232,214,194,.8) !important; transform: translateY(-2px); }
.capability-grid span { border-left: 0; background: transparent; border-top: 1px solid var(--line); border-radius: 0; }
.capability-grid b { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--gold-dark); }
.note-item { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; background: transparent !important; }

/* reader */
.reader { background: var(--ivory) !important; }
.reader-header { background: rgba(243,235,227,.95) !important; border-bottom: 1px solid var(--line) !important; }
.reader-title strong { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.15rem; }
.view-button { border-color: var(--line) !important; background: transparent !important; color: var(--muted) !important; font-family: var(--serif); }
.view-button.active { background: var(--gold-dark) !important; border-color: var(--gold-dark) !important; color: #fbf6ef !important; }
.reading-paragraph, .bilingual-cell { border: 0 !important; border-radius: 16px !important; background: rgba(246,238,230,.75) !important; font-family: var(--serif); line-height: 1.7; transition: background .6s; }
.reading-active { background: rgba(222,198,160,.55) !important; box-shadow: none !important; }
.reader-footer { background: rgba(243,235,227,.96) !important; border-top: 1px solid var(--line) !important; backdrop-filter: blur(10px); }
.control-label { font-weight: 400; font-style: italic; letter-spacing: .06em; text-transform: none; font-size: .9rem; }
.reader-actions { grid-template-columns: repeat(5, 1fr); width: min(760px, 100%); }
.tool-button { border-radius: 999px !important; background: transparent !important; border: 1px solid var(--line) !important; color: var(--bronze) !important; font-family: var(--serif); font-style: italic; font-weight: 400 !important; font-size: 1.02rem; transition: background .4s, color .4s; }
.tool-button:hover { background: rgba(176,141,87,.14) !important; }
.tool-button.translate { color: var(--gold-dark) !important; border-color: var(--gold) !important; }
.assistant-panel { border: 0 !important; border-radius: 26px 26px 0 0 !important; background: var(--paper) !important; }
.answer-card, .evidence-item, .grounded-note { border: 0 !important; border-radius: 16px !important; background: rgba(239,227,214,.6) !important; color: var(--ink) !important; }
.toast { border-radius: 999px; background: var(--bronze); color: #fbf6ef; font-family: var(--serif); font-style: italic; }

@media (max-width: 760px) {
  body { font-size: 17px; }
  .reader-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tool-button { font-size: .88rem; padding: 0 4px; }
  .trust p { font-size: 1rem; }
}
/* refinements */
.hero-art { width: min(780px, 100%); }
label { display: block; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 7px; }
label > b { display: inline; margin-left: 2px; }
.step-title > span { display: inline-grid; place-items: center; font-size: 1rem; font-variant-numeric: lining-nums; line-height: 1; }
.app-header { background: transparent !important; border-bottom: 0 !important; backdrop-filter: none; padding-top: 2px; }
.shell { width: min(980px, calc(100% - 28px)); }
.section-heading .eyebrow { margin-bottom: .2rem; }
.form-section .primary-button { min-width: 220px; }
.upload-card { gap: 12px; }
body:not([data-view="patientView"]) .brand-button { visibility: hidden; }
.chron, .app-header { width: min(980px, calc(100% - 28px)); }

.hero-art::after { height: 7%; }
.hero-content { padding-top: 22px; }

/* ===== Madhu Kamath house style (matches madhukamath.com and the CGI pages) ===== */
:root { --ink: #3b2a1e; --charcoal: #3b2a1e; --deep: #5a2a18; --gold: #a8792e; --gold-dark: #a8792e; --muted: #7d6a58; --line: rgba(168,121,46,.38); --sc: "Cormorant SC", "Cormorant Garamond", Georgia, serif; }
body { font-size: 16px; color: var(--ink); }
h1 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); font-weight: 300; color: var(--ink); }
h1 em { color: var(--gold); }
h2 { font-size: 1.15rem; font-weight: 400; color: var(--ink); }
.eyebrow { font-family: var(--sc); font-style: normal; font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--gold); }

/* no panels, no shadows: hairlines only */
.card, .form-section, .patient-section, .login-card, .patient-welcome, .upload-card, .share-result, .patient-document, .answer-card, .evidence-item, .grounded-note, .reading-paragraph, .bilingual-cell {
  background: transparent !important; box-shadow: none !important; border: 0 !important; border-radius: 0 !important;
}
.form-section, .patient-section { padding: 26px 0 !important; margin: 0 !important; border-top: 1px solid var(--line) !important; }
.upload-card { padding: 0 !important; }
.patient-document { border-bottom: 1px solid var(--line) !important; padding: 14px 4px !important; }
.reading-paragraph, .bilingual-cell { padding: 6px 2px 10px !important; border-bottom: 1px solid rgba(168,121,46,.16) !important; }
.reading-active { background: rgba(168,121,46,.10) !important; }

/* buttons: hairline, square, small spaced capitals, never filled */
.primary-button, .secondary-button, .tool-button, .view-button, .file-picker, .chron .btn, .text-back {
  background: transparent !important; color: var(--deep) !important; border: 1px solid var(--line) !important; border-radius: 0 !important;
  font-family: var(--sc) !important; font-style: normal !important; font-weight: 500 !important; font-size: 11px !important;
  letter-spacing: .3em !important; text-transform: uppercase; min-height: 38px; padding: 0 20px !important; box-shadow: none !important;
  transition: border-color .5s, color .5s, background .5s;
}
.primary-button { border-color: rgba(168,121,46,.75) !important; }
.primary-button:hover, .secondary-button:hover, .tool-button:hover, .file-picker:hover, .chron .btn:hover { background: rgba(168,121,46,.08) !important; border-color: var(--gold) !important; color: var(--deep) !important; }
.view-button.active { background: transparent !important; color: var(--deep) !important; border-color: var(--gold) !important; }
.view-button + .view-button { margin-left: 0; }
.text-back { border: 0 !important; padding: 0 !important; min-height: 0; }
.form-section .primary-button { min-width: 0; }
.round-button, .icon-button { border-radius: 50% !important; border: 1px solid var(--line) !important; background: transparent !important; color: var(--deep) !important; }
.round-button.play { background: transparent !important; color: var(--deep) !important; border-color: var(--gold) !important; }
.step-title > span { display: none !important; }
.tool-button { min-height: 40px; }

/* inputs: a single underline, no boxes */
input, textarea, select { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; background: transparent !important; padding: 8px 2px !important; font-size: 1rem; color: var(--ink); }
textarea { border: 1px solid var(--line) !important; padding: 10px !important; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold) !important; }
label { font-family: var(--sc); font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
label b { color: var(--gold); }
.document-number { font-family: var(--sc); font-style: normal; font-size: 11px; letter-spacing: .3em; color: var(--gold); }
.note-strip, .upload-status, .form-status, .quiet-centre { font-size: .9rem; }

/* header strip in her house style */
.chron .brand b { font-family: var(--sc); font-style: normal; font-weight: 500; font-size: 12px; letter-spacing: .42em; color: var(--deep); text-transform: uppercase; }
.chron .brand small { font-family: var(--sc); font-size: 9px; letter-spacing: .34em; color: var(--gold); }
.chron .brand img { height: 30px; }
.brand-copy strong { font-size: 1.15rem; color: var(--gold); }

/* opening page text sized down */
.hero-content .lede, .trust p { font-size: 1rem; }
.role-link span { font-family: var(--sc); font-style: normal; font-size: 12px; letter-spacing: .32em; text-transform: uppercase; color: var(--deep); }
.role-link small { font-style: italic; font-size: .92rem; margin-top: 6px; }
.role-link { padding: 12px 22px; border: 1px solid var(--line); transition: border-color .5s, background .5s; }
.role-link::after { display: none; }
.role-link:hover { border-color: var(--gold); background: rgba(168,121,46,.06); }

/* reader */
.reader-footer, .reader-header { background: rgba(235,220,206,.96) !important; }
.reader-title strong { font-size: 1.05rem; }
.trial-badge, .source-pill { border-radius: 0; font-family: var(--sc); font-style: normal; font-size: 10px; letter-spacing: .26em; text-transform: uppercase; }
.toast { border-radius: 0; background: var(--ivory); color: var(--deep); border: 1px solid var(--gold); }
.assistant-panel { border-radius: 0 !important; background: var(--ivory) !important; border-top: 1px solid var(--gold) !important; }
@media (max-width: 760px) { .tool-button { letter-spacing: .12em !important; padding: 0 4px !important; font-size: 10px !important; } }

.demo-tick { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; text-transform: none; letter-spacing: .02em; font-family: var(--serif); font-size: .95rem; font-style: italic; color: var(--muted); }
.demo-tick input { width: auto !important; margin: 0; accent-color: #a8792e; }

/* ===== Clear reading for older eyes: page one carries the reading help ===== */
:root { --page-zoom: 1; --reader-font: 20px; }
.shell { zoom: var(--page-zoom); }
body { font-size: 18px; }
.hero-content .lede, .trust p { font-size: 1.12rem; line-height: 1.65; }
.trust p:last-child { color: var(--ink); }
.quiet-centre { font-size: 1rem; color: var(--ink); }
label { font-size: 13px; letter-spacing: .16em; color: #6b5846; }
.eyebrow { font-size: 12px; }
.primary-button, .secondary-button, .tool-button, .view-button, .file-picker, .chron .btn { font-size: 13px !important; letter-spacing: .18em !important; min-height: 46px; }
.role-link span { font-size: 14px; letter-spacing: .2em; }
.role-link small { font-size: 1rem; color: var(--ink); }

.access-bar { position: sticky; top: 0; z-index: 70; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 22px;
  margin: 0 auto 18px; padding: 12px 10px; background: rgba(235,220,206,.97); border-bottom: 1px solid var(--line); zoom: calc(1 / var(--page-zoom)); }
.access-group { display: flex; align-items: center; gap: 10px; margin: 0; }
.access-label { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ink); letter-spacing: 0; text-transform: none; }
.access-btn { min-width: 54px; height: 54px; padding: 0 14px; border: 1px solid rgba(168,121,46,.7); background: rgba(246,238,230,.6); color: var(--deep);
  font-family: var(--serif); font-size: 1.35rem; cursor: pointer; transition: background .4s, border-color .4s; }
.access-btn.big { font-size: 1.7rem; }
.access-btn.wide { font-size: 1.15rem; padding: 0 22px; display: inline-flex; align-items: center; gap: 10px; }
.access-btn.wide span { font-size: .9rem; color: var(--gold); }
.access-btn:hover, .access-btn.on { background: rgba(168,121,46,.14); border-color: var(--gold); }
.access-group.lang select { height: 54px; min-width: 190px; font-size: 1.12rem !important; padding: 0 10px !important; border: 1px solid rgba(168,121,46,.7) !important; background: rgba(246,238,230,.6) !important; color: var(--deep); }

/* reader: large, clear controls */
.reader-header .icon-button, .page-controls .icon-button, .reader-accessibility .icon-button { width: 48px; height: 48px; font-size: 1.3rem; }
.page-controls span { font-size: 1rem; color: var(--ink); min-width: 110px; }
.reader-accessibility select, .speech-row select { font-size: 1.05rem !important; min-height: 46px; }
.reading-stage, .bilingual-stage { font-size: var(--reader-font); line-height: 1.75; color: var(--ink); }
.round-button { width: 50px !important; height: 50px !important; font-size: 1.1rem; }
.round-button.play { width: 58px !important; height: 58px !important; font-size: 1.3rem; }
.control-label { font-size: 1.05rem; color: var(--ink); display: inline !important; }
.tool-button { min-height: 52px !important; font-size: 14px !important; }
.reader-title strong { font-size: 1.25rem; }
.reader-title span { font-size: .9rem; }
.reader-scroll { padding-bottom: 210px; }

@media (max-width: 760px) {
  .access-bar { gap: 10px; }
  .access-btn.wide { flex: 1 1 100%; justify-content: center; }
  .access-group.lang { flex: 1 1 100%; justify-content: center; }
  .access-group.lang select { flex: 1; }
  .tool-button { font-size: 12px !important; letter-spacing: .06em !important; }
  .reader-actions { grid-template-columns: repeat(3, 1fr) !important; }
}
.file-picker { display: flex !important; align-items: center; justify-content: center; }

.access-label { white-space: nowrap; }

/* Language chooser: big, written in each language's own script */
.lang-btn b { font-weight: 500; color: var(--deep); }
.lang-btn span { font-size: 1.2rem !important; }
.language-picker { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(59,42,30,.28); animation: softIn .4s ease both; }
.language-sheet { width: min(980px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column; background: var(--ivory); border: 1px solid var(--gold); padding: 20px clamp(16px, 3vw, 30px) 24px; }
.language-sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.language-sheet h2 { margin: 0; font-size: 1.6rem; font-style: italic; }
.language-sheet .icon-button { width: 52px; height: 52px; font-size: 1.6rem; }
#languageFilter { font-size: 1.2rem !important; padding: 12px 6px !important; margin-bottom: 14px; }
.language-grid { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding-bottom: 6px; }
.language-choice { min-height: 70px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 10px 16px; text-align: left;
  border: 1px solid var(--line); background: rgba(246,238,230,.6); color: var(--ink); cursor: pointer; transition: background .3s, border-color .3s; }
.language-choice .native { font-size: 1.3rem; line-height: 1.25; font-family: var(--serif), "Noto Sans", system-ui, sans-serif; }
.language-choice small { font-size: .95rem; color: var(--muted); }
.language-choice:hover, .language-choice:focus-visible { background: rgba(168,121,46,.12); border-color: var(--gold); outline: none; }
.language-choice.chosen { border-color: var(--gold); background: rgba(168,121,46,.16); }
@media (max-width: 600px) { .language-grid { grid-template-columns: 1fr 1fr; } .language-choice .native { font-size: 1.15rem; } }
