/* Chat Builder - Base styles */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
}

.theme-toggle button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    cursor: pointer;
    font-size: 20px;
}

/* App shell - claymorphism */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 3vw, 1.5rem);
    margin-bottom: 1rem;
    background: var(--gradient-surface, var(--color-surface));
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    position: sticky;
    top: 0;
    z-index: 250;
    transition: box-shadow 0.2s ease;
    flex-wrap: wrap;
    min-width: 0;
}

/* Main content column: below sidebar/overlay so sidebar draws on top when open (mobile/desktop) */
#appWithSidebarMain {
    position: relative;
    z-index: var(--z-app-main, 100);
}

/* Content wrap: below header within main column so header dropdowns are visible */
.app-main-content-wrap,
#appWithSidebarMain > .app-main-content-wrap {
    position: relative;
    z-index: 200;
    min-width: 0;
    overflow-x: hidden;
}

/* Notification dropdown: fixed position, below main content so it never overlaps filters */
.notification-dropdown--fixed {
    position: fixed !important;
    top: 0;
    right: 0;
    width: 360px;
    min-width: 320px;
    max-width: 360px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 150;
    margin-top: 0 !important;
}

.notification-dropdown--fixed #notificationList {
    max-width: 100%;
}

.notification-dropdown--fixed .notification-item > div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.app-header-back {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.app-header-back:hover {
    color: var(--color-primary);
    transform: scale(1.05);
}

.app-header-back:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-clay-pressed);
}

.app-header-back svg {
    width: 20px;
    height: 20px;
}

.app-header-sidebar-collapse {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.app-header-sidebar-collapse:hover {
    color: var(--color-primary);
    transform: scale(1.05);
}

.app-header-sidebar-collapse:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-clay-pressed);
}

.app-header-sidebar-collapse svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 768px) {
    .app-header-sidebar-collapse.hide-mobile {
        display: inline-flex;
    }
}

.app-header-spacer {
    flex: 1;
    min-width: 0;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--color-text-primary);
    font-weight: 700;
    font-size: 18px;
    padding: 0.25rem 0;
    transition: color 0.2s ease, transform 0.2s ease;
}

.app-logo:hover {
    color: var(--color-primary);
}

.app-logo:active .app-logo-icon {
    transform: scale(0.96);
    box-shadow: var(--shadow-clay-pressed);
}

.app-logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-logo-icon:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-clay-card);
}

.app-logo-icon svg {
    width: 24px;
    height: 24px;
}

.header-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--color-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-clay-card);
}

.header-unread-badge.is-hidden {
    display: none;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-header-actions .clay-btn-circle {
    width: 40px;
    height: 40px;
    font-size: 18px;
    flex-shrink: 0;
}

.app-header-actions .clay-btn-circle:hover {
    transform: scale(1.05);
}

.app-header-actions .clay-btn-circle:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-clay-pressed);
}

.theme-toggle-inline {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

/* View-as (admin read-only impersonation) */
.view-as-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(90deg, var(--color-primary-muted, rgba(99, 102, 241, 0.15)), var(--color-surface));
    border-bottom: 1px solid var(--color-border);
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    z-index: 240;
}

.view-as-banner__text {
    flex: 1;
    min-width: 12rem;
}

.view-as-banner__form {
    margin: 0;
    display: flex;
    align-items: center;
}

.view-as-banner__exit {
    white-space: nowrap;
}

.view-as-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10050;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 2rem;
    box-sizing: border-box;
}

.view-as-modal {
    width: 100%;
    max-width: 420px;
    max-height: min(70vh, 520px);
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.view-as-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 0.9375rem;
}

.view-as-modal__close {
    border: none;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0.25rem;
    border-radius: var(--radius-input, var(--radius-base));
}

.view-as-modal__close:hover {
    color: var(--color-text-primary);
    background: var(--color-muted);
}

.view-as-modal__search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.view-as-modal__search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input, var(--radius-base));
    background: var(--color-input-bg);
    color: var(--color-text-primary);
    box-sizing: border-box;
}

.view-as-modal__list {
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
    max-height: 360px;
    padding: 0.25rem 0;
}

.view-as-modal__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    font: inherit;
    color: var(--color-text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}

.view-as-modal__item:hover {
    background: var(--color-muted);
}

.view-as-modal__item:last-child {
    border-bottom: none;
}

.view-as-modal__meta {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.15rem;
}

.view-as-modal__empty,
.view-as-modal__err {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.user-pill-wrap {
    position: relative;
}

.user-pill.clay-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-pill.clay-pill:hover {
    transform: scale(1.02);
}

.user-pill.clay-pill:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.user-pill-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-primary);
    color: var(--color-primary-foreground, #fff);
    font-size: 0.75rem;
    font-weight: 600;
}

.user-pill-avatar svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
}

/* When showing profile image, no colored background so photo is visible */
.user-pill-avatar:has(.user-pill-avatar-img) {
    background: transparent;
}

.user-pill-avatar .user-pill-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-pill-avatar .user-pill-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.app-body {
    min-height: calc(100vh - 68px);
    height: calc(100vh - 68px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* base_app: header + banner + scrollable main (chat, etc.) */
.app-chrome-stack {
    min-height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-chrome-stack > .app-header,
.app-chrome-stack > .view-as-banner {
    flex-shrink: 0;
}

.app-chrome-stack > .app-body {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    max-height: none;
}

/* Scripts between header and .app-body must not consume flex space */
.app-chrome-stack > script {
    display: block;
    flex: 0 0 0;
    height: 0;
    width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Sidebar shell: when view-as banner is visible, main scrolls inside remaining space */
body.view-as-readonly #appWithSidebarMain {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    min-height: 100vh;
    min-width: 0;
}

body.view-as-readonly #appWithSidebarMain > .app-main-content-wrap {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* View-as read-only: hide FAB (template also omits include); dim destructive header actions */
body.view-as-readonly .fab-container {
    display: none !important;
}

body.view-as-readonly #notificationMarkAllRead {
    pointer-events: none;
    opacity: 0.45;
    cursor: not-allowed;
}

body.view-as-readonly .view-as-readonly-hide {
    display: none !important;
}

/* View-as: visually disable write controls in main content (server + JS still enforce) */
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap input:not([type="hidden"]):not([type="search"]):not(.view-as-allow),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap textarea:not(.view-as-allow),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap select:not(.view-as-allow),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap button[type="submit"]:not(.view-as-allow),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap input[type="submit"]:not(.view-as-allow),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap input[type="file"]:not(.view-as-allow) {
    pointer-events: none;
    opacity: 0.68;
    cursor: not-allowed;
}

body.view-as-readonly .app-chrome-stack > .app-body input:not([type="hidden"]):not([type="search"]):not(.view-as-allow),
body.view-as-readonly .app-chrome-stack > .app-body textarea:not(.view-as-allow),
body.view-as-readonly .app-chrome-stack > .app-body select:not(.view-as-allow),
body.view-as-readonly .app-chrome-stack > .app-body button[type="submit"]:not(.view-as-allow),
body.view-as-readonly .app-chrome-stack > .app-body input[type="submit"]:not(.view-as-allow),
body.view-as-readonly .app-chrome-stack > .app-body input[type="file"]:not(.view-as-allow) {
    pointer-events: none;
    opacity: 0.68;
    cursor: not-allowed;
}

/* Primary / danger action buttons (type=button) not covered by submit rule */
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap button.clay-btn-primary:not(.view-as-allow):not(.clay-tab),
body.view-as-readonly #appWithSidebarMain .app-main-content-wrap button.clay-btn-danger:not(.view-as-allow):not(.clay-tab),
body.view-as-readonly .app-chrome-stack > .app-body button.clay-btn-primary:not(.view-as-allow):not(.clay-tab),
body.view-as-readonly .app-chrome-stack > .app-body button.clay-btn-danger:not(.view-as-allow):not(.clay-tab) {
    pointer-events: none;
    opacity: 0.55;
    cursor: not-allowed;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Mulish', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[hidden] {
    display: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
}

code {
    font-family: 'JetBrains Mono', monospace;
}

/* Custom scrollbar (reference-aligned) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-muted);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}

.auth-container {
    max-width: 420px;
    margin: 60px auto;
    padding: 40px;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.auth-container:hover {
    box-shadow: var(--shadow-hover);
}

.auth-container.clay-card {
    padding: 40px;
}

.auth-container h1 {
    margin-top: 0;
    font-size: 24px;
    text-align: center;
    color: var(--color-text-primary);
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    margin: -8px 0 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 4px 18px;
    border-radius: var(--radius-input);
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.input-wrap:focus-within {
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
    transform: translateY(-2px);
    background: var(--color-surface);
}

.input-wrap .input-icon {
    flex-shrink: 0;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
}

.input-wrap:focus-within .input-icon {
    color: var(--color-primary);
}

.input-wrap .input-icon svg {
    width: 22px;
    height: 22px;
}

.input-wrap--password {
    position: relative;
}

.input-password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-input, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
}

.input-password-toggle:hover {
    color: var(--color-primary);
    background: rgba(255, 255, 255, 0.06);
}

.input-password-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.input-password-toggle .input-password-toggle-icon svg {
    width: 20px;
    height: 20px;
}

.input-password-toggle .input-password-toggle-icon[hidden] {
    display: none;
}

.input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 16px;
    color: var(--color-text-primary);
}

.input-wrap input::placeholder {
    color: var(--color-text-secondary);
}

.input-wrap input:focus {
    outline: none;
}

/* Fix browser autofill background color - make it transparent */
.input-wrap input:-webkit-autofill,
.input-wrap input:-webkit-autofill:hover,
.input-wrap input:-webkit-autofill:focus,
.input-wrap input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
    -webkit-text-fill-color: var(--color-text-primary) !important;
    background-color: transparent !important;
    transition: background-color 9999s ease-in-out 0s, color 9999s ease-in-out 0s;
    caret-color: var(--color-text-primary);
    font-size: 16px !important;
    font-family: inherit !important;
}

/* Firefox autofill fix */
.input-wrap input:autofill {
    background-color: transparent !important;
    color: var(--color-text-primary) !important;
    font-size: 16px !important;
    font-family: inherit !important;
}

.form-group input.clay-input {
    width: 100%;
}

.form-group .errorlist {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    color: #dc2626;
    font-size: 14px;
}

.form-group .errorlist {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    color: #dc2626;
    font-size: 14px;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    margin-top: 8px;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    box-shadow: var(--shadow-clay-btn-primary);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-link {
    background: none;
    color: var(--color-primary);
    text-decoration: none;
    margin-top: 12px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

/* auth-logo moved to claymorphism.css for enhanced styling */

.auth-logo svg {
    width: 32px;
    height: 32px;
}

.signup-toggle-wrap {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    justify-content: center;
}

.signup-toggle-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-input);
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s ease, color 0.2s ease;
}

.signup-toggle-btn:hover {
    color: var(--color-text-primary);
}

.signup-toggle-btn.active {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    box-shadow: var(--shadow-clay-btn-primary);
}

.signup-section {
    margin-top: 0;
}

.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.divider span {
    padding: 0 12px;
    color: #64748b;
    font-size: 14px;
}

.error-msg {
    color: #dc2626;
    font-size: 14px;
    margin-top: 8px;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-clay-card);
}

#phoneAuthSection {
    margin-top: 16px;
}

#recaptcha-container {
    margin: 12px 0;
}

/* Chat layout */
.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Chat sidebar: 260px, rounded right side only (like #appSidebar) */
.chat-sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    position: relative;
    border-radius: 0 var(--radius-base, 1.5rem) var(--radius-base, 1.5rem) 0;
    overflow: hidden;
    background: var(--gradient-surface, var(--color-surface));
    box-shadow: var(--shadow-clay-card);
    transition: width 0.25s ease, min-width 0.25s ease, max-width 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Chat sidebar collapsed state (desktop) */
.chat-sidebar.collapsed {
    width: var(--chat-sidebar-collapsed);
    min-width: var(--chat-sidebar-collapsed);
    max-width: var(--chat-sidebar-collapsed);
    overflow: visible;
    position: relative;
    z-index: 500;
}

.chat-sidebar.collapsed .chat-sidebar-brand__text {
    display: none;
}

.chat-sidebar.collapsed .chat-sidebar-brand {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.chat-sidebar.collapsed .sidebar-header h2,
.chat-sidebar.collapsed .sidebar-search {
    display: none;
}

.chat-sidebar.collapsed .sidebar-header-top {
    justify-content: center;
    margin-bottom: 0;
}

.chat-sidebar.collapsed .sidebar-header {
    padding: 0.5rem;
    margin: 0 0.5rem 0.35rem;
}

.chat-sidebar.collapsed .conversation-list {
    padding: 0.35rem 0.5rem;
}

.chat-sidebar.collapsed .conversation-link {
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    min-height: 2.5rem;
}

.chat-sidebar.collapsed .conversation-link .conv-name,
.chat-sidebar.collapsed .conversation-link .conv-preview {
    display: none;
}

.chat-sidebar.collapsed .conversation-link::before {
    content: "💬";
    font-size: 1.25rem;
    line-height: 1;
}

.chat-sidebar.collapsed .conv-unread-badge {
    top: 50%;
    right: 0.25rem;
    transform: translateY(-50%);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
}

.chat-sidebar.collapsed .empty-state {
    padding: 0.5rem;
    margin: 0 0.5rem;
}

.chat-sidebar.collapsed .empty-state .empty-state-title,
.chat-sidebar.collapsed .empty-state .empty-state-text,
.chat-sidebar.collapsed .empty-state .clay-empty-icon {
    display: none;
}

.chat-sidebar.collapsed .empty-state::before {
    content: "💬";
    font-size: 1.5rem;
    display: block;
}

/* Add-task dropdown when chat sidebar collapsed: open to the right, above chat main */
.chat-sidebar.collapsed .sidebar-add-task-dropdown-menu {
    left: 100%;
    right: auto;
    margin-left: 0.5rem;
    margin-top: 0;
    min-width: 200px;
    z-index: 9999;
    isolation: isolate;
}

/* When JS applies fixed positioning (collapsed sidebar), menu is viewport-positioned so it is never clipped. Left/top set by JS. */
.chat-sidebar.collapsed .sidebar-add-task-dropdown-menu.add-task-dropdown-fixed {
    position: fixed !important;
    margin-left: 0 !important;
    right: auto !important;
    z-index: 10000 !important;
}

/* Hover tooltips when chat sidebar collapsed */
.chat-sidebar.collapsed .chat-sidebar-brand,
.chat-sidebar.collapsed .sidebar-add-task-dropdown .dropdown-trigger,
.chat-sidebar.collapsed .conversation-link,
.chat-sidebar.collapsed .empty-state {
    position: relative;
}

.chat-sidebar.collapsed .chat-sidebar-brand[data-tooltip]:hover::after,
.chat-sidebar.collapsed .sidebar-add-task-dropdown .dropdown-trigger[data-tooltip]:hover::after,
.chat-sidebar.collapsed .conversation-link[data-tooltip]:hover::after,
.chat-sidebar.collapsed .empty-state[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    margin-left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.4rem 0.6rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-primary);
    background: var(--color-surface);
    border-radius: var(--radius-input, var(--radius-base));
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    white-space: nowrap;
    z-index: 350;
    pointer-events: none;
    animation: chat-sidebar-tooltip-in 0.15s ease;
}

@keyframes chat-sidebar-tooltip-in {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.chat-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin: 0.75rem 0.75rem 0.5rem;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
}

.chat-sidebar-brand:hover {
    color: var(--color-primary);
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
    transform: translateY(-2px);
}

.chat-sidebar-brand:active {
    transform: translateY(0);
    box-shadow: var(--shadow-clay-pressed);
}

.chat-sidebar-brand__icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    border-radius: 50%;
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
}

.chat-sidebar-brand__icon svg {
    width: 22px;
    height: 22px;
}

.chat-sidebar-brand__text {
    font-weight: 700;
    font-size: 1.125rem;
}

.chat-sidebar .sidebar-header {
    flex-shrink: 0;
    padding: 1rem;
    margin: 0 0.75rem 0.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
}

.sidebar-add-task-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.sidebar-add-task-btn:hover {
    transform: scale(1.02);
    color: var(--color-primary);
    box-shadow: var(--shadow-clay-card);
}

.sidebar-add-task-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

/* Add task dropdown: choose workspace then go to task page */
.sidebar-add-task-dropdown {
    position: relative;
    flex-shrink: 0;
}

.sidebar-add-task-dropdown button.sidebar-add-task-btn {
    border: none;
    cursor: pointer;
    font: inherit;
}

.sidebar-add-task-dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
    top: 100%;
    margin-top: 0.35rem;
    min-width: 200px;
    max-width: 260px;
    padding: 0.35rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    overflow-x: hidden;
    overflow-y: visible;
    z-index: 250;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
}

/* Scroll only the workspace links (~3 rows); header + search stay fixed */
.sidebar-add-task-dropdown-menu .sidebar-add-task-dropdown-list {
    --add-task-ws-row: 2.25rem;
    max-height: calc(3 * var(--add-task-ws-row));
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    margin-top: 0.15rem;
}

.sidebar-add-task-dropdown-menu .sidebar-add-task-dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-add-task-dropdown-menu .sidebar-add-task-dropdown-list::-webkit-scrollbar-thumb {
    background: var(--color-muted, rgba(128, 128, 140, 0.45));
    border-radius: 999px;
}

.sidebar-add-task-dropdown-menu .app-sidebar-dropdown-item:not(.app-sidebar-dropdown-item--muted) {
    min-height: var(--add-task-ws-row, 2.25rem);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Beat specificity above so dropdown.js search hiding works (data-filter-hidden) */
.sidebar-add-task-dropdown-menu a.app-sidebar-dropdown-item[data-filter-hidden="true"] {
    display: none;
}

.sidebar-add-task-dropdown-menu.visible,
.sidebar-add-task-dropdown-menu.scale-100 {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.sidebar-add-task-dropdown-header {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.25rem;
}

.sidebar-header {
    padding-bottom: 0;
    margin-bottom: 0;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sidebar-header-top h2 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-text-primary);
    flex: 1;
}

.sidebar-search {
    margin-bottom: 0;
}

.sidebar-search .clay-input {
    width: 100%;
}

.sidebar-header h2 {
    margin: 0 0 12px;
}

.sidebar-header .profile-link {
    font-size: 13px;
    color: var(--color-primary, #7c3aed);
    text-decoration: none;
    margin-bottom: 12px;
    display: inline-block;
}

.new-chat-form {
    display: flex;
    gap: 8px;
}

.new-chat-form .clay-input {
    flex: 1;
}

.conversation-list {
    list-style: none;
    padding: 0.5rem 0.75rem;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.conversation-item {
    margin-bottom: 0.4rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.conversation-item:last-child {
    margin-bottom: 0;
}

.conversation-link {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.7rem 1rem;
    text-decoration: none;
    color: var(--color-text-primary);
    border-radius: var(--radius-input, var(--radius-base));
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
    min-height: 2.5rem;
    font-size: 0.9375rem;
}

.conversation-link:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-clay-card);
}

.conversation-link.active {
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-pressed);
    font-weight: 500;
}

.conversation-link:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

/* Light theme overrides for conversation list readability */
[data-theme="light"] .conversation-link,
[data-theme="light"] .conv-name {
    color: var(--color-text-primary);
}

[data-theme="light"] .conv-preview {
    color: var(--color-text-secondary);
}

[data-theme="light"] .conversation-link.active {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

[data-theme="light"] .conversation-link.active .conv-preview {
    color: var(--color-text-secondary);
}

.conv-name {
    font-weight: 500;
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 2.75rem;
    box-sizing: border-box;
}

.conv-preview {
    font-size: 13px;
    color: var(--color-text-secondary, #64748b);
    display: block;
    margin-top: 4px;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.35;
    box-sizing: border-box;
}

.conv-unread-badge {
    position: absolute;
    right: 12px;
    top: 14px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-clay-card);
}

.conv-unread-badge.is-hidden {
    display: none;
}

.conversation-pin-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-input, var(--radius-base));
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.conversation-pin-btn:hover {
    opacity: 1;
    color: var(--color-primary);
    background: var(--color-muted);
}

.conversation-item.is-pinned .conversation-pin-btn {
    opacity: 1;
    color: var(--color-primary);
}

.conversation-item:hover .conversation-pin-btn {
    opacity: 1;
}

.clay-file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    color: var(--color-text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Inside message bubbles (e.g. voice call ended): no glow/shadow */
.message-bubble .clay-file-link {
    box-shadow: none;
    border: 1px solid var(--color-border);
}

.clay-file-link:active {
    box-shadow: var(--shadow-clay-pressed);
    transform: scale(0.98);
}

.message-bubble .clay-file-link:active {
    box-shadow: none;
}

/* Empty state inside chat sidebar - match app sidebar panel style */
.chat-sidebar .empty-state {
    margin: 0 0.75rem;
    padding: 1rem 0.75rem;
    text-align: center;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-input);
}

.empty-state {
    padding: 1.5rem 1.25rem;
    text-align: center;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.empty-state-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text-primary);
    margin: 0 0 0.5rem;
}

.empty-state-text {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.main-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.main-empty .clay-empty-icon {
    margin-bottom: 24px;
}

.main-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 8px;
}

.main-empty-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    padding: 1rem;
    background: var(--color-bg-primary);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
}

.chat-main .chat-room {
    flex: 1;
    align-self: stretch;
    width: 100%;
    max-width: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-panel);
    background: var(--color-surface);
    overflow: hidden;
}

.welcome-panel {
    text-align: center;
}

.welcome-panel h1 {
    margin-top: 0;
}

.back-link {
    color: var(--color-primary, #7c3aed);
    text-decoration: none;
}

.chat-room {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.chat-header,
.chat-main .chat-room .chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-surface);
    border-radius: var(--radius-base) var(--radius-base) 0 0;
}

.chat-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.chat-header-avatar.clickable-avatar:hover {
    transform: scale(1.08);
    filter: brightness(1.15);
}

.chat-header-avatar svg {
    width: 26px;
    height: 26px;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
    transition: opacity 0.2s ease;
}

.chat-header-info.clickable-info:hover {
    opacity: 0.8;
}

.chat-header-info.clickable-info:hover .chat-header-name {
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.chat-header-name {
    margin: 0 0 2px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.3;
}

.chat-header-status {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.typing-indicator {
    font-size: 0.8rem;
    color: var(--color-primary);
    font-style: italic;
}

.chat-header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chat-header-actions .call-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.2rem;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    color: var(--color-text-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
}

.chat-header-actions .call-btn:hover {
    transform: scale(1.05);
}

.chat-header-actions .call-btn:active {
    transform: scale(0.95);
}

/* More menu dropdown */
.more-menu-wrap {
    position: relative;
}

.more-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 220px;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    padding: 8px 0;
    z-index: 1000;
}

.more-dropdown[hidden] {
    display: none;
}

.dropdown-item-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    transition: background 0.2s;
    pointer-events: auto;
}

.dropdown-item-btn:hover {
    background: var(--color-surface-hover);
}

.dropdown-item-btn * {
    pointer-events: none;
}

.dropdown-icon {
    font-size: 18px;
    width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dropdown-divider {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* Merged header styles */
.merged-header {
    justify-content: space-between;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-sidebar-collapse-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

/* Center both icons with absolute positioning so expanded and collapsed states align the same */
.chat-sidebar-collapse-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    flex-shrink: 0;
}

.chat-sidebar-collapse-btn .hidden {
    visibility: hidden !important;
    pointer-events: none !important;
}

.chat-sidebar-collapse-btn:hover {
    color: var(--color-primary);
    transform: scale(1.02);
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
}

.chat-sidebar-collapse-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.chat-sidebar-collapse-btn:focus {
    outline: none;
}

.chat-sidebar-collapse-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
}

@media (min-width: 768px) {
    .chat-sidebar-collapse-btn.hide-mobile {
        display: inline-flex;
    }
}

.back-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease;
    text-decoration: none;
    color: var(--color-text-primary);
}

.back-btn:hover {
    transform: scale(1.05);
}

.back-btn svg {
    display: block;
}

.user-pill-compact {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.user-pill-compact .user-pill-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.user-pill-compact .user-pill-avatar svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.theme-toggle-inline {
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.user-pill-wrap {
    position: relative;
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    margin: -8px -8px 8px;
}

.dropdown-header--with-avatar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-header-text {
    min-width: 0;
}

.dropdown-header-text strong {
    display: block;
    color: var(--color-text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.dropdown-header-text small {
    display: block;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.dropdown-header strong {
    display: block;
    color: var(--color-text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.dropdown-header small {
    display: block;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.theme-toggle-inline {
    font-size: 18px;
}

.chat-messages-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
    position: relative;
}

.chat-date-overlay {
    position: sticky;
    top: 12px;
    align-self: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-secondary);
    z-index: 2;
}

.chat-messages {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-messages-empty {
    margin: auto;
    padding: 2.5rem 1.5rem;
    text-align: center;
    font-size: 1rem;
    color: var(--color-text-secondary);
    max-width: 320px;
    line-height: 1.5;
}

.chat-messages:not(:has(.message-bubble)) {
    display: flex;
    flex-direction: column;
}

.chat-messages:not(:has(.message-bubble)) .chat-messages-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.chat-messages-empty-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.9em;
    opacity: 0.85;
}

.chat-input-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 1rem 0.75rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-base) var(--radius-base);
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.chat-input-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.chat-text-row {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-form.chat-input--voice .chat-text-row {
    display: none;
}

.chat-input-form .clay-input,
.chat-input-form .chat-message-input,
.chat-message-input {
    flex: 1;
    min-width: 0;
}

.chat-send-btn {
    flex-shrink: 0;
    padding: 12px 20px;
}

.attach-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.reply-preview {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin: 0 20px 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-input);
    border-radius: var(--radius-input);
}

.file-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-modal.hidden {
    display: none;
}

.file-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.file-preview-panel {
    position: relative;
    width: min(900px, 94vw);
    max-height: 92vh;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-clay-card);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.file-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-preview-title {
    font-weight: 700;
    color: var(--color-text-primary);
}

.file-preview-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: auto;
}

.file-preview-media img,
.file-preview-media video {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: var(--shadow-clay-card);
    background: var(--color-bg-primary);
}

.file-preview-media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    font-size: 32px;
    color: var(--color-text-secondary);
}

.file-preview-name {
    font-weight: 600;
    color: var(--color-text-primary);
}

.file-preview-size {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.file-preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.chat-input-form .chat-message-input,
.chat-message-input {
    resize: none;
    max-height: 140px;
    line-height: 1.4;
    min-height: 48px;
    padding: 10px 14px;
}

.reply-text {
    flex: 1;
    font-size: 13px;
    color: #64748b;
}

.reply-cancel {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
}

.chat-search-bar {
    position: absolute;
    top: 12px;
    right: 12px;
    left: auto;
    transform: none;
    width: min(420px, 86%);
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
}

.chat-search-bar .clay-input {
    flex: 1;
    height: 34px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
}

.chat-search-bar .clay-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
}

.chat-search-count {
    font-size: 12px;
    color: var(--color-text-secondary);
    min-width: 36px;
    text-align: center;
}

.msg-search-hit {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

.voice-recording {
    margin: 0;
    padding: 12px 14px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    box-shadow: var(--shadow-clay-card);
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.voice-recording-inline {
    width: 100%;
    display: none;
}

.voice-recording-inline:not([hidden]) {
    display: flex;
}

.chat-input-form.chat-input--voice .voice-recording-inline {
    display: flex;
}

.voice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.voice-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
    animation: voicePulse 1.4s ease-in-out infinite;
}

.voice-wave {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    flex: 1;
    justify-content: flex-start;
    opacity: 0.85;
    padding: 0;
    border-radius: 0;
    background: transparent;
}

.voice-wave canvas {
    width: 100%;
    height: 18px;
    display: block;
}


.voice-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.voice-actions .clay-btn {
    min-width: 68px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 13px;
}

.voice-actions .clay-btn-primary {
    box-shadow: 0 10px 24px rgba(124, 103, 248, 0.35);
}

.voice-preview {
    display: flex;
    align-items: center;
}

.voice-preview audio {
    width: 100%;
}

.voice-label {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.voice-timer {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

@keyframes voicePulse {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Emoji picker — claymorphism theme (matches project UI) */
emoji-picker.emoji-picker,
.emoji-picker {
    position: fixed;
    z-index: 9999;
    background: var(--color-surface) !important;
    box-shadow: var(--shadow-clay-card);
    border-radius: var(--radius-base);
    border: 1px solid var(--color-border);
    /* Theme the inner Shadow DOM via CSS variables (emoji-picker-element API) */
    --background: var(--color-surface);
    --border-color: var(--color-border);
    --border-radius: var(--radius-base);
    --border-size: 1px;
    --button-active-background: var(--color-muted);
    --button-hover-background: var(--color-muted);
    --category-font-color: var(--color-text-primary);
    --indicator-color: var(--color-primary);
    --indicator-height: 3px;
    --input-border-color: var(--color-border);
    --input-border-radius: var(--radius-input);
    --input-font-color: var(--color-text-primary);
    --input-placeholder-color: var(--color-text-secondary);
    --outline-color: transparent;
    --outline-size: 0;
}

.emoji-picker.hidden {
    display: none;
}

.msg-reply {
    font-size: 12px;
    opacity: 0.95;
    margin-bottom: 6px;
    display: block;
    width: 100%;
    max-width: 100%;
    text-align: left;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font: inherit;
    color: inherit;
    line-height: 1.35;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.msg-reply:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.message-bubble--sent .msg-reply {
    background: rgba(255, 255, 255, 0.14);
}

.message-bubble--sent .msg-reply:hover {
    background: rgba(255, 255, 255, 0.22);
}

.msg-forwarded {
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 4px;
}

.msg-date-separator {
    position: relative;
    width: 100%;
    align-self: center;
    margin: 12px 0 6px;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.msg-date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--color-border);
    opacity: 0.6;
}

.msg-date-separator::after {
    content: attr(data-label);
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    position: relative;
    z-index: 1;
}

.edit-preview {
    margin: 0 24px 10px;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.edit-cancel {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--color-text-secondary);
}

/* Message bubbles */
.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    margin-bottom: 4px;
    word-wrap: break-word;
    position: relative;
    display: inline-block;
    align-self: flex-start;
}

.msg-reaction-bar {
    position: absolute;
    top: -22px;
    left: 8px;
    display: none;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    background: var(--color-surface);
    border-radius: 999px;
    padding: 4px 6px;
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    z-index: 3;
}

.message-bubble--sent .msg-reaction-bar {
    left: auto;
    right: 40px;
}

.message-bubble:hover .msg-reaction-bar {
    display: flex;
}

.reaction-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.reaction-btn:focus,
.reaction-btn:focus-visible {
    outline: none;
}

.reaction-btn:active {
    background: transparent;
}

.reaction-btn--more {
    font-size: 12px;
}


.msg-more-wrap {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 4;
}

.msg-more-open .msg-more-wrap:not(.is-open) .msg-more-btn {
    opacity: 0;
    pointer-events: none;
}

.msg-more-btn {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-size: 14px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.message-bubble--sent .msg-more-btn {
    background: rgba(255, 255, 255, 0.2);
}

.msg-more-menu {
    position: absolute;
    top: 28px;
    right: 0;
    min-width: 120px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-clay-card);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    padding: 6px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.msg-more-menu.is-floating {
    position: fixed;
    right: auto;
    width: max-content;
    min-width: 120px;
    z-index: 10000;
}

.msg-menu-item {
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 12px;
}

.msg-menu-item:hover {
    background: var(--color-surface-hover);
}

.message-bubble:hover .msg-more-btn {
    opacity: 1;
}

.message-bubble--selected {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* All sent messages (regular, voice, system): same background as Send button */
.message-bubble--sent {
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    border-radius: 20px 20px 4px 20px;
    align-self: flex-end;
    margin-left: auto;
    box-shadow: none;
    border: 1.5px solid hsl(250, 35%, 45%);
}

.message-bubble--received {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-clay-panel);
    border-radius: 20px 20px 20px 4px;
    border: 1px solid var(--color-border);
}

/* System task message: same background as Send button (primary), no heavy glow */
.message-bubble--system-task {
    align-self: flex-start;
    margin-left: 0;
    max-width: 320px;
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    box-shadow: none;
    border-radius: 20px 20px 20px 4px;
    border: 1px solid hsl(250, 35%, 45%);
    padding: 1rem 1.25rem;
}

/* Override sent styling so system task uses primary (Send button) color, left-aligned */
.message-bubble--system-task.message-bubble--sent {
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    align-self: flex-start;
    margin-left: 0;
    border-color: hsl(250, 35%, 45%);
}

/* Same task card look in all panels: when "received" (other user view), still use primary bubble + white text */
.message-bubble--received.message-bubble--system-task {
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid hsl(250, 35%, 45%);
    border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 0.25rem;
    align-self: flex-start;
    margin-left: 0;
}

/* Icons and controls on primary background (match Send button) */
.message-bubble--system-task .msg-more-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-primary-foreground);
    opacity: 1;
}

.message-bubble--system-task .msg-more-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    color: var(--color-primary-foreground);
}

.message-bubble--system-task .msg-reaction-bar {
    left: 8px;
    right: auto;
}

.message-bubble--system-task .reaction-btn {
    background: transparent;
    color: var(--color-primary-foreground);
}

.message-bubble--system-task .reaction-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.message-bubble--system-task .reaction-btn:focus,
.message-bubble--system-task .reaction-btn:focus-visible {
    outline: none;
}

.message-bubble--system-task .msg-reaction-pill {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-primary-foreground);
}

.message-bubble--system-task .msg-reaction-pill:hover {
    background: rgba(255, 255, 255, 0.25);
}

.message-bubble--system-task .msg-reaction-pill.is-active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

.message-bubble--system-task .msg-reaction-pill:focus,
.message-bubble--system-task .msg-reaction-pill:focus-visible {
    outline: none;
}

.message-bubble--system-task .msg-time {
    color: rgba(255, 255, 255, 0.85);
    opacity: 1;
}

/* Task card text on primary background: ensure visibility */
.message-bubble--system-task .msg-task-card-title {
    color: #fff;
}

.message-bubble--system-task .msg-task-card-meta,
.message-bubble--system-task .msg-task-card-label {
    color: rgba(255, 255, 255, 0.92);
}

.message-bubble--system-task .msg-task-card-label {
    font-weight: 600;
}

.message-bubble--system-task .msg-task-card-meta-wrap {
    border-bottom-color: rgba(255, 255, 255, 0.25);
}

.message-bubble--system-task .msg-task-card-badge {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.message-bubble--system-task .msg-task-card-link {
    color: rgba(255, 255, 255, 0.95);
}

.message-bubble--system-task .msg-task-card-link:hover {
    color: #fff;
    text-decoration: underline;
}

.msg-task-card {
    padding: 0;
    min-width: 200px;
}

.msg-task-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.msg-task-card-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(124, 58, 237, 0.15);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
}

.msg-task-card-status {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-pill);
    background: var(--color-muted);
    color: var(--color-text-secondary);
}

.msg-task-card-status--pending { background: rgba(234, 179, 8, 0.25); color: #b45309; }
.msg-task-card-status--in_progress { background: rgba(59, 130, 246, 0.25); color: #1d4ed8; }
.msg-task-card-status--completed { background: rgba(34, 197, 94, 0.25); color: #15803d; }
.msg-task-card-status--overdue { background: rgba(239, 68, 68, 0.25); color: #dc2626; }
.msg-task-card-status--cancelled { background: var(--color-muted); color: var(--color-text-secondary); }

.msg-task-card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    line-height: 1.35;
    color: var(--color-text-primary);
}

.msg-task-card-meta-wrap {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.msg-task-card-meta {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.35rem;
    opacity: 1;
}

.msg-task-card-meta:last-child {
    margin-bottom: 0;
}

.msg-task-card-label {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-right: 0.35rem;
    opacity: 1;
}

.msg-task-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.msg-task-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-input, var(--radius-base));
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: var(--shadow-clay-card);
}

.msg-task-card-btn--primary {
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground, #fff);
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
}

.msg-task-card-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card)), var(--shadow-focus);
}

.msg-task-card-btn--primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-clay-pressed);
}

.msg-task-card-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.msg-task-card-link:hover {
    color: var(--color-primary-hover, var(--color-primary));
    text-decoration: underline;
}

.message-bubble .msg-content {
    display: block;
    margin-bottom: 4px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-media-preview {
    margin: 8px 0;
    display: inline-block;
    max-width: 100%;
}

.msg-media-preview.voice-msg {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.06);
}

.message-bubble--sent .msg-media-preview.voice-msg {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.voice-play-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    color: #111111;
    box-shadow:
        2px 2px 6px 0px rgba(0, 0, 0, 0.12),
        inset 0 1px 2px rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.message-bubble--sent .voice-play-btn {
    background: #f8f7ff;
    color: #1a1a1a;
    box-shadow:
        2px 2px 6px 0px rgba(0, 0, 0, 0.15),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.voice-bar {
    position: relative;
    flex: 1;
    min-width: 120px;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.32);
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.voice-progress {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, #ffffff, rgba(255, 255, 255, 0.65));
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.35);
}

.voice-duration {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.82);
    min-width: 44px;
    text-align: right;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.voice-audio {
    display: none;
}

.msg-link-preview {
    margin: 8px 0;
}

.link-preview-card {
    display: flex;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: var(--shadow-clay-card);
}

.link-preview-card img {
    width: 120px;
    height: 90px;
    object-fit: cover;
}

.link-preview-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.link-preview-title {
    font-size: 13px;
    font-weight: 700;
}

.link-preview-desc {
    font-size: 12px;
    color: var(--color-text-secondary);
    max-height: 32px;
    overflow: hidden;
}

.link-preview-site {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.msg-media-preview img,
.msg-media-preview video {
    border-radius: 8px;
    display: block;
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
}

.msg-media-preview video {
    background: #000;
}

.chat-video-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    vertical-align: middle;
    line-height: 0;
}

.chat-video-wrap:focus-visible {
    outline: 2px solid var(--color-primary, #8b5cf6);
    outline-offset: 2px;
}

.chat-inline-video,
.msg-media-preview--video .chat-video-wrap video {
    display: block;
    min-height: 120px;
    max-height: min(50vh, 320px);
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #0f0f0f;
    border-radius: 10px;
}

.chat-video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.25) 100%);
    border-radius: 10px;
}

.chat-video-play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.chat-video-play-btn svg {
    width: 26px;
    height: 26px;
    margin-left: 4px;
}

.message-bubble--sent .chat-video-play-btn {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.msg-file-link {
    display: inline-block;
    padding: 8px 12px;
    background: var(--color-surface-hover);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text-primary);
    font-size: 14px;
    border: 1px solid var(--color-border);
    transition: background 0.2s;
}

.msg-file-link:hover {
    background: var(--color-primary);
    color: white;
}

.message-bubble .msg-time {
    font-size: 11px;
    opacity: 0.7;
    display: inline-block;
    margin-top: 4px;
}

.msg-reactions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.msg-reaction-pill {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    color: var(--color-text-primary);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.msg-reaction-pill:focus,
.msg-reaction-pill:focus-visible {
    outline: none;
}

.msg-reaction-pill:active {
    opacity: 0.9;
}

.msg-reaction-pill.is-active {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.msg-edited {
    margin-right: 6px;
    font-size: 10px;
    opacity: 0.8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: inherit;
}

.msg-star-indicator {
    margin-right: 6px;
    font-size: 11px;
    opacity: 0.9;
}

.message-bubble .msg-status {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 5px;
}

.message-bubble .msg-status .msg-tick-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.message-bubble--sent .msg-status--sent {
    color: rgba(255, 255, 255, 0.7);
}

.message-bubble--received .msg-status--sent {
    color: var(--color-text-secondary, #64748b);
}

.message-bubble--sent .msg-status--read {
    color: #b8e8ff;
}

.message-bubble--received .msg-status--read {
    color: #0ea5e9;
}

.message-bubble .msg-status--sending {
    color: rgba(255, 255, 255, 0.75);
}

.message-bubble--received .msg-status--sending {
    color: var(--color-text-secondary);
}

.msg-sending-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    animation: msg-sending-spin 0.65s linear infinite;
    vertical-align: middle;
}

.message-bubble--received .msg-sending-spinner {
    border-color: rgba(100, 116, 139, 0.35);
    border-top-color: var(--color-text-secondary, #64748b);
}

@keyframes msg-sending-spin {
    to {
        transform: rotate(360deg);
    }
}

.msg-status--failed .msg-send-failed-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.message-bubble--send-failed.message-bubble--sent {
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.5);
}

.pinned-banner {
    margin: 0 24px 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pinned-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    flex: 1;
}

.pinned-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pinned-close {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-secondary);
}

.chat-load-more,
.chat-start-indicator {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    padding: 6px 0 10px;
}

.edit-history-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.edit-history-modal.hidden {
    display: none;
}

.edit-history-card {
    width: min(520px, 92vw);
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-clay-card);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edit-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.edit-history-close {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 18px;
}

.edit-history-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
}

.edit-history-item {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
}

.edit-history-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.edit-history-content {
    font-size: 13px;
    color: var(--color-text-primary);
    white-space: pre-wrap;
}

.edit-history-empty,
.edit-history-loading {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.forward-bar {
    margin: 0 24px 10px;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.forward-actions {
    display: flex;
    gap: 8px;
}

.forward-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.forward-modal.hidden {
    display: none;
}

.forward-modal-card {
    width: min(520px, 92vw);
    background: var(--color-surface);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-clay-card);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.forward-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.forward-modal-head h3 {
    margin: 0 0 4px;
    font-size: 18px;
    color: var(--color-text-primary);
}

.forward-modal-head p {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.forward-count-pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--color-input-bg);
    box-shadow: var(--shadow-clay-input);
    font-size: 12px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.forward-search .clay-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
}

.forward-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 2px;
}

.forward-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-clay-input);
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.forward-item:hover {
    box-shadow: var(--shadow-clay-card);
    transform: translateY(-1px);
}

.forward-item input {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-input);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.forward-item input:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-clay-btn-primary);
}

.forward-item input:checked::after {
    content: '✓';
    color: var(--color-primary-foreground);
    font-size: 12px;
    font-weight: 700;
}

.forward-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(124, 103, 248, 0.2);
    color: var(--color-text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.forward-name {
    font-weight: 600;
}

.forward-item input:checked ~ .forward-avatar {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
}

.forward-empty {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    padding: 10px 0;
}

.forward-modal-actions {
    justify-content: flex-end;
}

.message-bubble--sent .msg-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-bubble--received .msg-time {
    color: var(--color-text-secondary);
}

/* Profile Settings */
.profile-settings-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* Starred Messages */
.starred-container {
    max-width: 760px;
    margin: 40px auto;
    padding: 0 24px;
}

.starred-card {
    padding: 24px;
}

.starred-header h1 {
    margin: 0 0 6px;
}

.starred-header p {
    margin: 0 0 18px;
    color: var(--color-text-secondary);
}

.starred-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.starred-item {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
}

.starred-item:hover {
    box-shadow: var(--shadow-hover);
}

.starred-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.starred-preview {
    font-size: 14px;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.starred-time {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.starred-empty {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 20px 0;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-clay-card);
    overflow: hidden;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.error-msg {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    padding: 12px 16px;
    border-radius: var(--radius-input);
    margin-bottom: 24px;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

@media (max-width: 600px) {
    .profile-settings-container {
        padding: 0 16px;
    }

    .profile-settings-container .clay-card {
        padding: 24px 20px;
    }

    .profile-settings-container form>div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* Call page */
.call-container {
    max-width: 800px;
    margin: 40px auto;
    text-align: center;
}

.call-videos {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 24px 0;
}

.video-container {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.clay-video-box {
    box-shadow: var(--shadow-clay-card);
}

.video-container video {
    width: 100%;
    max-width: 320px;
    display: block;
}

.video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.call-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 24px 0;
}

.call-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
}

.call-end {
    background: #dc2626;
    color: white;
}

/* Conversation page: responsive and empty-area utilization */
@media (max-width: 900px) {
    .chat-sidebar {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
    }

    .chat-main {
        padding: 16px;
    }

    .chat-room {
        max-width: 100%;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-form {
        padding: 8px 12px 12px;
    }
}

@media (max-width: 768px) {
    .chat-sidebar {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
        padding: 0;
    }

    .chat-main {
        padding: 12px;
    }

    .chat-header-avatar {
        width: 42px;
        height: 42px;
    }

    .chat-header-avatar svg {
        width: 22px;
        height: 22px;
    }

    .chat-header-name {
        font-size: 1rem;
    }

    .chat-header-actions .call-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .chat-messages-empty {
        padding: 32px 20px;
        font-size: 0.95rem;
    }

    .attach-btn {
        width: 44px;
        height: 44px;
    }

    .chat-send-btn {
        padding: 10px 16px;
    }
}

@media (max-width: 600px) {
    .chat-layout {
        flex-direction: column;
        min-height: calc(100vh - 68px);
    }

    .chat-sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 0 0 auto;
        max-height: 45vh;
        border-radius: var(--radius-base) var(--radius-base) 0 0;
        padding: 0;
    }

    .chat-sidebar-brand {
        margin: 0.5rem 0.75rem 0.5rem;
        padding: 0.75rem 1rem;
    }

    .chat-sidebar .sidebar-header {
        margin: 0 0.75rem 0.5rem;
        padding: 0.75rem 1rem;
    }

    .chat-sidebar .sidebar-header-top {
        margin-bottom: 0.75rem;
    }

    .conversation-list {
        padding: 0.5rem 0.75rem;
    }

    .chat-sidebar .empty-state {
        margin: 0 0.75rem 0.5rem;
    }

    .chat-main {
        flex: 1;
        padding: 12px;
        min-height: 0;
    }

    .chat-room {
        min-height: 300px;
    }

    .chat-messages-wrap {
        min-height: 180px;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        max-height: 40vh;
    }

    .chat-sidebar .sidebar-header,
    .chat-sidebar-brand {
        padding: 0.625rem 0.75rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    .sidebar-header-top h2 {
        font-size: 0.9375rem;
    }

    .conversation-list {
        padding: 0.5rem;
    }

    .chat-main {
        padding: 8px;
    }

    .chat-header {
        padding: 10px 12px;
        gap: 10px;
    }

    .chat-header-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-header-avatar svg {
        width: 20px;
        height: 20px;
    }

    .chat-header-name {
        font-size: 0.95rem;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-form {
        padding: 6px 10px 10px;
        gap: 6px;
    }

    .reply-preview {
        margin: 0 12px 10px;
        padding: 8px 12px;
    }
}

/* Profile Settings - Responsive Styles */
.profile-settings-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.profile-card {
    width: 100%;
    max-width: 1200px;
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: slideIn 0.3s ease;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    min-width: 80px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-clay-card);
}

.profile-panels {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-areas:
        "photo photo photo photo photo photo photo photo photo photo photo photo"
        "basic basic basic basic basic basic basic appearance appearance appearance appearance appearance"
        "notifications notifications notifications notifications notifications notifications notifications privacy privacy privacy privacy privacy"
        "about about about about about about about about about about about about";
    gap: 18px;
}

.profile-panel {
    background: var(--color-surface);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    grid-column: span 6;
}

.profile-panel--full {
    grid-column: 1 / -1;
}

.profile-panel--photo {
    grid-area: photo;
}

.profile-panel--basic {
    grid-area: basic;
}

.profile-panel--about {
    grid-area: about;
}

.profile-panel--privacy {
    grid-area: privacy;
}

.profile-panel--appearance {
    grid-area: appearance;
}

.profile-panel--notifications {
    grid-area: notifications;
}

.profile-panel-head h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.profile-panel-head p {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.profile-header-text {
    flex: 1;
    min-width: 0;
}

.profile-header-text h1 {
    margin: 0 0 4px;
    font-size: 24px;
    color: var(--color-text-primary);
    word-break: break-word;
}

.profile-header-text p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
    word-break: break-word;
}

.error-msg {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: var(--radius-input);
    font-size: 14px;
    animation: shake 0.3s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.profile-avatar-preview {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-clay-card);
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-preview .avatar-fallback {
    font-weight: 700;
    color: var(--color-text-primary);
}

.profile-avatar-actions .file-input {
    display: none;
}

.profile-section h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
}

.toggle-label {
    font-size: 14px;
    color: var(--color-text-primary);
}

.profile-panel .toggle-row input[type="checkbox"] {
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), inset 0 -1px 2px rgba(255, 255, 255, 0.06);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.profile-panel .toggle-row input[type="checkbox"]:checked {
    background: linear-gradient(145deg, rgba(124, 103, 248, 0.9), rgba(124, 103, 248, 0.5));
    border-color: rgba(124, 103, 248, 0.6);
    box-shadow: 0 6px 16px rgba(124, 103, 248, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.35);
}

.profile-panel .toggle-row input[type="checkbox"]:checked::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.profile-panel .toggle-row input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(124, 103, 248, 0.6);
    outline-offset: 2px;
}

.form-row-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.profile-panel .input-wrap,
.profile-panel select.clay-input,
.profile-panel textarea.clay-input {
    width: 100%;
}

.profile-panel select.clay-input {
    appearance: none;
    background-image: linear-gradient(145deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0)),
        radial-gradient(circle at right 12px center, rgba(255, 255, 255, 0.35) 0 2px, transparent 3px),
        linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.7) 50%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.7) 50%, transparent 50%);
    background-position: 0 0, 0 0, right 12px center, right 6px center;
    background-size: 100% 100%, 100% 100%, 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-clay-input);
}

.profile-panel select.clay-input:focus {
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
}

.profile-panel .input-wrap input {
    min-width: 0;
    width: 100%;
}

.profile-panel .input-wrap {
    overflow: hidden;
}

.form-hint {
    color: var(--color-text-secondary);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    margin-top: 8px;
    flex-wrap: wrap-reverse;
}

.btn-cancel {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.account-info-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.account-info-section h3 {
    font-size: 16px;
    margin: 0 0 12px;
    color: var(--color-text-primary);
}

.account-info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--color-text-secondary);
    word-break: break-word;
    gap: 12px;
}

.status-verified {
    color: var(--color-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Tablet - Medium screens (768px and up) */
@media (max-width: 767px) {
    .profile-settings-container {
        padding: 16px 8px;
    }

    .profile-card {
        max-width: 100%;
        padding: 24px 16px;
        gap: 20px;
    }

    .profile-panels {
        grid-template-columns: 1fr;
    }

    .profile-header {
        gap: 12px;
    }

    .profile-avatar-large {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }

    .profile-header-text h1 {
        font-size: 20px;
    }

    .profile-header-text p {
        font-size: 13px;
    }

    .form-row-two {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .clay-btn {
        width: 100%;
    }

    .info-row {
        flex-direction: column;
        gap: 4px;
    }

    /* Merged header mobile adjustments */
    .merged-header {
        padding: 12px 16px;
    }

    .back-btn {
        width: 36px;
        height: 36px;
    }

    .chat-header-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-header-avatar svg {
        width: 20px;
        height: 20px;
    }

    .chat-header-name {
        font-size: 1rem;
    }

    .chat-header-actions {
        gap: 6px;
    }

    .chat-header-actions .call-btn,
    .user-pill-compact,
    .theme-toggle-inline {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* Mobile - Small screens (480px and up) */
@media (max-width: 479px) {
    .profile-settings-container {
        padding: 12px 0;
    }

    .profile-card {
        border-radius: 16px 16px 0 0;
        padding: 20px 12px;
        gap: 16px;
    }

    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }

    .profile-avatar-large {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }

    .profile-header-text h1 {
        font-size: 18px;
    }

    .profile-header-text p {
        font-size: 12px;
    }

    .form-group label {
        font-size: 14px;
    }

    .form-hint {
        font-size: 11px;
    }

    .form-actions {
        gap: 8px;
    }

    .form-actions .clay-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .account-info-section h3 {
        font-size: 14px;
    }

    .info-row {
        font-size: 13px;
    }

    .input-wrap {
        padding: 8px 8px 8px 12px;
    }

    textarea.clay-input {
        min-height: 70px;
        font-size: 14px;
    }
}

/* Extra small - Very small screens (under 375px) */
@media (max-width: 374px) {
    .profile-card {
        padding: 16px 8px;
    }

    .profile-avatar-large {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    .profile-header-text h1 {
        font-size: 16px;
    }

    .profile-header-text p {
        font-size: 11px;
    }

    .form-actions .clay-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .info-row {
        font-size: 12px;
    }
}

@media (max-width: 1024px) {
    .profile-card {
        padding: 28px;
    }

    .profile-panels {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "photo photo"
            "basic basic"
            "appearance appearance"
            "about about"
            "privacy privacy"
            "notifications notifications";
    }

    .profile-panel--full {
        grid-column: 1 / -1;
    }

    .profile-panel--basic,
    .profile-panel--appearance,
    .profile-panel--privacy,
    .profile-panel--notifications {
        grid-column: span 1;
    }
}

@media (max-width: 680px) {
    .profile-card {
        padding: 22px;
    }

    .profile-avatar-row {
        align-items: flex-start;
    }

    .form-row-two {
        grid-template-columns: 1fr;
    }

    .profile-panels {
        grid-template-columns: 1fr;
        grid-template-areas:
            "photo"
            "basic"
            "appearance"
            "about"
            "privacy"
            "notifications";
    }

    .profile-panel {
        grid-column: 1 / -1;
    }
}

/* Sidebar collapse icon toggle */
.hidden {
    display: none !important;
}

/* ─── App sidebar (claymorphism) ─────────────────────────────────────────────── */
:root {
    --app-sidebar-width: 260px;
    --app-sidebar-collapsed: 72px;
    --app-header-height: 64px;
    --chat-sidebar-collapsed: 72px;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--app-sidebar-width);
    height: 100vh;
    background: var(--gradient-surface, var(--color-surface));
    border-radius: 0 var(--radius-base) var(--radius-base) 0;
    box-shadow: var(--shadow-clay-card);
    z-index: var(--z-sidebar, 500);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Sidebar collapsed state (desktop) */
.app-sidebar.collapsed {
    width: var(--app-sidebar-collapsed);
    overflow-x: hidden;
    min-width: var(--app-sidebar-collapsed);
}

.app-sidebar.collapsed .app-sidebar-brand__name {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-brand__link {
    justify-content: center;
}

/* app_sidebar.html (admin/super_admin fallback) collapsed */
.app-sidebar.collapsed .app-sidebar-user {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-brand .app-sidebar-logo {
    font-size: 0;
    display: flex;
    justify-content: center;
}

.app-sidebar.collapsed .app-sidebar-brand .app-sidebar-logo::first-letter {
    font-size: 1.125rem;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-link,
.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-dropdown .dropdown-trigger {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    min-width: 0;
    max-width: 100%;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-link-label,
.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-dropdown .dropdown-trigger .app-sidebar-link-label {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-dropdown-arrow {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-link .app-sidebar-badge {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-link-icon,
.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-dropdown .dropdown-trigger .app-sidebar-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.app-sidebar.collapsed .app-sidebar-nav {
    overflow-x: hidden;
    overflow-y: auto;
}

.app-sidebar.collapsed .app-sidebar-nav .app-sidebar-dropdown-menu {
    left: 100%;
    right: auto;
    margin-left: 0.5rem;
    min-width: 180px;
}

.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-link,
.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-btn {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-link-label,
.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-btn .app-sidebar-link-label {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-link-icon,
.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-btn .app-sidebar-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.app-sidebar-footer .app-sidebar-link-icon--svg,
.app-sidebar-footer .app-sidebar-btn .app-sidebar-link-icon--svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-sidebar-footer .app-sidebar-link-icon--svg svg,
.app-sidebar-footer .app-sidebar-btn .app-sidebar-link-icon--svg svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
}

.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-link-icon--svg svg,
.app-sidebar.collapsed .app-sidebar-footer .app-sidebar-btn .app-sidebar-link-icon--svg svg {
    width: 22px;
    height: 22px;
}

.app-sidebar-brand {
    padding: 1rem 1rem;
    margin: 0.75rem 0.75rem 0.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.app-sidebar-brand:hover {
    box-shadow: var(--shadow-clay-card), var(--shadow-focus);
    transform: translateY(-2px);
}

.app-sidebar-brand:active {
    transform: translateY(0);
    box-shadow: var(--shadow-clay-pressed);
}

.app-sidebar-brand__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: color 0.2s ease;
}

.app-sidebar-brand__link:hover {
    color: var(--color-primary);
}

.app-sidebar-brand__icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground);
    border-radius: 50%;
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
}

.app-sidebar-brand__icon svg {
    width: 22px;
    height: 22px;
}

.app-sidebar-brand__name {
    font-weight: 700;
    font-size: 1.125rem;
}

.app-sidebar-user {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    padding-left: 0.15rem;
}

.app-sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 0.5rem 0.75rem;
    overflow-y: auto;
}

.app-sidebar-nav .app-sidebar-link {
    margin-bottom: 0.4rem;
    border-radius: var(--radius-input, var(--radius-base));
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-sidebar-link-icon {
    flex-shrink: 0;
    margin-right: 0.35rem;
    font-size: 1rem;
}

.app-sidebar-link-label {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 0.9375rem;
}

.app-sidebar-link:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-clay-card);
}

.app-sidebar-link:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.app-sidebar-link--secondary {
    font-size: 0.9rem;
    opacity: 0.92;
}

/* Sidebar "Workspace chats" dropdown */
.app-sidebar-dropdown {
    position: relative;
    margin-bottom: 0.4rem;
}

.app-sidebar-dropdown .dropdown-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    opacity: 0.92;
    border: none;
    border-radius: var(--radius-input, var(--radius-base));
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    color: var(--color-text-primary);
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-sidebar-dropdown .dropdown-trigger:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-clay-card);
}

.app-sidebar-dropdown-arrow {
    font-size: 0.65rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
}

.app-sidebar-dropdown-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    padding: 0.35rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-card);
    z-index: 250;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
}

/* Only the workspace list scrolls; exactly 3 items visible, rest scroll */
.app-sidebar-dropdown-list {
    max-height: 6.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.app-sidebar-dropdown-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.app-sidebar-dropdown-item {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-input, var(--radius-base));
    transition: background 0.15s ease;
}

a.app-sidebar-dropdown-item:hover {
    background: var(--color-muted);
}

.app-sidebar-dropdown-item--muted {
    color: var(--color-text-secondary);
    cursor: default;
}

.app-sidebar-dropdown-search-wrap {
    padding: 0.35rem 0.35rem 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.25rem;
}

.app-sidebar-dropdown-search {
    width: 100%;
    padding: 0.4rem 0.6rem 0.4rem 2rem;
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    background: var(--color-input-bg);
    border: none;
    border-radius: var(--radius-input, var(--radius-base));
    box-shadow: var(--shadow-clay-input);
    outline: none;
}

.app-sidebar-dropdown-search::placeholder {
    color: var(--color-text-secondary);
}

.app-sidebar-dropdown-search:focus {
    box-shadow: var(--shadow-clay-input), var(--shadow-focus);
}

.app-sidebar-dropdown-item[data-filter-hidden="true"] {
    display: none;
}

.app-sidebar-link.app-sidebar-btn {
    width: 100%;
    border: none;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    cursor: pointer;
    text-align: left;
    font: inherit;
    border-radius: var(--radius-input, var(--radius-base));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-sidebar-link.app-sidebar-btn:hover {
    transform: scale(1.02);
}

.app-sidebar-link.app-sidebar-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.app-sidebar-badge {
    min-width: 1.25rem;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
}

.app-sidebar-footer {
    padding: 0.75rem 0.75rem 1rem;
    margin: 0.5rem 0.75rem 0.75rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-input);
}

.app-sidebar-footer .app-sidebar-link {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius-input, var(--radius-base));
    margin-bottom: 0.25rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-sidebar-footer .app-sidebar-link:last-child {
    margin-bottom: 0;
}

.app-sidebar-footer .app-sidebar-link:hover {
    transform: scale(1.02);
}

.app-sidebar-footer .app-sidebar-link:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-clay-pressed);
}

.app-with-sidebar-main {
    margin-left: 0;
    min-height: 100vh;
    padding: clamp(0.75rem, 4vw, 1.5rem);
    transition: margin-left 0.25s ease;
    min-width: 0;
    overflow-x: hidden;
}

.app-with-sidebar-wrap {
    overflow-x: hidden;
}

.app-with-sidebar-wrap.has-sidebar .app-with-sidebar-main {
    margin-left: 0;
}

@media (min-width: 768px) {
    .app-with-sidebar-wrap.has-sidebar.sidebar-collapsed .app-with-sidebar-main {
        margin-left: var(--app-sidebar-collapsed);
    }
}

.app-sidebar-toggle {
    display: none;
    position: fixed;
    /* Align with header: same left as main padding, vertically centered with header row */
    top: calc(1.5rem + (var(--app-header-height, 64px) - 44px) / 2);
    left: 2rem;
    z-index: var(--z-sidebar-toggle, 510);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-card);
    cursor: pointer;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

.app-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: var(--z-sidebar-overlay, 400);
    opacity: 0;
    transition: opacity 0.2s;
}

.app-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ─── FAB (Floating Action Button) - mobile/tablet ────────────────────────────── */
.fab-container {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 180;
}

@media (max-width: 1023px) {
    .fab-container {
        display: block;
    }
}

@media (min-width: 1024px) {
    .fab-container {
        display: none !important;
    }
}

.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-primary, var(--color-primary));
    color: var(--color-primary-foreground, #fff);
    cursor: pointer;
    box-shadow: var(--shadow-clay-btn-primary, var(--shadow-clay-card));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab-button:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-focus, var(--shadow-clay-card));
}

.fab-button:active {
    transform: scale(0.96);
}

.fab-button .fab-icon-default,
.fab-button .fab-icon-close {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-button .fab-icon-close.hidden {
    display: none !important;
}

.fab-container.open .fab-button .fab-icon-default {
    display: none !important;
}

.fab-container.open .fab-button .fab-icon-close {
    display: flex !important;
}

.fab-button svg {
    width: 24px;
    height: 24px;
}

.fab-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 0.75rem;
    min-width: 200px;
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 181;
}

.fab-container.open .fab-menu {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 0.9375rem;
    border-radius: var(--radius-input, var(--radius-base));
    transition: background 0.15s ease;
}

.fab-menu-item:hover {
    background: var(--color-muted);
}

.fab-menu-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.fab-menu-icon--primary {
    background: var(--color-primary-muted, rgba(79, 70, 229, 0.15));
}

.fab-menu-icon--green {
    background: rgba(34, 197, 94, 0.15);
}

.fab-menu-icon--purple {
    background: rgba(147, 51, 234, 0.15);
}

.chat-widget-open .fab-container {
    display: none !important;
}

@media (min-width: 768px) {
    .app-with-sidebar-wrap.has-sidebar:not(.sidebar-collapsed) .app-with-sidebar-main {
        margin-left: var(--app-sidebar-width);
    }
}

@media (max-width: 767px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-sidebar-toggle {
        display: flex;
    }
}

.app-breadcrumbs {
    padding: 0.75rem 1.5rem 0;
}

.app-breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: clamp(0.8125rem, 2vw, 0.85rem);
    color: var(--color-text-secondary);
    min-width: 0;
}

.app-breadcrumbs li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.app-breadcrumbs-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 0.25rem;
    color: inherit;
}

.app-breadcrumbs-icon svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.app-breadcrumbs li:not(:last-child)::after {
    content: ">";
    opacity: 0.6;
}

.app-breadcrumbs a {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.app-breadcrumbs a:hover {
    color: var(--color-text-primary);
}

/* ─── Tasks page (claymorphism) ───────────────────────────────────────────────────── */
.tasks-manage {
    max-width: 100%;
    margin: 1.25rem auto;
    padding: 0 1rem;
}

.tasks-manage__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tasks-manage__title {
    margin: 0 0 0.35rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.tasks-manage__subtitle {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
}

.tasks-manage__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tasks-filter-badge {
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    font-size: 0.72rem;
    font-weight: 600;
}

.tasks-messages {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.tasks-message {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-input);
    font-size: 0.9375rem;
}

.tasks-message--success {
    background: var(--color-surface);
    color: var(--color-success, #059669);
    border-left: 4px solid var(--color-success, #059669);
}

.tasks-message--error {
    background: var(--color-surface);
    color: var(--color-danger);
    border-left: 4px solid var(--color-danger);
}

.tasks-message--info,
.tasks-message--warning {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-clay-card);
}

.tasks-form-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-clay-card);
    border-radius: var(--radius-base);
}

.tasks-form-card__heading {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.tasks-form__group {
    margin-bottom: 1rem;
}

.tasks-form__label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.tasks-form__input {
    width: 100%;
    max-width: 100%;
}

.tasks-form__input--narrow {
    max-width: 5rem;
}

.tasks-form__textarea {
    min-height: 4rem;
    resize: vertical;
}

.tasks-form__row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tasks-form__row .tasks-form__group {
    flex: 1;
    min-width: 140px;
}

.tasks-form__radios,
.tasks-form__radio-label,
.tasks-form__checkbox-label {
    margin-right: 1rem;
    font-weight: normal;
    color: var(--color-text-primary);
}

.tasks-form__radios {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tasks-recurring-panel {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-clay-input);
}

.tasks-recurring-panel__title {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--color-text-primary);
}

.tasks-recurring-panel__row {
    margin-bottom: 0.75rem;
}

.tasks-recurring-panel__days,
.tasks-recurring-panel__ends {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.tasks-recurring-panel__preview {
    margin-top: 0.5rem;
}

.tasks-recurring-panel__preview-text {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.tasks-form__submit {
    margin-top: 0.25rem;
}

.tasks-kanban-card {
    padding: 1.25rem;
    box-shadow: var(--shadow-clay-card);
    border-radius: var(--radius-base);
}

.tasks-kanban-card__heading {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.kanban-mobile-switch {
    margin-bottom: 0.75rem;
}

.kanban-columns {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.kanban-column {
    min-width: 280px;
    flex-shrink: 0;
}

.kanban-column__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

.kanban-column__title {
    color: var(--color-text-primary);
    font-size: 0.9375rem;
}

.kanban-column--overdue .kanban-column__title { color: var(--color-danger, #dc2626); }
.kanban-column--completed .kanban-column__title { color: var(--color-success, #166534); }
.kanban-column--cancelled .kanban-column__title { color: var(--color-text-secondary); }

.kanban-column__count {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    background: var(--color-muted);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
}

.kanban-column__drop {
    min-height: 140px;
    padding: 0.5rem;
    border-radius: var(--radius-base);
    background: var(--color-muted);
    box-shadow: var(--shadow-clay-input);
}

.kanban-column--overdue .kanban-column__drop {
    background: var(--kanban-bg-overdue, rgba(239, 68, 68, 0.12));
}

.kanban-column--pending .kanban-column__drop {
    background: var(--kanban-bg-pending, rgba(245, 158, 11, 0.15));
}

.kanban-column--in_progress .kanban-column__drop {
    background: var(--kanban-bg-in-progress, rgba(59, 130, 246, 0.12));
}

.kanban-column--completed .kanban-column__drop {
    background: var(--kanban-bg-completed, rgba(16, 185, 129, 0.12));
}

.kanban-column--cancelled .kanban-column__drop {
    background: var(--kanban-bg-cancelled, rgba(107, 114, 128, 0.12));
}

.clay-task-card.kanban-card--updating {
    opacity: 0.7;
    pointer-events: none;
}

.clay-task-card__meta {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.clay-task-card__title {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
}

.clay-task-card__assignee {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.clay-task-card__due { font-size: 0.8rem; color: var(--color-text-secondary); }
.clay-task-card__due--overdue { color: var(--color-danger, #dc2626); font-weight: 600; }
.clay-task-card__footer { display: flex; gap: 0.5rem; margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid var(--color-border); font-size: 0.75rem; color: var(--color-text-secondary); }
.clay-task-card .line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clay-task-card { position: relative; padding-left: 0.5rem; cursor: grab; }
.clay-task-card:active { cursor: grabbing; }
.priority-strip { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--radius-base) 0 0 var(--radius-base); }
.priority-strip.priority-low { background: var(--priority-low, #6b7280); }
.priority-strip.priority-medium { background: var(--priority-medium, #f59e0b); }
.priority-strip.priority-high { background: var(--priority-high, #f97316); }
.priority-strip.priority-urgent { background: var(--priority-urgent, #ef4444); }
.kanban-column__drop.sortable-drag-over { background: var(--color-primary-muted, rgba(59, 130, 246, 0.2)); border: 2px dashed var(--color-primary, #2563eb); }
.clay-task-card.sortable-ghost { opacity: 0.4; }
.clay-task-card.sortable-drag { opacity: 0.9; transform: rotate(2deg) scale(1.01); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15); }

.tasks-manage__back {
    margin-top: 1.5rem;
}

.tasks-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
    box-sizing: border-box;
}

.tasks-modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 2rem);
    padding: 1.25rem;
    box-shadow: var(--shadow-clay-card);
    border-radius: var(--radius-base);
    overflow-y: auto;
    box-sizing: border-box;
    margin: auto;
}

.tasks-modal--wide {
    max-width: min(560px, calc(100vw - 2rem));
}

.tasks-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.tasks-modal__header strong {
    color: var(--color-text-primary);
}

.tasks-modal__body {
    display: grid;
    gap: 0.75rem;
}

.tasks-modal__divider {
    margin: 0.9rem 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

.tasks-modal__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.tasks-detail-label {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.tasks-detail-grid {
    gap: 0.5rem;
    min-width: 0;
}

.tasks-detail-grid strong,
.tasks-detail-box {
    word-break: break-word;
}

.tasks-detail-section {
    margin-bottom: 0.5rem;
}

.tasks-detail-change-status {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tasks-detail-change-status .clay-select {
    min-width: 0;
    flex: 1;
    max-width: 12rem;
}

.tasks-detail-change-status .clay-btn {
    flex-shrink: 0;
}

.tasks-detail-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.tasks-detail-box {
    max-height: 120px;
    overflow: auto;
    padding: 0.5rem;
    border-radius: var(--radius-input);
    background: var(--color-surface);
    box-shadow: var(--shadow-clay-input);
}

.tasks-detail-box--tall {
    max-height: 160px;
}

.tasks-detail-comment-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tasks-detail-comment-form .clay-input {
    flex: 1;
}