:root {
    --nexus-shell-navy-950: #07152d;
    --nexus-shell-navy-900: #0a1e3d;
    --nexus-shell-navy-800: #12325e;
    --nexus-shell-blue-600: #2563eb;
    --nexus-shell-blue-500: #3b82f6;
    --nexus-shell-blue-100: #dbeafe;
    --nexus-shell-slate-950: #0f172a;
    --nexus-shell-slate-700: #334155;
    --nexus-shell-slate-500: #64748b;
    --nexus-shell-slate-300: #cbd5e1;
    --nexus-shell-slate-200: #e2e8f0;
    --nexus-shell-slate-100: #f1f5f9;
    --nexus-shell-canvas: #e5e9ef;
    --nexus-shell-surface: #ffffff;
    --nexus-shell-sidebar-width: 17.5rem;
    --nexus-shell-sidebar-collapsed-width: 5.25rem;
    --nexus-shell-topbar-height: 4.5rem;
    --nexus-shell-radius-sm: .55rem;
    --nexus-shell-radius-md: .8rem;
    --nexus-shell-shadow: 0 12px 30px rgba(15, 23, 42, .08);
    --nexus-shell-transition: 180ms cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

body.nexus-app-body {
    min-width: 320px;
    margin: 0;
    overflow-x: hidden;
    background: var(--nexus-shell-canvas);
    color: var(--nexus-shell-slate-950);
}

.nexus-app-shell { min-height: 100vh; }

.nexus-app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    display: flex;
    width: var(--nexus-shell-sidebar-width);
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(148, 163, 184, .18);
    background:
        radial-gradient(circle at 10% 0, rgba(59, 130, 246, .24), transparent 25rem),
        linear-gradient(180deg, var(--nexus-shell-navy-900), var(--nexus-shell-navy-950));
    color: #e8eef8;
    box-shadow: 10px 0 30px rgba(7, 21, 45, .12);
    transition: width var(--nexus-shell-transition), transform var(--nexus-shell-transition);
}

.nexus-app-brand {
    display: flex;
    min-height: var(--nexus-shell-topbar-height);
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    padding: .8rem 1rem;
}

.nexus-app-brand-mark,
.nexus-app-command-mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    background: linear-gradient(145deg, #60a5fa, #2563eb);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 8px 22px rgba(37, 99, 235, .35);
}

.nexus-app-brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .72rem;
    font-size: 1.1rem;
}

.nexus-app-brand-copy {
    display: grid;
    min-width: 0;
    line-height: 1.1;
}

.nexus-app-brand-copy strong { color: #fff; font-size: 1rem; letter-spacing: .01em; }
.nexus-app-brand-copy span { margin-top: .22rem; color: #94b8e8; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

.nexus-shell-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
}

.nexus-app-icon-button {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: var(--nexus-shell-radius-sm);
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.nexus-app-icon-button:hover,
.nexus-app-icon-button:focus-visible { background: rgba(148, 163, 184, .16); outline: none; }
.nexus-app-sidebar-close { display: none; margin-left: auto; }
.nexus-app-sidebar-hide { margin-left: auto; color: #9eb6d6; }
.nexus-app-sidebar-hide .nexus-shell-icon { transform: rotate(180deg); }

.nexus-app-nav-search {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: .9rem .8rem .45rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: .68rem;
    background: rgba(255, 255, 255, .07);
    padding: .65rem .72rem;
    color: #9bb8de;
}

.nexus-app-nav-search:focus-within { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .14); }
.nexus-app-nav-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; font-size: .84rem; }
.nexus-app-nav-search input::placeholder { color: #88a7cf; }

.nexus-app-nav { min-height: 0; flex: 1; overflow: auto; padding: .25rem .65rem 1rem; scrollbar-color: rgba(148, 163, 184, .35) transparent; }
.nexus-app-nav-section { margin-top: .45rem; }

.nexus-app-nav-section-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .62rem;
    border: 0;
    border-radius: .58rem;
    background: transparent;
    padding: .52rem .55rem;
    color: #89a8cf;
    cursor: pointer;
    font: inherit;
    font-size: .68rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-align: left;
    text-transform: uppercase;
}

.nexus-app-nav-section-toggle:hover,
.nexus-app-nav-section-toggle:focus-visible { background: rgba(255, 255, 255, .05); color: #c9dbf2; outline: none; }
.nexus-app-nav-section-icon { display: grid; width: 1.5rem; place-items: center; }
.nexus-app-nav-section-icon .nexus-shell-icon { width: .95rem; height: .95rem; }
.nexus-app-nav-chevron { width: .85rem; height: .85rem; margin-left: auto; transition: transform var(--nexus-shell-transition); }
.nexus-app-nav-section-toggle[aria-expanded="true"] .nexus-app-nav-chevron { transform: rotate(90deg); }
.nexus-app-nav-items { display: grid; gap: .16rem; margin-top: .1rem; }
.nexus-app-nav-items[hidden] { display: none !important; }

.nexus-app-nav-item {
    display: flex;
    min-height: 2.45rem;
    align-items: center;
    gap: .7rem;
    border-radius: .62rem;
    padding: .52rem .72rem .52rem 1rem;
    color: #cad8eb;
    font-size: .84rem;
    font-weight: 680;
    text-decoration: none;
    transition: background var(--nexus-shell-transition), color var(--nexus-shell-transition), transform var(--nexus-shell-transition);
}

.nexus-app-nav-item:hover,
.nexus-app-nav-item:focus-visible { background: rgba(255, 255, 255, .08); color: #fff; outline: none; transform: translateX(2px); }
.nexus-app-nav-item.is-active { background: linear-gradient(90deg, rgba(37, 99, 235, .9), rgba(59, 130, 246, .55)); color: #fff; box-shadow: inset 0 0 0 1px rgba(147, 197, 253, .2); }
.nexus-app-nav-item.is-active .nexus-shell-icon { filter: drop-shadow(0 2px 4px rgba(0,0,0,.15)); }
.nexus-app-nav-empty { padding: 1rem; color: #8fa9cb; font-size: .82rem; }

.nexus-app-sidebar-footer { flex: 0 0 auto; border-top: 1px solid rgba(255, 255, 255, .09); padding: .7rem; }
.nexus-app-collapse { display: flex; width: 100%; align-items: center; gap: .65rem; border: 0; border-radius: .6rem; background: transparent; padding: .62rem .72rem; color: #9eb6d6; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 700; }
.nexus-app-collapse:hover,
.nexus-app-collapse:focus-visible { background: rgba(255, 255, 255, .07); color: #fff; outline: none; }
.nexus-app-collapse .nexus-shell-icon { transform: rotate(180deg); transition: transform var(--nexus-shell-transition); }

.nexus-app-workspace {
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--nexus-shell-sidebar-width);
    transition: margin-left var(--nexus-shell-transition);
}

.nexus-app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    min-height: var(--nexus-shell-topbar-height);
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--nexus-shell-slate-200);
    background: rgba(255, 255, 255, .94);
    padding: .7rem 1.25rem;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .045);
    backdrop-filter: blur(14px);
}

.nexus-app-menu-button { display: none; color: var(--nexus-shell-slate-700); }
.nexus-app-page-identity { display: grid; min-width: 8rem; line-height: 1.12; }
.nexus-app-page-identity span { color: #3864a4; font-size: .64rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.nexus-app-page-identity strong { margin-top: .22rem; color: var(--nexus-shell-slate-950); font-size: 1rem; }

.nexus-app-command {
    display: flex;
    width: min(31rem, 42vw);
    min-height: 2.65rem;
    align-items: center;
    gap: .68rem;
    margin-inline: auto;
    border: 1px solid var(--nexus-shell-slate-200);
    border-radius: .72rem;
    background: #f8fafc;
    padding: .45rem .55rem;
    color: var(--nexus-shell-slate-500);
    text-decoration: none;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, .02);
}

.nexus-app-command:hover,
.nexus-app-command:focus-visible { border-color: #93c5fd; background: #fff; color: #1d4ed8; outline: 3px solid rgba(59, 130, 246, .12); }
.nexus-app-command-mark { width: 1.75rem; height: 1.75rem; border-radius: .5rem; font-size: .75rem; }
.nexus-app-command span:nth-child(2) { flex: 1; font-size: .86rem; font-weight: 700; }
.nexus-app-command kbd { border: 1px solid var(--nexus-shell-slate-200); border-bottom-color: var(--nexus-shell-slate-300); border-radius: .36rem; background: #fff; padding: .15rem .4rem; color: var(--nexus-shell-slate-500); font: inherit; font-size: .7rem; }

.nexus-app-topbar-actions { display: flex; min-width: max-content; align-items: center; gap: .65rem; margin-left: auto; }
.nexus-header-mailbox { position: relative; color: var(--nexus-shell-slate-700); }
.nexus-header-mailbox > summary { display: flex; min-height: 2.25rem; max-width: 19rem; align-items: center; gap: .42rem; border: 1px solid var(--nexus-shell-slate-200); border-radius: .65rem; background: #f8fafc; padding: .38rem .55rem; cursor: pointer; list-style: none; user-select: none; }
.nexus-header-mailbox > summary::-webkit-details-marker { display: none; }
.nexus-header-mailbox > summary:hover,
.nexus-header-mailbox > summary:focus-visible,
.nexus-header-mailbox[open] > summary { border-color: #93c5fd; background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, .10); }
.nexus-header-mailbox-dot { width: .5rem; height: .5rem; flex: 0 0 auto; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .12); }
.nexus-header-mailbox-dot.is-connected { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .12); }
.nexus-header-mailbox-dot.is-disconnected { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .10); }
.nexus-header-mailbox-label { color: var(--nexus-shell-slate-500); font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.nexus-header-mailbox > summary strong { min-width: 0; overflow: hidden; color: var(--nexus-shell-slate-700); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.nexus-header-mailbox-caret { margin-left: .1rem; color: var(--nexus-shell-slate-500); transition: transform 160ms ease; }
.nexus-header-mailbox[open] .nexus-header-mailbox-caret { transform: rotate(180deg); }
.nexus-header-mailbox-menu { position: absolute; top: calc(100% + .5rem); right: 0; z-index: 120; display: grid; width: min(23rem, calc(100vw - 2rem)); gap: .75rem; border: 1px solid var(--nexus-shell-slate-200); border-radius: .8rem; background: #fff; padding: .85rem; box-shadow: 0 18px 45px rgba(15, 23, 42, .18); }
.nexus-header-mailbox-status { display: grid; gap: .18rem; }
.nexus-header-mailbox-status span,
.nexus-header-mailbox-menu label { color: var(--nexus-shell-slate-500); font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.nexus-header-mailbox-status strong { font-size: .88rem; }
.nexus-header-mailbox-status small,
.nexus-header-mailbox-menu p { margin: 0; color: var(--nexus-shell-slate-500); font-size: .76rem; }
.nexus-header-mailbox-menu form { display: grid; gap: .35rem; }
.nexus-header-mailbox-menu select, .nexus-header-mailbox-menu input[type="password"] { width: 100%; min-height: 2.4rem; border: 1px solid var(--nexus-shell-slate-300); border-radius: .5rem; background: #fff; padding: .4rem .55rem; color: inherit; font: inherit; font-size: .8rem; }
.nexus-header-mailbox-connect { border-top: 1px solid var(--nexus-shell-slate-200); padding-top: .7rem; }
.nexus-app-user { display: grid; width: 2.15rem; height: 2.15rem; place-items: center; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-size: .78rem; font-weight: 900; }
.nexus-app-content { min-width: 0; padding: 1rem 0 2rem; }
.nexus-app-content > .wrap { max-width: none; }
.nexus-app-scrim,
.nexus-app-mobile-nav { display: none; }

.nexus-assistant-compat-tabs { display: none !important; }
.nexus-assistant-shell-intro { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .4rem 1rem 1rem; padding: .2rem .1rem; }
.nexus-assistant-shell-intro h1 { margin: 0; color: var(--nexus-shell-slate-950); font-size: clamp(1.35rem, 2vw, 1.75rem); }
.nexus-assistant-shell-intro p { margin: .25rem 0 0; color: var(--nexus-shell-slate-500); font-size: .88rem; }

@media (min-width: 1025px) {
    html.nexus-shell-prefers-hidden .nexus-app-sidebar,
    .nexus-app-shell.is-sidebar-hidden .nexus-app-sidebar { transform: translateX(-103%); }
    html.nexus-shell-prefers-hidden .nexus-app-workspace,
    .nexus-app-shell.is-sidebar-hidden .nexus-app-workspace { margin-left: 0; }
    html.nexus-shell-prefers-hidden .nexus-app-menu-button,
    .nexus-app-shell.is-sidebar-hidden .nexus-app-menu-button { display: grid; }
    html.nexus-shell-prefers-collapsed .nexus-app-sidebar,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-sidebar { width: var(--nexus-shell-sidebar-collapsed-width); }
    html.nexus-shell-prefers-collapsed .nexus-app-workspace,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-workspace { margin-left: var(--nexus-shell-sidebar-collapsed-width); }
    html.nexus-shell-prefers-collapsed .nexus-app-brand-copy,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-search input,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-section-toggle > span:not(.nexus-app-nav-section-icon),
    html.nexus-shell-prefers-collapsed .nexus-app-nav-chevron,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-item span,
    html.nexus-shell-prefers-collapsed .nexus-app-collapse span,
    html.nexus-shell-prefers-collapsed .nexus-app-sidebar-hide,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-brand-copy,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-search input,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-section-toggle > span:not(.nexus-app-nav-section-icon),
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-chevron,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-item span,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-collapse span,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-sidebar-hide { display: none; }
    html.nexus-shell-prefers-collapsed .nexus-app-brand,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-search,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-section-toggle,
    html.nexus-shell-prefers-collapsed .nexus-app-nav-item,
    html.nexus-shell-prefers-collapsed .nexus-app-collapse,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-brand,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-search,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-section-toggle,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-item,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-collapse { justify-content: center; padding-inline: .5rem; }
    html.nexus-shell-prefers-collapsed .nexus-app-nav-search,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-search { min-height: 2.65rem; }
    html.nexus-shell-prefers-collapsed .nexus-app-nav-section-toggle,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-nav-section-toggle { margin-top: .4rem; }
    html.nexus-shell-prefers-collapsed .nexus-app-collapse .nexus-shell-icon,
    .nexus-app-shell.is-sidebar-collapsed .nexus-app-collapse .nexus-shell-icon { transform: none; }
}

@media (max-width: 1024px) {
    .nexus-app-sidebar { width: min(19rem, 88vw); transform: translateX(-103%); }
    .nexus-app-shell.is-sidebar-open .nexus-app-sidebar { transform: translateX(0); }
    .nexus-app-workspace { margin-left: 0; }
    .nexus-app-sidebar-close,
    .nexus-app-menu-button { display: grid; }
    .nexus-app-sidebar-hide { display: none; }
    .nexus-app-collapse { display: none; }
    .nexus-app-scrim { position: fixed; inset: 0; z-index: 70; border: 0; background: rgba(7, 21, 45, .48); cursor: default; }
    .nexus-app-shell.is-sidebar-open .nexus-app-scrim { display: block; }
    body.nexus-shell-navigation-open { overflow: hidden; }
}

@media (max-width: 760px) {
    .nexus-app-topbar { min-height: 4rem; padding: .55rem .7rem; }
    .nexus-app-page-identity { min-width: 0; }
    .nexus-app-page-identity span { display: none; }
    .nexus-app-page-identity strong { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .nexus-app-command { width: auto; min-height: 2.35rem; margin-left: auto; padding: .35rem; }
    .nexus-app-command span:nth-child(2),
    .nexus-app-command kbd { display: none; }
    .nexus-header-mailbox-label { display: none; }
    .nexus-header-mailbox > summary { max-width: 10rem; }
    .nexus-app-topbar-actions .nexus-status { display: none; }
    .nexus-app-user { display: none; }
    .nexus-app-content { padding-bottom: 5rem; }
    .nexus-app-mobile-nav { position: fixed; inset: auto 0 0; z-index: 60; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--nexus-shell-slate-200); background: rgba(255, 255, 255, .97); padding: .35rem max(.25rem, env(safe-area-inset-right)) calc(.3rem + env(safe-area-inset-bottom)) max(.25rem, env(safe-area-inset-left)); box-shadow: 0 -8px 24px rgba(15, 23, 42, .08); backdrop-filter: blur(14px); }
    .nexus-app-mobile-nav a,
    .nexus-app-mobile-nav button { display: grid; min-width: 0; place-items: center; gap: .18rem; border: 0; border-radius: .55rem; background: transparent; padding: .35rem .1rem; color: var(--nexus-shell-slate-500); font: inherit; font-size: .64rem; font-weight: 750; text-decoration: none; }
    .nexus-app-mobile-nav a.is-active { background: var(--nexus-shell-blue-100); color: #1d4ed8; }
    .nexus-app-mobile-nav .nexus-shell-icon { width: 1.15rem; height: 1.15rem; }
    .nexus-assistant-shell-intro { margin-inline: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .nexus-app-sidebar,
    .nexus-app-workspace,
    .nexus-app-nav-item,
    .nexus-app-nav-chevron { transition: none; }
}

/* Action feedback is deliberately stronger than informational notices. */
[data-nexus-ui] [data-nexus-feedback][role] {
    padding: 16px 20px;
    margin-bottom: 18px;
    border-radius: 10px;
    border: 1px solid;
    border-left-width: 5px;
    font-weight: 650;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .08);
}
[data-nexus-ui] [data-nexus-feedback="success"][role] {
    background: #dcfce7;
    border-color: #16a34a;
    color: #14532d;
}
[data-nexus-ui] [data-nexus-feedback="error"][role] {
    background: #fee2e2;
    border-color: #dc2626;
    color: #7f1d1d;
}
[data-nexus-ui] [data-nexus-feedback="warning"][role] {
    background: #fef3c7;
    border-color: #d97706;
    color: #78350f;
}
