.kb-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
    background: #fff;
}

/* TOP BAR - Confluence-style minimal header */
.kb-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid #e1e4e8;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.kb-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #6b778c;
}

.kb-crumb {
    color: #6b778c;
    text-decoration: none;
    transition: color 0.15s ease;
}
.kb-crumb:hover { color: #0052cc; }
.kb-sep { color: #dfe1e6; margin: 0 0.25rem; }
.kb-current { color: #42526e; font-weight: 500; }

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

/* TOOLBAR - Confluence-style floating toolbar */
.kb-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 2rem;
    border-bottom: 1px solid #e1e4e8;
    background: #fafbfc;
    position: sticky;
    top: 49px;
    z-index: 99;
}

.kb-tb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #42526e;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.kb-tb-btn:hover { background: #e4e6eb; }
.kb-tb-btn.kb-tb-ai { color: var(--rz-primary); }
.kb-tb-btn.kb-tb-ai:hover { background: var(--rz-primary-lighter); }
.kb-tb-btn.kb-tb-loading { cursor: wait; opacity: 0.7; }
.kb-tb-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
@keyframes kb-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.kb-tb-loading .rz-icon { animation: kb-spin 1s linear infinite; }
.kb-tb-sep { width: 1px; height: 20px; background: #dfe1e6; margin: 0 6px; }
.kb-tb-select {
    height: 32px;
    padding: 0 6px;
    border: 1px solid #dfe1e6;
    border-radius: 4px;
    background: transparent;
    color: #42526e;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}
.kb-tb-select:hover { border-color: #b3b9c4; }
.kb-tb-select:focus { border-color: var(--rz-primary); }

/* CONTENT AREA - Confluence-style wide layout */
.kb-content-area {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 3rem 4rem;
    width: 100%;
}

/* TITLE - Confluence-style full-width prominent title with block highlighting */
.kb-title-input {
    font-size: 2.5rem;
    font-weight: 600;
    border: none;
    outline: none;
    width: 100%;
    padding: 0.5rem 12px;
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: 2rem;
    background: transparent;
    color: #172b4d;
    line-height: 1.2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    letter-spacing: -0.01em;
    border-radius: 4px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.kb-title-input::placeholder {
    color: #c1c7cf;
    font-weight: 500;
}
.kb-title-input:hover {
    background: rgba(9, 30, 66, 0.04);
}
.kb-title-input:focus {
    background: rgba(0, 82, 204, 0.08);
    box-shadow: -4px 0 0 0 #0052cc;
}

.kb-title {
    font-size: 2.5rem;
    font-weight: 600;
    margin: 0 0 2rem 0;
    color: #172b4d;
    cursor: text;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.kb-title:empty::before {
    content: attr(data-placeholder);
    color: #a5adba;
    font-style: italic;
}
.kb-icon { margin-right: 0.75rem; }

/* EDITOR - Confluence-style block highlighting */
.kb-editor {
    min-height: 500px;
    outline: none;
    font-size: 1.0625rem;
    line-height: 1.8;
    color: #172b4d;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
.kb-editor:empty::before {
    content: "Comienza a escribir o usa / para comandos...";
    color: #b3bac5;
    font-style: italic;
}
.kb-editor:focus {
    outline: none;
}

/* Confluence-style block highlighting on hover and focus */
.kb-editor p,
.kb-editor h1,
.kb-editor h2,
.kb-editor h3,
.kb-editor h4,
.kb-editor ul,
.kb-editor ol,
.kb-editor blockquote,
.kb-editor pre {
    position: relative;
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 4px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.kb-editor p:hover,
.kb-editor h1:hover,
.kb-editor h2:hover,
.kb-editor h3:hover,
.kb-editor h4:hover,
.kb-editor ul:hover,
.kb-editor ol:hover,
.kb-editor blockquote:hover,
.kb-editor pre:hover {
    background: rgba(9, 30, 66, 0.04);
}

.kb-editor p:focus,
.kb-editor h1:focus,
.kb-editor h2:focus,
.kb-editor h3:focus,
.kb-editor h4:focus,
.kb-editor ul:focus,
.kb-editor ol:focus,
.kb-editor blockquote:focus,
.kb-editor pre:focus {
    outline: none;
    background: rgba(0, 82, 204, 0.08);
    box-shadow: -4px 0 0 0 #0052cc;
}

.kb-editor p { margin-bottom: 1rem; }
.kb-editor h1, .kb-editor h2, .kb-editor h3, .kb-editor h4 { margin: 2rem 0 1rem; font-weight: 600; }
.kb-editor h1 { font-size: 1.875rem; }
.kb-editor h2 { font-size: 1.5rem; border-bottom: 1px solid #e1e4e8; padding-bottom: 0.5rem; }
.kb-editor h3 { font-size: 1.25rem; }
.kb-editor h4 { font-size: 1.125rem; }
.kb-editor ul, .kb-editor ol { margin-bottom: 1rem; padding-left: 2rem; }
.kb-editor li { margin-bottom: 0.25rem; }
.kb-editor a { color: #0052cc; text-decoration: none; }
.kb-editor a:hover { text-decoration: underline; }
.kb-editor img { max-width: 100%; border-radius: 4px; margin: 1rem 0; }
.kb-editor blockquote {
    border-left: 3px solid #0052cc;
    background: #f4f5f7;
    padding: 0.75rem 1rem 0.75rem 1rem !important;
    margin: 1rem -12px;
    font-style: italic;
    color: #5e6c84;
}
.kb-editor code {
    background: #f4f5f7;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.875em;
    font-family: "SFMono-Regular", Consolas, monospace;
    color: #d63384;
}
.kb-editor pre {
    background: #1e1e1e !important;
    color: #d4d4d4;
    padding: 1rem 1.25rem !important;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem -12px;
}
.kb-editor pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* VIEW MODE CONTENT - Confluence-style readable typography */
.kb-content {
    font-size: 1.0625rem;
    line-height: 1.8;
    color: #172b4d;
    cursor: text;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
.kb-content.kb-empty { min-height: 200px; }
.kb-placeholder { color: #a5adba; font-style: italic; }
.kb-content h1, .kb-content h2, .kb-content h3, .kb-content h4 { margin: 2rem 0 1rem; font-weight: 600; }
.kb-content h1 { font-size: 1.875rem; }
.kb-content h2 { font-size: 1.5rem; border-bottom: 1px solid #e1e4e8; padding-bottom: 0.5rem; }
.kb-content h3 { font-size: 1.25rem; }
.kb-content h4 { font-size: 1.125rem; }
.kb-content p { margin-bottom: 1rem; }
.kb-content ul, .kb-content ol { margin-bottom: 1rem; padding-left: 2rem; }
.kb-content li { margin-bottom: 0.25rem; }
.kb-content a { color: #0052cc; text-decoration: none; }
.kb-content a:hover { text-decoration: underline; }
.kb-content img { max-width: 100%; border-radius: 4px; margin: 1rem 0; }
.kb-content blockquote {
    border-left: 3px solid #0052cc;
    background: #f4f5f7;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: #5e6c84;
}
.kb-content code { background: #f4f5f7; padding: 2px 6px; border-radius: 3px; font-size: 0.875em; font-family: "SFMono-Regular", Consolas, monospace; color: #d63384; }
.kb-content pre { background: #1e1e1e; color: #d4d4d4; padding: 1rem 1.25rem; border-radius: 6px; overflow-x: auto; margin: 1rem 0; }
.kb-content pre code { background: transparent; color: inherit; padding: 0; }
.kb-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.kb-content th, .kb-content td { border: 1px solid #dfe1e6; padding: 0.75rem; text-align: left; }
.kb-content th { background: #f4f5f7; font-weight: 600; }
.kb-content tr:hover { background: rgba(9, 30, 66, 0.04); }

/* CHILDREN */
.kb-children {
    border-top: 1px solid #e1e4e8;
    margin-top: 3rem;
    padding-top: 2rem;
}
.kb-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    color: #172b4d;
    text-decoration: none;
}
.kb-child:hover { color: #0052cc; }

/* PULSE ANIMATION for new section members button */
.kb-pulse-button {
    animation: kb-pulse 1.5s ease-in-out infinite;
}
@keyframes kb-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 82, 204, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(0, 82, 204, 0); }
}

.kb-page.compact {
    min-height: auto;
}

.kb-page.compact .kb-topbar,
.kb-page.compact .kb-toolbar {
    position: static;
}

.kb-page.compact .kb-topbar {
    padding: 0.875rem 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
}

.kb-page.compact .kb-breadcrumbs {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.125rem;
}

.kb-page.compact .kb-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.kb-page.compact .kb-toolbar {
    padding: 0.5rem 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
}

.kb-page.compact .kb-content-area {
    max-width: 100%;
    padding: 1rem 1rem 2rem;
}

.kb-page.compact .kb-title,
.kb-page.compact .kb-title-input {
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

.kb-page.compact .kb-content,
.kb-page.compact .kb-editor {
    font-size: 1rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.kb-page.compact .kb-editor {
    min-height: 55dvh;
}

.kb-page.compact .kb-editor p,
.kb-page.compact .kb-editor h1,
.kb-page.compact .kb-editor h2,
.kb-page.compact .kb-editor h3,
.kb-page.compact .kb-editor h4,
.kb-page.compact .kb-editor ul,
.kb-page.compact .kb-editor ol,
.kb-page.compact .kb-editor blockquote,
.kb-page.compact .kb-editor pre {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.kb-page.compact .kb-editor blockquote,
.kb-page.compact .kb-editor pre {
    margin: 1rem 0;
}

.kb-page.compact .kb-content table,
.kb-page.compact .kb-editor table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.kb-page.compact .kb-content img,
.kb-page.compact .kb-editor img {
    height: auto;
}

.kb-page.compact .kb-children {
    margin-top: 2rem;
    padding-top: 1.25rem;
}

@media (max-width: 768px) {
    .kb-page.compact .kb-actions .rz-button {
        min-height: 36px;
    }

    .kb-page.compact .kb-title,
    .kb-page.compact .kb-title-input {
        font-size: 1.5rem;
    }
}
