:root {
  color-scheme: light;
  --paper: #faf9f5;
  --surface: #fffefa;
  --ink: #213e3a;
  --muted: #606e67;
  --teal: #23665a;
  --teal-dark: #174f44;
  --soft: #e6eee7;
  --line: #d9e0d6;
  --error: #8c3830;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Geeza Pro", Tahoma, Arial, sans-serif; line-height: 1.75; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button, input { color: inherit; }
a { color: var(--teal); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #a47e36; outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 31px; line-height: 1.45; }
h2 { font-size: 21px; line-height: 1.5; }
h3 { font-size: 17px; line-height: 1.6; }
svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); }
.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; }
.skip-link { position: fixed; top: -80px; right: 16px; background: var(--surface); padding: 12px 18px; z-index: 10; border: 1px solid var(--teal); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { height: 80px; padding-inline: 32px; max-width: 1180px; margin: auto; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; }
.brand-logo { display: block; width: 144px; height: 72px; object-fit: contain; }
.header-caption { font-size: 13px; color: var(--muted); }
#main { max-width: 1030px; margin: auto; padding: 36px 32px 24px; }
#main:focus { outline: none; }
.state-panel { max-width: 460px; margin: 42px auto 80px; }
.state-panel h1 { font-size: 28px; margin-top: 10px; }
.state-description { margin: 15px 0 24px; color: var(--muted); line-height: 1.9; }
.section-kicker { display: block; color: var(--teal); font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.state-panel label { display: block; font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.state-panel input { width: 100%; border: 1px solid #b9c9bd; border-radius: 13px; background: var(--surface); padding: 13px 18px; min-height: 61px; font-size: 24px; letter-spacing: 5px; font-family: Arial, sans-serif; }
.state-panel input::placeholder { font-size: 21px; color: #7b817b; }
.field-help { margin: 14px 0 20px; font-size: 14px; color: var(--muted); }
.form-error { border-inline-start: 3px solid var(--error); padding: 10px 13px; color: var(--error); background: #f8eeea; border-radius: 5px; font-size: 14px; margin: 12px 0 20px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 50px; padding: 11px 22px; border: 0; border-radius: 13px; font-weight: 700; text-decoration: none; transition: background .15s ease, transform .15s ease; }
.button:active { transform: scale(.985); }
.primary { background: var(--teal); color: white; }
.primary:hover:not(:disabled) { background: var(--teal-dark); }
.full { width: 100%; }
.access-note { color: var(--muted); font-size: 13px; text-align: center; margin-top: 27px; }
.state-symbol { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--soft); color: var(--teal); margin-bottom: 17px; }
.loading-mark { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .9s linear infinite; margin-bottom: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
.patient-page { animation: appear .2s ease-out; }
@keyframes appear { from { opacity: .4; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.patient-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; }
.avatar { width: 65px; height: 65px; flex-shrink: 0; border-radius: 24px; background: #e0e8d9; color: #606f53; display: grid; place-items: center; font-size: 27px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.patient-identity { min-width: 0; flex: 1; }
.patient-identity h1 { overflow-wrap: anywhere; }
.welcome { color: var(--muted); font-size: 14px; margin-top: 5px; }
.icon-button { min-height: 46px; min-width: 46px; border: 1px solid var(--line); background: transparent; color: var(--teal); border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; }
.icon-button:hover { background: var(--soft); }
.page-columns { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(255px, 1fr); gap: 34px; }
.updates-column { min-width: 0; }
.update { padding: 24px; border: 1px solid oklch(89% .014 150); border-radius: 18px; background: var(--surface); }
#history { display: grid; gap: 18px; }
.latest-heading { margin-bottom: 14px; }
.latest { border: 1.25px solid oklch(75% .035 160); background: var(--soft); }
.update-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.update-kind { color: var(--muted); overflow-wrap: anywhere; }
.update time { unicode-bidi: isolate; font-weight: 500; }
.update-text { font-size: 18px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; margin: 14px 0 18px; }
.latest .update-text { font-size: 23px; }
.media-player { display: block; width: 100%; margin: 16px 0; border-radius: 12px; background: #edece3; }
audio.media-player { min-height: 54px; direction: ltr; }
.update-image { display: block; width: 100%; max-height: 480px; object-fit: contain; margin: 16px 0; border-radius: 12px; background: var(--soft); }
.media-label { font-size: 14px; font-weight: 700; margin-top: 12px; }
.media-error { font-size: 13px; color: var(--muted); margin: 10px 0; }
.support-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid #cbd9cd; padding-top: 12px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.support-button { min-height: 46px; padding: 7px 0 7px 10px; display: inline-flex; gap: 8px; align-items: center; border: 0; background: transparent; color: var(--teal); font-size: 14px; font-weight: 700; }
.support-button[aria-pressed=true] svg { fill: var(--teal); stroke: var(--teal); }
.support-button:disabled { opacity: 1; }
.history-section { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 18px; }
.section-heading > span { font-size: 13px; }
.empty-updates { padding: 28px 22px; background: var(--soft); border-top: 3px solid var(--teal); border-radius: 4px 4px 20px 20px; }
.empty-updates p { margin-top: 12px; color: var(--muted); }
.visiting-section { border-top: 1px solid var(--line); padding-top: 20px; }
.visiting-section h2 { margin-bottom: 20px; }
.visit-detail { display: flex; gap: 12px; margin-bottom: 22px; }
.visit-detail svg { color: var(--teal); margin-top: 3px; }
.visit-detail p { margin-top: 3px; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.visit-detail h3 { overflow-wrap: anywhere; }
.visit-status { font-size: 14px; color: var(--teal); background: var(--soft); border-radius: 10px; padding: 11px 14px; margin-bottom: 20px; }
.map-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; border: 1px solid #c3d1c4; border-radius: 12px; padding: 12px 16px; color: var(--teal); text-decoration: none; font-size: 14px; font-weight: 700; }
.map-link:hover { background: var(--soft); }
.page-footer { text-align: center; color: var(--muted); margin-top: 36px; font-size: 13px; line-height: 2; }
.page-footer span { font-size: 12px; }
@media (max-width: 760px) {
  .header-inner { height: 69px; padding-inline: 22px; }
  #main { padding: 26px 22px 24px; max-width: 580px; }
  .state-panel { margin-top: 27px; }
  .patient-heading { gap: 13px; margin-bottom: 24px; }
  .avatar { width: 57px; height: 57px; border-radius: 21px; }
  h1 { font-size: 27px; }
  .welcome { font-size: 13px; }
  .patient-heading .icon-button { border: 0; min-width: 40px; }
  .page-columns { display: flex; flex-direction: column; gap: 26px; }
  .latest { padding: 20px; }
  .latest .update-text { font-size: 21px; }
  .update-meta { font-size: 12px; }
  .history-section { margin-top: 32px; }
  .update { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Comments stay subordinate to the patient's news; expand them only on demand. */
textarea { font: inherit; color: inherit; }
textarea:focus-visible { outline: 3px solid oklch(63% .1 80); outline-offset: 3px; }
.state-panel .name-input { font: inherit; font-size: 18px; letter-spacing: normal; margin-bottom: 12px; }
.comments-section { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; }
.comments-toggle, .text-button { border: 0; background: transparent; color: var(--teal); min-height: 44px; padding: 8px 4px; text-align: start; }
.comments-toggle { width: 100%; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.comments-toggle::after { content: '+'; font-size: 21px; }
.comments-toggle[aria-expanded=true]::after { content: '−'; }
.text-button:hover:not(:disabled), .comments-toggle:hover { text-decoration: underline; }
.comments-body .field-help { margin: 8px 0 14px; overflow-wrap: anywhere; }
.comment-form { margin: 12px 0 16px; }
.comment-form label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.comment-form textarea { display: block; resize: vertical; width: 100%; min-height: 92px; max-height: 320px; padding: 10px 12px; border: 1px solid oklch(73% .025 155); border-radius: 10px; background: var(--surface); line-height: 1.7; font-size: 16px; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-top: 8px; }
.comment-actions .button { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.comment-actions .field-help { margin: 0; font-size: 12px; }
.comments-list { margin-top: 8px; }
.comment { padding: 18px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.comment-meta strong { font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.comment-text { font-size: 16px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; }
.comment .text-button { font-size: 13px; }
.danger { color: var(--error); }
.comment-confirm { padding: 12px 0; }
.comment-confirm button { margin-inline-end: 16px; }
.comments-body > .muted { font-size: 13px; }
