/* Conversation workspace inherits Regal's live palette and type. */
.chat-workspace{display:grid;grid-template-columns:minmax(220px,29%) minmax(0,1fr);height:calc(100dvh - 142px);min-height:520px;border:1px solid var(--line2);border-radius:16px;overflow:hidden;background:var(--solid)}
.chat-rooms{display:flex;flex-direction:column;border-right:1px solid var(--line2);min-width:0;background:var(--bg2)}
.chat-room-heading{display:flex;align-items:center;justify-content:space-between;padding:20px 16px 14px;gap:12px}.chat-room-heading h2{font-size:25px}.chat-room-items{overflow-y:auto;flex:1;padding:4px 8px 16px}.chat-room{display:flex;align-items:center;gap:11px;width:100%;padding:13px 10px;text-align:left;border-radius:12px;min-height:72px}.chat-room:hover{background:var(--panel2)}.chat-room.selected{background:var(--panel2);box-shadow:inset 0 0 0 1px var(--line2)}.chat-room-copy{min-width:0;flex:1}.chat-room-copy strong{display:block;font-size:13px;font-weight:800;line-height:1.45}.chat-room-copy small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:11px;margin-top:4px}.chat-room-avatar,.chat-header-avatar{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;background:var(--panel2);color:var(--blue);flex:none}.ai-avatar{color:var(--gold);background:var(--glow1)}.chat-unread{background:var(--gold);color:var(--on-gold);font-size:11px;font-weight:800;min-width:23px;height:23px;border-radius:20px;display:grid;place-items:center;padding:0 5px}.chat-room-foot{display:flex;align-items:center;gap:8px;padding:16px;color:var(--muted);font-size:11px;border-top:1px solid var(--line)}.chat-live-dot{width:7px;height:7px;background:var(--warn);border-radius:50%}.chat-live-dot.online{background:var(--ok)}
.chat-conversation{min-width:0;display:flex;flex-direction:column;overflow:hidden}.chat-header{display:flex;align-items:center;gap:12px;flex:none;border-bottom:1px solid var(--line);padding:16px 20px;min-height:82px}.chat-header>div{min-width:0;flex:1}.chat-header h2{font-size:26px;line-height:1.15;overflow-wrap:anywhere}.chat-header p{color:var(--muted);font-size:11px;margin-top:4px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.chat-header .btn{padding:10px;min-width:42px;min-height:42px}.chat-rooms-toggle{display:none!important}.chat-timeline{flex:1;overflow:auto;padding:20px 24px;overscroll-behavior:contain;scrollbar-gutter:stable}.chat-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;max-width:530px;min-height:340px;margin:0 auto;padding:28px 8px;gap:18px}.chat-empty-mark{display:grid;place-items:center;width:76px;height:76px;border-radius:24px;background:var(--glow1);color:var(--gold)}.chat-empty h2{font-size:38px}.chat-empty p{color:var(--muted);font-size:14px;max-width:45ch;line-height:1.7}.chat-empty small{color:var(--muted);font-size:11px}.ai-starters{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:4px}.ai-starters .btn{min-height:44px;white-space:normal;text-align:left;font-size:12px;padding:10px 14px;background:var(--panel)}
.chat-date{text-align:center;margin:6px 0 20px}.chat-date time{font-size:10px;font-weight:700;color:var(--muted);background:var(--panel2);padding:4px 12px;border-radius:20px}.chat-message{display:flex;align-items:flex-start;flex-direction:column;margin:0 0 18px;max-width:87%;overflow-wrap:anywhere}.chat-message.mine{align-items:flex-end;margin-left:auto}.message-bubble{padding:12px 15px 8px;border-radius:14px 14px 14px 4px;background:var(--bg2);max-width:100%;min-width:100px;border:1px solid var(--line)}.mine .message-bubble{border-radius:14px 14px 4px 14px;background:var(--panel2);border-color:var(--line2)}.ai-message .message-bubble{background:var(--bg2);border-color:var(--gold)}.message-author{display:flex;align-items:center;gap:7px;color:var(--blue);font-size:11px;margin-bottom:6px}.ai-message .message-author{color:var(--gold)}.message-text{white-space:pre-wrap;font-size:13px;line-height:1.7;max-width:70ch}.message-meta{display:flex;justify-content:flex-end;gap:7px;color:var(--muted);font-size:10px;margin-top:6px;font-variant-numeric:tabular-nums}.message-controls{display:flex;flex-wrap:wrap;gap:2px;margin-top:3px;opacity:.65}.chat-message:hover .message-controls,.chat-message:focus-within .message-controls{opacity:1}.message-controls .btn{border:0;background:none;font-size:10px;min-height:28px;padding:4px 8px}.message-reactions{display:flex;gap:4px;flex-wrap:wrap;margin-top:4px}.message-reactions .btn{font-size:11px;min-height:30px;padding:4px 10px}.message-reactions [aria-pressed=true]{border-color:var(--gold)}.message-bubble blockquote{margin:0 0 10px;padding:8px 10px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);font-size:11px;color:var(--muted)}.message-bubble blockquote b{display:block;color:var(--ink);margin-bottom:3px}.system-message{margin:0 auto 14px;max-width:92%;align-items:center}.system-message .message-bubble{background:transparent;border-style:dashed;text-align:center}.system-message .message-author{justify-content:center;color:var(--muted)}.system-message .message-text{font-size:11px;color:var(--muted)}.system-message .message-meta{justify-content:center}.chat-photo{display:block;max-width:320px;margin-bottom:6px}.chat-photo img{max-height:260px;width:100%;object-fit:cover;border-radius:9px;display:block}.chat-file{display:flex;align-items:center;gap:10px;padding:10px;background:var(--panel2);border-radius:8px;text-decoration:none;min-width:170px}.chat-file>span{min-width:0;flex:1;overflow-wrap:anywhere;font-size:12px}.chat-file small,.chat-voice small{display:block;color:var(--muted);font-size:10px}.chat-voice{max-width:100%}.chat-voice audio{width:260px;max-width:100%;height:42px}.chat-photo-link{display:flex;align-items:center;justify-content:center;gap:7px;color:var(--blue);font-size:12px;padding:10px}.chat-earlier{display:block;margin:0 auto 20px;font-size:11px}.chat-typing{min-height:22px;color:var(--muted);font-size:11px;padding:0 4px}.ai-stream{padding:16px;border:1px solid var(--line2);border-radius:14px;max-width:90%;margin-bottom:14px}.ai-stream strong{display:flex;align-items:center;gap:8px;color:var(--gold);font-size:12px}.ai-stream p{font-size:13px;line-height:1.7;white-space:pre-wrap;margin-top:7px}
.chat-composer{flex:none;border-top:1px solid var(--line);background:var(--solid);padding:14px 18px 10px}.chat-compose-row{display:flex;align-items:flex-end;gap:8px}.chat-compose-row textarea{min-height:46px;max-height:120px;resize:vertical;flex:1;min-width:0;border-radius:12px;padding:12px;font-size:13px}.chat-compose-row .iconbtn{flex:none;width:44px;height:46px;display:flex;align-items:center;justify-content:center}.chat-attach{cursor:pointer}.chat-send{height:46px;flex:none;padding:12px 15px;gap:8px;border-radius:12px}.chat-send span{font-size:12px}.chat-composer-note{display:flex;justify-content:space-between;gap:10px;font-size:9px;color:var(--muted);margin-top:9px}.composer-context{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;margin-bottom:10px;background:var(--panel2);border-radius:10px;gap:8px;font-size:11px}.composer-context>span{display:block;overflow-wrap:anywhere}.composer-context b{display:block;color:var(--gold)}.chat-composer [hidden],.ai-stream[hidden],#chat-search[hidden]{display:none!important}.chat-composer .recording{color:var(--bad);background:var(--panel2)}#chat-search{padding:10px 20px;border-bottom:1px solid var(--line)}#chat-search label{display:flex;align-items:center;gap:12px;font-size:11px}#chat-search input{flex:1;min-width:0}.chat-peer-list{display:flex;flex-direction:column;gap:8px}.chat-peer-list .btn{justify-content:space-between;min-height:48px}.chat-peer-list small{color:var(--muted)}.chat-reaction-picker{display:flex;flex-wrap:wrap;gap:10px}.chat-reaction-picker .btn{min-width:46px;font-size:22px}.ai-confirm{border:1px solid var(--gold);border-radius:14px;padding:18px;max-width:90%;margin:12px 0 22px;background:var(--bg2)}.ai-confirm>div:first-child{display:flex;align-items:center;gap:10px;color:var(--gold)}.ai-confirm h3{font-size:24px}.ai-confirm>p{margin-top:12px;font-size:13px}.ai-confirm dl{font-size:11px;margin:12px 0}.ai-confirm dl>div{display:grid;grid-template-columns:80px minmax(0,1fr);gap:10px;border-bottom:1px solid var(--line);padding:7px 0}.ai-confirm dt{color:var(--muted)}.ai-confirm dd{margin:0;overflow-wrap:anywhere;white-space:pre-wrap}.ai-confirm-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.ai-edit-fields{display:block;margin:12px 0;min-height:200px;font-size:12px}.chat-skeleton{display:flex;flex-direction:column;gap:20px;padding:30px 0}.chat-skeleton i{display:block;height:60px;width:64%;border-radius:14px;background:var(--panel2);animation:chat-breathe 1.5s ease-in-out infinite alternate}.chat-skeleton i:nth-child(2){align-self:flex-end;width:48%}.chat-skeleton span{color:var(--muted);font-size:12px}.ask-regal{position:fixed;bottom:24px;right:28px;z-index:25;display:flex;align-items:center;gap:10px;padding:13px 18px;border-radius:14px;background:var(--gold);color:var(--on-gold);box-shadow:0 8px 25px rgba(0,0,0,.18);font-size:12px;font-weight:800;min-height:46px}body:has(.chat-workspace) .ask-regal{display:none}.chat-nav-badge{margin-left:auto}.chat-settings{margin-top:20px}.chat-settings .checklabel{margin:10px 0}.chat-message:last-child .message-bubble{animation:chat-arrive .24s cubic-bezier(.16,1,.3,1)}
@keyframes chat-arrive{from{transform:translateY(5px);background-color:var(--glow1)}}@keyframes chat-breathe{to{background:var(--panel)}}
@media(min-width:1500px){.chat-workspace{height:calc(100dvh - 150px)}}
@media(max-width:1100px){.chat-workspace{grid-template-columns:220px minmax(0,1fr)}.chat-timeline{padding:18px 16px}.chat-header{padding:14px}.chat-message{max-width:94%}.chat-room-copy strong{font-size:12px}}
@media(max-width:800px){.main:has(.chat-workspace){padding:10px 10px 86px}.chat-workspace{display:block;height:calc(100dvh - 167px);min-height:360px;position:relative}.chat-conversation{height:100%}.chat-rooms{display:none;position:absolute;inset:0;z-index:5;border:0}.chat-workspace.rooms-open .chat-rooms{display:flex}.chat-workspace.rooms-open .chat-conversation{visibility:hidden}.chat-rooms-toggle{display:inline-flex!important}.chat-room-heading h2{font-size:28px}.chat-room-copy strong{font-size:14px}.chat-room-copy small{font-size:12px}.chat-room{min-height:78px}.chat-header{min-height:74px;gap:8px;padding:10px 12px}.chat-header h2{font-size:24px}.chat-header-avatar{width:32px;height:36px}.chat-header p{font-size:10px}.chat-header .btn{min-width:36px;padding:7px}.chat-timeline{padding:16px 12px}.chat-empty{min-height:260px;padding:16px 4px;gap:14px}.chat-empty h2{font-size:31px}.chat-empty p{font-size:12px}.chat-empty-mark{width:60px;height:60px;border-radius:18px}.ai-starters{gap:7px}.ai-starters .btn{font-size:11px;padding:9px 11px}.chat-composer{padding:10px}.chat-compose-row{gap:4px}.chat-compose-row textarea{font-size:13px;padding:11px 9px}.chat-compose-row .iconbtn{width:35px;min-width:35px}.chat-send{padding:12px;min-width:44px}.chat-send span{display:none}.chat-composer-note{font-size:8px;gap:6px}.chat-composer-note>span:last-child{display:none}.message-text{font-size:12px}.message-bubble{padding:10px 12px 7px}.message-controls{opacity:1}.message-controls .btn{min-height:36px;padding:5px 9px;font-size:10px}.chat-voice audio{width:220px}.ai-confirm{max-width:100%;padding:14px}.ask-regal{bottom:calc(84px + env(safe-area-inset-bottom));right:16px;padding:12px 14px}.chat-unread{min-width:21px;height:21px}.tabbar [data-chat-badge]{position:absolute;top:4px;right:8px}.tabbar a:has([data-chat-badge]){position:relative}.chat-preferences-button{display:none!important}}
@media(max-width:370px){.chat-header-avatar{display:none}.chat-header h2{font-size:21px}.chat-room-heading{padding:16px 12px}.chat-message{max-width:97%}.chat-composer{padding:8px}.chat-voice audio{width:190px}}
@media(prefers-reduced-motion:reduce){
  .chat-message:last-child .message-bubble{animation:chat-arrive .48s cubic-bezier(.16,1,.3,1)!important}
  .chat-skeleton i{animation:chat-breathe 3s ease-in-out infinite alternate!important}
}
@media(max-width:800px){.chat-workspace{min-height:240px}.message-text{font-size:14px}.message-author{font-size:12px}.message-meta{font-size:11px}.message-controls .btn{min-height:44px;font-size:11px}.chat-preferences-button{display:inline-flex!important}.chat-compose-row .iconbtn{width:32px;min-width:32px}}

.chat-pinned:empty{display:none}.chat-pinned{display:flex;gap:6px;overflow-x:auto;padding:7px 14px;border-bottom:1px solid var(--line);flex:none}.chat-pinned .btn{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;min-height:36px;display:block}

.chat-composer[hidden]{display:none!important}

/* Recovery remains in the conversation, with a clear action and readable copy. */
.chat-load-error{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px;margin:0 0 18px;border:1px solid var(--line2);border-radius:12px;background:var(--bg2)}
.chat-load-error p{font-size:14px;line-height:1.6;color:var(--ink);margin:0;max-width:60ch}
.chat-load-error .btn{flex:none;min-height:44px;min-width:72px}
.chat-header .btn{min-height:44px;min-width:44px}
.chat-date time,.message-meta{font-variant-numeric:tabular-nums}
.chat-document-review{margin-top:8px;min-height:44px}
.document-original,.document-status,.document-decision,.document-history{margin:0 0 16px;overflow-wrap:anywhere}
.document-original,.document-status{padding:12px 0;border-bottom:1px solid var(--line)}
.document-original p,.document-status p{margin:4px 0 8px}
.document-decision{display:grid;gap:12px}
.document-decision label{display:grid;gap:6px;min-width:0}
.document-field,.document-details[open]{display:grid;gap:8px}
.document-details[open]>label{margin-top:8px}
.document-details summary{padding:8px 0}
.document-decision .input{width:100%;min-height:44px;max-width:100%}
.document-decision .form-error{margin:0}
.document-decision .form-error:empty{display:none}
.document-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.document-actions .btn{min-height:44px;white-space:normal;text-align:center}
.document-history ol{margin:8px 0;padding-inline-start:24px}
.document-history li{margin:6px 0}
.document-history li span{display:block;color:var(--muted)}
.chat-photos-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;max-width:360px;margin-bottom:6px}
.chat-photos-grid .chat-photo{max-width:none;margin-bottom:0}
.chat-photos-grid .chat-photo img{height:150px;width:100%;object-fit:cover;border-radius:8px}
.chat-photos-grid[data-count="3"] .chat-photo:last-child{grid-column:1 / -1}
.chat-photos-grid[data-count="3"] img{height:auto;max-height:none;aspect-ratio:16 / 10;object-fit:contain;background:var(--bg2)}
.message-text ul{margin:4px 0;padding-inline-start:1.4em;white-space:normal}
.message-text li{white-space:pre-wrap}
.message-text code{padding:1px 4px;border-radius:4px;background:var(--panel);overflow-wrap:anywhere}
.top .ask-regal{position:static;flex:none;min-height:42px;padding:0 12px;box-shadow:none}
#root > .ask-regal{bottom:calc(20px + env(safe-area-inset-bottom))}
#root:has(> .ask-regal:not([hidden])) .main{padding-bottom:calc(88px + env(safe-area-inset-bottom))}
.ask-regal[hidden]{display:none}
@media(max-width:900px){
  .top:has(.ask-regal:not([hidden])){grid-template-columns:minmax(0,1fr) repeat(3,44px)}
  .top:has(.ask-regal:not([hidden])) .title{grid-column:1;grid-row:1}
  .top .ask-regal{grid-column:2;grid-row:1;width:44px;min-height:44px;padding:0;justify-content:center}
  .top .ask-regal span{display:none}
  #root > .ask-regal{bottom:calc(82px + env(safe-area-inset-bottom));right:16px}
  #root:has(> .ask-regal:not([hidden])) .main{padding-bottom:calc(150px + env(safe-area-inset-bottom))}
}
.composer-files{display:flex;flex-wrap:wrap;gap:6px;flex:1;min-width:0}
.composer-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 6px;border-radius:8px;background:var(--panel);border:1px solid var(--line);max-width:220px}
.composer-chip>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.composer-chip .iconbtn{width:26px;height:26px;min-width:26px;min-height:26px;padding:0}
.chat-attachments,.chat-voice{display:grid;gap:7px;min-width:0}
.chat-file{min-width:0}
.chat-file svg{flex:none}
.chat-file .chat-file-type,.composer-chip .chat-file-type{flex:none;padding:4px 6px;border:1px solid var(--line2);border-radius:5px;color:var(--ink);background:var(--panel);font-size:10px;font-weight:700}
.chat-voice-actions{display:flex;gap:5px;flex-wrap:wrap}
.chat-voice-transcript{font-size:12px;white-space:pre-wrap;color:var(--ink)}
.chat-voice-transcript[hidden]{display:none}
.chat-recording{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 8px;margin-bottom:8px;background:var(--panel2);border:1px solid var(--line);border-radius:10px}
.chat-record-time{display:flex;align-items:center;gap:6px;flex:1 0 auto;font-size:11px;font-weight:700;font-variant-numeric:tabular-nums}
.chat-record-time i{width:7px;height:7px;border-radius:50%;background:var(--bad)}
.chat-voice-toggle[aria-pressed=true]{border-color:var(--gold);color:var(--gold)}
@media(max-width:800px){.chat-compose-row textarea{resize:none}.chat-recording .btn,.chat-voice-actions .btn{min-height:44px;padding-inline:8px}}
.composer-thumb{width:28px;height:28px;border-radius:5px;object-fit:cover;flex:none}
.chat-camera{cursor:pointer}
@media(max-width:800px){.chat-compose-row .iconbtn{width:44px;min-width:44px}.chat-header .btn{min-width:44px}.chat-load-error{align-items:flex-start;flex-direction:column;gap:10px}.chat-composer-note{font-size:10px}.chat-pinned .btn{min-height:44px}}
