:root {
    --app-bg: #f4f7fb;
    --panel-bg: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(15, 23, 42, 0.08);
    --ink: #111827;
    --muted: #64748b;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --success: #16a34a;
    --soft-blue: rgba(37, 99, 235, 0.08);
    --shadow-sm: 0 14px 35px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 24px 60px rgba(15, 23, 42, 0.12);
    --radius-lg: 24px;
    --radius-md: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.processity-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34rem),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 30rem),
        linear-gradient(180deg, #f8fbff 0%, var(--app-bg) 46%, #eef3fb 100%);
    color: var(--ink);
    overflow-x: hidden;
}

body.processity-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent 70%);
    z-index: -2;
}

.app-main {
    width: 100%;
    max-width: 1900px;
    margin: 0 auto;
    padding: 28px 24px 18px;
}

.app-message-wrap {
    max-width: 1600px;
    margin: 0 auto 16px;
}

.app-navbar {
    background: rgba(17, 24, 39, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-navbar .navbar-toggler-icon {
    filter: invert(1);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff !important;
    letter-spacing: -0.01em;
}

.brand-lockup span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-lockup small {
    color: #93c5fd;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-mark,
.brand-mark-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #60a5fa, #2563eb 52%, #1d4ed8);
    color: #fff;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.38);
    font-weight: 900;
}

.brand-mark-small {
    width: 42px;
    height: 42px;
    border-radius: 16px;
}

.app-navbar .nav-link {
    color: rgba(255, 255, 255, 0.72);
    font-weight: 600;
    border-radius: 999px;
    padding: 8px 13px !important;
    transition: all 0.18s ease;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.user-chip {
    display: inline-flex;
    max-width: 240px;
    padding: 7px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.07);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-sync-btn,
.nav-connect-btn,
.nav-logout-btn {
    border-radius: 999px;
    font-weight: 700;
}

.app-footer {
    color: var(--muted);
    padding: 18px 0 28px;
    font-size: 0.86rem;
}

.footer-muted {
    color: #94a3b8;
}

.mail-shell,
.landing-shell {
    max-width: 1840px;
    margin: 0 auto;
}

.mail-topbar {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 22px;
    padding: 24px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.74)),
        radial-gradient(circle at 85% 10%, rgba(37, 99, 235, 0.16), transparent 24rem);
    box-shadow: var(--shadow-sm);
}

.mail-topbar::after {
    content: "";
    position: absolute;
    top: -65px;
    right: 8%;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.08);
    animation: floatOrb 6s ease-in-out infinite;
}

.mail-title {
    font-size: clamp(1.35rem, 1.2rem + 0.9vw, 2.2rem);
    letter-spacing: -0.04em;
}

.mail-subtitle,
.landing-copy {
    color: var(--muted);
}

.eyebrow-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.78);
    color: #334155;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.035em;
}

.status-live {
    color: #166534;
    background: rgba(22, 163, 74, 0.10);
    border-color: rgba(22, 163, 74, 0.18);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 rgba(22, 163, 74, 0.45);
    animation: pulseDot 1.7s infinite;
}

.mail-top-stats {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
}

.mini-stat {
    min-width: 86px;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    text-align: center;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
}

.mini-stat span {
    display: block;
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.mini-stat small {
    color: var(--muted);
    font-weight: 700;
}

.mini-stat.accent span {
    color: var(--brand);
}

.panel-card {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    background: var(--panel-bg);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-sm);
}

.sidebar-panel,
.assistant-card,
.list-panel,
.detail-panel {
    overflow: hidden;
}

.sidebar-panel {
    padding: 18px;
}

.sidebar-brand-block,
.assistant-card-head,
.compose-header,
.mail-list-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-action {
    border: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 13px;
    border-radius: 15px;
    background: #f8fafc;
    color: #334155;
    font-weight: 800;
    transition: all 0.18s ease;
}

.sidebar-action:hover {
    transform: translateY(-1px);
    background: #eef4ff;
    color: var(--brand-dark);
}

.sidebar-action.active,
.sidebar-action.compose-action {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.28);
}

.count-badge,
.shortcut-chip,
.list-count-pill,
.unread-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 900;
    padding: 4px 9px;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
}

.count-badge.muted {
    background: rgba(100, 116, 139, 0.14);
    color: #334155;
}

.sidebar-action.active .count-badge,
.sidebar-action.compose-action .shortcut-chip {
    color: #fff;
}

.sync-note {
    border-radius: 18px;
    padding: 14px;
    background: rgba(37, 99, 235, 0.07);
    color: #1e3a8a;
}

.sync-note p {
    font-size: 0.82rem;
    color: #475569;
}

.filter-panel {
    padding: 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.filter-field.span-2 {
    grid-column: span 2;
}

.filter-field label,
.form-label {
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.soft-input {
    border: 1px solid rgba(15, 23, 42, 0.10);
    background-color: #f8fafc;
    border-radius: 14px;
    min-height: 44px;
    transition: all 0.18s ease;
}

.soft-input:focus {
    border-color: rgba(37, 99, 235, 0.48);
    background: #fff;
    box-shadow: 0 0 0 0.22rem rgba(37, 99, 235, 0.12);
}

.soft-button {
    min-height: 44px;
    border-radius: 14px;
    font-weight: 800;
}

.mail-list-header {
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.list-count-pill {
    color: #1e3a8a;
    background: rgba(37, 99, 235, 0.09);
}

.email-list-panel {
    max-height: 64vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.email-row {
    border: 0 !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07) !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.72);
    transition: all 0.16s ease;
}

.email-row:hover,
.email-row:focus {
    background: #fff;
    transform: translateX(3px);
}

.email-row.unread-email {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.92));
}

.mail-row-inner {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px 16px;
}

.mail-avatar {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #e0ecff, #c7d2fe);
    color: #1d4ed8;
    font-weight: 900;
    text-transform: uppercase;
}

.mail-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mail-sender,
.mail-subject {
    color: #0f172a;
}

.mail-subject {
    margin-top: 4px;
    font-weight: 800;
}

.mail-snippet {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.86rem;
}

.mail-date {
    color: #64748b;
    font-size: 0.78rem;
    white-space: nowrap;
}

.unread-pill {
    background: #2563eb;
    color: #fff;
    padding: 3px 7px;
    font-size: 0.68rem;
}

.detail-panel {
    min-height: 68vh;
}

.empty-state {
    min-height: 68vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.empty-state h2 {
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 900;
    margin-top: 18px;
}

.empty-orb {
    width: 92px;
    height: 92px;
    border-radius: 32px;
    background:
        radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.95), transparent 30%),
        linear-gradient(135deg, #60a5fa, #2563eb);
    box-shadow: 0 24px 60px rgba(37, 99, 235, 0.28);
    animation: floatOrb 5s ease-in-out infinite;
}

.hint-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.hint-row code {
    border-radius: 999px;
    padding: 5px 10px;
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.08);
}

.compose-header {
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.compose-body-wrap {
    padding: 18px;
}

.compose-textarea {
    min-height: 230px;
    resize: vertical;
}

.human-loop-note {
    margin-top: 10px;
    text-align: center;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 700;
}

.assistant-card {
    padding: 16px;
    position: sticky;
    top: 88px;
}

.assistant-card-head {
    margin-bottom: 14px;
}

.assistant-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #111827, #2563eb);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.24);
}

.assistant-messages {
    height: 260px;
    overflow-y: auto;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    padding: 12px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.9));
    scrollbar-width: thin;
}

.assistant-bubble {
    border-radius: 16px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.35;
    animation: messageIn 0.2s ease both;
}

.assistant-bubble.user {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    margin-left: 18px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.assistant-bubble.bot {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    margin-right: 18px;
    color: #1f2937;
}

.example-label {
    color: #94a3b8;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.assistant-example-btn {
    border: 0;
    width: 100%;
    display: block;
    text-align: left;
    background: transparent;
    color: #2563eb;
    padding: 5px 0;
    line-height: 1.25;
    font-weight: 700;
}

.assistant-example-btn:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.debug-details summary {
    cursor: pointer;
    color: #64748b;
    font-weight: 800;
}

.debug-output {
    margin: 10px 0 0;
    padding: 10px;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    color: #334155;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    font-size: 0.74rem;
}

.compose-fill-highlight {
    box-shadow: 0 0 0 0.22rem rgba(37, 99, 235, 0.18) !important;
    background: #fff !important;
    transition: box-shadow 0.25s ease, background 0.25s ease;
}

.empty-list-state {
    padding: 42px 24px;
    text-align: center;
    color: var(--muted);
}

.empty-list-icon {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: 20px;
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
    font-size: 1.5rem;
}

.min-width-0 {
    min-width: 0;
}

.landing-shell {
    position: relative;
    overflow: hidden;
    min-height: calc(100vh - 170px);
    border-radius: 34px;
    padding: clamp(28px, 5vw, 70px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(239, 246, 255, 0.82)),
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.22), transparent 30rem);
    box-shadow: var(--shadow-md);
}

.landing-title {
    max-width: 820px;
    color: #0f172a;
    font-size: clamp(2.4rem, 4vw, 5.3rem);
    line-height: 0.95;
    font-weight: 950;
    letter-spacing: -0.07em;
}

.landing-copy {
    max-width: 650px;
    margin-top: 20px;
    font-size: 1.12rem;
    line-height: 1.75;
}

.landing-note {
    max-width: 330px;
    display: inline-flex;
    align-items: center;
    color: #64748b;
    font-weight: 700;
}

.landing-bg-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(2px);
    opacity: 0.7;
    pointer-events: none;
}

.orb-one {
    width: 240px;
    height: 240px;
    right: -70px;
    top: -70px;
    background: rgba(37, 99, 235, 0.14);
    animation: floatOrb 7s ease-in-out infinite;
}

.orb-two {
    width: 160px;
    height: 160px;
    left: 42%;
    bottom: -60px;
    background: rgba(14, 165, 233, 0.12);
    animation: floatOrb 8s ease-in-out infinite reverse;
}

.demo-window {
    position: relative;
    z-index: 1;
    max-width: 620px;
    margin-left: auto;
    border-radius: 28px;
    padding: 18px;
    background: rgba(15, 23, 42, 0.94);
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.30);
    border: 1px solid rgba(255, 255, 255, 0.10);
    transform: rotate(1deg);
}

.demo-window-bar {
    display: flex;
    gap: 7px;
    margin-bottom: 18px;
}

.demo-window-bar span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
}

.demo-assistant-line {
    width: fit-content;
    max-width: 88%;
    padding: 11px 13px;
    margin-bottom: 12px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 0.92rem;
}

.demo-assistant-line.user {
    margin-left: auto;
    color: #fff;
    background: #2563eb;
}

.demo-assistant-line.bot {
    color: #dbeafe;
    background: rgba(255, 255, 255, 0.10);
}

.demo-ui-card,
.demo-compose-card {
    padding: 18px;
    border-radius: 22px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.demo-compose-card strong {
    color: #fff;
}

.demo-row,
.demo-input {
    height: 14px;
    margin-bottom: 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.32);
}

.demo-row.short,
.demo-input.short {
    width: 70%;
}

.demo-row.tiny {
    width: 45%;
}

.shimmer-card {
    position: relative;
    overflow: hidden;
}

.shimmer-card::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
    animation: shimmer 2.5s infinite;
}

.feature-card {
    height: 100%;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.07);
    transition: all 0.18s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 55px rgba(15, 23, 42, 0.12);
}

.feature-card span {
    color: #2563eb;
    font-weight: 900;
}

.feature-card h3 {
    margin-top: 10px;
    font-size: 1.1rem;
    font-weight: 900;
}

.feature-card p {
    color: #64748b;
    margin-bottom: 0;
}

.email-body-view {
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
    70% { box-shadow: 0 0 0 9px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

@keyframes floatOrb {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(12px) rotate(4deg); }
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.animate-in {
    animation: pageIn 0.45s ease both;
}

.animate-delay-1 {
    animation-delay: 0.08s;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1199.98px) {
    .assistant-card {
        position: static;
    }

    .assistant-messages {
        height: 210px;
    }
}

@media (max-width: 991.98px) {
    .app-main {
        padding: 20px 14px 14px;
    }

    .mail-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .mail-top-stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .demo-window {
        margin: 0;
        transform: none;
    }
}

@media (max-width: 575.98px) {
    .mail-top-stats,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-field.span-2 {
        grid-column: span 1;
    }

    .mail-row-inner {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .mail-date {
        grid-column: 2;
    }

    .landing-title {
        letter-spacing: -0.045em;
    }
}


/* v4 focused layout fix: keep opened email centered, readable, and scrollable */
.detail-panel {
    min-height: 68vh;
    height: 68vh;
    display: flex;
    flex-direction: column;
}

.email-detail-header {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.92);
}

.email-detail-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    line-height: 1.35;
    font-weight: 900;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.email-detail-meta {
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.email-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 22px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.06), transparent 34%),
        #f8fafc;
}

.email-paper {
    width: min(100%, 860px);
    min-height: 100%;
    margin: 0 auto;
    padding: 24px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.email-body-view {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.68;
    color: #1f2937;
    font-size: 0.95rem;
}

.email-loading-state {
    min-height: 68vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-weight: 700;
}

.min-width-0 {
    min-width: 0;
}

@media (max-width: 1199.98px) {
    .detail-panel {
        height: auto;
        min-height: 62vh;
    }

    .email-detail-body {
        max-height: none;
    }
}

@media (max-width: 575.98px) {
    .email-detail-header {
        flex-direction: column;
    }

    .email-detail-body {
        padding: 14px;
    }

    .email-paper {
        padding: 16px;
        border-radius: 18px;
    }
}

/* v5: rich assistant cards + Gmail thread/conversation view */
.assistant-rich-card {
    margin: 10px 0;
    padding: 12px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.96));
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    animation: cardPop 0.22s ease-out;
}

.assistant-rich-card-type {
    display: inline-flex;
    margin-bottom: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.assistant-rich-card-title {
    color: #0f172a;
    font-weight: 900;
    line-height: 1.25;
}

.assistant-rich-card-subtitle,
.assistant-rich-card-meta {
    margin-top: 4px;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.45;
}

.assistant-card-btn {
    margin-top: 10px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 8px 10px;
    background: #2563eb;
    color: #fff;
    font-weight: 900;
    font-size: 0.78rem;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.assistant-card-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(37, 99, 235, 0.3);
}

.thread-summary,
.thread-panel {
    width: min(100%, 860px);
    margin: 16px auto 0;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.07);
}

.thread-summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    color: #64748b;
    font-size: 0.86rem;
}

.thread-summary strong {
    color: #0f172a;
}

.thread-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.thread-panel-head strong {
    display: block;
    color: #0f172a;
    font-weight: 950;
}

.thread-panel-head span {
    color: #64748b;
    font-size: 0.82rem;
}

.thread-badge {
    flex-shrink: 0;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8 !important;
    font-weight: 900;
}

.thread-list {
    padding: 8px;
}

.thread-item {
    width: 100%;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    padding: 12px;
    text-align: left;
    transition: background 0.18s ease, transform 0.18s ease;
}

.thread-item:hover {
    background: rgba(37, 99, 235, 0.06);
    transform: translateX(2px);
}

.thread-item.active {
    background: rgba(37, 99, 235, 0.1);
}

.thread-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12);
}

.thread-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #0f172a;
}

.thread-topline small {
    color: #94a3b8;
    white-space: nowrap;
}

.thread-subject,
.thread-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-subject {
    margin-top: 2px;
    color: #334155;
    font-weight: 800;
    font-size: 0.86rem;
}

.thread-preview {
    margin-top: 3px;
    color: #64748b;
    font-size: 0.8rem;
}

@keyframes cardPop {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 575.98px) {
    .thread-panel-head,
    .thread-topline {
        flex-direction: column;
    }

    .thread-topline small {
        white-space: normal;
    }
}

/* --------------------------------------------------------------------------
   v7 upgrades: dark mode + compose-area AI command box
   -------------------------------------------------------------------------- */

:root[data-theme="dark"] {
    --app-bg: #0b1220;
    --panel-bg: rgba(15, 23, 42, 0.88);
    --panel-border: rgba(148, 163, 184, 0.18);
    --ink: #e5edf9;
    --muted: #9aa9bd;
    --brand: #60a5fa;
    --brand-dark: #3b82f6;
    --success: #4ade80;
    --soft-blue: rgba(96, 165, 250, 0.14);
    --shadow-sm: 0 14px 35px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 24px 70px rgba(0, 0, 0, 0.36);
}

:root[data-theme="dark"] body.processity-body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), transparent 34rem),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.13), transparent 30rem),
        linear-gradient(180deg, #0a1020 0%, #0b1220 46%, #111827 100%);
}

:root[data-theme="dark"] body.processity-body::before {
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
}

.nav-theme-btn {
    border-radius: 999px;
    font-weight: 800;
    min-width: 92px;
}

.ai-compose-box {
    padding: 16px;
    border-radius: 22px;
    border: 1px solid rgba(37, 99, 235, 0.18);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.13), transparent 60%),
        rgba(255, 255, 255, 0.70);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.ai-mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--brand-dark);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

:root[data-theme="dark"] .app-navbar {
    background: rgba(2, 6, 23, 0.94);
    border-bottom-color: rgba(148, 163, 184, 0.16);
}

:root[data-theme="dark"] .panel-card,
:root[data-theme="dark"] .mini-stat,
:root[data-theme="dark"] .assistant-rich-card,
:root[data-theme="dark"] .thread-panel,
:root[data-theme="dark"] .thread-summary,
:root[data-theme="dark"] .email-paper,
:root[data-theme="dark"] .feature-card,
:root[data-theme="dark"] .assistant-messages,
:root[data-theme="dark"] .assistant-bubble.bot,
:root[data-theme="dark"] .debug-output,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .card-header,
:root[data-theme="dark"] .card-body,
:root[data-theme="dark"] .list-group-item {
    background: var(--panel-bg);
    border-color: var(--panel-border);
    color: var(--ink);
}

:root[data-theme="dark"] .mail-topbar {
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.78)),
        radial-gradient(circle at 85% 10%, rgba(96, 165, 250, 0.16), transparent 24rem);
    border-color: var(--panel-border);
    color: var(--ink);
}

:root[data-theme="dark"] .landing-shell {
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.82)),
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.20), transparent 30rem);
    border-color: var(--panel-border);
    color: var(--ink);
}

:root[data-theme="dark"] .ai-compose-box {
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, 0.16), transparent 60%),
        rgba(15, 23, 42, 0.82);
    border-color: rgba(148, 163, 184, 0.24);
    color: var(--ink);
}

:root[data-theme="dark"] .soft-input,
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
    background-color: rgba(15, 23, 42, 0.82);
    border-color: rgba(148, 163, 184, 0.24);
    color: var(--ink);
}

:root[data-theme="dark"] .soft-input::placeholder,
:root[data-theme="dark"] .form-control::placeholder {
    color: rgba(203, 213, 225, 0.52);
}

:root[data-theme="dark"] .text-muted,
:root[data-theme="dark"] .mail-subtitle,
:root[data-theme="dark"] .email-detail-meta,
:root[data-theme="dark"] .thread-preview,
:root[data-theme="dark"] .landing-copy,
:root[data-theme="dark"] .landing-note {
    color: var(--muted) !important;
}

:root[data-theme="dark"] .email-row,
:root[data-theme="dark"] .thread-item {
    background: rgba(15, 23, 42, 0.48);
    border-color: rgba(148, 163, 184, 0.14);
    color: var(--ink);
}

:root[data-theme="dark"] .email-row:hover,
:root[data-theme="dark"] .thread-item:hover,
:root[data-theme="dark"] .thread-item.active {
    background: rgba(37, 99, 235, 0.18);
}

:root[data-theme="dark"] .email-body-view,
:root[data-theme="dark"] .email-detail-title,
:root[data-theme="dark"] .mail-title,
:root[data-theme="dark"] .landing-title,
:root[data-theme="dark"] .feature-card h3,
:root[data-theme="dark"] .filter-field label,
:root[data-theme="dark"] .form-label,
:root[data-theme="dark"] .assistant-rich-card-title,
:root[data-theme="dark"] .thread-summary strong,
:root[data-theme="dark"] .thread-panel-head strong,
:root[data-theme="dark"] .thread-topline,
:root[data-theme="dark"] .thread-subject,
:root[data-theme="dark"] .mail-sender,
:root[data-theme="dark"] .mail-subject,
:root[data-theme="dark"] .empty-state h2,
:root[data-theme="dark"] .assistant-bubble.bot,
:root[data-theme="dark"] .debug-output,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .card h1,
:root[data-theme="dark"] .card h2,
:root[data-theme="dark"] .card h3,
:root[data-theme="dark"] .card h4,
:root[data-theme="dark"] .card h5,
:root[data-theme="dark"] .card h6 {
    color: var(--ink);
}

:root[data-theme="dark"] .btn-light,
:root[data-theme="dark"] .bg-white {
    background-color: rgba(15, 23, 42, 0.92) !important;
    color: var(--ink) !important;
    border-color: rgba(148, 163, 184, 0.24) !important;
}

:root[data-theme="dark"] .footer-shell {
    color: var(--muted);
}

#composeAssistantInput {
    min-height: 92px;
    resize: vertical;
}

@media (max-width: 991px) {
    .nav-theme-btn {
        width: 100%;
        margin-bottom: 8px;
    }
}
