@font-face { font-family: DM; src: url('/fonts/dm/dm-sans-latin-400-normal.woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: DM; src: url('/fonts/dm/dm-sans-latin-600-normal.woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Space; src: url('/fonts/space/space-grotesk-latin-600-normal.woff2'); font-weight: 600; font-display: swap; }
:root { font-family: DM, sans-serif; color: #20342e; background: #e9efec; --paper: #fbfcfa; --surface: #f1f5f2; --line: #d7e1db; --muted: #64796e; --ink: #20342e; --accent: #186e55; --accent-light: #dceee5; --warm: #dc8e6a; }
.native-vault-form { display: grid; gap: 8px; max-width: 440px; }
.native-vault-form label { font-weight: 600; margin-top: 10px; }
.native-vault-form input { min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #b9cdc0; border-radius: 5px; background: #fff; color: var(--ink); }
.native-vault-form input::placeholder { color: #53695d; }
.native-vault-form button { margin-top: 12px; min-height: 44px; }
.native-vault-deliveries { padding-left: 20px; line-height: 1.6; overflow-wrap: anywhere; }
.native-vault-deliveries li { margin: 12px 0; }
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
img { display: block; width: 19px; height: 19px; }
.workspace { display: grid; grid-template-columns: var(--sidebar-w, 260px) 6px minmax(0, 1fr); height: 100dvh; max-width: 1800px; margin: auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--paper); }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: #ecf2ee; border-right: 1px solid var(--line); }
.sidebar-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 14px 12px; }
.brand { display: flex; align-items: center; gap: 9px; font: 600 18px Space, sans-serif; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; background: var(--accent); color: #fff; font: 600 24px Space, sans-serif; border-radius: 6px; letter-spacing: 0; white-space: nowrap; }
.brand-mark span { color: #f3ba9a; }
.brand-mark.small { width: 36px; height: 36px; font-size: 17px; }
.icon-button { border: 0; background: transparent; color: var(--ink); width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.icon-button:hover { background: #deebe2; }
.danger-icon:hover { background: #f8e3df; }
.section-heading { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px 8px 17px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.heading-count { display: flex; align-items: center; gap: 2px; }
.heading-new-topic { width: 30px; height: 30px; }
.heading-new-topic img { width: 16px; height: 16px; }
.heading-new-topic:hover { background: #deebe2; }
.topic-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.topic-row { display: grid; grid-template-columns: minmax(0, 1fr) 28px 28px 28px; align-items: center; border-radius: 6px; }
.topic-item { width: 100%; min-width: 0; min-height: 44px; display: grid; grid-template-columns: 32px 1fr; gap: 8px; align-items: center; border: 0; border-radius: 6px; padding: 6px 8px; background: transparent; text-align: left; color: var(--ink); }
.topic-item:hover { background: #e0ebe4; }
.topic-item.active { background: var(--accent-light); }
.topic-action { width: 28px; height: 28px; opacity: 0; }
.topic-action img { width: 14px; height: 14px; }
.topic-action.ghost { opacity: 0 !important; pointer-events: none; }
.topic-row:hover .topic-action, .topic-action:focus-visible { opacity: 1; }
.topic-initial { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 5px; color: #fff; font: 600 14px Space, sans-serif; background: #859d8e; position: relative; }
.unread-badge { position: absolute; top: -5px; right: -7px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; background: var(--warm); color: #fff; font: 600 10px/1 DM, sans-serif; border-radius: 9px; border: 2px solid #ecf2ee; pointer-events: none; }
.topic-pin-preview { display: block; font-size: 11px; font-weight: 400; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 170px; }
.pin-bar { display: flex; align-items: center; gap: 8px; max-width: 960px; margin: 0 auto; padding: 6px clamp(12px, 3vw, 40px); margin-left: auto; margin-right: auto; width: 100%;
  border-bottom: 1px solid var(--line); background: var(--surface); font-size: 12px; color: var(--muted); }
.pin-bar-icon { width: 15px; height: 15px; flex: none; opacity: .75; }
.pin-bar-label { flex: 1; min-width: 0; display: flex; }
.pin-bar-label.cycle { cursor: pointer; border-radius: 4px; }
.pin-bar-label.cycle:hover .pin-bar-text { color: var(--accent); }
.pin-bar-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; color: var(--ink); }
.pin-bar-jump { border: 0; background: transparent; color: var(--accent); font: 600 11px DM, sans-serif; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.pin-bar-jump:hover { background: #deebe2; }
.pin-bar-unpin { width: 28px; height: 28px; }
.pin-bar-unpin img { width: 15px; height: 15px; }
.message.pinned .bubble { border-left: 3px solid var(--warm); }
.message-pin { display: inline-block; width: 12px; height: 12px; margin-left: 5px; vertical-align: -2px; opacity: .8; }
.message-meta { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; margin: 5px 4px 0; }
.message.owner .message-meta { text-align: right; }
/* time first, then the icons after it — aligned to the LEFT start of the
   chat box for every message (owner bubbles included) */
.message-meta .message-time-inline { flex: none; }
.message.owner .message-meta { justify-content: flex-start; text-align: left; }
.message.owner .message-meta .message-time-inline { text-align: left; }
.message-actions { display: flex; }
.pin-action, .reply-action { width: 30px; height: 26px; }
.pin-flash { outline: 2px solid var(--warm); outline-offset: 2px; border-radius: 4px; transition: outline-color .4s; }
.inline-keyboard { display: flex; flex-direction: column; gap: 5px; margin-top: 9px; }
.inline-keyboard-row { display: flex; gap: 5px; }
.inline-key { flex: 1; min-height: 34px; padding: 5px 10px; border: 1px solid #bdcfc4; border-radius: 5px; background: #fff; color: var(--accent); font: 600 13px DM, sans-serif; white-space: normal; }
.inline-key:hover { background: var(--accent-light); border-color: var(--accent); }
.inline-key.used { opacity: .55; }
.topic-item.active .topic-initial { background: var(--accent); }
.topic-info { overflow: hidden; }
.topic-name { display: block; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.archived-section { flex: none; border-top: 1px solid var(--line); }
.archived-section summary { display: flex; justify-content: space-between; align-items: center; min-height: 40px; padding: 0 17px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
.archived-section summary:hover { background: #e0ebe4; }
.archived-topics { max-height: 35dvh; overflow-y: auto; padding: 0 8px 8px; }
.archived-topics:empty::after { content: 'No archived topics'; display: block; padding: 8px; color: var(--muted); font-size: 12px; }
.sidebar-bottom { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-bottom button { margin-left: auto; }
.connection-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.conversation { min-height: 0; display: flex; flex-direction: column; position: relative; background-color: var(--paper); background-image: radial-gradient(#dae6df 0.6px, transparent 0.6px); background-size: 22px 22px; }
.conversation-header { z-index: 1; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 8px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.header-titles { flex: 1; min-width: 0; }
.header-titles h2 { font: 600 17px Space, sans-serif; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-titles span { font-size: 11px; color: var(--muted); }
.back { display: none; }
.empty-state { display: flex; flex: 1; flex-direction: column; justify-content: center; align-items: flex-start; padding: 48px clamp(30px, 10vw, 130px); }
.empty-glyph { display: grid; place-items: center; width: 86px; height: 86px; border: 1px solid var(--line); border-radius: 8px; font: 600 34px Space, sans-serif; color: var(--accent); background: var(--paper); }
.empty-state h2 { font: 600 30px Space, sans-serif; margin: 25px 0 6px; }
.empty-state p { margin: 0 0 24px; color: var(--muted); line-height: 1.5; max-width: 320px; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 45px; padding: 0 18px; border-radius: 5px; border: 0; color: #fff; background: var(--accent); font-weight: 600; }
.primary:hover, .send-button:hover { background: #0d5942; }
.primary img, .send-button img { filter: brightness(0) invert(1); }
.messages { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 3vw, 40px); }
.messages.loading-history { cursor: progress; }
.message-stack { max-width: 960px; margin: auto; display: flex; flex-direction: column; gap: 10px; min-height: 100%; justify-content: flex-end; }
.message { max-width: min(88%, 780px); align-self: flex-start; }
.message.owner { align-self: flex-end; }
.message-label { font-size: 10px; font-weight: 600; color: var(--muted); margin: 0 0 3px 4px; }
.message.owner .message-label { text-align: right; margin-right: 4px; }
.bubble { padding: 8px 12px; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text.formatted { white-space: normal; }
.message-text.formatted > :first-child { margin-top: 0; }
.message-text.formatted > :last-child { margin-bottom: 0; }
.message-text.formatted p, .message-text.formatted ul, .message-text.formatted ol, .message-text.formatted blockquote, .message-text.formatted pre { margin-block: 9px; }
.message-text.formatted ul, .message-text.formatted ol { padding-left: 24px; }
.message-text.formatted blockquote { margin-left: 0; padding-left: 12px; border-left: 3px solid #b9cdc0; color: var(--muted); }
.message-text.formatted code { padding: 1px 4px; border-radius: 3px; background: var(--surface); font: 13px/1.5 ui-monospace, monospace; }
.message-text.formatted pre { overflow-x: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); white-space: pre; }
.message-text.formatted pre code { padding: 0; background: transparent; }
.message-text.formatted a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.message-text.formatted table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; white-space: nowrap; }
.message-text.formatted th, .message-text.formatted td { padding: 7px 10px; border: 1px solid var(--line); text-align: left; }
.message-text.formatted th { background: var(--surface); font-weight: 600; }
.message.owner .bubble { background: var(--accent-light); border-color: #c5e4d2; }
.processing .bubble { min-width: 49px; min-height: 39px; display: flex; align-items: center; justify-content: center; gap: 2px; }
.processing-dots span { display: inline-block; font-weight: 600; animation: processing-dot 1.2s ease-in-out infinite; }
.processing-dots span:nth-child(2) { animation-delay: .15s; }
.processing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes processing-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .processing-dots span { animation: none; opacity: 1; } }
.message-time { color: var(--muted); font-size: 11px; margin: 5px 4px 0; }
.message.owner .message-time { text-align: right; }
.message-file { display: flex; gap: 9px; align-items: center; margin-top: 8px; padding: 8px 10px; background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 4px; text-decoration: none; color: var(--accent); font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.message-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 3px; margin-top: 8px; }
.compose { padding: 10px clamp(12px, 3vw, 40px) 12px; background: var(--paper); border-top: 1px solid var(--line); }
.compose-row, .attachment-preview { max-width: 960px; margin: auto; }
.compose-row { display: flex; align-items: flex-end; gap: 8px; padding: 7px; border: 1px solid #bdcfc4; border-radius: 7px; background: #fff; }
.compose-row:focus-within { border-color: var(--accent); }
.attach-button { cursor: pointer; margin-bottom: 1px; }
.compose textarea { resize: none; max-height: calc(11.2em + 18px); min-height: 42px; flex: 1; padding: 10px 4px; border: 0; outline: 0; background: transparent; line-height: 1.4; overflow-y: hidden; }
.compose textarea:focus-visible { outline: 0; }
.send-button { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border: 0; border-radius: 5px; background: var(--accent); }
.stop-button { background: #a64433; }
.stop-button:hover { background: #873426; }
.stop-button img { filter: brightness(0) invert(1); }
.attachment-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 5px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 5px; font-size: 13px; }
.attachment-preview span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.error { min-height: 0; margin: 5px 0 0; color: #a64433; font-size: 13px; }
.error:empty { display: none; }
.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background-color: #e9efec; background-image: radial-gradient(#cfdbd3 1px, transparent 1px); background-size: 24px 24px; }
.login-panel { width: min(100%, 390px); padding: 36px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 20px 60px #243d2d12; }
.kicker { color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .1em; margin: 30px 0 2px; }
.login-panel h1 { font: 600 37px Space, sans-serif; margin: 0; }
.login-subtitle { color: var(--muted); margin: 5px 0 35px; }
.login-panel label, .topic-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.login-panel input, .topic-form input { width: 100%; height: 46px; border: 1px solid #b9cdc0; border-radius: 5px; padding: 0 12px; background: #fff; }
.login-submit { width: 100%; margin-top: 15px; }
dialog { width: min(420px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 7px; padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 25px 70px #20342e33; }
dialog::backdrop { background: #142e24a0; }
.settings { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); --muted: #50665b; }
.settings-scroll { overflow-y: auto; padding: 12px 40px 64px; }
.settings-scroll > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.settings h3 { margin: 0; font: 600 20px Space, sans-serif; text-wrap: balance; }
.settings h4 { margin: 0 0 14px; font: 600 16px Space, sans-serif; }
.settings p { font-size: 14px; line-height: 1.6; max-width: 70ch; }
.settings-section { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 48px; padding: 40px 0 48px; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.settings-section-heading { align-self: start; position: sticky; top: 24px; }
.settings-section-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.settings-section-body { min-width: 0; }
.section-description { color: var(--muted); margin: 0 0 24px; }
.settings-subsection { padding: 28px 0 32px; }
.settings-subsection > label { display: block; margin: 20px 0 8px; font-weight: 600; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.connection-list-heading, .connection-row { display: grid; grid-template-columns: 20px minmax(120px, 1fr) minmax(150px, 1.2fr) minmax(110px, .8fr); gap: 14px; align-items: center; }
.connection-list-heading { padding-left: 44px; }
.connection-grip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 28px; margin-left: -8px; padding: 0; border: 0; background: none; cursor: grab; color: var(--muted); border-radius: 6px; }
.connection-grip:hover { background: var(--surface); color: var(--text); }
.connection-grip:active { cursor: grabbing; }
.connection-grip img { pointer-events: none; }
.connection-row.dragging { opacity: .45; }
.connection-row.drop-above { box-shadow: inset 0 2px 0 var(--accent, #4a7dff); }
.connection-row.drop-below { box-shadow: inset 0 -2px 0 var(--accent, #4a7dff); }
body.entity-reordering { user-select: none; }
.connection-list-heading { padding: 0 10px 7px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.entity-connections { border-block: 1px solid var(--line); }
.connection-row { min-height: 44px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.connection-row:last-child { border-bottom: 0; }
.connection-row.current { background: var(--surface); }
.connection-row code { overflow: hidden; color: var(--muted); font: 12px ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.connection-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.connection-state::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: #95a59d; }
.connection-state[data-state=connected] { color: #12553e; font-weight: 600; }
.connection-state[data-state=connected]::before { background: var(--accent); }
.password-form { max-width: 620px; }
.password-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.password-fields label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
.password-fields label:first-child { grid-column: 1 / -1; }
.password-fields input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #b9cdc0; border-radius: 5px; background: #fff; }
.field-hint { margin: 7px 0 0; color: var(--muted); font-size: 12px !important; }
.password-form .secondary { margin-top: 12px; }
.connection-facts { display: grid; gap: 12px; padding: 18px 20px; margin: 0 0 28px; background: var(--surface); border-radius: 6px; }
.connection-facts > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; font-size: 13px; }
.connection-facts dt { color: var(--muted); }
.connection-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.setup-options { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 20px 32px; margin-block: 24px; }
.setup-options > div { flex: 1; min-width: min(240px, 100%); }
.setup-options label, .setup-options legend { font-size: 13px; font-weight: 600; }
.setup-options input:not([type=radio]) { display: block; width: 100%; height: 42px; margin-top: 8px; padding: 0 12px; border: 1px solid #b9cdc0; border-radius: 5px; background: #fff; }
.setup-options p { font-size: 12px; margin: 6px 0 0; color: var(--muted); }
.shell-picker { border: 0; padding: 0; margin: 0; }
.shell-picker legend { margin-bottom: 10px; }
.shell-picker label { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding-right: 12px; }
.shell-picker input { accent-color: var(--accent); }
.setup-steps > details { border-top: 1px solid var(--line); }
.setup-steps > details:last-child { border-bottom: 1px solid var(--line); }
.settings summary { cursor: pointer; font-weight: 600; line-height: 1.5; padding: 18px 0; }
.settings summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step-content { padding: 0 0 22px; }
.step-content > p:first-child { margin-top: 0; }
.command-block { display: flex; align-items: flex-start; gap: 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 6px; margin: 12px 0; min-width: 0; }
.command-block pre { flex: 1; min-width: 0; margin: 0; padding: 9px; white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto; font-size: 12px; line-height: 1.7; }
.command-block code { font-family: ui-monospace, monospace; }
.settings .setup-note { color: var(--muted); font-size: 13px; }
.secondary { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; padding: 8px 14px; border: 1px solid #b9cdc0; border-radius: 5px; background: transparent; color: var(--ink); font-weight: 600; font-size: 13px; }
.secondary:hover { background: var(--surface); }
.danger { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 45px; margin-top: 22px; padding: 0 18px; border: 0; border-radius: 5px; background: #a64433; color: #fff; font-weight: 600; }
.danger:hover { background: #873426; }
.danger img { filter: brightness(0) invert(1); }
.delete-warning { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.confirm-row { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-row .secondary { margin-top: 0; min-height: 45px; }
.danger-inline { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 45px; padding: 0 18px; border: 0; border-radius: 5px; background: #a64433; color: #fff; font-weight: 600; }
.danger-inline:hover { background: #873426; }
.danger-inline img { filter: brightness(0) invert(1); }
.verification-detail { padding: 12px 0; color: var(--muted); }
.verification-detail[data-state=confirmed] { color: #12553e; font-weight: 600; }
.verification-detail[data-state=timed_out] { color: #9a382b; }
.settings-feedback { color: #12553e; overflow-wrap: anywhere; }
.command-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.command-bar-intro { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.command-bar-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.command-chip { border: 1px solid #bdcfc4; background: #fff; color: var(--accent); font: 600 12px DM, sans-serif; padding: 4px 10px; border-radius: 12px; cursor: pointer; }
.command-chip:hover { background: var(--accent-light); border-color: var(--accent); }
.settings-feedback:empty { display: none; }
.connection-setup > .settings-section-body > .setup-help { border-top: 1px solid var(--line); }
.troubleshooting { margin-top: 0; }
.troubleshooting dt { font-size: 14px; font-weight: 600; margin-top: 18px; }
.troubleshooting dd { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; max-width: 70ch; }
.sidebar-bottom #settings-open { margin-left: auto; }
.sidebar-bottom #logout { margin-left: 0; }
.settings .primary, .settings .secondary { max-width: 100%; white-space: normal; }
@media (max-width: 1000px) {
  .settings-section { display: block; }
  .settings-section-heading { position: static; margin-bottom: 22px; }
  .connection-list-heading { display: none; }
  .connection-row { grid-template-columns: 20px minmax(0, 1fr) auto; gap: 3px 10px; padding-block: 10px; }
  .connection-row code { grid-column: 1 / -1; grid-row: 2; }
  .connection-state { grid-column: 2; grid-row: 1; }
}
@media (max-width: 700px) {
  .settings { height: 100dvh; }
  .workspace.settings-open .sidebar, .workspace.settings-open .conversation { display: none; }
  .settings-scroll { padding: 0 18px 40px; }
  .settings-section { display: block; padding: 30px 0 36px; }
  .settings-section-heading { position: static; margin-bottom: 22px; }
  .settings-section-heading p { margin-top: 5px; }
  .settings h3 { font-size: 20px; }
  .connection-facts > div { grid-template-columns: 1fr; gap: 4px; }
  .setup-options { gap: 16px; }
  .password-fields { grid-template-columns: 1fr; }
  .password-fields label:first-child { grid-column: auto; }
}
.topic-form { padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.dialog-heading h2 { font: 600 22px Space, sans-serif; margin: 0; }
.topic-form .primary { width: 100%; margin-top: 22px; }
@media (max-width: 700px) {
  .workspace { display: block; }
  .sidebar { height: 100dvh; }
  .conversation { height: 100dvh; }
  .workspace:not(.chat-open) .conversation { display: none; }
  .workspace.chat-open .sidebar { display: none; }
  .back { display: grid; }
  .conversation-header { min-height: 56px; padding: 6px 10px; gap: 4px; }
  .messages { padding: 12px; }
  .compose { padding: 8px 10px 10px; }
  .message { max-width: 92%; }
  .topic-action { opacity: 1; }
}

.entity-picker { padding: 2px 10px 10px; }
.entity-picker > label { display: block; padding: 0 7px 5px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.entity-picker-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 36px); align-items: center; gap: 2px; }
.entity-picker select { width: 100%; min-width: 0; height: 36px; padding: 0 8px; border: 1px solid #b9cdc0; border-radius: 5px; background: #fff; color: var(--ink); font: 600 13px DM, sans-serif; }
.entity-picker .icon-button { width: 36px; height: 36px; }
.entity-picker .icon-button:disabled { background: transparent; }
textarea { font: inherit; color: inherit; background: var(--surface, #fff); border: 1px solid #bbb; border-radius: 5px; padding: 10px; max-width: 100%; }
#admin-settings, #admin-add-user { display: grid; gap: 12px; margin: 20px 0; }
#admin-settings label, #admin-add-user label { display: grid; gap: 6px; }
.admin-user { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid #ddd; }
#simple-feedback { overflow-wrap: anywhere; }

/* Keep the guided connection and administration fields readable on narrow screens. */
.settings-section input:not([type="checkbox"]), .settings-section textarea {
  width: 100%; min-width: 0; font: inherit; padding: 10px 12px;
  border: 1px solid #b9cdc0; border-radius: 5px; background: #fff;
}
.settings-section > label { display: block; margin-top: 16px; margin-bottom: 8px; font-weight: 600; }
#admin-settings label:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
#admin-settings input[type="checkbox"] { width: auto; }
#wrapper-command { display: block; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; background: #eef3ef; border-radius: 5px; }
.tap-feedback { color: #12553e; font-size: 12px; margin: 5px 0 0; }
.tap-feedback:empty { display: none; }


.provider-tabs { display:flex; gap:8px; flex-wrap:wrap; margin:20px 0; }
.provider-tabs [role="tab"] { padding:10px 16px; border:1px solid #a5afa9; border-radius:8px; background:transparent; color:inherit; cursor:pointer; }
.provider-tabs [aria-selected="true"] { background:#243e37; color:#fff; }
[role="tabpanel"] pre { overflow-x:auto; white-space:pre-wrap; overflow-wrap:anywhere; }

/* Scroll navigation pills (top/bottom center) */
.scroll-nav { position: absolute; left: 50%; transform: translateX(-50%); z-index: 3; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); display: grid; place-items: center; box-shadow: 0 4px 14px #20342e22; opacity: .92; }
.scroll-nav:hover { background: var(--accent-light); }
.scroll-nav img { width: 17px; height: 17px; }
.scroll-nav-top { top: 70px; }
.scroll-nav-bottom { bottom: 92px; }
.conversation { position: relative; }

/* Built-in media viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: #142e24e6; display: grid; place-items: center; grid-template-rows: auto minmax(0, 1fr) auto; padding: 20px; }
.viewer-content { display: grid; place-items: center; min-height: 0; }
.viewer-content img { max-width: min(96vw, 1400px); max-height: 82dvh; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px #00000066; cursor: grab; background: #fff; }
.viewer-content video { max-width: min(96vw, 1400px); max-height: 82dvh; border-radius: 6px; box-shadow: 0 30px 80px #00000066; background: #000; }
.viewer-close { justify-self: end; width: 40px; height: 40px; background: #ffffff1a; border-radius: 50%; }
.viewer-close:hover { background: #ffffff33; }
.viewer-close img { filter: brightness(0) invert(1); }
.viewer-caption { color: #fff; text-align: center; font-size: 13px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90vw; }

/* Inline video bubbles */
.message-video { display: block; width: auto; max-width: 100%; max-height: 340px; border-radius: 3px; margin-top: 8px; background: #000; }
.message-media-name { font-size: 11.5px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }

/* Archived category selector + dropdown */
.category-bar { display: flex; align-items: center; gap: 6px; padding: 5px 10px 4px 12px; }
.category-list { flex: 1; min-width: 0; display: flex; }
.category-select { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 8px; font-size: 11.5px; font-weight: 600; line-height: 1; padding: 6px 9px; cursor: pointer; }
.category-select:hover { background: #deebe2; }
.category-select-icon img, .category-select-caret img { width: 12px; height: 12px; opacity: .75; }
.category-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-select-count { color: var(--muted); font-weight: 600; padding-left: 10px; border-left: 1px solid var(--line); margin-left: 2px; }
.category-select-caret { margin-left: 2px; }
.category-popover { position: fixed; z-index: 40; min-width: 220px; max-height: 300px; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 36px #20342e26; padding: 6px; }
.category-popover-title { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 4px 8px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-option { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font-size: 12.5px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.category-option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-option-menu + .category-option-menu { margin-left: 8px; }
.category-option:hover { background: #e0ebe4; }
.category-option.current { font-weight: 700; color: var(--accent); }
.category-option-create, .category-option.create { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 2px; justify-content: space-between; }
.category-option-count { flex: none; color: var(--muted); font-size: 11px; opacity: .85; margin-left: 8px; min-width: 16px; text-align: right; }
.category-option-menu { opacity: 0; transition: opacity .12s; display: inline-flex; }
.category-option:hover .category-option-menu { opacity: 1; }
.category-option-menu-icon img { width: 12px; height: 12px; display: block; }

.topic-row.categorised-row { grid-template-columns: minmax(0, 1fr) 28px 28px 28px 28px; padding-right: 6px; }
.archived-topics .topic-row { padding-right: 6px; }
.topic-row .topic-action { margin-right: 0; }
.topic-row .topic-action + .topic-action { margin-left: 0; }
/* Sidebar collapse (desktop only) */
.sidebar-toggle { width: 30px; height: 30px; border-radius: 6px; }
.sidebar-toggle img { width: 15px; height: 15px; }
.sidebar-toggle:hover { background: #deebe2; }
.workspace.collapsed { grid-template-columns: 44px minmax(0, 1fr); }
.workspace.collapsed .sidebar-resizer { display: none; }
/* Collapsed entity rail: icon tiles with unread badges (Telegram-style) */
.entity-rail { display: none; }
.workspace.collapsed .entity-rail { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 2px 0 8px; }
.entity-tile { width: 36px; height: 36px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; }
.entity-tile-disc { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; color: #fff; font: 600 14px Space, sans-serif; background: #859d8e; position: relative; }
.entity-tile.active .entity-tile-disc { background: var(--accent); }
.entity-tile-badge { top: -6px; right: -8px; }
.workspace.collapsed .sidebar-bottom, .workspace.collapsed #archived-section,
.workspace.collapsed .entity-picker, .workspace.collapsed .section-heading,
.workspace.collapsed .topic-row .topic-action,
.workspace.collapsed .topic-item .topic-info { display: none; }
.workspace.collapsed #topics { flex: 1; overflow-y: auto; padding: 4px 2px 8px; }
.workspace.collapsed .topic-row { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 0; }
.workspace.collapsed .topic-item { width: auto; grid-template-columns: auto; padding: 6px; }
.workspace.collapsed .topic-item.active { background: var(--accent-light); }
.workspace.collapsed .topic-initial { width: 30px; height: 30px; }
.workspace.collapsed .sidebar-top { flex-direction: column; gap: 10px; justify-content: center; padding: 12px 0 6px; }
.workspace.collapsed .brand { display: none; }
.workspace.collapsed .sidebar-toggle { margin: 0; }
.workspace.collapsed .sidebar-toggle img { transform: rotate(180deg); }
@media (min-width: 500px) and (max-width: 700px) {
  .conversation-header h2, #topic-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
  .back { display: none; }
  .scroll-nav { width: 32px; height: 32px; }
  .scroll-nav-top { top: 56px; }
  .scroll-nav-bottom { bottom: 82px; }
  .workspace { display: flex; }
  .sidebar { width: 56px; flex: none; min-height: 0; height: 100dvh; }
  .conversation { flex: 1; min-width: 0; height: 100dvh; }
  .workspace.chat-open .sidebar { display: flex; }
  .workspace:not(.chat-open) .conversation { display: block; }
  .entity-picker, .section-heading, .sidebar-bottom { display: none; }
  .sidebar-top { flex-direction: column; gap: 10px; justify-content: center; padding: 12px 0 6px; }
  .brand { display: none; }
  .sidebar-toggle { display: grid; margin: 0; }
  .sidebar-toggle img { transform: rotate(180deg); }
  .workspace.band-expanded .sidebar { width: 260px; padding: 0 14px; }
  .workspace.band-expanded .entity-picker, .workspace.band-expanded .section-heading,
  .workspace.band-expanded .sidebar-bottom { display: block; }
  .workspace.band-expanded .brand { display: flex; }
  .workspace.band-expanded .sidebar-top { flex-direction: row; padding: 16px 0 12px; }
  .workspace.band-expanded .topic-row { grid-template-columns: minmax(0, 1fr) 28px 28px 28px; justify-items: stretch; }
  .workspace.band-expanded .topic-row .topic-action { display: grid; }
  .workspace.band-expanded .topic-item { width: 100%; grid-template-columns: 32px 1fr; }
  .workspace.band-expanded .topic-item .topic-info { display: grid; }
  .workspace.band-expanded .topic-initial { width: 32px; height: 32px; }
  .workspace.band-expanded .sidebar-toggle img { transform: none; }
  .topic-row { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 0; }
  .topic-row .topic-action { display: none; }
  .topic-item { width: auto; grid-template-columns: auto; padding: 6px; }
  .topic-item .topic-info { display: none; }
  .topic-initial { width: 30px; height: 30px; }
  #topics { flex: 1; overflow-y: auto; padding: 4px 2px 8px; }
}
/* Secure prompt */
.bubble-secret .secret-shield { width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; }
.secret-open { margin-top: 8px; border: 1px solid var(--accent); background: var(--accent-light); color: var(--accent); border-radius: 7px; font-size: 12.5px; font-weight: 600; padding: 6px 12px; cursor: pointer; }
.secret-open:disabled { opacity: .7; border-color: var(--line); background: transparent; color: var(--muted); }
.secret-dialog { position: fixed; inset: 0; z-index: 60; background: #142e24d9; display: grid; place-items: center; padding: 18px; }
.secret-card { width: min(430px, 94vw); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 70px #00000045; padding: 22px; display: grid; gap: 12px; }
.secret-card h2 { font: 600 17px Space, sans-serif; margin: 0; overflow-wrap: anywhere; }
.secret-note { color: var(--muted); font-size: 12px; margin: 0; }
.secret-dialog input[type="password"], .secret-dialog input[type="text"] { font: 600 15px DM, monospace, sans-serif; padding: 10px 12px; border: 1px solid #b9cdc0; border-radius: 7px; }
.secret-actions { display: flex; justify-content: space-between; align-items: center; }
.secret-eye { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.secret-send { border: 0; background: var(--accent); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 700; padding: 9px 22px; cursor: pointer; }
.secret-send:disabled { opacity: .6; }
.secret-err { color: #a33; font-size: 12px; margin: 0; min-height: 14px; }
.secret-status { margin-top: 6px; color: var(--accent); font-weight: 600; font-size: 12px; }

/* Sidebar width resizer */
.sidebar-resizer { cursor: col-resize; background: transparent; position: relative; }
.sidebar-resizer::after { content: ''; position: absolute; inset: 0 -2px; }
.sidebar-resizer:hover::after, .sidebar-resizer.dragging::after { background: #bfdec9; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing video { pointer-events: none; }

@media (max-width: 700px) { .sidebar-resizer { display: none; } }

/* Replies */
.message-quote { display: flex; gap: 8px; align-items: baseline; max-width: 100%; margin: 2px 0 6px; padding: 5px 10px; border-left: 3px solid var(--accent); background: #eef4ef; border-radius: 6px; cursor: pointer; font-size: 12px; min-width: 0; }
.message-quote-sender { flex: none; font-weight: 700; color: var(--accent); }
.message-quote-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.message-quote:hover { background: #e0ebe4; }
.quote-flash { outline: 2px solid var(--accent); border-radius: 6px; }
.reply-bar { display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-top: 1px solid var(--line); background: #eef4ef; }
.reply-arrow { color: var(--accent); font-weight: 700; flex: none; }
.reply-meta { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; font-size: 12px; }
.reply-meta #reply-sender { font-weight: 700; color: var(--accent); flex: none; }
.reply-meta #reply-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .icon-button { width: 30px; height: 30px; }
.reply-bar .icon-button img { width: 14px; height: 14px; }
.reply-bar .icon-button:hover { background: #deebe2; }


/* Message action row: reply / pin / delete share ONE size, one baseline, even gaps. */
.message-actions { align-items: center; gap: 2px; }
.message-actions .icon-button { width: 30px; height: 26px; opacity: 0; }
.message-actions .icon-button img { width: 14px; height: 14px; }
.message:hover .message-actions .icon-button,
.message-actions .icon-button:focus-visible { opacity: 1; }
.message-actions .delete-action.confirming { opacity: 1; background: #f8e3df; }
.message-actions .delete-action.confirming img { filter: sepia(1) saturate(6) hue-rotate(-45deg); }

/* Delete affordance: always visible on touch (no hover), clearly armed when confirming. */
.delete-confirm-hint { font: 600 10px DM, sans-serif; color: #a4342f; white-space: nowrap; margin-left: 2px; }
.message-actions .delete-action.confirming { width: auto; padding: 0 8px; }
@media (hover: none) {
  .message-actions .icon-button { opacity: 1; }
}

.live-work-launch { flex: none; margin-left: auto; min-height: 40px; padding: 0 12px; }
.live-work-dialog { width: min(1100px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 18px; overflow: auto; }
.live-work-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.live-work-heading h2 { margin: 0; font: 600 24px Space, sans-serif; }
.live-work-dialog p { margin: 12px 0; line-height: 1.5; }
.live-work-task { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.live-work-task select { flex: 1; min-width: 120px; min-height: 44px; max-width: 100%; }
.live-work-canvas { width: 100%; height: min(62dvh, 650px); min-height: 240px; overflow: hidden; background: #15211c; border: 1px solid var(--line); border-radius: 4px; }
.live-work-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.live-work-dialog button { min-height: 44px; }
.live-work-dialog input { box-sizing: border-box; width: 100%; min-height: 44px; margin-top: 12px; }
.live-work-dialog button:focus-visible, .live-work-dialog select:focus-visible, .live-work-dialog input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 700px) {
  .live-work-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); padding: 12px; }
  .live-work-canvas { height: max(240px, calc(100dvh - 330px)); }
  .live-work-controls button { flex: 1 1 110px; }
}

.sales-panel { width: min(680px, calc(100vw - 24px)); max-height: 90dvh; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); font-family: DM, sans-serif; }
.sales-panel::backdrop { background: rgb(20 40 30 / .35); }
.sales-panel header, .sales-toolbar, .sales-rule { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sales-panel header { justify-content: space-between; }
.sales-panel h2 { font-size: 1.35rem; margin: 0; }
.sales-panel h3 { font-size: 1.1rem; margin: 24px 0 12px; }
.sales-panel p { line-height: 1.5; overflow-wrap: anywhere; }
.sales-panel select, .sales-panel input { min-height: 44px; max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); }
.sales-panel input { width: 70px; }
.sales-panel button { min-height: 44px; }
.sales-cases { list-style: none; padding: 0; margin: 0; }
.sales-cases li, .sales-rule { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sales-cases p { margin: 6px 0; }
.sales-rule p { flex: 1 1 250px; }
#sales-consent { margin-top: 20px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
#sales-consent h3 { margin-top: 0; }
#sales-consent button { margin: 8px 8px 0 0; }

#sales-sidebar { display: none; }
@media (max-width: 499px) {
  .workspace:not(.chat-open) #sales-sidebar { display: inline-flex; }
}

.control-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.control-tabs button[aria-current="page"] { background: var(--accent); color: white; }
.control-panel > label { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
#control-sidebar { display: none; }
#sales-onboarding textarea { display: block; width: 100%; margin: 12px 0; min-height: 80px; }
#sales-account button { margin: 4px 8px 4px 0; }
@media (max-width: 499px) { .workspace:not(.chat-open) #control-sidebar { display: inline-flex; } }

.sales-cases li { overflow-wrap: anywhere; }

.team-panel { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
.team-panel header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.team-panel section { margin-block: 20px; }
.team-panel form { display: grid; gap: 12px; margin-block: 12px 24px; }
.team-panel label { display: grid; gap: 6px; font-weight: 600; }
.team-panel input, .team-panel select, .team-panel textarea { box-sizing: border-box; width: 100%; min-height: 44px; }
.team-panel textarea { min-height: 96px; resize: vertical; }
.team-panel pre, .team-panel code { white-space: pre-wrap; overflow-wrap: anywhere; }
.team-row { padding-block: 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.team-row button { margin: 4px 8px 4px 0; min-height: 44px; }
.team-panel :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 700px) { .team-panel { padding: 12px; } .team-panel header { align-items: flex-start; } }


/* --- Topic search (single row: icon, field, prev/next, count, close) --- */
.topic-search-toggle { margin-left: 8px; }
.topic-search { border-bottom: 1px solid var(--line); background: var(--surface); padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
.topic-search-icon { display: inline-flex; color: var(--muted); flex: none; }
.topic-search-icon img { width: 15px; height: 15px; }
.topic-search input[type="search"] { flex: 1; min-width: 0; background: var(--bg, #fff); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; color: var(--text); }
.topic-search input[type="search"]:focus { outline: 2px solid var(--accent, #4a7dff); outline-offset: -1px; border-color: transparent; }
.topic-search .icon-button { flex: none; }
.topic-search-count { color: var(--muted); font-size: 12px; flex: none; min-width: 44px; text-align: right; }
mark.topic-hit { background: rgba(255, 213, 79, .55); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.topic-hit.current { background: rgba(255, 145, 0, .75); }

.copy-action img, .branch-action img { width: 15px; height: 15px; }
.branch-action.busy { opacity: .5; pointer-events: none; }
