/* ==========================================================================
   MiniWiki - Nowoczesny, lekki arkusz stylów CSS
   ========================================================================== */

:root {
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #f1f5f9;
    --bg-header: #ffffff;
    
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-link: #2563eb;

    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-bg: #e2e8f0;
    --secondary-hover: #cbd5e1;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --success-text: #065f46;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #991b1b;

    --code-bg: #0f172a;
    --code-text: #f8fafc;
    --inline-code-bg: #f1f5f9;
    --inline-code-text: #0f172a;

    --header-height: 60px;
    --sidebar-width: 290px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-page);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Topbar (Nagłówek)
   ========================================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    font-size: 1.85rem;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
}

.brand-logo-img {
    height: 42px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-top: -2px;
}

.topbar-center {
    flex: 1;
    max-width: 480px;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-form input[type="search"] {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.2rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.search-form input[type="search"]:focus {
    outline: none;
    background: #fff;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
}

/* User Badge (plakietka ADMIN / USER) */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
}

.badge-admin {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-user {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* ==========================================================================
   Przyciski & Formularze
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    line-height: 1.25;
    height: 32px;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--secondary-bg);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger-color);
    color: #fff;
}
.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-block {
    width: 100%;
}

.inline-form {
    display: inline;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--text-primary);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Alert Boxes */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}
.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}
.alert-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

/* ==========================================================================
   Layout & Sidebar
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
}


.sidebar-filter {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-filter-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.sidebar-filter-wrapper .filter-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    z-index: 2;
}

.sidebar-filter-wrapper input {
    width: 100%;
    padding: 0.45rem 1.85rem 0.45rem 2.05rem;
    font-size: 0.825rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.sidebar-filter-wrapper input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.filter-clear-btn {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    width: 22px;
    height: 22px;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    line-height: 1;
    border-radius: 50%;
    z-index: 2;
    transition: all 0.12s ease;
}

.sidebar-filter-wrapper.has-value .filter-clear-btn {
    display: inline-flex !important;
}

.filter-clear-btn:hover {
    color: var(--text-primary);
    background: #e2e8f0;
}

/* Przełącznik widoku szkiców w panelu bocznym */
.sidebar-drafts-toggle-wrap {
    margin-top: 0.5rem;
}

.btn-toggle-drafts {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.btn-toggle-drafts:hover {
    color: var(--text-primary);
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-toggle-drafts-main {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.btn-toggle-drafts-main i {
    font-size: 0.875rem;
    color: #d97706;
}

.drafts-check-icon {
    font-size: 1rem;
    font-weight: 700;
    color: #b45309;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.btn-toggle-drafts.active {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.15);
}

.btn-toggle-drafts.active .btn-toggle-drafts-main i {
    color: #b45309;
}

/* Panel boczny: zunifikowana płaska lista wyników (tekst + szkice) */
.sidebar-flat-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.25rem 1rem 0.5rem;
}

.sidebar-flat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem 0.5rem 0.5rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.sidebar-flat-title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
}

.sidebar-flat-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.sidebar-flat-empty i {
    font-size: 2.2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: inline-block;
}

.sidebar-flat-empty i.bi-file-earmark-check {
    color: #10b981;
}

.flat-empty-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.flat-empty-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.flat-filter-list {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flat-filter-list .tree-file-row {
    padding: 0.35rem 0.5rem;
}

.flat-filter-list .file-title-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.flat-filter-list .flat-folder-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: normal;
    opacity: 0.85;
}

.flat-filter-list .flat-folder-tag i {
    font-size: 0.68rem;
    color: #94a3b8;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.25rem 1rem 0.5rem;
}

/* Drzewko plików */
.nav-tree {
    list-style: none;
    padding-left: 0.75rem;
}

.sidebar-nav > .nav-tree {
    padding-left: 0;
}

.tree-node {
    margin: 0.15rem 0;
}

.tree-folder > details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    user-select: none;
    list-style: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.tree-folder > details > summary::-webkit-details-marker {
    display: none;
}
.tree-folder > details > summary:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}
.tree-folder > details > summary.active-folder {
    background: #fef3c7;
    color: #92400e;
}
.tree-folder > details > summary.active-folder .folder-label i {
    color: #d97706;
}

.tree-folder > details > summary .folder-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.tree-folder > details > summary i {
    font-size: 0.95rem;
    color: #f59e0b; /* Delikatny ciepły kolor folderu */
    flex-shrink: 0;
}

.folder-actions {
    display: none;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.35rem;
}

.tree-folder > details > summary:hover .folder-actions,
.tree-folder > details > summary.active-folder .folder-actions {
    display: inline-flex;
}

.tree-folder > details > summary.active-folder .tree-action-btn {
    color: #92400e;
}

.tree-folder > details > summary.active-folder .tree-action-btn:hover {
    background: rgba(146, 64, 14, 0.15);
    color: #78350f;
}

.tree-folder > details > summary.active-folder .tree-action-delete:hover {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.15) !important;
}

.tree-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.15rem 0.3rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.tree-action-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--primary-color);
}

.tree-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-radius: var(--radius-sm);
    transition: all 0.12s ease;
    background: transparent;
}

.tree-file-row:hover {
    background: rgba(0, 0, 0, 0.04);
}

.tree-file-row.active,
.tree-file-row:has(.tree-file-link.active) {
    background: #e0f2fe;
}

.tree-file-row.active:hover,
.tree-file-row:has(.tree-file-link.active):hover {
    background: #bae6fd;
}

.tree-file-link {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.1s ease;
    flex-grow: 1;
    min-width: 0;
    background: transparent;
}

.tree-file-link i {
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tree-file-link .file-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-file-link:hover {
    color: var(--text-primary);
}
.tree-file-link:hover i {
    color: var(--text-primary);
}

.tree-file-link.active {
    color: var(--primary-color);
    font-weight: 600;
    background: transparent;
}
.tree-file-link.active i {
    color: var(--primary-color);
}

.tree-eye-badge {
    margin-left: 0.35rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    flex-shrink: 0;
}

.tree-eye-badge.is-published {
    color: #10b981;
    opacity: 0.7;
}

.tree-file-row:hover .tree-eye-badge.is-published {
    opacity: 1;
}

.tree-eye-badge.is-draft {
    color: #f59e0b;
    opacity: 1;
}

.tree-file-row.is-draft .file-title {
    opacity: 0.75;
    font-style: italic;
}

.file-actions {
    display: none;
    align-items: center;
    gap: 0.15rem;
    padding-right: 0.35rem;
    flex-shrink: 0;
}

.tree-file-row:hover .file-actions,
.tree-file-row:focus-within .file-actions {
    display: inline-flex;
}

.tree-action-delete:hover {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.1) !important;
}

/* Przyciski akcji na podświetlonym (aktywnym) pliku */
.tree-file-row.active .tree-action-btn,
.tree-file-row:has(.tree-file-link.active) .tree-action-btn {
    color: var(--primary-color);
    background: transparent;
}

.tree-file-row.active .tree-action-btn:hover,
.tree-file-row:has(.tree-file-link.active) .tree-action-btn:hover {
    background: rgba(2, 132, 199, 0.15);
    color: #0369a1;
}

.tree-file-row.active .tree-action-delete:hover,
.tree-file-row:has(.tree-file-link.active) .tree-action-delete:hover {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.15) !important;
}

.tree-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.2rem 0.5rem;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main-content {
    flex: 1;
    padding: 2rem 3rem;
    max-width: 1040px;
    margin: 0 auto;
}

.main-content:has(.has-toc) {
    max-width: 1320px;
}

.content-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
}

/* Układ dokumentu z bocznym spisem treści (TOC) */
.doc-layout {
    display: flex;
    align-items: flex-start;
    gap: 2.5rem;
    width: 100%;
}

.doc-layout.no-toc .doc-container {
    width: 100%;
}

.doc-layout.has-toc .doc-container {
    flex: 1;
    min-width: 0;
}

.doc-toc {
    width: 230px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    max-height: calc(100vh - var(--header-height) - 3rem);
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    padding-left: 1.25rem;
}

.doc-toc::-webkit-scrollbar {
    width: 4px;
}
.doc-toc::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.doc-toc-sticky {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.doc-toc-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.doc-toc-nav {
    display: flex;
    flex-direction: column;
}

.doc-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.doc-toc-item {
    margin: 0;
    padding: 0;
}

.doc-toc-level-1 {
    font-weight: 600;
    margin-top: 0.35rem;
}

.doc-toc-level-2 {
    padding-left: 0.25rem;
}

.doc-toc-level-3 {
    padding-left: 0.9rem;
    font-size: 0.78rem;
}

.doc-toc-level-4 {
    padding-left: 1.5rem;
    font-size: 0.75rem;
}

.doc-toc-link {
    display: block;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.815rem;
    line-height: 1.35;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-toc-link:hover {
    color: var(--primary-color);
    background: rgba(2, 132, 199, 0.05);
}

.doc-toc-link.active {
    color: var(--primary-color);
    font-weight: 600;
    background: rgba(2, 132, 199, 0.1);
}

.doc-toc.has-recent-widget {
    width: 250px;
}

/* ==========================================================================
   Recent Articles Widget (Prawy panel na stronie głównej)
   ========================================================================== */

.doc-recent-widget {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.recent-articles-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.recent-article-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s ease;
}

.recent-article-item:hover {
    border-color: #93c5fd;
    background: #f0f9ff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.recent-article-item.is-updated {
    background: #f0fdf4;
    border-color: #86efac;
    border-left: 3px solid #10b981;
}

.recent-article-item.is-updated:hover {
    background: #ecfdf5;
    border-color: #34d399;
}

.recent-article-title {
    font-size: 0.815rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-article-item:hover .recent-article-title {
    color: var(--primary-color);
}

.recent-article-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.recent-article-folder {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}

.recent-article-date {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    font-size: 0.7rem;
}

.doc-toc-bordered-top {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

/* Nagłówek dokumentu */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.25rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.doc-meta-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.doc-path {
    font-family: var(--font-mono);
    font-weight: 500;
}

.doc-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1.3;
    width: fit-content;
    margin-top: 0.15rem;
}

.doc-status-badge.is-published {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.doc-status-badge.is-draft {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

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

.doc-actions .btn {
    height: 32px;
    padding: 0 0.75rem;
    font-size: 0.8rem;
    line-height: 1;
    font-family: inherit;
    box-sizing: border-box;
}

/* ==========================================================================
   Markdown Body Styling
   ========================================================================== */

.markdown-body {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--text-primary);
    font-weight: 700;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    scroll-margin-top: calc(var(--header-height) + 1.25rem);
}

.markdown-body h1 {
    font-size: 2.15rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

.markdown-body h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.35rem;
}

.markdown-body h3 {
    font-size: 1.25rem;
}

.markdown-body p {
    margin-bottom: 1.25rem;
}

.markdown-body a {
    color: var(--text-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.markdown-body a:hover {
    color: var(--primary-hover);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 0.75rem 1.25rem;
    margin: 1.25rem 0;
    background: #f8fafc;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
    margin: 1rem 0 1.25rem 1.75rem;
}

.markdown-body li {
    margin-bottom: 0.35rem;
}

.markdown-body li.task-item {
    list-style: none;
    margin-left: -1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tabele */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.markdown-body th,
.markdown-body td {
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-body th {
    background: #f1f5f9;
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background: #fafafa;
}

/* Kod */
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.markdown-body pre {
    background: var(--code-bg);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
}

.markdown-body pre code {
    background: transparent;
    color: var(--code-text);
    padding: 0;
    border: none;
    font-size: 0.875rem;
    line-height: 1.5;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1.25rem 0;
    border: 1px solid var(--border-color);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
    background-color: #fff;
    display: inline-block;
    vertical-align: middle;
}

/* Wyróżnienie tekstu (Highlight mark) */
mark.wiki-highlight,
.wiki-highlight {
    background-color: var(--highlight-color, #fef08a);
    color: #0f172a !important; /* Zawsze czytelny, kontrastowy ciemny tekst na pastelowym tle */
    padding: 0.12em 0.38em;
    margin: 0 0.08em;
    border-radius: var(--radius-sm);
    font-weight: inherit;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.markdown-body :is(h1, h2, h3, h4, h5, h6) mark,
.markdown-body :is(h1, h2, h3, h4, h5, h6) .wiki-highlight {
    font-weight: inherit;
}

/* ==========================================================================
   Edytor (Markdown Editor)
   ========================================================================== */

.editor-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-bottom: 5rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.flex-1 {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.editor-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: visible;
    background: #fff;
}

.editor-toolbar {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    padding: 0.4rem 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: relative;
    z-index: 20;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.tool-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.tool-btn:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.tool-btn-notoc.active {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: #fca5a5 !important;
}
.tool-btn-notoc.active:hover {
    background: #fecaca !important;
}

/* Przycisk stanu publikacji na pasku edycji */
.toolbar-publish-wrapper {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-right: 0.5rem;
}

.tool-publish-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.tool-publish-btn.is-published {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.tool-publish-btn.is-published:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
}
.tool-publish-btn.is-published i {
    color: #10b981;
}

.tool-publish-btn.is-draft {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}
.tool-publish-btn.is-draft:hover {
    background: #fef3c7;
    border-color: #fcd34d;
}
.tool-publish-btn.is-draft i {
    color: #f59e0b;
}

/* Dropdown w pasku narzędziowym edytora */
.toolbar-dropdown {
    position: relative;
    display: inline-flex;
}

.toolbar-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 500;
}

.toolbar-dropdown-toggle .dropdown-arrow {
    font-size: 0.65rem;
    transition: transform 0.15s ease;
}

.toolbar-dropdown.open .toolbar-dropdown-toggle .dropdown-arrow {
    transform: rotate(180deg);
}

.toolbar-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    min-width: 190px;
    padding: 0.35rem 0;
    display: none;
    flex-direction: column;
}

.toolbar-dropdown.open .toolbar-dropdown-menu {
    display: flex;
}

.toolbar-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.82rem;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}

.toolbar-dropdown-menu .dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.toolbar-dropdown-menu .dropdown-item strong {
    display: inline-block;
    min-width: 26px;
    padding: 0.1rem 0.35rem;
    background: #e2e8f0;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-color);
    text-align: center;
}

/* Split button w pasku narzędzi edytora */
.toolbar-split-btn {
    display: inline-flex;
    align-items: stretch;
    position: relative;
    vertical-align: middle;
}

.toolbar-split-btn .split-main-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    padding: 0.35rem 0.52rem;
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 1;
}

.toolbar-split-btn .split-arrow-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid var(--border-color);
    padding: 0.35rem 0.35rem;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.toolbar-split-btn .split-main-btn:hover,
.toolbar-split-btn .split-arrow-btn:hover {
    z-index: 2;
    color: var(--text-primary);
}

.toolbar-split-btn .split-arrow-btn .dropdown-arrow {
    transition: transform 0.15s ease;
}

.toolbar-split-btn.open .split-arrow-btn .dropdown-arrow {
    transform: rotate(180deg);
}

.toolbar-split-btn.open .split-arrow-btn {
    background: #e2e8f0;
    color: var(--text-primary);
}

/* Przycisk ze spotem (kropką) koloru w toolbarze */
.highlight-spot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0.35rem 0.5rem;
}

.highlight-color-spot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #fef08a;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: background-color 0.15s ease, transform 0.15s ease;
    vertical-align: middle;
}

.highlight-spot-btn:hover .highlight-color-spot {
    transform: scale(1.18);
}

/* Kompaktowe menu nagłówków (H1 - H6) */
.toolbar-dropdown-menu.heading-compact-menu {
    min-width: 48px;
    padding: 0.25rem;
    gap: 0.15rem;
}

.compact-heading-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.3rem 0.45rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.compact-heading-item:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

/* Kompaktowe menu kółek kolorów */
.toolbar-dropdown-menu.color-swatch-compact-menu {
    min-width: auto;
    padding: 0.35rem 0.45rem;
    flex-direction: row;
}

.color-swatches-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.color-circle-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--swatch-color);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    flex-shrink: 0;
}

.color-circle-btn:hover {
    transform: scale(1.22);
    box-shadow: 0 0 0 2px var(--primary-color), 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Interaktywny picker rozmiaru tabeli */
.toolbar-dropdown-menu.table-grid-menu {
    min-width: auto;
    padding: 0.5rem 0.6rem 0.6rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.table-grid-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.table-grid-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.02em;
    min-height: 1.1em;
}

.table-grid-picker {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    grid-template-rows: repeat(8, 18px);
    gap: 3px;
    user-select: none;
    cursor: pointer;
}

.table-grid-cell {
    width: 18px;
    height: 18px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 2px;
    box-sizing: border-box;
    transition: background 0.05s ease, border-color 0.05s ease;
}

.table-grid-cell.selected {
    background: #bae6fd;
    border-color: #0284c7;
}

.table-grid-cell:hover {
    filter: brightness(0.97);
}

/* W trybie podglądu ukryj przyciski formatowania i wyrównaj zakładki */
.editor-toolbar.preview-mode .toolbar-group {
    display: none;
}

.editor-toolbar.preview-mode {
    justify-content: flex-end;
}

/* Zakładki Edycja / Podgląd */
.toolbar-tabs {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: #e2e8f0;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1;
    transition: all 0.15s ease;
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(2, 132, 199, 0.35);
}

.tab-btn.active i {
    color: #ffffff !important;
}

/* ==========================================================================
   Podświetlanie składni edytora Markdown (Live Syntax Highlighting)
   ========================================================================== */

.editor-syntax-wrap {
    position: relative;
    width: 100%;
    min-height: 480px;
    background: #ffffff;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    overflow: hidden;
}

.editor-syntax-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    background: transparent;
    box-sizing: border-box;
}

.editor-syntax-pre {
    margin: 0 !important;
    padding: 1rem !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    color: var(--text-primary);
    box-sizing: border-box !important;
    min-height: 100%;
}

.editor-syntax-pre,
.editor-syntax-pre code,
.editor-textarea {
    font-family: var(--font-mono) !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
    tab-size: 4 !important;
    -moz-tab-size: 4 !important;
    font-variant-ligatures: none !important;
    -webkit-font-smoothing: antialiased;
}

.editor-syntax-pre code {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    display: block;
    box-sizing: border-box !important;
}

/* Reset dla elementów wewnętrznych podświetlania (żeby nie psuły wyrównania znaków) */
.editor-syntax-pre span {
    display: inline;
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    box-sizing: border-box;
}

/* Jednolite wyróżnienie dla wszystkich znaczników składni wraz z zawartością (delikatne czerwone tło jak kod) */
.editor-syntax-pre span.syn-tag {
    color: #b91c1c;
    background-color: rgba(239, 68, 68, 0.08);
    border-radius: 2px;
}

.editor-textarea {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    min-height: 480px;
    margin: 0;
    padding: 1rem !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    resize: vertical;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

/* Gdy podświetlanie składni jest aktywne - ukryj tekst textarea, zachowaj kursor i selekcję */
.editor-syntax-wrap.syntax-active .editor-textarea {
    color: transparent !important;
    caret-color: var(--text-primary, #0f172a);
}

.editor-syntax-wrap.syntax-active .editor-textarea::selection {
    background: rgba(2, 132, 199, 0.28) !important;
    color: transparent !important;
}

.editor-syntax-wrap.syntax-active .editor-textarea::placeholder {
    color: var(--text-muted);
}

.editor-syntax-wrap.dragover,
.editor-textarea.dragover,
.editor-areas.dragover .editor-syntax-wrap,
.editor-areas.dragover .editor-textarea {
    background-color: #f0f9ff !important;
    outline: 2px dashed var(--primary-color);
    outline-offset: -4px;
}

.editor-preview {
    padding: 1.5rem;
    min-height: 380px;
    background: #fff;
}

.editor-footer {
    position: fixed;
    bottom: 1.5rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.45rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin: 0;
    transition: all 0.2s ease;
}
.editor-footer:hover {
    box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.18), 0 6px 10px -2px rgba(0, 0, 0, 0.08);
}
.editor-footer .btn {
    border-radius: 9999px;
}
.editor-footer .btn-primary {
    padding: 0.5rem 1.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

@media (max-width: 768px) {
    .editor-footer {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        justify-content: flex-end;
        border-radius: var(--radius-md);
    }
}

/* ==========================================================================
   Wyszukiwarka (Search Results)
   ========================================================================== */

.search-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.search-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.search-results-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.search-result-item {
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    transition: box-shadow 0.15s ease;
}
.search-result-item:hover {
    box-shadow: var(--shadow-md);
}

.result-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-link);
    text-decoration: none;
}
.result-title:hover {
    text-decoration: underline;
}

.result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.4rem 0 0.6rem 0;
}

.result-snippet {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

mark {
    background: #fef08a;
    color: #854d0e;
    padding: 0.1rem 0.25rem;
    border-radius: 2px;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ==========================================================================
   Ekran logowania (Login Page)
   ========================================================================== */

.login-body {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    font-size: 3.8rem;
    color: var(--primary-color);
    display: inline-block;
    margin-bottom: 0.75rem;
}

.login-logo-img {
    height: 80px;
    width: auto;
    max-width: 280px;
    object-fit: contain;
    display: inline-block;
    margin-bottom: 0.75rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

/* ==========================================================================
   RWD / Responsywność
   ========================================================================== */

@media (max-width: 860px) {
    .doc-toc {
        display: none !important;
    }
    .doc-layout {
        display: block !important;
    }

    .mobile-toggle {
        display: block;
    }

    .topbar-center {
        display: none; /* schowaj w headerze na rzecz mobilnego lub zmniejsz */
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        z-index: 99;
        transition: left 0.25s ease;
        background: #fff;
        box-shadow: var(--shadow-md);
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding: 1rem;
    }

    .content-wrapper {
        padding: 1.25rem;
    }

    .form-row {
        flex-direction: column;
    }
}

/* Klasy pomocnicze */
.text-danger {
    color: var(--danger-color);
}
.text-muted {
    color: var(--text-muted);
}

/* ==========================================================================
   SPA Dynamic UI (Pasek postępu i powiadomienia Toast)
   ========================================================================== */

#spaProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: #3b82f6;
    z-index: 99999;
    opacity: 0;
    transition: width 0.25s ease, opacity 0.2s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 99999;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius-md);
    background: #0f172a;
    color: #fff;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 380px;
}

.toast.toast-success {
    background: #064e3b;
    border: 1px solid #059669;
    color: #ecfdf5;
}

.toast.toast-danger {
    background: #7f1d1d;
    border: 1px solid #dc2626;
    color: #fef2f2;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Media Management & Picker
   ========================================================================== */

.modal-dialog-lg {
    max-width: 800px;
    width: 95%;
}

.modal-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.modal-sub-path {
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-picker-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.25rem;
}

.media-upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    background: #f8fafc;
    padding: 1.25rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.media-upload-dropzone:hover,
.media-upload-dropzone.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.dropzone-icon {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.dropzone-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dropzone-browse-label {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.dropzone-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.media-picker-options {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.options-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.size-options {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.size-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.size-pill input {
    display: none;
}

.size-pill:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.size-pill.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}


.media-grid-wrap {
    min-height: 180px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.media-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.media-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.media-card.just-uploaded {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.media-card-thumb {
    width: 100%;
    height: 110px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.media-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.media-card-thumb:hover img {
    transform: scale(1.05);
}

.media-card-meta {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}

.media-card-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-card-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.media-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: #fafafa;
}

.media-empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.media-empty-icon {
    font-size: 2.2rem;
    color: #cbd5e1;
}

/* ==========================================================================
   Wydruk i eksport do PDF (@media print)
   ========================================================================== */

@media print {
    @page {
        size: A4 portrait;
        margin: 20mm 15mm;
    }

    /* Reset tła i wymiarów dla czystego dokumentu */
    html, body {
        background: #fff !important;
        color: #111 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        font-size: 11pt !important;
        line-height: 1.6 !important;
    }

    /* Ukrycie wszystkich zbędnych elementów interfejsu Wiki */
    .topbar,
    .sidebar,
    .mobile-toggle,
    .doc-actions,
    .doc-toc,
    .alert,
    .modal-backdrop,
    #spaProgressBar,
    #toastContainer,
    .media-picker-backdrop,
    .user-badge {
        display: none !important;
    }

    /* Dopasowanie kontenera artykułu na pełną szerokość strony */
    .app-layout,
    .main-content,
    .content-wrapper,
    .doc-layout,
    .doc-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
        overflow: visible !important;
    }

    /* Czysty nagłówek dokumentu ze ścieżką i datą modyfikacji */
    .doc-header {
        display: block !important;
        border-bottom: 1px solid #cbd5e1 !important;
        padding-bottom: 0.75rem !important;
        margin-bottom: 1.5rem !important;
    }

    .doc-meta-info {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        font-size: 8.5pt !important;
        color: #64748b !important;
    }

    /* Formatowanie treści Markdown pod wydruk */
    .markdown-body {
        font-size: 11pt !important;
        color: #111 !important;
        line-height: 1.6 !important;
    }

    .markdown-body h1,
    .markdown-body h2,
    .markdown-body h3,
    .markdown-body h4,
    .markdown-body h5,
    .markdown-body h6 {
        color: #0f172a !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        margin-top: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .markdown-body p,
    .markdown-body li {
        orphans: 3;
        widows: 3;
    }

    .markdown-body a {
        color: #0284c7 !important;
        text-decoration: none !important;
    }

    .markdown-body pre {
        background: #f8fafc !important;
        color: #0f172a !important;
        border: 1px solid #cbd5e1 !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        box-shadow: none !important;
        padding: 0.75rem !important;
    }

    .markdown-body code {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        border: 1px solid #e2e8f0 !important;
        font-size: 9.5pt !important;
    }

    .markdown-body pre code {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
    }

    .markdown-body table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
        margin: 1rem 0 !important;
    }

    .markdown-body tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .markdown-body th,
    .markdown-body td {
        border: 1px solid #cbd5e1 !important;
        padding: 6px 10px !important;
        color: #1e293b !important;
    }

    .markdown-body th {
        background-color: #f8fafc !important;
        font-weight: 600 !important;
    }

    .markdown-body blockquote {
        border-left: 3px solid #94a3b8 !important;
        background: #f8fafc !important;
        color: #334155 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        padding: 0.5rem 1rem !important;
    }

    .markdown-body img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
    }
}
