/* ========== Kanbadger design baseline (applies to entire app) ==========
   Use var(--kb-*) in new components so changes here affect the whole system. */
:root {
    --kb-primary: #155E8F;
    --kb-primary-dark: #124a73;
    --kb-font-size-base: 14px;
    --kb-font-size-sm: 13px;
    --kb-font-size-xs: 12px;
    --kb-font-size-lg: 15px;
    --kb-line-height: 1.4;
    --kb-input-height: 32px;
    --kb-input-padding-x: 0.5rem;
    --kb-input-padding-y: 0.25rem;
    --kb-border-radius: 4px;
    --kb-spacing-unit: 0.25rem;
}
html {
    font-size: var(--kb-font-size-base);
}
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: var(--kb-line-height);
}
/* Form controls – smaller, consistent height */
input.form-control,
textarea.form-control,
select.form-control,
.form-control {
    font-size: var(--kb-font-size-base) !important;
    padding: var(--kb-input-padding-y) var(--kb-input-padding-x) !important;
    min-height: var(--kb-input-height) !important;
    height: auto !important;
    line-height: var(--kb-line-height) !important;
    border-radius: var(--kb-border-radius);
}
textarea.form-control {
    min-height: 4rem;
    padding: 0.35rem 0.5rem !important;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
    font-size: var(--kb-font-size-base);
    padding: var(--kb-input-padding-y) var(--kb-input-padding-x);
    border-radius: var(--kb-border-radius);
}
/* Headings – tighter scale */
h1, .h1 { font-size: 1.5rem; font-weight: 600; }
h2, .h2 { font-size: 1.25rem; font-weight: 600; }
h3, .h3 { font-size: 1.1rem; font-weight: 600; }
h4, .h4, h5, .h5, h6, .h6 { font-size: 1rem; font-weight: 600; }
/* Buttons – proportional to baseline */
.btn {
    font-size: var(--kb-font-size-base);
    padding: 0.35rem 0.75rem;
    line-height: var(--kb-line-height);
    border-radius: var(--kb-border-radius);
}
/* Labels and small text */
label, .form-label {
    font-size: var(--kb-font-size-sm);
}
small, .text-muted, .form-text {
    font-size: var(--kb-font-size-xs);
}
/* ========== End baseline ========== */

a, .btn-link {
    color: var(--kb-primary);
}

.btn-primary {
    color: #fff;
    background-color: var(--kb-primary);
    border-color: var(--kb-primary-dark);
}

.btn-primary:hover {
    background-color: var(--kb-primary-dark);
    border-color: var(--kb-primary-dark);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--kb-primary);
}

.content {
    padding-top: 1.1rem;
    max-width: 56rem;
    margin-left: auto;
    margin-right: auto;
}

/* Página Backlog: área de conteúdo mais larga para a tabela */
.content:has(.backlog-page) {
    max-width: 90rem;
}

/* Página Panel (Kanban): área um pouco mais larga para o board */
.content:has(.panel-page) {
    max-width: 95rem;
}

/* Documents: left-aligned column (no horizontal centering) */
.content:has(.documents-page) {
    max-width: 44rem;
    margin-left: 0;
    margin-right: auto;
}

/* Document full-page editor: wider column, content-first vertical space */
.content:has(.documents-editor-page) {
    max-width: min(100%, 56rem);
}

/* Priority text uses same color as flag (Backlog / Panel) */
.priority-low { color: #198754; }
.priority-medium { color: #e6a800; }
.priority-high { color: #dc3545; }

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* Auth pages — toward the top */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0.35rem 1rem 1rem;
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 0.85rem 1.5rem 1.5rem;
}

.auth-logo {
    max-width: 280px;
    height: auto;
    display: block;
    margin: -0.15rem auto 0;
    line-height: 0;
    vertical-align: top;
}

.auth-card h1 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    margin-top: 0.15rem;
    text-align: center;
}

.nav-logo {
    height: 80px;
    width: auto;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* Logo no canto: topo fixo, esquerda com margem fixa 0.5rem da borda do main */
.welcome-page {
    text-align: left;
    padding: 0;
    margin: -2.5rem 0 0 0;
    max-width: 36rem;
}

@media (min-width: 641px) {
    /* Na home, article ocupa toda a largura do main (sem centralizar) para o logo ficar fixo à esquerda */
    main article.content:has(.welcome-page) {
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0.5rem !important;
    }

    .welcome-page {
        margin-left: 0;
    }
}

@media (max-width: 640.98px) {
    main article.content:has(.welcome-page) {
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0.5rem !important;
    }

    .welcome-page {
        margin-left: 0;
    }
}

.welcome-logo {
    max-width: 160px;
    height: auto;
    margin: 0;
}

/* Language / locale selector (dropdown) – matches auth form style */
.locale-dropdown {
    position: relative;
    width: 100%;
}

.locale-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.locale-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    min-height: var(--kb-input-height);
    padding: var(--kb-input-padding-y) var(--kb-input-padding-x);
    padding-right: 2rem;
    border: 1px solid #ced4da;
    border-radius: var(--kb-border-radius);
    background: #fff;
    font-size: var(--kb-font-size-base);
    line-height: var(--kb-line-height);
    text-align: left;
    cursor: pointer;
    color: #212529;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.locale-dropdown-trigger:hover {
    border-color: #adb5bd;
}

.locale-dropdown.open .locale-dropdown-trigger {
    position: relative;
    z-index: 1000;
    border-color: var(--kb-primary);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(21, 94, 143, 0.15);
}

.locale-dropdown.open .locale-dropdown-menu {
    z-index: 1001;
}

.locale-dropdown-label {
    flex: 1;
    min-width: 0;
}

/* Chevron: CSS arrow (no emoji) */
.locale-dropdown-chevron {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 0.35rem solid transparent;
    border-right: 0.35rem solid transparent;
    border-top: 0.4rem solid #6c757d;
    transition: transform 0.2s ease, border-top-color 0.15s ease;
}

.locale-dropdown.open .locale-dropdown-chevron {
    transform: translateY(-50%) rotate(180deg);
    border-top-color: var(--kb-primary);
}

.locale-dropdown-menu {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.375rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    animation: locale-menu-in 0.15s ease;
}

@keyframes locale-menu-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.locale-dropdown-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 1.25rem;
    border: 0;
    background: none;
    font-size: var(--kb-font-size-base);
    text-align: left;
    cursor: pointer;
    color: #212529;
    transition: background 0.1s ease;
}

.locale-dropdown-item:hover {
    background: #f8f9fa;
}

.locale-dropdown-item.selected {
    background: rgba(21, 94, 143, 0.08);
    color: var(--kb-primary);
    font-weight: 500;
}

.locale-dropdown-item.selected::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1rem;
    background: var(--kb-primary);
    border-radius: 0 2px 2px 0;
}

.locale-flag {
    flex-shrink: 0;
    width: 22px;
    height: 16px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Organization card: área fixa para a imagem, centralizada */
.org-card .org-card-image-wrap {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-secondary-bg, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,.125));
}

/* Ícone da org na lista de projetos */
.proj-list-org-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-secondary-bg, #f8f9fa);
    border-radius: var(--kb-border-radius, 4px);
}

.org-card .org-card-image-wrap .org-image,
.org-image {
    width: auto;
    height: auto;
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    display: block;
}

.org-card .org-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.org-card .org-card-actions .btn {
    white-space: nowrap;
}

.org-card .org-card-btn {
    border-radius: 0.45rem;
    font-weight: 600;
}

.org-card .org-card-btn-projects {
    color: #0f5f58;
    border: 1px solid #8fc6c1;
    background: #eef8f7;
}

.org-card .org-card-btn-projects:hover {
    color: #0b4f49;
    background: #dff2f0;
    border-color: #79b8b2;
}

.org-card .org-card-btn-users {
    color: #325ba8;
    border: 1px solid #a8bde8;
    background: #f1f5fd;
}

.org-card .org-card-btn-users:hover {
    color: #274a8e;
    background: #e4ecfb;
    border-color: #95b0e2;
}

.org-card .org-card-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.org-card .org-card-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid #cfd4dc;
    background: #f7f8fa;
    border-radius: 0.375rem;
    padding: 0;
    color: #5b6472;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.org-card .org-card-menu-btn:hover {
    background: #eceff4;
    color: #3f4856;
    border-color: #c1c8d3;
}

.org-card .org-card-menu-icon {
    display: block;
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='4' r='1.25'/%3E%3Ccircle cx='8' cy='8' r='1.25'/%3E%3Ccircle cx='8' cy='12' r='1.25'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.org-card .org-card-menu-popover {
    position: absolute;
    top: calc(100% + 0.3rem);
    right: 0;
    min-width: 10rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0.4rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
    z-index: 25;
}

.org-card .org-card-menu-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    border-radius: 0.3rem;
    padding: 0.45rem 0.55rem;
    color: inherit;
    text-decoration: none;
    font-size: 0.875rem;
}

.org-card .org-card-menu-item:hover {
    background: #f8f9fa;
}

.org-card .org-card-menu-item-danger {
    color: #c82333;
}

@media (max-width: 575.98px) {
    .org-card .org-card-actions {
        flex-wrap: wrap;
    }

    .org-card .org-card-actions > .btn {
        width: 100%;
    }
}

/* Project framework icons (Kanban / Sprint) */
.framework-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 8rem;
}
/* Selected state: light background + primary border so blue icon stays visible */
.framework-option.framework-option-selected {
    border-color: var(--kb-primary);
    border-width: 2px;
    background-color: rgba(21, 94, 143, 0.08);
    color: var(--kb-primary);
}
.framework-option .framework-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.framework-icon-inline {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
}
.framework-badge-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    vertical-align: middle;
}

/* Project list: light badge so blue Sprint icon stays visible */
.framework-badge {
    background-color: #e8eef3;
    color: #1a1a1a;
    border: 1px solid #c5d0dc;
}

.framework-help-modal-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.framework-help-trigger {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 50%;
    border: 1px solid currentColor;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.framework-help-trigger:hover {
    color: var(--kb-primary);
    border-color: var(--kb-primary);
}
.framework-help-body p {
    margin-bottom: 0.5rem;
}
.framework-help-body p:last-child {
    margin-bottom: 0;
}

.org-users-role-icon {
    width: 1.2rem;
    height: 1.2rem;
    object-fit: contain;
    display: inline-block;
}

.org-users-role-icon-lg {
    width: 1.45rem;
    height: 1.45rem;
}

.org-users-role-icon-xl {
    width: 3rem;
    height: 3rem;
}

.org-users-role-icon-xxl {
    width: 2.8rem;
    height: 2.8rem;
}

.org-users-role-radio-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.org-users-role-radio-group-sm {
    gap: 0.35rem;
}

.org-users-role-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid #d1d7e2;
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.45rem 0.65rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #334155;
}

.org-users-role-radio input[type="radio"] {
    margin: 0;
}

.org-users-role-radio.selected {
    border-color: #9ab4e8;
    background: #eef3fd;
}

.org-users-org-context {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.org-users-org-logo {
    width: 2.8rem;
    height: 2.8rem;
    object-fit: contain;
    border-radius: 0.35rem;
    border: 1px solid #d8dee8;
    background: #f8fafc;
    padding: 0.18rem;
}

.org-users-member-role-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

.org-users-member-role-item:last-child {
    margin-bottom: 0;
}

/* Project list table: fixed-width Framework column for alignment */
.projects-list-table .projects-list-framework-col {
    width: 1%;
    white-space: nowrap;
}

/* ========== Documents (Story 6.1) – aligned with Panel tokens ========== */
.documents-redesign {
    --doc-bg: #ffffff;
    --doc-surface: #f9fafb;
    --doc-border: #e5e7eb;
    --doc-text: #1a1d26;
    --doc-muted: #6b7280;
    --doc-accent: var(--kb-primary, #155E8F);
    --doc-accent-soft: rgba(21, 94, 143, 0.1);
    --doc-accent-ring: rgba(21, 94, 143, 0.35);
    --doc-radius: 10px;
    --doc-radius-sm: 6px;
    --doc-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --doc-shadow-card: 0 4px 24px rgba(15, 23, 42, 0.07);
    --doc-project: #0d9488;
    --doc-project-bg: rgba(13, 148, 136, 0.1);
    --doc-user: #64748b;
    --doc-user-bg: rgba(100, 116, 139, 0.12);
    --doc-org: var(--kb-primary, #155E8F);
    --doc-org-bg: rgba(21, 94, 143, 0.1);
}

.documents-page.documents-redesign {
    min-height: 100%;
    padding: 1.5rem 0 2.5rem;
    background: var(--doc-bg);
}

.documents-header {
    margin-bottom: 1.35rem;
}

.documents-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--doc-text);
    letter-spacing: -0.02em;
    margin: 0 0 0.35rem 0;
}

.documents-context {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.6rem;
    margin: 0;
    font-size: 0.875rem;
}

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

.documents-context-value {
    color: var(--doc-accent);
    font-weight: 600;
}

.documents-main {
    min-height: 12rem;
}

.documents-empty {
    padding: 2.75rem 1.5rem;
    text-align: left;
    background: var(--doc-surface);
    border-radius: var(--doc-radius);
    border: 1px dashed var(--doc-border);
}

.documents-empty-icon {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 0 1rem 0;
    opacity: 0.45;
    background: no-repeat center / contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z'/%3E%3C/svg%3E");
}

.documents-empty-text {
    margin: 0;
    color: var(--doc-muted);
    font-size: 0.9375rem;
    max-width: 28rem;
    line-height: 1.5;
}

.documents-alert {
    padding: 0.65rem 1rem;
    border-radius: var(--doc-radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.documents-alert--warning {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.documents-loading {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 2.5rem 0;
    color: var(--doc-muted);
}

.documents-loading-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--doc-accent);
    opacity: 0.35;
    animation: documents-dot 1s ease-in-out infinite;
}

.documents-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.documents-loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes documents-dot {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.9); }
    40% { opacity: 1; transform: scale(1); }
}

.documents-card {
    background: var(--doc-bg);
    border-radius: var(--doc-radius);
    border: 1px solid var(--doc-border);
    box-shadow: var(--doc-shadow-card);
    overflow: visible;
}

.documents-card-head {
    padding: 1rem 1.15rem 0.85rem;
    background: linear-gradient(180deg, var(--doc-surface) 0%, var(--doc-bg) 100%);
    border-bottom: 1px solid var(--doc-border);
}

.documents-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--doc-text);
    margin: 0 0 0.35rem 0;
}

.documents-card-desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--doc-muted);
    line-height: 1.45;
}

.documents-card-body {
    padding: 0.85rem 0.65rem 1rem 0.85rem;
}

.documents-tree {
    padding: 0.15rem 0;
}

.documents-tree-node {
    list-style: none;
    margin: 0;
    padding: 0;
}

.documents-tree-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.35rem;
    padding: 0.35rem 0.45rem 0.35rem 0.5rem;
    margin: 0.12rem 0;
    border-radius: var(--doc-radius-sm);
    border: 1px solid transparent;
    background: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.documents-tree-row:hover {
    background: var(--doc-surface);
    border-color: var(--doc-border);
}

.documents-tree-row:focus-within {
    border-color: var(--doc-accent-ring);
    box-shadow: 0 0 0 2px var(--doc-accent-soft);
}

.documents-tree-row--root .documents-tree-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.documents-tree-icon {
    flex-shrink: 0;
    width: 1.15rem;
    height: 1.15rem;
    background: no-repeat center / contain;
    opacity: 0.85;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23155E8F' d='M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z'/%3E%3C/svg%3E");
}

.documents-tree-row--project .documents-tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%230d9488' d='M2 2h4a2 2 0 0 1 2 2v1h5a1 1 0 0 1 1 1v8a1 1 90 0 1-1 1H3a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z'/%3E%3C/svg%3E");
}

.documents-tree-row--user .documents-tree-icon {
    opacity: 0.65;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z'/%3E%3C/svg%3E");
}

.documents-tree-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--doc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.documents-tree-row--root .documents-tree-name {
    color: var(--doc-org);
}

.documents-tree-row--project .documents-tree-name {
    color: #0f766e;
}

.documents-tree-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex-shrink: 0;
}

.documents-pill {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    line-height: 1.2;
}

.documents-pill--org {
    color: var(--doc-org);
    background: var(--doc-org-bg);
}

.documents-pill--project {
    color: #0f766e;
    background: var(--doc-project-bg);
}

.documents-pill--user {
    color: var(--doc-user);
    background: var(--doc-user-bg);
}

.documents-tree-add {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    margin-left: 0.15rem;
    border: 1px solid var(--doc-border);
    border-radius: var(--doc-radius-sm);
    background: var(--doc-bg);
    color: var(--doc-accent);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.documents-tree-add:hover {
    background: var(--doc-accent);
    border-color: var(--doc-accent);
    color: #fff;
}

.documents-tree-add:active {
    transform: scale(0.96);
}

.documents-tree-add:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--doc-bg), 0 0 0 4px var(--doc-accent-ring);
}

.documents-tree-add-icon {
    display: block;
    width: 0.95rem;
    height: 0.95rem;
    background-color: var(--doc-accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 12.5v-9z'/%3E%3C/svg%3E") no-repeat center / contain;
}

.documents-tree-add:hover .documents-tree-add-icon {
    background-color: #fff;
}

.documents-tree-doc-new-inner {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    margin-top: -1px;
}

.documents-tree-children {
    position: relative;
    margin: 0.15rem 0 0.35rem 0.5rem;
    padding: 0 0 0 0.75rem;
}

.documents-tree-children::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0.35rem;
    width: 2px;
    background: linear-gradient(180deg, var(--doc-accent) 0%, var(--doc-border) 60%);
    opacity: 0.4;
    border-radius: 1px;
    pointer-events: none;
}

.documents-tree-chevron {
    flex-shrink: 0;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: var(--doc-radius-sm);
    background: transparent;
    color: var(--doc-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.documents-tree-chevron span {
    display: block;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    margin-top: -0.15rem;
    transition: transform 0.18s ease;
}

.documents-tree-chevron--open span {
    transform: rotate(45deg);
    margin-top: 0.1rem;
}

.documents-tree-chevron:hover {
    background: var(--doc-surface);
    color: var(--doc-text);
}

.documents-tree-chevron:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--doc-bg), 0 0 0 4px var(--doc-accent-ring);
}

.documents-tree-chevron--spacer {
    visibility: hidden;
    pointer-events: none;
}

.documents-tree-doc-new,
.documents-tree-folder-rename,
.documents-doc-more,
.documents-tree-more {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.35rem;
    margin-left: 0.15rem;
    border: 1px solid var(--doc-border);
    border-radius: var(--doc-radius-sm);
    background: var(--doc-bg);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--doc-accent);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.documents-tree-doc-new:hover,
.documents-tree-folder-rename:hover,
.documents-doc-more:hover,
.documents-tree-more:hover {
    background: var(--doc-accent-soft);
    border-color: var(--doc-accent);
}

.documents-tree-folder-rename span {
    display: block;
    width: 0.85rem;
    height: 0.85rem;
    background: no-repeat center / contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2394a3b8'%3E%3Cpath d='M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5V12h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z'/%3E%3C/svg%3E");
}

.documents-tree-folder-rename:hover span {
    filter: brightness(0.85);
}

.documents-more-dots {
    display: block;
    font-size: 1.05rem;
    line-height: 1;
    letter-spacing: 0.02em;
    transform: translateY(-0.05em);
    color: var(--doc-muted);
}

.documents-doc-more:hover .documents-more-dots,
.documents-tree-more:hover .documents-more-dots {
    color: var(--doc-accent);
}

.documents-doc-more:focus-visible,
.documents-tree-more:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--doc-bg), 0 0 0 4px var(--doc-accent-ring);
}

.documents-doc-more-wrap,
.documents-tree-more-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.documents-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1068;
}

.documents-doc-more-wrap--open .documents-doc-more,
.documents-tree-more-wrap--open .documents-tree-more {
    position: relative;
    z-index: 1070;
}

.documents-more-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.15rem);
    z-index: 1071;
    min-width: 10.5rem;
    padding: 0.3rem 0;
    margin: 0;
    list-style: none;
    background: var(--doc-bg);
    border: 1px solid var(--doc-border);
    border-radius: var(--doc-radius-sm);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
}

.documents-more-panel--doc {
    right: 0;
}

.documents-more-panel--tree {
    right: 0;
    top: calc(100% + 0.2rem);
}

.documents-more-item {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0.85rem;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--doc-text);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.documents-more-item:hover {
    background: var(--doc-surface);
}

.documents-more-item--danger {
    color: #b45309;
}

.documents-more-item--danger:hover {
    background: #fff7ed;
    color: #9a3412;
}

.documents-tree-below {
    margin: 0.15rem 0 0.35rem 0.5rem;
    padding: 0 0 0 0.35rem;
    border-left: 2px solid var(--doc-border);
}

.documents-doc-list {
    margin: 0 0 0.5rem 0;
    padding: 0;
}

.documents-doc-item {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    margin: 0.2rem 0;
    border-radius: var(--doc-radius-sm);
    border: 1px solid var(--doc-border);
    background: var(--doc-surface);
    overflow: visible;
}

.documents-doc-open {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    padding: 0.45rem 0.6rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.12s ease;
}

.documents-doc-open:hover {
    background: var(--doc-bg);
}

.documents-doc-title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--doc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.documents-doc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.2rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--doc-muted);
}

.documents-doc-scope {
    color: var(--doc-org);
}

.documents-doc-mode {
    color: #64748b;
}

.documents-doc-title-readonly {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: var(--doc-text, #1a1d26);
}

.documents-doc-body-readonly {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--doc-text, #1a1d26);
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    border-radius: var(--doc-radius-sm, 6px);
    border: 1px solid var(--doc-border, #e5e7eb);
    background: var(--doc-surface, #f9fafb);
}

.documents-doc-body-readonly :first-child {
    margin-top: 0;
}

.documents-doc-body-readonly :last-child {
    margin-bottom: 0;
}

.documents-doc-fieldset:disabled {
    opacity: 0.85;
}

/* Shared rich text toolbar — Backlog/Panel use scoped .razor.css; DocumentEditor and any unscoped markup need these. */
.kb-richtext-toolbar {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-wrap: wrap;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-bottom: none;
    border-radius: 0.25rem 0.25rem 0 0;
    padding: 0.25rem 0.35rem;
}

.documents-richtext .kb-richtext-toolbar {
    background: var(--doc-surface, #f9fafb);
    border: none;
    border-bottom: 1px solid var(--doc-border, #e5e7eb);
    border-radius: 0;
}

.kb-richtext-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border: none;
    background: transparent;
    border-radius: 4px;
    padding: 0;
    color: #495057;
    cursor: pointer;
}

.kb-richtext-btn:hover {
    background: var(--bs-light, #f8f9fa);
    color: #212529;
}

.kb-richtext-icon {
    display: block;
    width: 1rem;
    height: 1rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.kb-richtext-icon--bold {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23212529' viewBox='0 0 16 16'%3E%3Cpath d='M8.21 13c2.106 0 3.412-1.087 3.412-2.823 0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.767-1.018-2.98-2.674-2.98-1.767 0-2.98 1.002-3.226 2.55H4.627C4.923 4.259 6.07 3 8.016 3c2.34 0 3.855 1.18 4.064 3.055h-1.96c-.157-1.198-.962-2.004-2.104-2.004-1.307 0-2.168.963-2.168 2.335 0 1.369.861 2.335 2.168 2.335 1.142 0 1.947-.806 2.104-2.004h1.96c-.21 1.875-1.724 3.055-4.064 3.055z'/%3E%3C/svg%3E");
}

.kb-richtext-icon--italic {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23212529' viewBox='0 0 16 16'%3E%3Cpath d='M7.991 11.674 9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H6.211l-.11.52c1.101.096 1.224.212 1.347.807l1.538 7.219c.123.595.246.71 1.347.806l.11.52H3.549l.11-.52c1.102-.096 1.224-.211 1.347-.806z'/%3E%3C/svg%3E");
}

.kb-richtext-icon--ul {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23212529' viewBox='0 0 16 16'%3E%3Cpath d='M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m-3 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2'/%3E%3C/svg%3E");
}

.kb-richtext-icon--ol {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23212529' viewBox='0 0 16 16'%3E%3Cpath d='M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m-3 4.5 1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3m0-4 1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3m0 7 1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3'/%3E%3C/svg%3E");
}

.kb-richtext-toolbar-sep {
    width: 1px;
    height: 1.1rem;
    background: var(--bs-border-color, #dee2e6);
    margin: 0 0.2rem;
}

.documents-richtext .kb-richtext-toolbar-sep {
    background: var(--doc-border, #e5e7eb);
}

/* Editor body inside documents card (toolbar already has bottom border) */
.documents-richtext .kb-richtext-editor {
    border: none;
    border-radius: 0;
    padding: 0.6rem 0.75rem;
    background: var(--doc-bg, #ffffff);
    outline: none;
    line-height: 1.45;
}

.documents-richtext .kb-richtext-editor:focus {
    box-shadow: inset 0 0 0 2px var(--doc-accent-ring, rgba(21, 94, 143, 0.35));
}

.documents-richtext {
    border: 1px solid var(--doc-border, #e5e7eb);
    border-radius: var(--doc-radius-sm, 6px);
    background: var(--doc-bg, #ffffff);
    overflow: hidden;
}

.documents-editor-section--content .documents-richtext.documents-editor-richtext {
    min-height: 0;
}

.documents-richtext-editor {
    min-height: 7rem;
    max-height: 10rem;
    overflow-y: auto;
}

.documents-richtext--expanded .documents-richtext-editor {
    max-height: min(50vh, 22rem);
}

.documents-modal-panel--document {
    max-width: 42rem;
}

/* Full-page document editor (Story 6.2) — not modal overlay */
.documents-page.documents-editor-page {
    --ed-accent: var(--doc-accent, #155E8F);
    --ed-accent-faint: rgba(21, 94, 143, 0.09);
    --ed-accent-line: rgba(21, 94, 143, 0.22);
    --ed-chip: rgba(255, 255, 255, 0.88);
    --ed-text: var(--doc-text, #1a1d26);
    --ed-muted: var(--doc-muted, #5c6578);
    max-width: none;
    margin: 0;
    padding-left: clamp(0.5rem, 1.5vw, 1rem);
    padding-right: clamp(0.5rem, 1.5vw, 1rem);
    padding-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: min(calc(100dvh - 5.5rem), calc(100vh - 5.5rem));
}

.documents-page.documents-editor-page--reader {
    max-width: 48rem;
    margin-inline: auto;
}

.documents-editor-page--reader .documents-editor-reader-body {
    font-size: 1.0625rem;
    line-height: 1.68;
    padding: 1rem 0.25rem;
    border: none;
    background: transparent;
    min-height: clamp(16rem, 55vh, 36rem);
}

.documents-editor-header {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--doc-border, #e5e7eb);
    background: linear-gradient(180deg, transparent 60%, var(--ed-accent-faint) 160%);
    margin-left: calc(-1 * clamp(0.5rem, 1.5vw, 1rem));
    margin-right: calc(-1 * clamp(0.5rem, 1.5vw, 1rem));
    padding-left: clamp(0.5rem, 1.5vw, 1rem);
    padding-right: clamp(0.5rem, 1.5vw, 1rem);
}

.documents-editor-back {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ed-accent);
    text-decoration: none;
    padding: 0.2rem 0;
    line-height: 1.3;
}

.documents-editor-back:hover {
    text-decoration: underline;
    color: var(--ed-accent);
}

.documents-editor-header-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.75rem;
}

.documents-editor-title {
    font-size: clamp(1.1rem, 1.15rem + 0.2vw, 1.28rem);
    font-weight: 650;
    letter-spacing: -0.03em;
    color: var(--ed-text);
    margin: 0;
    line-height: 1.22;
}

.documents-editor-meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem 0.45rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--ed-muted);
}

.documents-editor-meta-bit {
    font-weight: 500;
}

.documents-editor-meta-sep {
    opacity: 0.45;
    user-select: none;
}

.documents-editor-loading {
    margin: 1rem 0;
    color: var(--doc-muted, #6b7280);
    font-size: 0.875rem;
}

.documents-editor-layout {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1 1 auto;
    min-height: 0;
}

.documents-editor-secondary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
    gap: 0.4rem;
    align-items: stretch;
}

@media (max-width: 40rem) {
    .documents-editor-secondary {
        grid-template-columns: 1fr;
    }
}

.documents-editor-section {
    padding: 1.15rem 1.25rem;
    background: var(--doc-surface, #f9fafb);
    border: 1px solid var(--doc-border, #e5e7eb);
    border-radius: var(--doc-radius, 10px);
    box-shadow: var(--doc-shadow, 0 1px 3px rgba(0, 0, 0, 0.06));
}

.documents-editor-section--name {
    padding: 0.45rem 0.65rem;
    box-shadow: none;
    border-color: var(--ed-accent-line);
    background: linear-gradient(135deg, var(--ed-accent-faint) 0%, transparent 55%), var(--doc-surface, #f9fafb);
}

.documents-editor-section--name .documents-editor-section-title {
    margin-bottom: 0.28rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

/* Context strip: readable type + soft “studio chips” */
.documents-editor-section--context {
    padding: 0.4rem 0.55rem;
    box-shadow: none;
    min-width: 0;
    display: flex;
    align-items: center;
    border-color: var(--ed-accent-line);
    background:
        radial-gradient(120% 180% at 100% -20%, var(--ed-accent-faint) 0%, transparent 55%),
        var(--doc-surface, #f9fafb);
}

.documents-editor-context-strip {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    width: 100%;
    min-width: 0;
}

.documents-editor-context-row {
    width: 100%;
    min-width: 0;
}

.documents-editor-context-fieldset {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.55rem;
    border: none;
    margin: 0;
    padding: 0.28rem 0.55rem;
    min-width: 0;
    background: var(--ed-chip);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.documents-editor-context-fieldset:disabled {
    opacity: 0.9;
}

.documents-editor-context-k {
    flex-shrink: 0;
    font-size: 0.8125rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    color: var(--ed-muted);
    line-height: 1.35;
    max-width: none;
    padding: 0.12rem 0;
    border-right: 1px solid rgba(148, 163, 184, 0.4);
    padding-right: 0.55rem;
    margin-right: 0.1rem;
}

.documents-editor-context-radios {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.85rem;
}

.documents-editor-context-check {
    margin: 0;
    padding: 0;
    padding-left: 0;
    min-height: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.documents-editor-section--context .documents-editor-context-check .form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    float: none;
    position: static;
    border-color: rgba(100, 116, 139, 0.55);
}

.documents-editor-section--context .documents-editor-context-check .form-check-input:checked {
    background-color: var(--ed-accent);
    border-color: var(--ed-accent);
}

.documents-editor-section--context .documents-editor-context-check .form-check-label {
    font-size: 0.9375rem;
    padding: 0;
    line-height: 1.35;
    color: var(--ed-text);
    font-weight: 500;
}

.documents-editor-context-project {
    flex: 1 1 6.25rem;
    min-width: 5.75rem;
    max-width: 13rem;
    font-size: 0.875rem;
    padding: 0.22rem 0.42rem;
    line-height: 1.3;
    height: auto;
    min-height: calc(1.35em + 0.48rem);
    border-radius: 6px;
    border-color: rgba(100, 116, 139, 0.35);
}

.documents-editor-context-project-ro {
    font-size: 0.8125rem;
    line-height: 1.35;
    max-width: 13rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--ed-text);
}

@media (max-width: 40rem) {
    .documents-editor-context-fieldset {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .documents-editor-context-k {
        border-right: none;
        padding-right: 0;
        margin-right: 0;
        width: 100%;
        border-bottom: 1px dashed rgba(148, 163, 184, 0.45);
        padding-bottom: 0.25rem;
    }
}

.documents-editor-section--content {
    background: var(--doc-bg, #ffffff);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.5rem 0.65rem;
}

.documents-editor-section--content .documents-editor-section-title {
    margin-bottom: 0.4rem;
    flex-shrink: 0;
    font-size: 0.8125rem;
    color: var(--ed-muted, var(--doc-muted, #5c6578));
}

.documents-editor-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--doc-muted, #6b7280);
    margin: 0 0 0.5rem 0;
}

.documents-editor-input {
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.45;
    padding: 0.42rem 0.75rem;
    border-radius: 8px;
}

.documents-editor-name-readonly {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0;
    color: var(--ed-text, var(--doc-text, #1a1d26));
    line-height: 1.45;
}

.documents-editor-body.documents-doc-body-readonly {
    max-height: none;
    flex: 1 1 auto;
    min-height: clamp(12rem, 42vh, 28rem);
    overflow-y: auto;
}

.documents-editor-section--content .documents-editor-richtext {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.documents-editor-richtext .documents-richtext-editor,
.documents-editor-richtext .kb-richtext-editor {
    flex: 1 1 auto;
    min-height: clamp(16rem, 52vh, 36rem) !important;
    max-height: none !important;
    overflow-y: auto;
}

.documents-editor-richtext.documents-richtext--expanded .documents-richtext-editor,
.documents-editor-richtext.documents-richtext--expanded .kb-richtext-editor {
    min-height: clamp(22rem, 68vh, 48rem) !important;
    max-height: min(78vh, 52rem) !important;
}

.documents-editor-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.65rem;
    margin-top: 0.15rem;
    padding-top: 0.35rem;
    flex-shrink: 0;
}

/* Modal */
.documents-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    /* Translúcido, mas ainda escurece o fundo o suficiente para focar no diálogo */
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: documents-fade-in 0.18s ease-out;
}

@keyframes documents-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.documents-modal-panel {
    width: 100%;
    max-width: 22rem;
    /* Fallbacks: markup do modal está fora de .documents-redesign, onde --doc-* é definido */
    background: var(--doc-bg, #ffffff);
    border-radius: var(--doc-radius, 10px);
    border: 1px solid var(--doc-border, #e5e7eb);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.22);
    animation: documents-modal-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes documents-modal-in {
    from {
        opacity: 0;
        transform: translateY(0.5rem) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.documents-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--doc-border, #e5e7eb);
    background: linear-gradient(
        180deg,
        var(--doc-surface, #f9fafb) 0%,
        var(--doc-bg, #ffffff) 100%
    );
}

.documents-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--doc-text, #1a1d26);
}

.documents-modal-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    margin: -0.25rem -0.25rem 0 0;
    padding: 0;
    border: none;
    border-radius: var(--doc-radius-sm, 6px);
    background: transparent;
    cursor: pointer;
    color: var(--doc-muted, #6b7280);
    transition: background 0.15s ease, color 0.15s ease;
}

.documents-modal-close span {
    display: block;
    width: 100%;
    height: 100%;
    background: no-repeat center / 0.65rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

.documents-modal-close:hover {
    background: var(--doc-surface, #f9fafb);
    color: var(--doc-text, #1a1d26);
}

.documents-modal-body {
    padding: 1rem;
}

.documents-modal-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: var(--kb-font-size-sm);
    font-weight: 600;
    color: var(--doc-text, #1a1d26);
}

.documents-modal-input {
    border-color: var(--doc-border, #e5e7eb);
}

.documents-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--doc-border, #e5e7eb);
    background: var(--doc-surface, #f9fafb);
}

.documents-modal-btn {
    min-width: 5rem;
}

.documents-modal-btn--primary {
    font-weight: 600;
}

