:root {
    color-scheme: dark;
    --bg: #0c0a09;
    --canvas: #0c0a09;
    --surface: #292524;
    --surface-strong: #1c1917;
    --surface-soft: #3b3633;
    --surface-hover: #3f3a37;
    --border: #57534e;
    --border-soft: rgba(87, 83, 78, .6);
    --text: #fafaf9;
    --muted: #a8a29e;
    --subtle: #78716c;
    --accent: #ea580c;
    --accent-readable: #fb923c;
    --accent-soft: rgba(67, 20, 7, .6);
    --focus: #ea580c;
    --focus-soft: rgba(234, 88, 12, .16);
    --success: #34d399;
    --warning: #f59e0b;
    --danger: #f87171;
    --shadow: 0 18px 44px rgba(0, 0, 0, .32);
    --topbar-height: 72px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f9fafb;
    --canvas: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --surface-soft: #f3f4f6;
    --surface-hover: #f5f5f4;
    --border: #e5e7eb;
    --border-soft: #eeeeec;
    --text: #111827;
    --muted: #6b7280;
    --subtle: #9ca3af;
    --accent: #ea580c;
    --accent-readable: #c2410c;
    --accent-soft: #fff7ed;
    --focus: #ea580c;
    --focus-soft: rgba(234, 88, 12, .12);
    --success: #059669;
    --warning: #b45309;
    --danger: #dc2626;
    --shadow: 0 18px 42px rgba(28, 25, 23, .12);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: 0;
}

button,
input,
textarea,
select {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .48;
}

.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;
}

.chat-app {
    min-width: 320px;
    height: 100%;
    display: grid;
    grid-template-rows: var(--topbar-height) minmax(0, 1fr);
    background: var(--bg);
}

.topbar {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-width: 0;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}

.brand,
.brand > div,
.topbar-actions,
.connection-state,
.profile-button {
    display: flex;
    align-items: center;
}

.brand {
    gap: 12px;
    flex: 0 0 auto;
}

.brand-mark,
.cover-mark {
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--accent);
    color: #ffffff;
    box-shadow: none;
    font-size: 10px;
    font-weight: 800;
}

.brand-mark {
    width: 38px;
    height: 38px;
}

.brand .brand-mark {
    color: #ffffff;
}

.brand > div {
    align-items: flex-start;
    flex-direction: column;
    line-height: 1.25;
}

.brand strong {
    font-size: 18px;
    font-weight: 600;
}

.brand span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.topbar-actions {
    min-width: 0;
    justify-content: flex-end;
    gap: 8px;
}

.connection-state {
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.connection-state > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
}

.connection-state.is-online > span {
    background: var(--success);
}

.connection-state.is-offline > span {
    background: var(--danger);
}

.actor-switcher select,
.profile-button,
.icon-button,
.command-button,
.secondary-button,
.danger-button,
.send-button {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.actor-switcher select {
    max-width: 190px;
    padding: 0 30px 0 10px;
}

.profile-button {
    max-width: 220px;
    gap: 8px;
    padding: 4px 12px 4px 5px;
    font-size: 13px;
    font-weight: 500;
}

.profile-button > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 10px;
    font-weight: 900;
}

.avatar-current {
    background: var(--accent);
    color: #ffffff;
}

.icon-button {
    width: 38px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    color: var(--muted);
    font-weight: 700;
}

.icon-button:hover,
.icon-button:focus-visible,
.profile-button:hover,
.profile-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
    border-color: var(--accent);
    background: var(--surface-hover);
    color: var(--text);
    outline: none;
}

.icon-button.compact {
    width: 30px;
    min-height: 30px;
}

.search-icon {
    position: relative;
    width: 12px;
    height: 12px;
    display: inline-block;
    flex: 0 0 auto;
    border: 1.5px solid currentColor;
    border-radius: 50%;
}

.search-icon::after {
    content: "";
    position: absolute;
    right: -4px;
    bottom: -2px;
    width: 5px;
    height: 1.5px;
    border-radius: 999px;
    background: currentColor;
    transform: rotate(45deg);
    transform-origin: center;
}

.workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: 300px minmax(420px, 1fr) 320px;
    transition: grid-template-columns .16s ease;
}

.chat-app:not(.details-open) .workspace {
    grid-template-columns: 300px minmax(420px, 1fr) 0;
}

.sidebar,
.conversation,
.details-panel {
    min-width: 0;
    min-height: 0;
}

.sidebar {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-right: 1px solid var(--border-soft);
    background: var(--surface);
}

.sidebar-head {
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--border-soft);
}

.search-field {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    padding: 0 12px;
    color: var(--muted);
}

.search-field:focus-within {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-soft);
}

.search-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.search-field input::placeholder,
.composer textarea::placeholder,
.field input::placeholder,
.field textarea::placeholder {
    color: var(--subtle);
}

.view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
}

.view-tab {
    min-width: 0;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    padding: 0 8px;
    font-size: 12px;
    font-weight: 500;
}

.view-tab strong {
    min-width: 17px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 2px 5px;
    font-size: 9px;
}

.view-tab:hover,
.view-tab:focus-visible {
    background: var(--surface-hover);
    color: var(--text);
    outline: none;
}

.view-tab.is-active {
    border-color: rgba(234, 88, 12, .32);
    background: var(--accent-soft);
    color: var(--accent-readable);
}

.view-tab.is-active strong {
    background: var(--accent);
    color: #ffffff;
}

.channel-section {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.section-title,
.details-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.section-title {
    padding: 14px 14px 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.channel-list {
    min-height: 0;
    overflow: auto;
    padding: 0 8px 10px;
    scrollbar-gutter: stable;
}

.channel-row {
    position: relative;
    width: 100%;
    min-height: 62px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    padding: 9px 10px;
    text-align: left;
}

.channel-row::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 3px;
    width: 2px;
    border-radius: 999px;
    background: transparent;
}

.channel-row:hover,
.channel-row:focus-visible {
    border-color: var(--border);
    background: var(--surface-hover);
    outline: none;
}

.channel-row.is-selected {
    border-color: rgba(234, 88, 12, .32);
    background: var(--accent-soft);
}

.channel-row.is-selected::before {
    background: var(--accent);
}

.channel-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.channel-copy {
    min-width: 0;
}

.channel-copy strong,
.channel-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-copy strong {
    font-size: 13px;
    font-weight: 600;
}

.channel-copy span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.unread-badge {
    min-width: 22px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    padding: 3px 6px;
    text-align: center;
    font-size: 9px;
    font-weight: 950;
}

.browse-button {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    border-top: 1px solid var(--border-soft);
    background: transparent;
    color: var(--muted);
    padding: 0 16px;
    font-size: 12px;
    font-weight: 500;
}

.browse-button:hover,
.browse-button:focus-visible {
    background: var(--surface-hover);
    color: var(--text);
    outline: none;
}

.browse-button strong {
    min-width: 24px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 3px 6px;
    font-size: 9px;
}

.conversation {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--canvas);
}

.conversation-head {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--canvas);
    padding: 10px 20px;
}

.conversation-title {
    min-width: 0;
    flex: 1 1 auto;
}

.conversation-title > div {
    display: flex;
    align-items: center;
    gap: 7px;
}

.channel-symbol {
    color: var(--accent-readable);
    font-size: 16px;
    font-weight: 900;
}

.conversation-title h1 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
}

.conversation-title p {
    margin: 3px 0 0;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.visibility-badge {
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.conversation-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.mobile-back {
    display: none;
}

.message-region {
    min-height: 0;
    overflow: auto;
    padding: 18px 0 24px;
    scrollbar-gutter: stable;
}

.load-older {
    display: block;
    margin: 2px auto 12px;
    border: 0;
    background: transparent;
    color: var(--accent-readable);
    font-size: 11px;
    font-weight: 600;
}

.message-list {
    min-height: 100%;
}

.message {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 24px;
}

.message:hover {
    background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.message.is-highlighted {
    background: var(--focus-soft);
}

.message-main {
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.message-meta strong {
    font-size: 13px;
    font-weight: 600;
}

.message-meta time,
.edited-label {
    color: var(--subtle);
    font-size: 10px;
}

.message-body {
    margin: 3px 0 0;
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-body.is-deleted {
    color: var(--subtle);
    font-style: italic;
}

.reply-preview,
.forward-preview {
    margin: 5px 0;
    border-left: 2px solid var(--accent);
    background: var(--focus-soft);
    padding: 6px 8px;
    color: var(--muted);
    font-size: 11px;
}

.reply-preview strong,
.forward-preview strong {
    color: var(--text);
}

.message-actions {
    position: absolute;
    top: -11px;
    right: 15px;
    display: none;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 2px;
}

.message:hover .message-actions,
.message:focus-within .message-actions {
    display: flex;
}

.message-action {
    min-width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    padding: 0 6px;
    font-size: 10px;
    font-weight: 850;
}

.message-action:hover,
.message-action:focus-visible {
    background: var(--surface-hover);
    color: var(--text);
    outline: none;
}

.reaction-list,
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.reaction-chip,
.attachment-chip {
    min-height: 27px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 500;
}

.reaction-chip.is-mine {
    border-color: color-mix(in srgb, var(--focus) 52%, var(--border));
    background: var(--focus-soft);
    color: var(--text);
}

.attachment-chip {
    text-decoration: none;
}

.attachment-chip:hover,
.attachment-chip:focus-visible {
    border-color: var(--focus);
    color: var(--text);
    outline: none;
}

.empty-state {
    min-height: 260px;
    display: grid;
    place-content: center;
    gap: 6px;
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

.empty-state strong {
    color: var(--text);
    font-size: 14px;
}

.empty-state span {
    max-width: 360px;
    font-size: 11px;
    line-height: 1.5;
}

.composer {
    border-top: 1px solid var(--border-soft);
    background: var(--canvas);
    padding: 12px 20px 18px;
}

.composer-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    padding: 8px;
}

.composer-row:focus-within {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-soft);
}

.composer-icon {
    border: 0;
    background: transparent;
}

.composer textarea {
    width: 100%;
    max-height: 132px;
    resize: none;
    border: 0;
    background: transparent;
    padding: 8px 4px;
    outline: 0;
    line-height: 1.4;
}

.send-button,
.command-button,
.secondary-button,
.danger-button {
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
}

.send-button,
.command-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.send-button:hover,
.send-button:focus-visible,
.command-button:hover,
.command-button:focus-visible {
    border-color: #c2410c;
    background: #c2410c;
    outline: none;
}

.secondary-button {
    color: var(--text);
}

.danger-button {
    border-color: color-mix(in srgb, var(--danger) 48%, var(--border));
    background: color-mix(in srgb, var(--danger) 9%, var(--surface));
    color: var(--danger);
}

.danger-button:hover,
.danger-button:focus-visible {
    background: color-mix(in srgb, var(--danger) 16%, var(--surface));
    outline: none;
}

.compose-context,
.attachment-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 7px 43px;
}

.compose-context {
    justify-content: space-between;
    border-left: 2px solid var(--accent);
    background: var(--focus-soft);
    padding: 6px 7px 6px 9px;
}

.compose-context > div {
    min-width: 0;
}

.compose-context strong,
.compose-context span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-context strong {
    font-size: 10px;
}

.compose-context span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
}

.attachment-strip {
    flex-wrap: wrap;
}

.pending-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    padding: 4px 7px;
    color: var(--muted);
    font-size: 9px;
}

.pending-attachment button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0;
}

.details-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    border-left: 1px solid var(--border-soft);
    background: var(--surface);
    opacity: 1;
    overflow: hidden;
    transition: opacity .12s ease;
}

.chat-app:not(.details-open) .details-panel {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.details-panel > header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border-soft);
    padding: 12px 16px;
}

.details-panel h2,
.dialog h2 {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 600;
}

.eyebrow {
    color: var(--accent-readable);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.details-about,
.details-section,
.details-actions {
    border-bottom: 1px solid var(--border-soft);
    padding: 16px;
}

.details-about strong {
    font-size: 14px;
    font-weight: 600;
}

.details-about p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
}

.detail-meta span {
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 500;
}

.details-section {
    min-height: 0;
    overflow: auto;
}

.details-section-title {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--accent-readable);
    padding: 2px;
    font-size: 11px;
    font-weight: 600;
}

.member-list {
    display: grid;
    gap: 4px;
}

.member-row {
    min-height: 38px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    padding: 6px;
}

.member-row:hover {
    background: var(--surface-hover);
}

.member-row .avatar {
    width: 28px;
    height: 28px;
}

.member-row strong,
.member-row span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-row strong {
    font-size: 12px;
    font-weight: 600;
}

.member-row span {
    color: var(--muted);
    font-size: 10px;
}

.role-badge {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 500;
}

.select-field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.select-field select,
.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    color: var(--text);
}

.select-field select,
.field input,
.field select {
    height: 40px;
    padding: 0 12px;
}

.field textarea {
    resize: vertical;
    padding: 9px 10px;
}

.select-field select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-soft);
    outline: none;
}

.details-actions {
    display: grid;
    gap: 7px;
    border-bottom: 0;
}

.connection-cover {
    position: fixed;
    inset: var(--topbar-height) 0 0;
    z-index: 20;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 9px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(4px);
    padding: 24px;
    text-align: center;
}

.connection-cover[hidden] {
    display: none;
}

.cover-mark {
    width: 14px;
    height: 14px;
    margin-bottom: 4px;
    animation: pulse 1.2s ease-in-out infinite;
}

.connection-cover strong {
    font-size: 15px;
}

.connection-cover p {
    max-width: 380px;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

@keyframes pulse {
    50% {
        opacity: .45;
        transform: scale(.86);
    }
}

.dialog {
    width: min(480px, calc(100% - 28px));
    max-height: min(700px, calc(100% - 28px));
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 0;
}

.dialog::backdrop {
    background: rgba(2, 5, 8, .72);
    backdrop-filter: blur(2px);
}

.wide-dialog {
    width: min(680px, calc(100% - 28px));
}

.dialog form,
.dialog-body {
    display: grid;
    gap: 13px;
    padding: 20px;
}

.dialog header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dialog footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.field {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.dialog fieldset {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.dialog legend {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.segmented-control input {
    position: absolute;
    opacity: 0;
}

.segmented-control span {
    min-height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.segmented-control input:checked + span {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    background: var(--accent-soft);
    color: var(--text);
}

.dialog-search {
    flex: 0 0 auto;
}

.result-list,
.picker-list {
    min-height: 80px;
    max-height: 420px;
    overflow: auto;
    border-top: 1px solid var(--border-soft);
}

.picker-list {
    border: 1px solid var(--border);
    border-radius: 12px;
}

.result-row,
.picker-row {
    width: 100%;
    min-height: 54px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    background: transparent;
    color: var(--text);
    padding: 9px 4px;
    text-align: left;
}

.picker-row {
    min-height: 44px;
    padding: 7px 9px;
}

.result-row:last-child,
.picker-row:last-child {
    border-bottom: 0;
}

.result-row:hover,
.result-row:focus-visible,
.picker-row:hover,
.picker-row:focus-visible {
    background: var(--surface-hover);
    outline: none;
}

.result-row strong,
.result-row span,
.picker-row strong,
.picker-row span {
    display: block;
}

.result-row strong,
.picker-row strong {
    font-size: 12px;
    font-weight: 600;
}

.result-row span,
.picker-row span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.result-row em {
    color: var(--accent-readable);
    font-size: 10px;
    font-style: normal;
    font-weight: 600;
}

.form-error {
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
    border-radius: 12px;
    background: color-mix(in srgb, var(--danger) 9%, transparent);
    color: var(--danger);
    padding: 8px 9px;
    font-size: 10px;
}

.dialog blockquote {
    margin: 0;
    border-left: 2px solid var(--accent);
    background: var(--focus-soft);
    padding: 9px 10px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 40;
    max-width: min(380px, calc(100% - 32px));
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    padding: 10px 12px;
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1120px) {
    .workspace,
    .chat-app:not(.details-open) .workspace {
        grid-template-columns: 260px minmax(390px, 1fr);
    }

    .details-panel {
        position: fixed;
        top: var(--topbar-height);
        right: 0;
        bottom: 0;
        z-index: 12;
        width: min(320px, 88vw);
        box-shadow: var(--shadow);
    }

    .chat-app:not(.details-open) .details-panel {
        transform: translateX(100%);
    }
}

@media (max-width: 760px) {
    :root {
        --topbar-height: 58px;
    }

    .topbar {
        padding: 0 10px;
    }

    .connection-state,
    .profile-button > span:last-child {
        display: none;
    }

    .actor-switcher select {
        width: 138px;
        max-width: 38vw;
    }

    .actor-switcher:not([hidden]) ~ .profile-button {
        display: none;
    }

    .workspace,
    .chat-app:not(.details-open) .workspace {
        display: block;
        position: relative;
    }

    .sidebar,
    .conversation {
        position: absolute;
        inset: 0;
    }

    .conversation {
        transform: translateX(100%);
        transition: transform .16s ease;
    }

    .chat-app.mobile-conversation .conversation {
        transform: translateX(0);
    }

    .chat-app.mobile-conversation .sidebar {
        visibility: hidden;
    }

    .mobile-back {
        display: inline-grid;
    }

    .conversation-head {
        padding-inline: 9px;
    }

    .message {
        padding-inline: 12px;
    }

    .composer {
        padding: 8px;
    }

    .compose-context,
    .attachment-strip {
        margin-left: 0;
    }

    .message-actions {
        position: static;
        display: flex;
        width: max-content;
        margin-top: 5px;
        box-shadow: none;
    }
}

@media (max-width: 460px) {
    .brand > div > span {
        display: none;
    }

    .brand strong {
        font-size: 16px;
    }

    .conversation-title p,
    .visibility-badge {
        display: none;
    }

    .composer-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .send-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .dialog {
        width: calc(100% - 16px);
        max-height: calc(100% - 16px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
