[hidden] { display: none !important; }
.chat-page { padding-top: 16px; }
.chat-welcome { margin-bottom: 16px; }
.chat-security-note { margin-top: 14px; padding: 11px; border: 2px inset #c8b78c; background: #f0e2b8; font-size: 13px; line-height: 1.5; }
.chat-auth { max-width: 700px; margin: 0 auto 20px; }
.chat-auth > p { line-height: 1.45; }
.chat-form { display: grid; gap: 8px; margin: 12px 0; }
.chat-form label, .group-create label, .dm-create label { font-weight: bold; font-size: 13px; }
.chat-form input, .group-create input, .dm-create select, .send-form textarea { width: 100%; border: 2px inset #c7b790; background: #fffdf2; color: #33291f; border-radius: 0; padding: 10px; font: 15px Georgia, "Times New Roman", serif; }
.chat-form input:focus-visible, .group-create input:focus-visible, .dm-create select:focus-visible, .send-form textarea:focus-visible { outline: 3px solid #171c82; outline-offset: 1px; }
.chat-form .button { justify-self: start; }
.chat-form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button.secondary { background: #e6d9b8; color: #33291f; border-color: #a3936e; }
.key-panel { margin-top: 20px; padding: 14px; border: 3px ridge #b8a77e; background: #f4e8c3; }
.key-panel h3 { margin-top: 0; }
.key-panel li { margin: 5px 0; }
.recovery-code-row { display: flex; gap: 8px; align-items: stretch; margin: 6px 0 12px; }
.recovery-code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 12px; border: 1px solid #a08d60; background: #fff8df; font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; user-select: all; }
.acknowledge { display: flex; align-items: flex-start; gap: 8px; margin: 13px 0; font-weight: normal !important; }
.acknowledge input { width: auto; margin-top: 3px; }
.chat-toolbar { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 0 0 12px; border-bottom: 2px ridge #c4b58e; }
#signed-in-email { display: block; }
.chat-toolbar-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.chat-status { min-height: 1.4em; margin: 8px 0; font-size: 12px; color: #5f4c2f; }
.chat-status[data-kind="error"], #auth-feedback[data-kind="error"] { color: #8a1e18; font-weight: bold; }
.chat-status[data-kind="success"], #auth-feedback[data-kind="success"] { color: #315b24; }
.chat-layout { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 14px; align-items: stretch; min-height: 580px; }
.chat-sidebar { padding: 12px; background: #eee2c0; border: 2px inset #c4b58e; min-width: 0; }
.chat-sidebar h2 { margin-top: 0; font-size: 20px; }
.chat-sidebar > .button { width: 100%; }
.group-create { margin: 12px 0; padding: 10px; border: 1px solid #aa9667; background: #fff5d8; }
.group-create .chat-form-row .button { font-size: 12px; }
.member-options { max-height: 180px; overflow-y: auto; margin: 8px 0; border: 1px solid #c4b58e; background: #fffaf0; }
.member-choice { display: flex; gap: 7px; align-items: flex-start; padding: 6px; border-bottom: 1px solid #e1d5b7; font-size: 12px; overflow-wrap: anywhere; }
.member-choice input { margin: 2px 0 0; flex: 0 0 auto; }
.room-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 5px; }
.room-choice { width: 100%; text-align: left; padding: 9px; color: #33291f; font: 14px Georgia, "Times New Roman", serif; border: 2px outset #c5b58b; background: #fff8df; cursor: pointer; overflow-wrap: anywhere; }
.room-choice:hover { background: #f4e4b7; }
.room-choice[aria-current="true"] { border-style: inset; background: #dfd0a6; font-weight: bold; }
.room-choice small { display: block; margin-top: 3px; color: #705b37; font: 10px Arial, sans-serif; }
.dm-create { margin-top: 18px; padding-top: 12px; border-top: 3px double #b3a17a; }
.dm-create h3 { margin: 0 0 9px; font-size: 16px; }
.dm-create select { margin: 5px 0 8px; font-size: 13px; }
.dm-create .button { width: 100%; font-size: 12px; }
.chat-main { min-width: 0; display: flex; flex-direction: column; border: 2px inset #c4b58e; background: #fff8df; padding: 12px; }
.conversation-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 2px ridge #d2c19a; }
.conversation-header h2 { margin: 0 0 4px; font-size: 21px; overflow-wrap: anywhere; }
.conversation-header p { margin: 0; }
.encryption-stamp { flex: 0 0 auto; padding: 5px 7px; background: #dce6c6; border: 2px ridge #91a071; font: bold 11px Arial, sans-serif; white-space: nowrap; }
.message-history-actions { min-height: 28px; display: flex; justify-content: space-between; align-items: center; }
.chat-messages { display: flex; flex-direction: column; gap: 9px; flex: 1 1 auto; min-height: 250px; max-height: 520px; overflow: auto; list-style: none; margin: 0; padding: 8px 3px 16px; }
.chat-empty { margin: auto; text-align: center; padding: 26px 8px; color: #776748; font-style: italic; }
.chat-message { max-width: 95%; align-self: flex-start; min-width: 0; padding: 8px 10px; border: 2px ridge #d1c09a; background: #f5e9c6; overflow-wrap: anywhere; }
.chat-message.mine { align-self: flex-end; background: #e7eccf; border-color: #adbb8d; }
.chat-message.invalid { align-self: stretch; max-width: 100%; background: #f4d7cd; border-color: #bc7d6c; }
.message-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 5px; font-size: 12px; }
.message-head strong { color: #583621; }
.message-head time { color: #705f44; font: 10px Arial, sans-serif; }
.message-body { white-space: pre-wrap; word-break: break-word; line-height: 1.4; font-size: 14px; }
.message-security { margin-top: 5px; color: #6f3c2c; font: bold 9px Arial, sans-serif; letter-spacing: .4px; }
.send-form { margin-top: auto; padding-top: 9px; border-top: 2px ridge #d2c19a; }
.send-form textarea { min-height: 74px; max-height: 190px; resize: vertical; }
.send-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 7px; }
.send-footer .button { flex: 0 0 auto; }
.chat-footnote { margin: 13px 0 0; color: #68563a; font-size: 11px; line-height: 1.5; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; min-height: 0; }
  .chat-sidebar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .chat-messages { min-height: 280px; max-height: 55vh; }
  .chat-toolbar { align-items: flex-start; flex-direction: column; }
  .chat-toolbar-actions { width: 100%; }
  .chat-toolbar-actions .button { flex: 1; }
}
@media (max-width: 420px) {
  .recovery-code-row { flex-direction: column; }
  .send-footer { align-items: flex-start; }
  .send-footer .button { font-size: 12px; }
  .conversation-header h2 { font-size: 18px; }
}

.key-directory { margin-top: 16px; padding-top: 10px; border-top: 3px double #b3a17a; font-size: 12px; }
.key-directory summary { cursor: pointer; color: #33291f; font-weight: bold; }
.fingerprint-list { list-style: none; padding: 0; display: grid; gap: 9px; }
.fingerprint-list li { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.fingerprint-list code { display: block; padding: 5px; border: 1px solid #c5b58b; background: #fff8df; font: 9px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.fingerprint-warning strong, .fingerprint-warning code { color: #8a1e18; border-color: #b36b5d; }

.profile-identity { min-width: 0; }
.profile-settings { margin-top: 4px; font-size: 11px; }
.profile-settings summary { cursor: pointer; color: #171c82; }
.profile-form { display: flex; gap: 5px; align-items: center; margin-top: 5px; }
.profile-form input { min-width: 120px; width: 180px; max-width: 48vw; padding: 6px; border: 2px inset #c7b790; background: #fffdf2; font: 12px Georgia,serif; }
.profile-form .button { padding: 6px 8px; font-size: 11px; }
