:root {
    --bg: #0a0a0b;
    --panel: rgba(19, 19, 22, 0.88);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f5f2;
    --muted: #a8a79f;
    --accent: #ff8a1d;
    --accent-soft: rgba(255, 138, 29, 0.14);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 138, 29, 0.18), transparent 26%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.05), transparent 22%),
        var(--bg);
    color: var(--text);
    font-family: "Instrument Sans", sans-serif;
}

body,
#app {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, textarea, select {
    font: inherit;
}

h1, h2, h3, strong {
    font-family: "Sora", sans-serif;
}

h1, h2, h3, p {
    margin-top: 0;
}

.shell-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(140deg, rgba(255, 138, 29, 0.1), transparent 30%),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.06), transparent 16%);
}

.app-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.shell-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 22px;
    border-right: 1px solid var(--line);
    background: rgba(8, 8, 10, 0.76);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-lockup strong {
    display: block;
    font-size: 1rem;
}

.brand-lockup small,
.user-summary__meta,
.meta-inline,
.stack-item span,
.citation-card span,
.chunk-card small,
.panel__lead {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, var(--accent), #ffb055);
    color: #111;
    font-family: "Sora", sans-serif;
    font-weight: 800;
}

.sidebar-nav {
    display: grid;
    gap: 24px;
}

.sidebar-group {
    display: grid;
    gap: 8px;
}

.sidebar-label,
.eyebrow,
.section-caption {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--muted);
}

.nav-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: #dad9d1;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: var(--accent-soft);
    color: white;
    transform: translateX(4px);
}

.sidebar-foot {
    margin-top: auto;
}

.user-summary {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
}

.user-summary__name {
    display: block;
    font-weight: 700;
}

.shell-main {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

.shell-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 24px 32px 12px;
    background: linear-gradient(180deg, rgba(10, 10, 11, 0.88), rgba(10, 10, 11, 0));
    backdrop-filter: blur(18px);
}

.route-heading {
    font-size: 1.3rem;
    font-family: "Sora", sans-serif;
}

.shell-actions,
.toolbar-actions,
.hero-block__actions,
.toggle-row,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.session-pill,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    color: #ecebe4;
}

.shell-content {
    padding: 4px 32px 40px;
}

.section-toolbar,
.hero-block,
.panel,
.metric-panel,
.provider-card,
.center-stage__panel {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.section-toolbar,
.hero-block {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    border-radius: var(--radius-xl);
    padding: 24px 28px;
    margin-bottom: 22px;
}

.hero-block h1,
.section-toolbar h1 {
    max-width: 18ch;
    margin-bottom: 10px;
}

.metric-grid,
.workspace-grid,
.document-layout,
.document-stage,
.form-grid,
.chunk-grid {
    display: grid;
    gap: 18px;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric-panel {
    border-radius: 22px;
    padding: 18px 20px;
}

.metric-panel span,
.metric-panel small {
    display: block;
}

.metric-panel strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 2.2rem;
}

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

.panel {
    border-radius: var(--radius-xl);
    padding: 24px;
    min-width: 0;
}

.panel--sidebar {
    position: sticky;
    top: 100px;
    align-self: start;
}

.panel__header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.stack-list,
.form-stack,
.provider-stack,
.citation-list {
    display: grid;
    gap: 12px;
}

.stack-item,
.citation-card,
.chunk-card {
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.stack-item strong,
.citation-card strong,
.chunk-card strong {
    display: block;
    margin-bottom: 6px;
}

.stack-item__preview {
    margin-top: 10px;
    color: #eceae2;
    line-height: 1.55;
}

.stack-item__preview p {
    margin: 0;
}

.stack-item--button,
.tree-file,
.tab-button,
.button {
    cursor: pointer;
}

.stack-item--button {
    text-align: left;
    color: inherit;
    background: rgba(255, 255, 255, 0.02);
}

.stack-item--button.is-active,
.stack-item:hover,
.citation-card:hover,
.tree-file:hover,
.tree-file.is-active,
.provider-card:hover {
    border-color: rgba(255, 138, 29, 0.45);
    background: rgba(255, 138, 29, 0.08);
}

.document-layout {
    grid-template-columns: 320px minmax(0, 1fr);
}

.document-stage {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.tree-root {
    display: grid;
    gap: 8px;
}

.tree-folder summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 0;
    color: #f1efe8;
}

.tree-folder summary::-webkit-details-marker {
    display: none;
}

.tree-branch {
    display: grid;
    gap: 8px;
    padding-left: 14px;
    border-left: 1px solid var(--line);
    margin-left: 6px;
}

.tree-file {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    color: inherit;
    padding: 10px 12px;
    border-radius: 14px;
    text-align: left;
}

.document-html {
    line-height: 1.7;
    color: #f0eee7;
}

.document-html h1,
.document-html h2,
.document-html h3 {
    margin: 1.2rem 0 0.6rem;
}

.version-history {
    display: grid;
    gap: 14px;
}

.version-list {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.version-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.version-card span,
.version-card code {
    color: var(--muted);
    font-size: 0.92rem;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field--full {
    grid-column: 1 / -1;
}

.input {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid var(--line-strong);
    background: rgba(0, 0, 0, 0.24);
    color: var(--text);
}

.input:focus {
    outline: none;
    border-color: rgba(255, 138, 29, 0.65);
    box-shadow: 0 0 0 3px rgba(255, 138, 29, 0.14);
}

.input--invalid {
    border-color: rgba(255, 111, 97, 0.6);
}

.input--compact {
    min-width: 180px;
}

.input--textarea {
    min-height: 140px;
    resize: vertical;
}

.input--xl {
    min-height: 190px;
}

.input--otp {
    letter-spacing: 0.3em;
    font-size: 1.2rem;
}

.button {
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(145deg, var(--accent), #ffb158);
    color: #121212;
    font-weight: 800;
}

.button--secondary {
    background: white;
    color: #111;
}

.button--ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
}

.button--tiny {
    padding: 8px 10px;
    font-size: 0.84rem;
}

.notice {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    margin: 0 0 18px;
}

.notice--success {
    background: rgba(56, 201, 140, 0.12);
}

.notice--warning {
    background: rgba(255, 187, 69, 0.12);
}

.notice--danger {
    background: rgba(255, 111, 97, 0.12);
}

.notice--neutral {
    background: rgba(255, 255, 255, 0.04);
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.code-panel,
.result-panel {
    padding: 18px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    white-space: pre-wrap;
    line-height: 1.65;
}

.toggle-line {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #e9e6de;
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 22px 0;
}

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

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

.user-admin-list {
    display: grid;
    gap: 14px;
}

.user-admin-card {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 16px;
    padding: 16px 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.user-admin-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, rgba(255, 138, 29, 0.18), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 138, 29, 0.24);
    font-family: "Sora", sans-serif;
    font-weight: 800;
}

.user-admin-body {
    display: grid;
    gap: 12px;
}

.user-admin-row,
.user-admin-meta {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    align-items: start;
}

.user-admin-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.user-admin-tags {
    justify-content: flex-end;
    margin-bottom: 0;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(10px);
}

.confirm-box {
    width: min(560px, 100%);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--line);
    background: rgba(15, 15, 18, 0.96);
    box-shadow: var(--shadow);
}

.toggle-setting {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 18px;
}

.toggle-setting small {
    display: block;
    color: var(--muted);
    margin-top: 6px;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-slider {
    width: 52px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    position: relative;
    transition: background 160ms ease, border-color 160ms ease;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f3f0e8;
    transition: transform 160ms ease;
}

.toggle-input:checked + .toggle-slider {
    background: rgba(255, 138, 29, 0.24);
    border-color: rgba(255, 138, 29, 0.5);
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(22px);
    background: var(--accent);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.provider-card {
    border-radius: 22px;
    padding: 18px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

.poster-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 28px;
}

.poster-metrics strong {
    display: block;
    font-size: 1.5rem;
}

.auth-shell,
.center-stage {
    min-height: 100vh;
    display: grid;
}

.auth-shell {
    grid-template-columns: minmax(0, 1.2fr) minmax(420px, 560px);
}

.auth-poster {
    display: grid;
    align-items: end;
    padding: 48px;
}

.auth-poster__inner {
    max-width: 620px;
}

.auth-poster h1 {
    font-size: clamp(2.6rem, 6vw, 4.4rem);
    line-height: 0.96;
    margin: 16px 0 18px;
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-panel--single {
    grid-column: 1 / -1;
}

.auth-panel__card {
    width: 100%;
    max-width: 460px;
    padding: 28px;
    border-radius: 28px;
    background: rgba(17, 17, 20, 0.92);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.pending-state,
.verify-links {
    display: grid;
    gap: 14px;
}

.pending-state__icon {
    display: inline-flex;
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 187, 69, 0.12);
    border: 1px solid rgba(255, 187, 69, 0.2);
    color: #ffd287;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.verify-links {
    margin-top: 18px;
    color: var(--muted);
}

.tab-strip {
    display: inline-grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 18px;
}

.tab-button {
    padding: 10px 14px;
    border-radius: 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.tab-button.is-active {
    background: var(--accent);
    color: #111;
    font-weight: 700;
}

.center-stage {
    place-items: center;
    padding: 24px;
}

.center-stage__panel {
    width: min(640px, 100%);
    padding: 34px;
    border-radius: 28px;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 320px;
    text-align: center;
    color: var(--muted);
}

.validation-message {
    color: #ffad9f;
    font-size: 0.88rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 12px;
    right: 12px;
    left: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(255, 111, 97, 0.94);
    color: white;
    z-index: 1000;
}

#blazor-error-ui .reload {
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .app-shell,
    .auth-shell,
    .document-layout,
    .document-stage,
    .workspace-grid,
    .workspace-grid--account {
        grid-template-columns: 1fr;
    }

    .shell-sidebar {
        position: static;
        height: auto;
    }

    .metric-grid,
    .chunk-grid,
    .form-grid,
    .poster-metrics {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 760px) {
    .shell-header,
    .shell-content,
    .auth-poster,
    .auth-panel {
        padding-left: 18px;
        padding-right: 18px;
    }

    .section-toolbar,
    .hero-block,
    .panel,
    .auth-panel__card {
        padding: 18px;
    }

    .metric-grid,
    .chunk-grid,
    .form-grid,
    .poster-metrics {
        grid-template-columns: 1fr;
    }

    .user-admin-card,
    .toggle-setting {
        grid-template-columns: 1fr;
    }
}
