/* Chatmode — light/dark UI. Surfaces and shades follow --primary. */

:root {
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --nav-h: 64px;
    --font: 'Outfit', 'Cairo', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    --primary: #12d66b;
    --accent: var(--primary);
    --on-primary: #102117;
    --primary-hover: color-mix(in srgb, var(--primary) 78%, white);
    --primary-deep: color-mix(in srgb, var(--primary) 72%, black);
    --primary-glow: color-mix(in srgb, var(--primary) 32%, transparent);
    --accent-glow: color-mix(in srgb, var(--accent) 28%, transparent);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
    --accent-contrast: var(--on-primary);
    --danger: #ef4444;
    --success: var(--primary);
    --guest: #34d399;
    --member: #38bdf8;
    --owner: #fbbf24;

    --hero-badge-bg: color-mix(in srgb, var(--primary) 12%, transparent);
    --hero-badge-border: color-mix(in srgb, var(--primary) 28%, transparent);
    --feature-icon-bg: linear-gradient(135deg, color-mix(in srgb, var(--primary) 22%, transparent), color-mix(in srgb, var(--accent) 12%, transparent));
    --mesh-1: color-mix(in srgb, var(--primary) 18%, transparent);
    --mesh-2: color-mix(in srgb, var(--accent) 12%, transparent);
    --mesh-3: color-mix(in srgb, var(--primary-deep) 20%, transparent);
    --flash-success-bg: color-mix(in srgb, var(--primary) 14%, transparent);
    --flash-success-text: color-mix(in srgb, var(--primary) 42%, white);
    --flash-success-border: color-mix(in srgb, var(--primary) 32%, transparent);
    --primary-subtle: color-mix(in srgb, var(--primary) 15%, transparent);
}

/* ─── Dark theme ─── */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: color-mix(in srgb, var(--primary) 9%, #07080c);
    --bg-elevated: color-mix(in srgb, var(--primary) 13%, #101218);
    --surface: color-mix(in srgb, var(--primary) 8%, #161922);
    --surface-hover: color-mix(in srgb, var(--primary) 14%, #1c2030);
    --border: color-mix(in srgb, var(--primary) 16%, #2a3142);
    --border-strong: color-mix(in srgb, var(--primary) 26%, #3a4254);
    --text: color-mix(in srgb, var(--primary) 8%, #f4f6fb);
    --text-muted: color-mix(in srgb, var(--primary) 16%, #9aa3b2);
    --nav-bg: color-mix(in srgb, var(--bg) 82%, transparent);
    --input-bg: color-mix(in srgb, black 35%, var(--bg));
    --panel-bg: color-mix(in srgb, black 25%, var(--bg));
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.55);
    --flash-error-bg: rgba(239, 68, 68, 0.12);
    --flash-error-text: #fca5a5;
    --flash-error-border: rgba(239, 68, 68, 0.25);
    --chat-header-bg: color-mix(in srgb, var(--bg) 72%, transparent);
    --chat-composer-bg: color-mix(in srgb, var(--bg) 86%, transparent);
    --badge-muted-bg: color-mix(in srgb, white 6%, transparent);
    --danger-subtle: rgba(239, 68, 68, 0.1);
}

/* ─── Light theme ─── */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: color-mix(in srgb, var(--primary) 7%, #f6f7fb);
    --bg-elevated: #ffffff;
    --surface: color-mix(in srgb, var(--primary) 5%, white);
    --surface-hover: color-mix(in srgb, var(--primary) 9%, white);
    --border: color-mix(in srgb, var(--primary) 14%, #e6e8ee);
    --border-strong: color-mix(in srgb, var(--primary) 22%, #d5d8e0);
    --text: #14161c;
    --text-muted: #5c6573;
    --nav-bg: color-mix(in srgb, var(--bg) 88%, transparent);
    --input-bg: rgba(255, 255, 255, 0.92);
    --panel-bg: color-mix(in srgb, white 78%, transparent);
    --shadow: 0 4px 24px color-mix(in srgb, var(--primary) 10%, transparent);
    --shadow-lg: 0 8px 40px color-mix(in srgb, var(--primary) 14%, transparent);
    --flash-error-bg: rgba(239, 68, 68, 0.1);
    --flash-error-text: #b91c1c;
    --flash-error-border: rgba(239, 68, 68, 0.22);
    --flash-success-text: var(--primary-deep);
    --chat-header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
    --chat-composer-bg: color-mix(in srgb, var(--bg) 95%, transparent);
    --badge-muted-bg: color-mix(in srgb, var(--primary) 6%, transparent);
    --danger-subtle: rgba(239, 68, 68, 0.08);
}

/* ─── System theme (follow OS) ─── */
@media (prefers-color-scheme: light) {
    :root[data-theme="system"] {
        color-scheme: light;
        --bg: color-mix(in srgb, var(--primary) 7%, #f6f7fb);
        --bg-elevated: #ffffff;
        --surface: color-mix(in srgb, var(--primary) 5%, white);
        --surface-hover: color-mix(in srgb, var(--primary) 9%, white);
        --border: color-mix(in srgb, var(--primary) 14%, #e6e8ee);
        --border-strong: color-mix(in srgb, var(--primary) 22%, #d5d8e0);
        --text: #14161c;
        --text-muted: #5c6573;
        --nav-bg: color-mix(in srgb, var(--bg) 88%, transparent);
        --input-bg: rgba(255, 255, 255, 0.92);
        --panel-bg: color-mix(in srgb, white 78%, transparent);
        --shadow: 0 4px 24px color-mix(in srgb, var(--primary) 10%, transparent);
        --shadow-lg: 0 8px 40px color-mix(in srgb, var(--primary) 14%, transparent);
        --flash-error-bg: rgba(239, 68, 68, 0.1);
        --flash-error-text: #b91c1c;
        --flash-error-border: rgba(239, 68, 68, 0.22);
        --flash-success-text: var(--primary-deep);
        --chat-header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
        --chat-composer-bg: color-mix(in srgb, var(--bg) 95%, transparent);
        --badge-muted-bg: color-mix(in srgb, var(--primary) 6%, transparent);
        --danger-subtle: rgba(239, 68, 68, 0.08);
    }
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Ambient background */
.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 10% 0%, var(--mesh-1), transparent 50%),
        radial-gradient(ellipse 60% 50% at 90% 10%, var(--mesh-2), transparent 45%),
        radial-gradient(ellipse 50% 40% at 50% 100%, var(--mesh-3), transparent 50%),
        var(--bg);
    pointer-events: none;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: color-mix(in srgb, var(--accent) 78%, white); }

.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ─── Navigation ─── */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h);
    padding: 0 1.5rem;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
}

.nav-logo {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-link svg { width: 16px; height: 16px; }
.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.is-active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ─── Platform admin shell (ops console feel) ─── */
html.admin-html {
    --font: "Cairo", system-ui, sans-serif;
    --mono: "Cairo", system-ui, sans-serif;
    font-family: "Cairo", system-ui, sans-serif;
}
html.admin-html body,
html.admin-html body.admin-shell {
    --admin-rail-w: 240px;
    --admin-radius: 6px;
    --admin-rail-bg: #020805;
    --font: "Cairo", system-ui, sans-serif;
    --mono: "Cairo", system-ui, sans-serif;
    font-family: "Cairo", system-ui, sans-serif !important;
    min-height: 100vh;
}
html.admin-html body.admin-shell .admin-app,
html.admin-html body.admin-shell .admin-app *:not(svg):not(svg *) {
    font-family: "Cairo", system-ui, sans-serif !important;
}
body.admin-shell .bg-mesh { display: none; }

.admin-grid-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--bg) 88%, var(--primary) 12%) 0%, var(--bg) 42%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 23px,
            color-mix(in srgb, var(--primary) 8%, transparent) 23px,
            color-mix(in srgb, var(--primary) 8%, transparent) 24px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 23px,
            color-mix(in srgb, var(--primary) 6%, transparent) 23px,
            color-mix(in srgb, var(--primary) 6%, transparent) 24px
        );
    opacity: 0.55;
}

.admin-app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--admin-rail-w) minmax(0, 1fr);
    min-height: 100vh;
    font-family: var(--font);
}

.admin-rail {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.1rem 0.85rem 1rem;
    border-inline-end: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
    /* background: var(--admin-rail-bg); */
    color: #e8f5ee;
}

.admin-rail-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.35rem 0.45rem;
    text-decoration: none;
    color: var(--text);
}
.admin-rail-mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border));
    border-radius: var(--admin-radius);
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.admin-rail-mark svg { width: 1rem; height: 1rem; }
.admin-rail-brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.admin-rail-brand-name {
    font-family: var(--font);
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.admin-rail-brand-sub {
    font-family: var(--font);
    font-size: 0.72rem;
    color: rgba(232, 245, 238, 0.55);
    letter-spacing: 0.04em;
}

.admin-rail-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}
.admin-rail-label {
    margin: 0 0 0.45rem;
    padding: 0 0.55rem;
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(232, 245, 238, 0.45);
}
.admin-rail-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.6rem;
    border-radius: var(--admin-radius);
    border: 1px solid transparent;
    color: rgba(232, 245, 238, 0.68);
    text-decoration: none;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.admin-rail-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}
.admin-rail-link.is-active {
    color: var(--text);
    border-color: color-mix(in srgb, var(--primary) 35%, transparent);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    box-shadow: inset 3px 0 0 var(--primary);
}
html[dir="rtl"] .admin-rail-link.is-active {
    box-shadow: inset -3px 0 0 var(--primary);
}
.admin-rail-index {
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 1.4rem;
}
.admin-rail-footer {
    border-top: 1px dashed color-mix(in srgb, var(--primary) 22%, transparent);
    padding-top: 0.75rem;
}
.admin-rail-exit { color: rgba(232, 245, 238, 0.55); }

.admin-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 3.25rem;
    padding: 0.55rem 1.35rem;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px);
}
.admin-topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    font-family: var(--font);
    font-size: 0.86rem;
    font-weight: 600;
}
.admin-topbar-kicker {
    color: var(--primary);
    letter-spacing: 0.04em;
}
.admin-topbar-sep { color: var(--text-muted); }
.admin-topbar-title {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.admin-topbar-tools {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}
.admin-topbar-user {
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-main {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.35rem 1.35rem 2.5rem;
    font-family: var(--font);
}
body.admin-shell code,
body.admin-shell pre,
body.admin-shell .api-table,
body.admin-shell button,
body.admin-shell input,
body.admin-shell select,
body.admin-shell textarea {
    font-family: var(--font);
}

body.admin-shell .page-header,
.admin-page-header {
    margin-bottom: 1.35rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
}
body.admin-shell .page-eyebrow,
.admin-page-eyebrow {
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
}
body.admin-shell .page-header h1,
.admin-page-title {
    margin: 0.35rem 0 0.4rem;
    font-size: clamp(1.45rem, 2.2vw, 1.85rem);
    font-weight: 650;
    letter-spacing: -0.02em;
}
.admin-page-intro,
body.admin-shell .page-header .muted {
    max-width: 42rem;
}

body.admin-shell .panel,
body.admin-shell .card {
    border-radius: var(--admin-radius);
    border-color: color-mix(in srgb, var(--primary) 14%, var(--border));
    box-shadow: none;
}
body.admin-shell .api-table th {
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.admin-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}
a.admin-home-card {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 1.2rem 1.15rem 1.3rem;
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
    border-radius: var(--admin-radius);
    background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
a.admin-home-card:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-elevated));
    transform: translateY(-2px);
}
.admin-home-card-index {
    display: block;
    margin-bottom: 0.85rem;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--primary);
}
a.admin-home-card h2 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}
a.admin-home-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

@media (max-width: 900px) {
    .admin-app {
        grid-template-columns: 1fr;
    }
    .admin-rail {
        position: static;
        height: auto;
        border-inline-end: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
    }
    .admin-rail-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.35rem;
    }
    .admin-rail-label { width: 100%; }
    .admin-rail-footer {
        border-top: 0;
        padding-top: 0;
    }
    .admin-home-grid {
        grid-template-columns: 1fr;
    }
    .admin-topbar {
        flex-wrap: wrap;
    }
}

/* ─── Theme toggle ─── */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.theme-toggle-btn svg { width: 16px; height: 16px; }

.theme-toggle-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.theme-toggle-btn.is-active,
.theme-toggle-btn[aria-pressed="true"] {
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

:root[data-theme="dark"] .theme-toggle-btn.is-active,
:root[data-theme="dark"] .theme-toggle-btn[aria-pressed="true"] {
    color: var(--accent);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    border-color: transparent;
    color: var(--on-primary);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    box-shadow: 0 6px 28px var(--primary-glow);
    color: var(--on-primary);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }

.btn-danger-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}

.btn-danger-ghost:hover { background: var(--danger-subtle); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.65rem; border-radius: var(--radius); }

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

/* ─── Hero (landing) ─── */
.hero {
    text-align: center;
    padding: 4rem 1rem 3rem;
    max-width: 720px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--hero-badge-bg);
    border: 1px solid var(--hero-badge-border);
    border-radius: 999px;
}

.hero-badge svg { width: 16px; height: 16px; }

.hero-title {
    font-size: clamp(2.5rem, 6vw, 3.75rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 1.25rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-hover), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 540px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Features ─── */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    padding: 0;
    max-width: none;
    margin: 0;
}

.feature-card {
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.feature-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    background: var(--feature-icon-bg);
    border-radius: var(--radius);
    color: var(--primary);
}

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

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.product-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 2.5rem;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 3.5rem 0 1rem;
    text-align: start;
}

.product-hero .hero-title {
    margin-bottom: 1rem;
}

.product-hero .hero-subtitle {
    max-width: 38rem;
    margin: 0 0 1.5rem;
}

.product-story {
    padding-top: 4.5rem;
}

.product-story .hero-title {
    font-size: clamp(2rem, 4vw, 2.85rem);
}

.hero-link-card {
    width: 100%;
    max-width: none;
    margin: 0;
}

.hero-link-card .auth-header {
    margin-bottom: 1.25rem;
}

.hero-link-card .auth-header h2 {
    font-size: 1.35rem;
}

.hero-link-reminder {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.hero-link-reminder .hero-actions {
    margin-top: 0.75rem;
}

.integrate-jumps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    max-width: 1100px;
    margin: 1.5rem auto 0;
}

.integrate-jumps a {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.integrate-jumps a:hover { color: var(--primary); }

.stack-mock.product-preview { margin: 0; }

.product-preview-app {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    min-height: 280px;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    border-inline-end: 1px solid var(--border);
    background: var(--surface);
}

.app-nav span {
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.app-nav .is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.product-preview-site .site-mock {
    position: relative;
    min-height: 240px;
    padding: 1.25rem;
}

.site-line {
    display: block;
    height: 0.7rem;
    margin-bottom: 0.7rem;
    border-radius: 999px;
    background: var(--surface);
}

.site-line.is-short { width: 55%; }

.site-bubble {
    position: absolute;
    inset-inline-end: 1.25rem;
    inset-block-end: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.site-bubble svg {
    width: 16px;
    height: 16px;
}

.stack-mock {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
}

.stack-mock li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.5rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.stack-mock span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stack-mock strong {
    font-size: 0.85rem;
}

.product-hero .marketing-note {
    max-width: 38rem;
}

.product-points {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.product-points li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.product-points li::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 999px;
    background: var(--primary);
}

.product-preview {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.product-preview-inbox {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    min-height: 300px;
}

.product-preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    border-inline-end: 1px solid var(--border);
    background: var(--surface);
}

.product-preview-list span {
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.product-preview-list .is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.product-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.product-preview-bar span {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.product-preview-thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 220px;
    padding: 1rem;
}

.product-preview-msg {
    max-width: 85%;
    padding: 0.7rem 0.85rem;
    border-radius: 14px;
    background: var(--surface);
}

.product-preview-msg span {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.product-preview-msg p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
}

.product-preview-msg.is-guest { align-self: flex-start; }

.product-preview-msg.is-agent {
    align-self: flex-end;
    background: var(--primary-subtle);
}

.product-preview-composer {
    margin: 0 1rem 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.product-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.product-steps li {
    padding-top: 1rem;
    border-top: 2px solid var(--border);
}

.product-steps span {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
}

.product-steps h3 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}

.product-steps p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.product-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 2.5rem auto 0;
    padding: 1.5rem 1.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
}

.product-cta h2 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
}

.product-cta p {
    margin: 0;
    color: var(--text-muted);
}

.product-cta .hero-actions {
    justify-content: flex-end;
    flex-shrink: 0;
}

.product-section {
    max-width: 1100px;
    margin-inline: auto;
    padding-top: 2.75rem;
}

.product-section-head {
    max-width: 40rem;
    margin-bottom: 1.25rem;
}

.product-section-head h2,
.product-section-head .hero-title {
    margin: 0 0 0.5rem;
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    letter-spacing: -0.03em;
}

.product-section-head p:last-child {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.product-kicker {
    margin: 0 0 0.4rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.product-link {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(280px, 1fr);
    gap: 2rem;
    align-items: start;
    padding-bottom: 1rem;
}

.product-link .auth-card {
    max-width: none;
    margin: 0;
}

.marketing-starts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.marketing-starts .feature-card {
    display: flex;
    flex-direction: column;
}

.marketing-starts .feature-card a {
    margin-top: auto;
    padding-top: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.marketing-note {
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--primary-subtle);
    color: var(--text);
}

.marketing-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 2.5rem auto 0;
    padding: 1.5rem 0 3rem;
    border-top: 1px solid var(--border);
}

.marketing-footer-brand strong {
    display: block;
    margin-bottom: 0.25rem;
}

.marketing-footer-brand p {
    margin: 0;
    max-width: 28rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.marketing-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.marketing-footer a {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.marketing-footer a:hover {
    color: var(--text);
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    max-width: 1100px;
    margin-inline: auto;
    padding-bottom: 3rem;
}

.pricing-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pricing-card h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.pricing-card.is-featured {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.pricing-card:hover {
    transform: none;
}

.product-section-head .pricing-every {
    margin-top: 0.75rem;
    color: var(--text);
}

.pricing-note {
    margin: -0.35rem 0 0;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.pricing-price {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.pricing-price span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.pricing-limits {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex: 1;
}

.pricing-limits li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
}

.pricing-limits li span:first-child {
    color: var(--text-muted);
}

.pricing-card .btn {
    margin-top: auto;
}

/* ─── Auth pages ─── */
.auth-page {
    display: flex;
    justify-content: center;
    padding: 2rem 0 4rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2rem;
}

.auth-header {
    margin-bottom: 1.75rem;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.auth-header p { color: var(--text-muted); font-size: 0.95rem; }

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.workspace-choice-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.workspace-choice-form { margin: 0; }

.workspace-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    text-align: start;
    padding: 1rem 1.25rem;
}

.workspace-choice-name {
    font-weight: 600;
    color: var(--text);
}

.workspace-choice-role {
    font-size: 0.85rem;
    text-transform: capitalize;
}

.join-card { text-align: center; }

.join-channel-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-lg);
    color: var(--on-primary);
}

.join-channel-icon svg { width: 28px; height: 28px; }

.join-workspace {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* ─── Forms ─── */
.form { display: flex; flex-direction: column; gap: 1.1rem; }

.form > fieldset,
fieldset.field {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-inline-size: 0;
}

.form > fieldset > legend,
fieldset.field > legend {
    padding: 0;
    margin-bottom: 0.15rem;
}

.form label:not(.toggle-field):not(.radio-field):not(.internal-toggle):not(.checkbox-field),
.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form label:not(.toggle-field):not(.radio-field):not(.internal-toggle):not(.checkbox-field) > span,
.field > span,
.field > legend {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="url"],
.form input[type="number"],
.form input[type="search"],
select,
.select,
.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="url"],
.form input[type="number"],
.form input[type="search"],
.form input[type="tel"],
.form input[type="date"],
.form input[type="time"],
.form input:not([type]),
.form textarea,
.form select,
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input[type="search"],
.field input[type="tel"],
.field input[type="date"],
.field input[type="time"],
.field input:not([type]),
.field textarea,
.field select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}

.form textarea,
.field textarea {
    min-height: 6rem;
    resize: vertical;
    line-height: 1.45;
}

select,
.select,
.form select,
.field select {
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 2.5rem;
    background-color: var(--input-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2394a3a8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: calc(100% - 1rem) center;
    background-size: 16px 16px;
    background-repeat: no-repeat;
    cursor: pointer;
}

select:hover,
.select:hover,
.form select:hover,
.field select:hover {
    border-color: var(--border-strong, #475569);
}

html[dir="rtl"] select,
html[dir="rtl"] .select,
html[dir="rtl"] .form select,
html[dir="rtl"] .field select {
    background-position: 1rem center;
    padding-inline-end: 1rem;
    padding-inline-start: 2.5rem;
}

select option,
.select option,
.form select option,
.field select option {
    background-color: var(--surface, #1e293b);
    color: var(--text, #f1f5f9);
    padding: 0.5rem;
}

select:focus,
.select:focus,
.form input:focus,
.form textarea:focus,
.form select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form input::placeholder,
.form textarea::placeholder,
.field input::placeholder,
.field textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}

.password-input-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.form .password-input-wrap > input,
.field .password-input-wrap > input,
.password-input-wrap > input {
    width: 100%;
    padding-inline-end: 2.75rem;
    box-sizing: border-box;
}

.password-toggle-btn {
    position: absolute;
    inset-inline-end: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: color var(--transition), background var(--transition);
}

.password-toggle-btn:hover {
    color: var(--text);
    background: var(--surface-hover, rgba(148, 163, 184, 0.12));
}

.password-toggle-btn:focus-visible {
    outline: none;
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.password-toggle-btn svg {
    display: block;
    pointer-events: none;
}

.form input[type="file"],
.field input[type="file"] {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--panel-bg);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}

.form input[type="file"]::file-selector-button,
.field input[type="file"]::file-selector-button {
    margin-inline-end: 0.75rem;
    padding: 0.4rem 0.75rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.form input[disabled],
.form textarea[disabled],
.form select[disabled],
.field input[disabled],
.field textarea[disabled],
.field select[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.input-prefix {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-prefix:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-prefix .prefix {
    padding: 0.75rem 0 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--mono);
    white-space: nowrap;
}

html[dir="rtl"] .input-prefix .prefix {
    padding: 0.75rem 1rem 0.75rem 0;
}

.input-prefix input {
    flex: 1;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.75rem 1rem 0.75rem 0;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
}

html[dir="rtl"] .input-prefix input {
    padding: 0.75rem 0 0.75rem 1rem;
}

.toggle-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.toggle-label { display: block; font-weight: 500; font-size: 0.95rem; color: var(--text); }
.toggle-hint { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Switch-style checkbox */
input.toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 24px;
    margin: 0;
    flex-shrink: 0;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-hover);
    position: relative;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

input.toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    inset-inline-start: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}

input.toggle:checked {
    background: var(--accent);
    border-color: var(--accent);
}

input.toggle:checked::after {
    background: var(--accent-contrast);
    transform: translateX(20px);
}

html[dir="rtl"] input.toggle:checked::after {
    transform: translateX(-20px);
}

input.toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.radio-field {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.65rem;
    row-gap: 0.2rem;
    align-items: start;
    padding: 0.85rem 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.radio-field:hover {
    background: var(--surface-hover);
}

.radio-field:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--accent-soft);
}

.radio-field > input[type="radio"] {
    grid-column: 1;
    grid-row: 1;
    margin-top: 0.15rem;
}

.radio-field > span {
    grid-column: 2;
    font-weight: 560;
    font-size: 0.95rem;
    color: var(--text);
}

.radio-field > p,
.radio-field .muted {
    grid-column: 2;
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
}

.radio-field input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--input-bg);
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: border-color var(--transition);
}

.radio-field input[type="radio"]::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    transform: scale(0);
    transition: transform var(--transition);
}

.radio-field input[type="radio"]:checked {
    border-color: var(--accent);
}

.radio-field input[type="radio"]:checked::after {
    transform: scale(1);
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-field input[type="checkbox"],
.form input[type="checkbox"]:not(.toggle),
.field input[type="checkbox"]:not(.toggle) {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    border-radius: 5px;
    border: 2px solid var(--border-strong);
    background: var(--input-bg);
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.checkbox-field input[type="checkbox"]::after,
.form input[type="checkbox"]:not(.toggle)::after,
.field input[type="checkbox"]:not(.toggle)::after {
    content: "";
    width: 9px;
    height: 5px;
    border-inline-start: 2px solid var(--accent-contrast);
    border-bottom: 2px solid var(--accent-contrast);
    transform: rotate(-45deg) scale(0);
    transition: transform var(--transition);
    margin-top: -2px;
}

.checkbox-field input[type="checkbox"]:checked,
.form input[type="checkbox"]:not(.toggle):checked,
.field input[type="checkbox"]:not(.toggle):checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-field input[type="checkbox"]:checked::after,
.form input[type="checkbox"]:not(.toggle):checked::after,
.field input[type="checkbox"]:not(.toggle):checked::after {
    transform: rotate(-45deg) scale(1);
}

/* ─── Flash ─── */
.flash {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
}

.flash svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash-error { background: var(--flash-error-bg); color: var(--flash-error-text); border: 1px solid var(--flash-error-border); }
.flash-success { background: var(--flash-success-bg); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }

.owner-link-reminder {
    max-width: 720px;
    margin: 0 auto 2rem;
    padding: 0 1rem;
}
.owner-link-reminder-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--flash-success-border);
    background: var(--flash-success-bg);
    border-radius: var(--radius);
}
.owner-link-reminder-title {
    margin: 0 0 0.25rem;
    font-weight: 650;
    color: var(--flash-success-text);
}
.owner-link-reminder-copy .muted {
    margin: 0 0 0.5rem;
}
.owner-link-reminder-path {
    display: inline-block;
    font-size: 0.85rem;
    word-break: break-all;
}
.owner-link-reminder-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ─── Page header (dashboard) ─── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.page-eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.workspace-switch-form { margin-top: 0.75rem; }

.workspace-switch-field {
    margin: 0;
    max-width: 280px;
}

.workspace-switch-field select {
    width: 100%;
}

.color-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.color-row input[type="color"] {
    width: 48px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.color-row input[type="text"] {
    flex: 1;
}

.brand-preview {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
}

.brand-preview-swatch {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.new-workspace-form { margin-top: 0.75rem; }

.new-workspace-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.new-workspace-row input {
    flex: 1;
    min-width: 0;
}

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

.muted { color: var(--text-muted); }

/* ─── Stats ─── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
}

.stat-on { color: var(--success); }
.stat-off { color: var(--text-muted); }

/* ─── Panels ─── */
.panel {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel-header {
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ─── Channel grid ─── */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.channel-card {
    padding: 1.25rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.channel-card:hover { border-color: var(--border-strong); }

.channel-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.channel-card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.channel-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.channel-card h3 { font-size: 1rem; font-weight: 600; }

.channel-url {
    display: block;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem 0.65rem;
    background: var(--input-bg);
    border-radius: 6px;
    margin-bottom: 0.85rem;
    word-break: break-all;
}

.channel-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.channel-arrow {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* ─── Guest list ─── */
.guest-list { display: flex; flex-direction: column; gap: 0.5rem; }

.guest-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.guest-row:hover { background: var(--surface-hover); }

.guest-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    color: var(--on-primary);
    flex-shrink: 0;
}

.guest-info { flex: 1; min-width: 0; }
.guest-name { display: block; font-weight: 500; font-size: 0.95rem; }
.guest-time { display: block; font-size: 0.8rem; color: var(--text-muted); }

.empty-state { padding: 2rem; text-align: center; }

/* ─── Badges ─── */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.badge-guest { background: var(--primary-subtle); color: var(--guest); }
.badge-member { background: rgba(56, 189, 248, 0.15); color: var(--member); }
.badge-owner { background: rgba(251, 191, 36, 0.15); color: var(--owner); }
.badge-admin { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-agent { background: rgba(56, 189, 248, 0.15); color: var(--member); }
.badge-viewer { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.badge-muted { background: var(--badge-muted-bg); color: var(--text-muted); }
.badge-success { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

/* ─── Workspace Types & Flexibility ─── */
.ws-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.85rem;
    margin: 1.25rem 0;
}

.ws-type-card {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--panel-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    text-align: start;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: all var(--transition);
    font-family: inherit;
    color: inherit;
}

.ws-type-card:hover,
.ws-type-card.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.ws-type-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.ws-type-card-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}

.ws-type-card-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0;
}

.ws-flex-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
}

.ws-flex-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--panel-bg);
    border: 1px solid var(--border);
}

.ws-flex-icon {
    width: 22px;
    height: 22px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.ws-flex-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.15rem 0;
}

.ws-flex-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.ws-toolkit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.85rem;
}

.ws-toolkit-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}

.ws-toolkit-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.ws-toolkit-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.ws-toolkit-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.ws-toolkit-desc {
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0;
}

/* ─── Global fixes ─── */
[hidden] {
    display: none !important;
}

/* ─── Chat ─── */
body:has(.chat-shell) {
    overflow: hidden;
}

body:has(.chat-shell) .container {
    max-width: 100%;
    padding: 0;
    height: calc(100dvh - var(--nav-h));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.85rem clamp(1rem, 2.5vw, 1.75rem);
    border-bottom: 1px solid var(--border);
    background: var(--chat-header-bg);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.chat-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1.25rem;
    flex-wrap: wrap;
    min-width: 0;
}

.chat-header-aside {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-inline-start: auto;
    min-width: 0;
}

.chat-header-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.chat-header-toolbar {
    display: flex;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.guest-row-link {
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.guest-row-link:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.04));
}

.chat-back {
    margin-inline-end: 0.15rem;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 16rem;
}

.chat-header-titles {
    min-width: 0;
}

.chat-channel-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    border-radius: var(--radius);
    color: var(--on-primary);
    flex-shrink: 0;
}

.chat-channel-icon svg { width: 20px; height: 20px; }

.chat-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header .muted {
    font-size: 0.8rem;
    margin: 0.15rem 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem clamp(1rem, 2.5vw, 1.75rem);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    overflow-x: auto;
    flex-shrink: 0;
}

.presence-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    flex-shrink: 0;
}

.presence-users {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.presence-chip {
    font-size: 0.7rem;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem clamp(1rem, 2.5vw, 1.75rem);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--chat-composer-bg);
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    animation: typing-bounce 1.2s ease infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--success);
    padding: 0.35rem 0.75rem;
    background: var(--primary-subtle);
    border-radius: 999px;
}

.chat-status-connecting {
    color: var(--text-muted);
    background: var(--surface);
}

.chat-status-error {
    color: var(--danger);
    background: var(--danger-subtle);
}

.status-dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem clamp(1rem, 3vw, 2.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* WhatsApp-style Date Separators */
.chat-date-separator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.75rem 0;
    position: sticky;
    top: 0.5rem;
    z-index: 5;
    pointer-events: none;
}

.chat-date-pill {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.85rem;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
    letter-spacing: 0.01em;
    user-select: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Scroll-to-bottom Floating Button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 5rem;
    inset-inline-end: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.15s ease;
    animation: fade-scale-in 0.2s ease;
}

.scroll-bottom-btn:hover {
    background: var(--surface-hover, var(--border));
    transform: translateY(-2px);
}

.scroll-bottom-btn svg {
    width: 20px;
    height: 20px;
}

.scroll-unread-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    background: var(--primary);
    color: var(--primary-contrast, #fff);
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes fade-scale-in {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Message bubbles */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: min(720px, 72%);
    animation: msg-in 0.25s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 50%;
    color: var(--on-primary);
}

.avatar-badge-guest { background: linear-gradient(135deg, var(--accent), var(--primary)); }
.avatar-badge-member { background: linear-gradient(135deg, #38bdf8, #0ea5e9); }
.avatar-badge-owner { background: linear-gradient(135deg, #fbbf24, #f59e0b); }

.message-content { min-width: 0; }

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}

.message-author {
    font-size: 0.85rem;
    font-weight: 600;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-bubble {
    padding: 0.65rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) var(--radius) 4px;
}

.message-body {
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}

.load-older-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
    gap: 0.5rem;
    min-height: 2.25rem;
}

.load-older-spinner {
    width: 20px;
    height: 20px;
    color: var(--primary);
    animation: spin 0.8s linear infinite;
    display: none;
}

.load-older-wrap.loading .load-older-spinner {
    display: block;
}

.load-older-wrap.loading #load-older-btn {
    display: none;
}

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

.search-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.search-form input[type="search"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-result {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result-body {
    margin: 0 0 0.35rem;
}

.search-result-meta {
    margin: 0;
    font-size: 0.85rem;
}

.chat-composer {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    padding: 0.85rem clamp(1rem, 2.5vw, 1.75rem) 1rem;
    border-top: 1px solid var(--border);
    background: var(--chat-composer-bg);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.composer-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-composer input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all var(--transition);
}

.chat-composer input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.message-image {
    display: block;
    max-width: min(320px, 100%);
    max-height: 240px;
    border-radius: calc(var(--radius) - 2px);
    margin-bottom: 0.35rem;
    object-fit: cover;
}

.message-bubble .message-body:only-child,
.message-bubble .message-image + .message-body {
    margin: 0;
}

.attachment-preview {
    position: relative;
    display: inline-flex;
    align-self: flex-start;
}

.attachment-preview img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.attachment-clear {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.chat-locked {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-locked svg { width: 20px; height: 20px; opacity: 0.6; }

/* ─── Empty / error states ─── */
.empty-page {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 420px;
    margin: 3rem auto;
}

.empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
}

.empty-icon svg { width: 32px; height: 32px; }
.empty-icon-danger { color: var(--danger); border-color: var(--flash-error-border); }

.error-code {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--primary);
}

.empty-page h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-page .btn { margin-top: 1.25rem; }

/* ─── Misc ─── */
.inline-form { display: inline; }

/* ─── Notifications ─── */
.notification-settings .panel-header { margin-bottom: 1rem; }
.notification-settings-body { display: flex; flex-direction: column; gap: 0.75rem; }
.notification-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.notification-status { margin: 0; font-size: 0.875rem; }
.settings-divider { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.unread-badge {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    margin-inline-start: 0.4rem;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
}
.unread-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    margin-inline-start: 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}
.unread-count-badge[hidden] { display: none !important; }
.guest-row-unread {
    box-shadow: inset 3px 0 0 var(--accent);
}
html[dir="rtl"] .guest-row-unread {
    box-shadow: inset -3px 0 0 var(--accent);
}
.guest-row-unread .guest-name { font-weight: 600; }
.guest-row-unread .guest-time:first-of-type { color: var(--text); }
.presence-dot {
    position: absolute;
    inset-inline-end: -0.1rem;
    bottom: -0.05rem;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--muted, #94a3b8);
    border: 2px solid var(--surface, #fff);
    box-sizing: content-box;
}
.presence-dot.is-online,
.guest-row.is-online .presence-dot {
    background: #22c55e;
}
.inbox-live {
    font-size: 0.8rem;
}
.inbox-live.is-connected {
    color: #22c55e;
}
.nav-alerts-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.nav-alerts-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}
.nav-alerts-badge {
    position: absolute;
    top: -0.35rem;
    inset-inline-end: -0.55rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
}
.nav-alerts-badge[hidden] { display: none !important; }
.chat-notify-btn svg { width: 1.1rem; height: 1.1rem; }

/* ─── Embed page (iframe) ─── */
body.embed-page .nav { display: none; }
body.embed-page .container { max-width: none; padding: 0; margin: 0; }
body.embed-page .chat-shell { min-height: 100vh; border-radius: 0; }
body.embed-page .bg-mesh { display: none; }
body.embed-page .auth-page { min-height: 100vh; padding: 1rem; }

.embed-snippet-wrap { display: flex; flex-direction: column; gap: 0.75rem; }
.embed-snippet {
    margin: 0;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--surface-elevated);
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
    .product-link,
    .product-steps,
    .product-preview-inbox,
    .product-preview-app { grid-template-columns: 1fr; }
    .product-cta,
    .marketing-footer { flex-direction: column; align-items: flex-start; }
    .product-preview-list {
        flex-direction: row;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border);
    }
    .app-nav {
        flex-direction: row;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 640px) {
    .nav { padding: 0 1rem; }
    .nav-brand span { display: none; }
    .theme-toggle { order: -1; }
    .nav-links { gap: 0.5rem; }
    .hero { padding: 2.5rem 0.5rem 2rem; }
    .product-hero { grid-template-columns: 1fr; padding-top: 1.5rem; }
    .product-hero .product-hero-copy { text-align: center; }
    .product-hero .hero-subtitle { margin-inline: auto; }
    .product-hero .hero-actions,
    .product-points { justify-content: center; }
    .hero-actions { flex-direction: column; }
    .hero-actions .btn { width: 100%; }
    .auth-card { padding: 1.5rem; }
    .page-header { flex-direction: column; }
    .message { max-width: 95%; }
    .channel-grid { grid-template-columns: 1fr; }
    .chat-header-info { flex: 1 1 100%; }
    .thread-controls .btn span { display: none; }
}

/* === Message UX: edit, reactions, mentions, markdown (phase 30) === */

.message { position: relative; }

.message-actions {
    position: absolute;
    top: -10px;
    right: 8px;
    display: none;
    gap: 2px;
    padding: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
}

.message:hover .message-actions { display: inline-flex; }

.message-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.message-action:hover { background: var(--surface-hover); color: var(--text); }
.message-action svg { width: 15px; height: 15px; }

.message-edited {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.message-reactions:empty { display: none; }

.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-bg);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.reaction-chip:hover { border-color: var(--border-strong); color: var(--text); }
.reaction-chip svg { width: 14px; height: 14px; }

.reaction-mine {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.reaction-picker {
    position: absolute;
    z-index: 40;
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
}

.reaction-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.reaction-picker-btn:hover { background: var(--surface-hover); color: var(--primary); transform: scale(1.1); }
.reaction-picker-btn svg { width: 18px; height: 18px; }

.mention {
    color: var(--primary);
    font-weight: 600;
    background: var(--hero-badge-bg);
    border-radius: 4px;
    padding: 0 3px;
}

.mention-autocomplete {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.mention-autocomplete button {
    padding: 0.5rem 0.9rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    text-align: start;
    cursor: pointer;
}

.mention-autocomplete button:hover { background: var(--surface-hover); color: var(--primary); }

.composer-field { position: relative; }

.message-edit-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.message-edit-input {
    width: 100%;
    padding: 0.55rem 0.9rem;
    font-family: var(--font);
    font-size: 0.92rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    outline: none;
}

.message-edit-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.message-edit-actions { display: flex; gap: 6px; }

.md-inline-code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
}

.md-code {
    margin: 4px 0 0;
    padding: 0.6rem 0.8rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.md-code code {
    font-family: var(--mono);
    font-size: 0.82rem;
    white-space: pre;
}

.message-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.message-body strong { font-weight: 700; }
.message-body em { font-style: italic; }

/* === Support inbox: thread state, internal notes, CSAT (phase 32) === */

.inbox-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 1rem;
}

.inbox-filter-active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.thread-status {
    display: inline-flex;
    align-items: center;
    height: 2rem;
    padding: 0 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.thread-status-open {
    color: var(--primary);
    background: var(--hero-badge-bg);
    border: 1px solid var(--hero-badge-border);
}

.thread-status-resolved {
    color: var(--text-muted);
    background: var(--panel-bg);
    border: 1px solid var(--border);
}

.thread-assignee {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-inline-start: 6px;
}

.thread-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}

.thread-controls .btn svg {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-inline-end: 0.25rem;
}

.thread-assign {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.4rem 2rem 0.4rem 0.7rem;
    min-width: 9.5rem;
    font-family: var(--font);
    font-size: 0.82rem;
    color: var(--text);
    background-color: var(--input-bg);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
        linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position:
        calc(100% - 0.85rem) calc(50% - 0.12rem),
        calc(100% - 0.55rem) calc(50% - 0.12rem);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    cursor: pointer;
}

.thread-assign:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.internal-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}

.internal-toggle svg { width: 13px; height: 13px; }
.internal-toggle input { display: none; }
.internal-toggle:has(input:checked) {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.45);
    background: rgba(251, 191, 36, 0.08);
}

.message-internal .message-bubble {
    background: rgba(251, 191, 36, 0.07);
    border: 1px dashed rgba(251, 191, 36, 0.4);
}

.badge-internal {
    color: #b45309;
    background: rgba(251, 191, 36, 0.15);
}

:root[data-theme="dark"] .badge-internal { color: #fbbf24; }

.csat-widget {
    margin: 0.75rem auto;
    padding: 1rem 1.5rem;
    text-align: center;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 320px;
}

.csat-widget p { margin: 0 0 0.5rem; color: var(--text-muted); font-size: 0.9rem; }

.csat-stars { display: flex; justify-content: center; gap: 4px; }

.csat-star {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.csat-star:hover { color: #fbbf24; transform: scale(1.15); }
.csat-star.active { color: #fbbf24; }
.csat-star.active svg { fill: #fbbf24; }
.csat-star svg { width: 22px; height: 22px; }

.csat-rating-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    min-height: 1.25rem;
    margin-top: 0.25rem;
}

.csat-feedback-box {
    margin-top: 0.75rem;
}

.csat-comment {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    resize: none;
    outline: none;
    transition: border-color var(--transition);
}

.csat-comment:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.csat-submit-btn {
    width: 100%;
    margin-top: 0.5rem;
}

.csat-thankyou {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.csat-thankyou svg {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
}

.csat-thankyou p {
    margin: 0;
    font-weight: 500;
    color: var(--text);
}

.csat-analytics-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    align-items: center;
    padding: 1rem 0;
}

@media (max-width: 640px) {
    .csat-analytics-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
}

.csat-summary-box {
    text-align: center;
    padding: 1.25rem;
    background: var(--bg-subtle, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.csat-score-hero {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}

.csat-score-big {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.csat-score-max {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.csat-stars-hero {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

.csat-stars-hero svg {
    width: 28px;
    height: 28px;
    color: #fbbf24;
    fill: #fbbf24;
}

.csat-dist-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.csat-dist-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.csat-dist-label {
    min-width: 70px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.csat-dist-bar-track {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.csat-dist-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.csat-dist-count {
    min-width: 75px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

.csat-feedback-heading {
    margin-top: 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
}



.stacked-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 480px; }
.stacked-form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    resize: vertical;
    line-height: 1.45;
    box-sizing: border-box;
}
.stacked-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === AI assistant (phase 33) === */

.badge-assistant {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.14);
}

.avatar-badge-assistant,
.avatar-badge-guest.avatar-badge-assistant {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
}

.message[data-author-type="assistant"] .message-avatar {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
}

/* === Analytics dashboard (phase 35) === */

.analytics-range .btn-active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.analytics-charts {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.chart-block h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.bar-chart {
    position: relative;
    min-height: 160px;
}

.bar-chart-wrapper {
    position: relative;
    width: 100%;
}

.bar-chart-inner {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    min-height: 140px;
    padding-top: 0.5rem;
}

.bar-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    cursor: default;
    transition: transform 0.15s ease;
}

.bar-col:hover {
    transform: translateY(-1px);
}

.bar-fill {
    width: 100%;
    max-width: 28px;
    border-radius: 4px 4px 0 0;
    background: var(--accent);
    min-height: 4px;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.bar-fill.bar-messages { background: var(--accent); }
.bar-fill.bar-open { background: #38bdf8; max-width: 12px; }
.bar-fill.bar-resolved { background: #34d399; max-width: 12px; }

.bar-fill.bar-empty-zero {
    background: var(--border, #e5e7eb) !important;
    opacity: 0.7;
    min-height: 3px !important;
    border-radius: 2px 2px 0 0;
}

.bar-col:hover .bar-fill.bar-empty-zero {
    opacity: 1;
    background: var(--text-muted, #9ca3af) !important;
}

.bar-pair {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100px;
    width: 100%;
    justify-content: center;
}

.bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    user-select: none;
}

.bar-chart-watermark {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    text-align: center;
    white-space: nowrap;
}

.bar-chart-watermark-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-radius: 9999px;
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
}

[data-theme="dark"] .bar-chart-watermark-pill {
    background: var(--bg-elevated, #1f2937);
    border-color: var(--border, #374151);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.bar-chart-watermark-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    stroke-width: 2;
}

.chart-empty { margin: 2rem 0; text-align: center; }

.chart-legend {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-open::before,
.legend-resolved::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-inline-end: 0.35rem;
    vertical-align: middle;
}

.legend-open::before { background: #38bdf8; }
.legend-resolved::before { background: #34d399; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: start;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--panel-bg);
}

.data-table tbody tr:hover {
    background: var(--surface-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Alias used by older admin templates */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: start;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--panel-bg);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-panel {
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    gap: 0.75rem;
}

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

@media (max-width: 720px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

.filter-actions {
    display: flex;
    justify-content: flex-start;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-wrap {
    overflow-x: auto;
}

.empty-state {
    padding: 1.5rem;
    margin: 0;
}

.nowrap {
    white-space: nowrap;
}

.mono-cell {
    font-family: var(--mono);
    font-size: 0.85rem;
}

/* === Thread tags (phase 37) === */

.thread-tag-chip {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tag-color, #38bdf8);
    background: color-mix(in srgb, var(--tag-color, #38bdf8) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--tag-color, #38bdf8) 35%, transparent);
    margin-inline-start: 0.25rem;
}

.thread-tag-filter {
    border-color: color-mix(in srgb, var(--tag-color, #38bdf8) 40%, var(--border));
}

.tag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tag-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* === Locale switcher === */
.locale-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.locale-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
}
.locale-btn.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

/* === RTL / Arabic === */
html[dir="rtl"],
html[lang="ar"] {
    --font: 'Cairo', 'Outfit', system-ui, sans-serif;
}
html[dir="rtl"] body {
    font-family: var(--font);
}
html[dir="rtl"] .product-kicker,
html[dir="rtl"] .hero-title,
html[dir="rtl"] .page-header h1,
html[dir="rtl"] .auth-header h1 {
    letter-spacing: 0;
}
html[dir="rtl"] .hero-actions svg,
html[dir="rtl"] .btn-lg svg {
    transform: scaleX(-1);
}
html[dir="rtl"] .data-table th,
html[dir="rtl"] .data-table td,
html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: start;
}
html[dir="rtl"] .channel-arrow {
    right: auto;
    left: 1.25rem;
}
html[dir="rtl"] .attachment-clear {
    right: auto;
    left: 8px;
}
html[dir="rtl"] .msg.mine .msg-bubble {
    border-radius: 16px 16px 16px 4px;
}
html[dir="rtl"] .msg:not(.mine) .msg-bubble {
    border-radius: 16px 16px 4px 16px;
}

/* Directory search (people + channels) */
.directory-search {
    position: relative;
    min-width: min(280px, 100%);
}
.directory-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.directory-search-input {
    width: 100%;
    background: var(--bg-elevated, #101218);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    color: var(--text, #f4f6fb);
    border-radius: 10px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
}
.directory-results {
    position: absolute;
    z-index: 40;
    inset-inline-start: 0;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    background: var(--bg-elevated, #101218);
    border: 1px solid var(--border-strong, rgba(255,255,255,0.14));
    border-radius: 12px;
    padding: 0.5rem;
    max-height: 320px;
    overflow: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.directory-group-title {
    margin: 0.35rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim, #64748b);
    font-weight: 700;
}
.directory-hit {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}
.directory-hit:hover {
    background: var(--primary-subtle);
}
.directory-hit-title {
    font-weight: 600;
    font-size: 0.92rem;
}
.directory-hit-meta {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3a8);
}
.directory-empty {
    padding: 0.75rem;
    margin: 0;
    text-align: center;
}
.page-header .actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ─── Dashboard bar ─── */
.dash-bar {
    position: sticky;
    top: var(--nav-h);
    z-index: 90;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.dash-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Top bar: Breadcrumbs + Mode Switcher */
.dash-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0 0.2rem;
    flex-wrap: wrap;
}

.dash-mode-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 2px;
    gap: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dash-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9999px;
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.dash-mode-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    flex-shrink: 0;
    transition: opacity var(--transition);
}

.dash-mode-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.dash-mode-btn:hover svg {
    opacity: 1;
}

.dash-mode-btn.is-active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent);
    font-weight: 600;
}

.dash-mode-btn.is-active svg {
    opacity: 1;
}

.dash-bar-top-right {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Custom Workspace Dropdown in Top Bar */
.dash-ws-dropdown {
    position: relative;
    display: inline-block;
}

.dash-ws-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.dash-ws-trigger::-webkit-details-marker {
    display: none;
}

.dash-ws-trigger:hover,
.dash-ws-dropdown[open] .dash-ws-trigger {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.dash-ws-icon {
    width: 14px;
    height: 14px;
    color: var(--primary);
    flex-shrink: 0;
}

.dash-ws-title {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-ws-color-tag {
    width: 10px;
    height: 10px;
    border-radius: 9999px;
    flex-shrink: 0;
    background: var(--ws-color);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ws-color) 40%, #000);
}

.dash-ws-caret {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.dash-ws-dropdown[open] .dash-ws-caret {
    transform: rotate(180deg);
}

/* Dropdown Menu Popover */
.dash-ws-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 270px;
    max-width: 320px;
    padding: 0.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius, 12px);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.15));
    z-index: 250;
}

html[dir="rtl"] .dash-ws-menu {
    right: auto;
    left: 0;
}

.dash-ws-menu-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.35rem 0.6rem 0.25rem;
}

.dash-ws-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.dash-ws-item-form {
    margin: 0;
    width: 100%;
}

.dash-ws-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: background var(--transition), color var(--transition);
}

.dash-ws-item:hover {
    background: var(--surface-hover);
}

.dash-ws-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.dash-ws-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.dash-ws-check {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
    margin-inline-start: 0.5rem;
}

.dash-ws-item-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
    margin-inline-start: 0.5rem;
}

.dash-ws-menu-footer {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.dash-ws-footer-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 0.6rem 0.35rem;
}

.dash-ws-create-form {
    margin: 0;
}

.dash-ws-create-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.2rem;
}

.dash-ws-input {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 0.6rem;
    font-size: 0.8rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.dash-ws-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.nav-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    background: var(--surface-hover);
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
}

.nav-user-pill:hover {
    color: var(--text);
    background: var(--surface);
}

.nav-user-pill svg {
    width: 14px;
    height: 14px;
}

/* Breadcrumbs */
.dash-breadcrumbs {
    padding: 0;
}

.dash-breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-wrap: wrap;
}

.dash-breadcrumbs li {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.dash-breadcrumbs li a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.dash-breadcrumbs li a:hover {
    color: var(--primary);
}

.dash-breadcrumbs li[aria-current="page"] span {
    color: var(--text);
    font-weight: 500;
}

.crumb-sep {
    width: 12px;
    height: 12px;
    opacity: 0.4;
    flex-shrink: 0;
}

/* Tab menu */
.dash-menu {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.35rem 0 0;
}

.dash-menu::-webkit-scrollbar { display: none; }

.dash-menu-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: color var(--transition), background var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    flex-shrink: 0;
}

.dash-menu-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--transition);
}

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

.dash-menu-item:hover svg {
    opacity: 1;
}

.dash-menu-item.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--accent-soft);
}

.dash-menu-item.is-active svg {
    opacity: 1;
}

/* Light theme adjustments */
[data-theme="light"] .dash-bar {
    background: rgba(255, 255, 255, 0.88);
}

[data-theme="light"] .dash-menu-item.is-active {
    background: var(--accent-soft);
}

/* Adjust main padding when dash-bar present */
.container.has-dash-bar {
    padding-top: 1.5rem;
}

/* RTL: flip breadcrumb chevrons */
html[dir="rtl"] .crumb-sep {
    transform: scaleX(-1);
}

/* Mobile: tighten padding */
@media (max-width: 640px) {
    .dash-bar-inner {
        padding: 0 1rem;
    }

    .dash-menu-item span {
        display: none;
    }

    .dash-menu-item {
        padding: 0.45rem 0.6rem;
    }

    .dash-menu-item svg {
        width: 18px;
        height: 18px;
    }
}

/* ─── Conversation Header Interactive User Section & Profile Modal ─── */
.chat-header-interactive {
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius);
    padding: 0.35rem 0.6rem;
    margin-inline-start: -0.6rem;
    transition: background var(--transition), transform var(--transition);
}

.chat-header-interactive:hover {
    background: var(--surface-hover);
}

.chat-header-interactive:active {
    transform: scale(0.99);
}

.chat-header-interactive:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.profile-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.profile-modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.profile-modal {
    width: 100%;
    max-width: 500px;
    margin: auto 0;
    max-height: calc(100dvh - 3rem);
    max-height: calc(100vh - 3rem);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    outline: none;
}

.profile-modal-backdrop.open .profile-modal {
    transform: translateY(0) scale(1);
}

.profile-modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1.5rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.profile-modal-heading {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.profile-modal-subtitle {
    margin: 0.2rem 0 0 0;
    font-size: 0.82rem;
}

.profile-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.profile-close-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.profile-close-btn svg {
    width: 18px;
    height: 18px;
}

.profile-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overscroll-behavior: contain;
}

.profile-modal-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.85rem;
}

.profile-modal-avatar {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-strong);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.profile-modal-avatar-fallback {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.profile-modal-avatar-fallback.avatar-member {
    background: var(--surface);
    color: var(--member);
}

.profile-modal-avatar-fallback.avatar-guest {
    background: var(--surface);
    color: var(--guest);
}

.profile-modal-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.profile-modal-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

.profile-modal-handle {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.9rem;
}

.profile-modal-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.profile-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-modal-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.profile-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
}

.profile-detail-label {
    color: var(--text-muted);
}

.profile-detail-value {
    font-weight: 500;
    color: var(--text);
    text-align: end;
}

.profile-modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.profile-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.profile-btn-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.profile-modal-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius);
    background: var(--primary-subtle);
    border: 1px solid var(--hero-badge-border);
    font-size: 0.825rem;
    line-height: 1.4;
    color: var(--text);
}

.profile-notice-icon {
    width: 16px;
    height: 16px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

/* ─── Modal Form Structure & Responsive Scrolling ─── */
.profile-modal-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.profile-modal-form-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.15rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    overscroll-behavior: contain;
}

.profile-modal-form-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.modal-field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
}

.modal-options-stack {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.modal-radio-card {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--bg-canvas);
    transition: border-color var(--transition), background var(--transition);
}

.modal-radio-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.modal-radio-card:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.modal-radio-card input[type="radio"] {
    margin-top: 0.2rem;
    accent-color: var(--accent);
    flex-shrink: 0;
    cursor: pointer;
}

.modal-radio-card-content {
    flex: 1;
    min-width: 0;
}

.modal-radio-card-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.modal-radio-card-desc {
    margin: 0.1rem 0 0 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.modal-channel-list {
    display: none;
    margin-top: 0.65rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-canvas);
    max-height: 160px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-channel-list-hint {
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    font-weight: 600;
}

.modal-channel-list-items {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.modal-channel-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0;
}

.modal-channel-item input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

/* Custom Scrollbar for Modal Scroll Containers */
.profile-modal-body::-webkit-scrollbar,
.profile-modal-form-body::-webkit-scrollbar,
.modal-channel-list::-webkit-scrollbar {
    width: 6px;
}

.profile-modal-body::-webkit-scrollbar-track,
.profile-modal-form-body::-webkit-scrollbar-track,
.modal-channel-list::-webkit-scrollbar-track {
    background: transparent;
}

.profile-modal-body::-webkit-scrollbar-thumb,
.profile-modal-form-body::-webkit-scrollbar-thumb,
.modal-channel-list::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

/* Viewport height <= 800px (MacBook 13", 1440x900 / 1280x800 scaled, laptops, landscape tablets) */
@media (max-height: 800px) {
    .profile-modal-backdrop {
        padding: 1rem 0.75rem;
    }

    .profile-modal {
        max-height: calc(100dvh - 2rem);
        max-height: calc(100vh - 2rem);
        border-radius: var(--radius-lg);
    }

    .profile-modal-header {
        padding: 0.85rem 1.25rem 0.65rem;
    }

    .profile-modal-heading {
        font-size: 0.98rem;
    }

    .profile-modal-form-body {
        padding: 0.85rem 1.25rem;
        gap: 0.8rem;
    }

    .modal-field-label {
        font-size: 0.82rem;
        margin-bottom: 0.35rem;
    }

    .modal-options-stack {
        gap: 0.35rem;
    }

    .modal-radio-card {
        padding: 0.5rem 0.7rem;
        gap: 0.6rem;
    }

    .modal-radio-card-title {
        font-size: 0.84rem;
    }

    .modal-radio-card-desc {
        font-size: 0.75rem;
    }

    .modal-channel-list {
        max-height: 120px;
        padding: 0.6rem;
        margin-top: 0.45rem;
    }

    .profile-modal-form-footer {
        padding: 0.7rem 1.25rem;
    }
}

/* Viewport height <= 640px (e.g. mobile landscape, short windows) */
@media (max-height: 640px) {
    .profile-modal-backdrop {
        padding: 0.5rem;
    }

    .profile-modal {
        max-height: calc(100dvh - 1rem);
        max-height: calc(100vh - 1rem);
        border-radius: var(--radius);
    }

    .profile-modal-header {
        padding: 0.65rem 1rem 0.5rem;
    }

    .profile-modal-form-body {
        padding: 0.65rem 1rem;
        gap: 0.65rem;
    }

    .modal-radio-card {
        padding: 0.4rem 0.6rem;
    }

    .modal-channel-list {
        max-height: 100px;
    }

    .profile-modal-form-footer {
        padding: 0.55rem 1rem;
    }
}

/* Mobile & narrow viewports */
@media (max-width: 580px) {
    .profile-modal-backdrop {
        padding: 0.5rem;
    }

    .profile-modal {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .profile-modal-header {
        padding: 0.95rem 1.15rem 0.75rem;
    }

    .profile-modal-form-body {
        padding: 0.95rem 1.15rem;
        gap: 0.95rem;
    }

    .profile-modal-form-footer {
        padding: 0.75rem 1.15rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .profile-modal-form-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ─── Nav Notifications Dropdown & Feed ─── */
.nav-notifications-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

button.nav-alerts {
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
    line-height: inherit;
}

.nav-notifications-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: 380px;
    max-width: calc(100vw - 2rem);
    max-height: 480px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: navDropdownFadeIn 0.15s ease-out;
}

.nav-notifications-dropdown[hidden] {
    display: none !important;
}

@keyframes navDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.nav-notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.nav-notifications-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-notifications-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.nav-notifications-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
}

.nav-notifications-count-badge[hidden] {
    display: none !important;
}

.nav-notifications-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: 340px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
    position: relative;
    transition: background var(--transition);
}

.notification-item:hover {
    background: var(--surface-hover);
}

.notification-item.is-unread {
    background: var(--accent-soft);
}

.notification-item.is-unread:hover {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.notification-item-avatar-col {
    position: relative;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.notification-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.notification-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.notification-item-content {
    flex: 1 1 auto;
    min-width: 0;
}

.notification-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}

.notification-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.notification-item-subtitle {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.notification-item-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-unread-dot {
    position: absolute;
    inset-inline-end: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.nav-notifications-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.nav-notifications-empty-icon {
    width: 36px;
    height: 36px;
    stroke: var(--text-muted);
    opacity: 0.6;
}

.nav-notifications-empty-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.nav-notifications-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 0.8rem;
}

.nav-notifications-footer-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.nav-notifications-footer-link:hover {
    color: var(--accent);
}

/* ─── Notifications Page Grid & Feed ─── */
.notifications-page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    max-width: 1080px;
    margin: 0 auto;
}

@media (max-width: 860px) {
    .notifications-page-grid {
        grid-template-columns: 1fr;
    }
}

.notifications-feed-card {
    overflow: hidden;
}

.notifications-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notifications-feed-list {
    display: flex;
    flex-direction: column;
}

.notifications-feed-list .notification-item {
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

.notifications-feed-list .notification-item:last-child {
    border-bottom: none;
}

.notifications-feed-empty {
    padding: 3.5rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.notifications-empty-icon {
    width: 44px;
    height: 44px;
    stroke: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 0.75rem;
}

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

.notifications-empty-subtitle {
    font-size: 0.85rem;
    margin: 0;
}

/* Dashboard Sub-Navigation Tabs (Replies & Automation, Integrations) */
.replies-subnav,
.integrations-subnav {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    padding: 4px;
    gap: 4px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    max-width: 100%;
    overflow-x: auto;
}

.replies-subnav-tab,
.integrations-subnav-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-sm, 7px);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.replies-subnav-tab svg,
.integrations-subnav-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--transition);
}

.replies-subnav-tab:hover,
.integrations-subnav-tab:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.replies-subnav-tab:hover svg,
.integrations-subnav-tab:hover svg {
    opacity: 1;
}

.replies-subnav-tab.is-active,
.integrations-subnav-tab.is-active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.replies-subnav-tab.is-active svg,
.integrations-subnav-tab.is-active svg {
    opacity: 1;
}

/* --- Easy Templates Styles --- */
.templates-layout {
    display: grid;
    grid-template-columns: minmax(360px, 460px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 960px) {
    .templates-layout {
        grid-template-columns: 1fr;
    }
}

.form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .form-row-grid {
        grid-template-columns: 1fr;
    }
}

.template-buttons-builder {
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    padding: 0.85rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.02));
    margin: 0.5rem 0;
}

.buttons-builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.buttons-builder-header .field-label-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.buttons-builder-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.button-builder-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm, 6px);
}

.button-builder-row .btn-type-select {
    flex: 0 0 140px;
    width: auto;
    font-size: 0.82rem;
    padding: 0.35rem 1.85rem 0.35rem 0.65rem;
    background-position: calc(100% - 0.55rem) center;
    background-size: 13px 13px;
    border-radius: var(--radius-sm, 6px);
    height: 34px;
    line-height: 1.4;
}

html[dir="rtl"] .button-builder-row .btn-type-select {
    padding: 0.35rem 0.65rem 0.35rem 1.85rem;
    background-position: 0.55rem center;
}

.button-builder-row input[type="text"],
.button-builder-row input {
    flex: 1 1 auto;
    font-size: 0.82rem;
    padding: 0.35rem 0.65rem;
    min-width: 80px;
    height: 34px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.button-builder-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ─── App Styled Custom Dropdown Component ─── */
.app-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
    font-family: var(--font);
    box-sizing: border-box;
}

.app-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    cursor: pointer;
    text-align: start;
    user-select: none;
    box-sizing: border-box;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.app-dropdown-trigger:hover {
    border-color: var(--border-strong, #475569);
}

.app-dropdown.is-open .app-dropdown-trigger,
.app-dropdown-trigger:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.app-dropdown-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.app-dropdown-caret {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-inline-start: 0.5rem;
    transition: transform 0.2s ease;
}

.app-dropdown.is-open .app-dropdown-caret {
    transform: rotate(180deg);
}

.app-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 100%;
    padding: 0.4rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius, 10px);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.2));
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
    animation: navDropdownFadeIn 0.15s ease-out;
}

.app-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: background var(--transition), color var(--transition);
}

.app-dropdown-item:hover,
.app-dropdown-item:focus {
    background: var(--surface-hover);
    outline: none;
}

.app-dropdown-item.is-selected {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.app-dropdown-check {
    width: 15px;
    height: 15px;
    color: var(--accent);
    flex-shrink: 0;
    margin-inline-start: 0.5rem;
}

/* Compact variant for table rows and button builders */
.app-dropdown-sm {
    width: auto;
    flex: 0 0 145px;
}

.app-dropdown-sm .app-dropdown-trigger {
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm, 6px);
    height: 34px;
}

.app-dropdown-sm .app-dropdown-item {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}

.app-dropdown-sm .app-dropdown-menu {
    min-width: 150px;
}

.template-preview-box {
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    padding: 0.85rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.02));
}

.preview-box-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.preview-box-title .preview-title-icon {
    width: 14px;
    height: 14px;
}

.template-card-preview,
.template-message-preview {
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.tpl-prev-header {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    padding: 0.75rem 0.9rem 0.35rem 0.9rem;
}

.tpl-prev-body {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text);
    padding: 0.5rem 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.tpl-prev-footer {
    font-size: 0.76rem;
    color: var(--text-muted);
    padding: 0.25rem 0.9rem 0.75rem 0.9rem;
}

.tpl-prev-buttons {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
}

.tpl-btn-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    color: var(--primary, #3b82f6);
    font-size: 0.84rem;
    font-weight: 500;
    transition: background 0.15s ease;
    user-select: none;
}

.tpl-btn-chip .chip-svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.template-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.template-item-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    background: var(--surface);
    padding: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.template-item-card:hover {
    border-color: var(--border-hover, #cbd5e1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.template-item-card.is-inactive {
    opacity: 0.65;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.02));
}

.template-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.template-item-meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.template-item-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.template-cat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.template-cat-badge.cat-utility {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
}
[data-theme="dark"] .template-cat-badge.cat-utility {
    color: #94a3b8;
}

.template-cat-badge.cat-authentication {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
[data-theme="dark"] .template-cat-badge.cat-authentication {
    color: #34d399;
}

.template-cat-badge.cat-marketing {
    background: rgba(139, 92, 246, 0.12);
    color: #7c3aed;
}
[data-theme="dark"] .template-cat-badge.cat-marketing {
    color: #a78bfa;
}

.template-slug-tag {
    font-family: monospace;
    font-size: 0.78rem;
    background: var(--surface-secondary, #f1f5f9);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--text-muted);
}

.template-vars-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.template-vars-row .vars-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.var-chip {
    font-family: monospace;
    font-size: 0.74rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--border);
    color: var(--text);
}

/* In-Chat Message Interactive Buttons Grid */
.message-buttons-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .message-buttons-grid {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.tpl-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.48rem 0.85rem;
    border-radius: var(--radius-sm, 7px);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--primary, #3b82f6);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all var(--transition, 0.15s ease);
}

.tpl-action-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    color: var(--primary-hover, #2563eb);
}

.tpl-action-btn:active {
    transform: scale(0.985);
}

.tpl-action-btn .tpl-btn-svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.tpl-action-btn.copied {
    background: rgba(16, 185, 129, 0.12);
    border-color: #10b981;
    color: #059669;
}

[data-theme="dark"] .tpl-action-btn.copied {
    color: #34d399;
}

/* Template Picker Modal in Chat */
.template-picker-modal {
    max-width: 520px;
    width: 90vw;
}

.template-params-fields {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.template-params-fields h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* RTL Adaptations */
[dir="rtl"] .tpl-action-btn,
[dir="rtl"] .tpl-btn-chip {
    flex-direction: row-reverse;
}

[dir="rtl"] .buttons-builder-header,
[dir="rtl"] .template-item-header {
    flex-direction: row-reverse;
}

/* Template Analytics Bar in Dashboard */
.template-stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    margin-bottom: 0.75rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.02));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.8rem;
}

.template-stats-bar .stats-label {
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.template-stats-bar .stats-metrics-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.76rem;
}

.stat-pill .stat-name {
    color: var(--text-muted);
}

.stat-pill strong {
    font-weight: 600;
    color: var(--text);
}

.stat-pill.highlight {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #059669;
}

[data-theme="dark"] .stat-pill.highlight {
    color: #34d399;
}

/* Template Test Sandbox Modal */
.sandbox-modal-dialog {
    max-width: 580px;
    width: 92vw;
    border: none;
    border-radius: var(--radius-lg, 12px);
    padding: 0;
    background: transparent;
}

.sandbox-modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

/* Webhook Events Multi-Select Picker */
.webhook-events-picker-group {
    margin: 1.25rem 0;
}

.events-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.events-picker-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.events-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.events-count-badge.has-selected {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border-color: color-mix(in srgb, var(--primary) 30%, transparent);
    color: var(--primary);
}

.btn-xs {
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
}

.webhook-events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 0.75rem;
}

.webhook-event-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.95rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}

.webhook-event-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.webhook-event-card:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.webhook-event-card:has(.webhook-event-cb:checked),
.webhook-event-card.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

[data-theme="dark"] .webhook-event-card:has(.webhook-event-cb:checked),
[data-theme="dark"] .webhook-event-card.is-selected {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.webhook-event-cb {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.event-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.event-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.event-card-header .event-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.event-card-header .event-slug {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.webhook-event-card:has(.webhook-event-cb:checked) .event-card-header .event-slug,
.webhook-event-card.is-selected .event-card-header .event-slug {
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    color: var(--accent);
}

.event-card-content .event-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.event-card-check {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 1.5px solid var(--border-strong);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.webhook-event-card:hover .event-card-check {
    border-color: var(--text-muted);
}

.webhook-event-card:has(.webhook-event-cb:checked) .event-card-check,
.webhook-event-card.is-selected .event-card-check {
    background: var(--accent);
    border-color: var(--accent);
}

.event-check-svg {
    width: 14px;
    height: 14px;
    color: var(--accent-contrast);
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.15s ease;
}

.webhook-event-card:has(.webhook-event-cb:checked) .event-check-svg,
.webhook-event-card.is-selected .event-check-svg {
    opacity: 1;
    transform: scale(1);
}

/* Configured Webhooks List */
.webhook-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.webhook-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.webhook-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
}

.webhook-item-url {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    word-break: break-all;
}

.webhook-item-events {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.webhook-event-badge {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
}


