.family-chat {
  --fc-ink: #203e32;
  --fc-muted: #61776c;
  --fc-green: #176b48;
  --fc-border: #dce8e1;
  --fc-surface: #fff;
  --fc-soft: #f6faf7;
  --fc-canvas: #eef5f0;
  --fc-tint: #e4f1e8;
  --fc-dot: #d8e5dc;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 1180px;
  margin: 8px auto 24px;
  overflow: hidden;
  border: 1px solid var(--fc-border);
  border-radius: 24px;
  background: var(--fc-surface);
  box-shadow: 0 12px 40px #183e2910;
  color: var(--fc-ink);
  font-family: 'Plus Jakarta Sans', 'Sora', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}
.family-chat *, .family-chat *::before, .family-chat *::after { box-sizing: border-box; }
.family-chat--family { max-width: 980px; }
.family-chat svg { display: block; width: 22px; height: 22px; flex-shrink: 0; }
.family-chat .family-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 28px; border-bottom: 1px solid var(--fc-border); background: var(--fc-surface); }
.family-chat-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.family-chat-avatar { display: grid; place-items: center; width: 52px; height: 52px; flex-shrink: 0; border-radius: 18px; background: var(--fc-green); color: #fff; box-shadow: 0 5px 14px #176b4820; }
.family-chat-avatar svg { width: 27px; height: 27px; }
.family-chat-eyebrow { display: block; margin-bottom: 4px; color: var(--fc-muted); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.family-chat h3 { margin: 0; color: var(--fc-ink); font-family: inherit; font-size: 22px; font-weight: 800; line-height: 1.25; letter-spacing: -.035em; }
.family-chat-head p { margin: 6px 0 0; color: var(--fc-muted); font-size: 12px; line-height: 1.5; }
.family-chat-response { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 10px 14px; border: 1px solid var(--fc-border); border-radius: 14px; background: var(--fc-soft); color: var(--fc-muted); font-size: 10px; line-height: 1.5; }
.family-chat-response svg { color: var(--fc-green); width: 21px; height: 21px; }
.family-chat-response strong { color: var(--fc-green); font-size: 12px; font-weight: 800; }
.family-chat-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.family-chat--staff .family-chat-layout { grid-template-columns: 290px minmax(0, 1fr); }
.family-chat-conversation { min-width: 0; }
.family-chat-sidebar { min-width: 0; border-right: 1px solid var(--fc-border); background: var(--fc-soft); }
.family-chat-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 10px 20px; }
.family-chat h4 { margin: 0; color: var(--fc-ink); font-family: inherit; font-size: 13px; font-weight: 800; }
.family-chat button { font-family: inherit; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.family-chat button:disabled { cursor: default; }
.family-chat [data-refresh] { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--fc-border); border-radius: 12px; background: var(--fc-surface); color: var(--fc-green); }
.family-chat [data-refresh]:hover { background: var(--fc-tint); }
.family-chat [data-refresh] svg { width: 18px; height: 18px; }
.family-chat-threads { display: grid; align-content: start; gap: 8px; max-height: 480px; overflow: auto; padding: 4px 12px 18px; scrollbar-width: thin; scrollbar-color: var(--fc-border) transparent; }
.family-chat [data-conversation] { display: flex; align-items: flex-start; gap: 11px; width: 100%; min-width: 0; padding: 14px 12px; border: 1px solid transparent; border-radius: 15px; background: transparent; color: var(--fc-ink); text-align: left; }
.family-chat [data-conversation]:hover { background: var(--fc-surface); border-color: var(--fc-border); }
.family-chat [data-conversation][aria-pressed="true"] { border-color: #a6cdb6; background: var(--fc-surface); box-shadow: 0 3px 10px #183e2908; }
.family-chat-thread-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; background: var(--fc-tint); color: var(--fc-green); font-size: 11px; font-weight: 800; }
.family-chat-thread-copy { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.family-chat-thread-copy strong { font-size: 12px; line-height: 1.45; font-weight: 800; }
.family-chat-thread-family { color: var(--fc-muted); font-size: 11px; }
.family-chat-thread-state { color: var(--fc-green); font-size: 10px; line-height: 1.6; font-weight: 700; }
.family-chat-thread-state--overdue { color: #9a561a; }
.family-chat-inbox-empty { padding: 18px 10px; color: var(--fc-muted); font-size: 12px; }
.family-chat-inbox-empty strong { color: var(--fc-ink); font-size: 12px; }
.family-chat-inbox-empty p { margin: 8px 0 0; }
.family-chat-peer { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 15px 22px; border-bottom: 1px solid var(--fc-border); }
.family-chat-peer-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--fc-tint); color: var(--fc-green); flex-shrink: 0; }
.family-chat-peer-icon svg { width: 18px; height: 18px; }
.family-chat-peer > div { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.family-chat-peer strong { font-size: 12px; color: var(--fc-ink); }
.family-chat-peer [data-peer-detail] { font-size: 11px; color: var(--fc-muted); }
.family-chat-service { padding: 14px 24px 12px; border-bottom: 1px solid var(--fc-border); background: var(--fc-surface); }
.family-chat-status { display: inline-flex; align-items: baseline; gap: 7px; color: var(--fc-green); font-size: 11px; font-weight: 700; overflow-wrap: anywhere; }
.family-chat-status::before { content: ''; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: currentColor; }
.family-chat-status[data-state="pending"], .family-chat-status[data-state="overdue"] { color: #975316; }
.family-chat-status[data-state="loading"] { color: var(--fc-muted); }
.family-chat-service p { margin: 5px 0 0; color: var(--fc-muted); font-size: 10px; line-height: 1.55; }
.family-chat-messages { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; height: clamp(200px, 30dvh, 360px); min-width: 0; overflow: auto; padding: 20px 24px; background-color: var(--fc-canvas); background-image: radial-gradient(var(--fc-dot) .8px, transparent .8px); background-size: 16px 16px; scrollbar-width: thin; scrollbar-color: #b8cec0 transparent; overscroll-behavior: contain; }
.family-chat--staff .family-chat-messages { height: clamp(240px, 34dvh, 390px); }
.family-chat-day { align-self: center; width: 100%; margin: 1px 0 4px; text-align: center; }
.family-chat-day span { display: inline-block; padding: 4px 12px; border: 1px solid var(--fc-border); border-radius: 20px; background: var(--fc-surface); color: var(--fc-muted); font-size: 10px; }
.family-chat-message { display: flex; flex-direction: column; gap: 5px; max-width: min(82%, 560px); min-width: 80px; flex-shrink: 0; padding: 12px 16px 9px; border: 1px solid var(--fc-border); border-radius: 17px 17px 17px 5px; background: var(--fc-surface); box-shadow: 0 2px 6px #173e2905; color: var(--fc-ink); overflow-wrap: anywhere; }
.family-chat-message--own { align-self: flex-end; border-color: var(--fc-green); border-radius: 17px 17px 5px 17px; background: var(--fc-green); color: #fff; }
.family-chat-message strong { color: var(--fc-green); font-size: 10px; font-weight: 800; }
.family-chat-message--own strong { color: #d7efe0; }
.family-chat-message p { margin: 0; white-space: pre-wrap; color: inherit; font-size: 13px; line-height: 1.65; }
.family-chat-message time { align-self: flex-end; color: var(--fc-muted); font-size: 9px; }
.family-chat-message--own time { color: #d7efe0; }
.family-chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 100%; padding: 16px 10px; text-align: center; }
.family-chat-empty-icon { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 3px; border: 1px solid var(--fc-border); border-radius: 22px; background: var(--fc-surface); color: var(--fc-green); box-shadow: 0 4px 12px #173e2907; }
.family-chat-empty-icon svg { width: 30px; height: 30px; }
.family-chat-empty strong { color: var(--fc-ink); font-size: 14px; font-weight: 800; }
.family-chat-empty p { max-width: 310px; margin: 0; color: var(--fc-muted); font-size: 12px; line-height: 1.65; }
.family-chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 12px; margin: 0; padding: 16px 22px 12px; border-top: 1px solid var(--fc-border); background: var(--fc-surface); }
.family-chat-composer label { display: block; min-width: 0; margin: 0; }
.family-chat textarea { display: block; box-sizing: border-box; width: 100%; min-height: 58px; max-height: 150px; margin: 0; padding: 13px 15px; resize: vertical; border: 1px solid var(--fc-border); border-radius: 15px; outline: none; background: var(--fc-soft); color: var(--fc-ink); font-family: inherit; font-size: 13px; line-height: 1.5; }
.family-chat textarea::placeholder { color: var(--fc-muted); opacity: 1; }
.family-chat textarea:focus { border-color: #72a78a; background: var(--fc-surface); }
.family-chat textarea:disabled { opacity: .65; }
.family-chat-composer button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-width: 108px; min-height: 48px; padding: 12px 17px; border: 1px solid var(--fc-green); border-radius: 14px; background: var(--fc-green); color: #fff; font-size: 12px; font-weight: 800; box-shadow: 0 4px 10px #176b4816; }
.family-chat-composer button:hover:not(:disabled) { background: #125739; border-color: #125739; }
.family-chat-composer button:disabled { border-color: var(--fc-border); background: var(--fc-tint); color: var(--fc-muted); box-shadow: none; }
.family-chat-composer button svg { width: 17px; height: 17px; }
.family-chat-composer-note { display: flex; justify-content: space-between; gap: 10px; grid-column: 1 / -1; color: var(--fc-muted); font-size: 9px; line-height: 1.5; }
.family-chat [data-count] { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.family-chat-error { padding: 0 22px 14px; color: #a12d2d; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.family-chat-error:empty { display: none; }
.family-chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.family-chat button:focus-visible, .family-chat textarea:focus-visible, .family-chat-messages:focus-visible { outline: 3px solid #3c9062; outline-offset: -3px; }
body.dark-mode .family-chat { --fc-ink: #e1ede5; --fc-muted: #a5bdb0; --fc-green: #216d4c; --fc-border: #345444; --fc-surface: #1b3025; --fc-soft: #20382c; --fc-canvas: #172b21; --fc-tint: #284b38; --fc-dot: #2c4736; box-shadow: 0 12px 40px #0002; }
body.dark-mode .family-chat-avatar, body.dark-mode .family-chat-response strong, body.dark-mode .family-chat-response svg, body.dark-mode .family-chat [data-refresh], body.dark-mode .family-chat-thread-avatar, body.dark-mode .family-chat-thread-state, body.dark-mode .family-chat-peer-icon, body.dark-mode .family-chat-status, body.dark-mode .family-chat-empty-icon, body.dark-mode .family-chat-message--received strong { color: #a8dfba; }
body.dark-mode .family-chat textarea { background: var(--fc-soft)!important; color: var(--fc-ink)!important; border-color: var(--fc-border)!important; }
body.dark-mode .family-chat-status[data-state="pending"], body.dark-mode .family-chat-status[data-state="overdue"], body.dark-mode .family-chat-thread-state--overdue { color: #efbf83; }
body.dark-mode .family-chat-error { color: #ffb2ad; }
@media (max-width: 860px) {
  .family-chat--staff .family-chat-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .family-chat .family-chat-head { padding: 20px; }
  .family-chat h3 { font-size: 20px; }
  .family-chat-messages { padding: 18px; }
  .family-chat-composer { padding: 14px 18px 12px; }
}
@media (max-width: 640px) {
  .family-chat { margin-top: 4px; border-radius: 20px; }
  .family-chat .family-chat-head { align-items: flex-start; flex-wrap: wrap; gap: 12px; padding: 18px 16px; }
  .family-chat-brand { gap: 11px; flex: 1 1 220px; }
  .family-chat-avatar { width: 42px; height: 42px; border-radius: 14px; }
  .family-chat-avatar svg { width: 23px; height: 23px; }
  .family-chat h3 { font-size: 18px; }
  .family-chat-head p { font-size: 11px; }
  .family-chat-response { gap: 7px; padding: 7px 10px; border-radius: 10px; }
  .family-chat-response br { display: none; }
  .family-chat-response strong { margin-left: 4px; font-size: 11px; }
  .family-chat-response svg { width: 17px; height: 17px; }
  .family-chat--staff .family-chat-layout { grid-template-columns: minmax(0, 1fr); }
  .family-chat-sidebar { border-right: 0; border-bottom: 1px solid var(--fc-border); }
  .family-chat-sidebar-head { padding: 10px 14px 4px; }
  .family-chat-threads { display: flex; gap: 8px; max-height: none; padding: 6px 12px 12px; }
  .family-chat [data-conversation] { flex: 0 0 min(230px, 78vw); padding: 10px; background: var(--fc-surface); border-color: var(--fc-border); }
  .family-chat-peer { padding: 12px 16px; }
  .family-chat-service { padding: 12px 16px 10px; }
  .family-chat-messages, .family-chat--staff .family-chat-messages { height: clamp(200px, 30dvh, 300px); padding: 16px; }
  .family-chat-message { max-width: 90%; padding: 10px 13px 8px; }
  .family-chat-composer { align-items: end; gap: 8px; padding: 12px; }
  .family-chat textarea { padding: 11px 12px; font-size: 16px; }
  .family-chat-composer button { min-width: 48px; min-height: 48px; padding: 12px; }
  .family-chat-composer button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .family-chat-composer button svg { width: 20px; height: 20px; }
  .family-chat-composer-note { font-size: 8px; }
  .family-chat-error { padding: 0 14px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .family-chat button { transition: none; }
}
