/* ---------------------------------------------------------------- Modais */
.wd-modal-overlay {
    position: fixed; inset: 0; z-index: 200; background: rgba(8, 10, 20, .5);
    display: flex; align-items: flex-start; justify-content: center; padding: 7vh 20px;
    opacity: 0; pointer-events: none; transition: opacity .15s ease; overflow-y: auto;
}
.wd-modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.wd-modal {
    position: relative; width: 100%; max-width: 580px;
    background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 28px 30px; transform: translateY(10px) scale(.98); opacity: 0;
    transition: transform .18s cubic-bezier(.23, 1, .32, 1), opacity .18s ease;
}
.wd-modal-overlay.is-open .wd-modal { transform: translateY(0) scale(1); opacity: 1; }
.wd-modal-close {
    position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 8px;
    border: none; background: none; cursor: pointer; color: var(--color-text-dim);
    display: flex; align-items: center; justify-content: center;
}
.wd-modal-close:hover { background: var(--color-surface-alt); color: var(--color-text-muted); }
.wd-modal-close svg { width: 15px; height: 15px; }
.wd-modal-body h1 { padding-right: 28px; font-size: 19px; }
.wd-modal-body .form { max-width: none; }
.wd-modal-body .form-card { border: none; box-shadow: none; padding: 0; border-radius: 0; }
.wd-modal-body .page-header { margin-bottom: 16px; }
.wd-modal-body .card-page-grid { display: flex; flex-direction: column; gap: 20px; }
.wd-modal-body .card-sidebar { border-top: 1px solid var(--color-border); padding-top: 16px; }
body.wd-modal-lock { overflow: hidden; }
.modal-loading { padding: 50px 20px; text-align: center; color: var(--color-text-muted); font-size: 13px; }

/* ---------------------------------------------------------------- Toasts */
.wd-toast-stack {
    position: fixed; right: 20px; bottom: 20px; z-index: 400;
    display: flex; flex-direction: column-reverse; gap: 10px;
    width: 100%; max-width: 360px; pointer-events: none;
}
.wd-toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border-strong);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 12px 14px; font-size: 13px; color: var(--color-text);
    opacity: 0; transform: translateY(8px) scale(.98);
    transition: transform .2s cubic-bezier(.23, 1, .32, 1), opacity .2s ease;
}
.wd-toast.is-open { opacity: 1; transform: translateY(0) scale(1); }
.wd-toast.is-leaving { opacity: 0; transform: translateY(4px) scale(.98); transition-duration: .15s; }
.wd-toast-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.wd-toast-icon svg { width: 18px; height: 18px; }
.wd-toast-message { flex: 1; line-height: 1.45; }
.wd-toast-close { flex-shrink: 0; background: none; border: none; padding: 2px; margin: -2px -4px 0 0; cursor: pointer; color: var(--color-text-dim); display: flex; }
.wd-toast-close:hover { color: var(--color-text-muted); }
.wd-toast-close svg { width: 13px; height: 13px; }
.wd-toast-success { border-left-color: var(--color-success); }
.wd-toast-success .wd-toast-icon { color: var(--color-success); }
.wd-toast-danger { border-left-color: var(--color-danger); }
.wd-toast-danger .wd-toast-icon { color: var(--color-danger); }
.wd-toast-warning { border-left-color: var(--color-warning); }
.wd-toast-warning .wd-toast-icon { color: var(--color-warning); }
.wd-toast-info { border-left-color: var(--color-blue); }
.wd-toast-info .wd-toast-icon { color: var(--color-blue); }

@media (prefers-reduced-motion: reduce) {
    .wd-toast { transition-duration: .01s; transform: none; }
}
@media (max-width: 480px) {
    .wd-toast-stack { left: 12px; right: 12px; max-width: none; }
}

/* ---------------------------------------------------------------- Diálogo de confirmação */
.wd-confirm-overlay {
    position: fixed; inset: 0; z-index: 260; background: rgba(8, 10, 20, .5);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.wd-confirm-overlay.is-open { opacity: 1; pointer-events: auto; }
.wd-confirm {
    width: 100%; max-width: 380px; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 24px 26px; transform: translateY(10px) scale(.98); opacity: 0;
    transition: transform .18s cubic-bezier(.23, 1, .32, 1), opacity .18s ease;
}
.wd-confirm-overlay.is-open .wd-confirm { transform: translateY(0) scale(1); opacity: 1; }
.wd-confirm-icon {
    width: 40px; height: 40px; border-radius: 50%; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-danger-bg); color: var(--color-danger);
}
.wd-confirm-icon svg { width: 20px; height: 20px; }
.wd-confirm-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.wd-confirm-message { font-size: 13.5px; color: var(--color-text-muted); margin: 0 0 20px; line-height: 1.5; }
.wd-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
    .wd-confirm-overlay, .wd-confirm { transition-duration: .01s; }
}

/* Markdown renderizado fora do editor (descrição de projeto/card/task já salva) */
.md-content { font-size: 13.5px; line-height: 1.6; color: var(--color-text-muted); }
.md-content h2, .md-content h3, .md-content h4 { color: var(--color-text); margin: 14px 0 6px; }
.md-content p { margin: 0 0 10px; }
.md-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 8px 0;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
    -webkit-touch-callout: none;
}
.md-content code { background: var(--color-surface-alt); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md-content pre { background: var(--color-surface-alt); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.md-content ul, .md-content ol { padding-left: 20px; margin: 0 0 10px; }
.md-content blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--color-border-strong); }
.md-content a,
.md-preview-pane a {
    color: var(--color-blue);
    font-weight: 500;
    word-break: break-word;
    text-decoration: none;
}

/* ---------------------------------------------------------------- Card panels (página de cartão/task, Configurações) */
.card-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.card-panel + .card-panel { margin-top: 14px; }
.card-panel h3 { margin-top: 0; display: flex; align-items: center; gap: 7px; }
.card-panel h3 svg { width: 14px; height: 14px; color: var(--color-text-dim); flex-shrink: 0; }
.card-panel-danger { background: var(--color-danger-bg); border-color: var(--color-danger-border); }

/* ---------------------------------------------------------------- Toolbar CTA (botão primário na toolbar do board) */
.toolbar-btn-primary { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.toolbar-btn-primary:hover { filter: brightness(1.06); background: var(--gradient-brand); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.toolbar-btn-primary:active { transform: scale(.97) translateY(0); }

/* ---------------------------------------------------------------- Tags */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-toggle {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
    background: var(--color-surface-alt); border: 1px solid transparent; font: inherit; font-size: 12.5px; font-weight: 600;
    color: var(--color-text-muted); cursor: pointer; transition: background-color .15s var(--ease-out), color .15s var(--ease-out), transform .12s var(--ease-out);
}
.tag-toggle:active { transform: scale(.97); }
.tag-toggle::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tag-toggle.tag-hue-indigo { color: var(--hue-indigo); }
.tag-toggle.tag-hue-coral { color: var(--hue-coral); }
.tag-toggle.tag-hue-teal { color: var(--hue-teal); }
.tag-toggle.tag-hue-amber { color: var(--hue-amber); }
.tag-toggle.tag-hue-rose { color: var(--hue-rose); }
.tag-toggle.tag-hue-green { color: var(--hue-green); }
.tag-toggle.tag-hue-indigo.tag-toggle-active { background: var(--hue-indigo); color: #fff; }
.tag-toggle.tag-hue-coral.tag-toggle-active { background: var(--hue-coral); color: #fff; }
.tag-toggle.tag-hue-teal.tag-toggle-active { background: var(--hue-teal); color: #fff; }
.tag-toggle.tag-hue-amber.tag-toggle-active { background: var(--hue-amber); color: #fff; }
.tag-toggle.tag-hue-rose.tag-toggle-active { background: var(--hue-rose); color: #fff; }
.tag-toggle.tag-hue-green.tag-toggle-active { background: var(--hue-green); color: #fff; }
/* Checkbox de tag dentro de .segmented-option (form de criação de cartão) — mesma cor sólida ao marcar */
.segmented-option input:checked + .tag-toggle.tag-hue-indigo { background: var(--hue-indigo); color: #fff; }
.segmented-option input:checked + .tag-toggle.tag-hue-coral { background: var(--hue-coral); color: #fff; }
.segmented-option input:checked + .tag-toggle.tag-hue-teal { background: var(--hue-teal); color: #fff; }
.segmented-option input:checked + .tag-toggle.tag-hue-amber { background: var(--hue-amber); color: #fff; }
.segmented-option input:checked + .tag-toggle.tag-hue-rose { background: var(--hue-rose); color: #fff; }
.segmented-option input:checked + .tag-toggle.tag-hue-green { background: var(--hue-green); color: #fff; }
.tag-hint { font-size: 12.5px; color: var(--color-text-dim); margin: 0; }

/* Chip de tag no kanban card -- mesma estrutura do .kanban-card-project, sem a bolinha (já tem no título da coluna) */
.kanban-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.kanban-card-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; }
.kanban-card-tag.tag-hue-indigo { color: var(--hue-indigo); background: var(--hue-indigo-bg); }
.kanban-card-tag.tag-hue-coral { color: var(--hue-coral); background: var(--hue-coral-bg); }
.kanban-card-tag.tag-hue-teal { color: var(--hue-teal); background: var(--hue-teal-bg); }
.kanban-card-tag.tag-hue-amber { color: var(--hue-amber); background: var(--hue-amber-bg); }
.kanban-card-tag.tag-hue-rose { color: var(--hue-rose); background: var(--hue-rose-bg); }
.kanban-card-tag.tag-hue-green { color: var(--hue-green); background: var(--hue-green-bg); }

/* Seletor de 6 bolinhas de cor -- criação de tag em Configurações */
.hue-picker { display: flex; gap: 10px; }
.hue-picker label { cursor: pointer; }
.hue-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.hue-swatch { display: block; width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); transition: box-shadow .15s ease; }
.hue-swatch-indigo { background: var(--hue-indigo); }
.hue-swatch-coral { background: var(--hue-coral); }
.hue-swatch-teal { background: var(--hue-teal); }
.hue-swatch-amber { background: var(--hue-amber); }
.hue-swatch-rose { background: var(--hue-rose); }
.hue-swatch-green { background: var(--hue-green); }
.hue-picker input:checked + .hue-swatch-indigo { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-indigo); }
.hue-picker input:checked + .hue-swatch-coral { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-coral); }
.hue-picker input:checked + .hue-swatch-teal { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-teal); }
.hue-picker input:checked + .hue-swatch-amber { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-amber); }
.hue-picker input:checked + .hue-swatch-rose { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-rose); }
.hue-picker input:checked + .hue-swatch-green { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--hue-green); }

/* ---------------------------------------------------------------- Configurações */
.settings-tag-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.settings-tag-row + .settings-tag-row { border-top: 1px solid var(--color-border); }
.settings-tag-name { flex: 1; font-size: 13.5px; font-weight: 600; }
.settings-section-sub { margin: -8px 0 16px; }
.hue-swatch-sm { width: 12px; height: 12px; box-shadow: none; flex-shrink: 0; }

/* Layout mobile legado removido — ver assets/css/mobile-app.css (shell estilo app). */
@media (max-width: 899px) {
    .card-page-grid, .finance-layout, .split { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================
   WIKI — Notebooks, Páginas, Tree Navigation & Compact Buttons
   ================================================================ */

/* ---------------------------------------------------------------- Layout wiki */
body.wiki-page .content {
    padding: 0;
    /* "overflow-x: hidden" sozinho força o browser a tratar overflow-y como "auto" também
       (regra do spec: eixo não-visible "puxa" o outro pra auto) — isso transformava .content
       num container de scroll próprio, dessincronizado do scroll da janela. Como .app-topbar
       (sticky) fica FORA de .content, e .wiki-sidebar (sticky) fica DENTRO, os dois sticky
       passavam a contar o offset do topbar duas vezes: um espaço estranho entre a barra
       superior e o conteúdo, e a árvore "descolando" ao rolar em vez de ficar fixa.
       "overflow: visible" nos dois eixos devolve o scroll pra janela, como o resto do app já assume. */
    overflow: visible;
}
@media (max-width: 899px) {
    body.wiki-page .content {
        padding: calc(var(--mobile-app-bar-h, 52px) + var(--mobile-safe-top, 0px)) 0 calc(var(--mobile-tab-bar-h, 60px) + var(--mobile-safe-bottom, 0px));
    }
}

/* Container do Index (/wiki) e formulários soltos */
.wiki-index-wrap {
    padding: 32px 48px 64px;
    width: 100%;
    max-width: 1280px;
}
@media (max-width: 899px) {
    .wiki-index-wrap {
        padding: 20px 18px 48px;
    }
}

.wiki-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar-h));
    align-items: stretch;
    gap: 0;
    width: 100%;
}
/* ---------------------------------------------------------------- Wiki Buttons (Compactos & Elegantes) */
.wiki-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--font-sans);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: all .15s var(--ease-out);
}
.wiki-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

.wiki-btn:hover {
    background: var(--color-surface-alt);
    border-color: var(--color-border-strong);
    color: var(--color-text);
    text-decoration: none;
    transform: translateY(-0.5px);
    box-shadow: var(--shadow-sm);
}
.wiki-btn:active { transform: translateY(0); }

.wiki-btn-primary {
    background: var(--gradient-brand);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px -1px rgba(31, 111, 235, .35);
}
.wiki-btn-primary:hover {
    filter: brightness(1.06);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px -1px rgba(31, 111, 235, .45);
}

.wiki-btn-danger {
    color: var(--color-danger);
    border-color: color-mix(in srgb, var(--color-danger) 25%, var(--color-border));
}
.wiki-btn-danger:hover {
    background: var(--color-danger-bg);
    border-color: var(--color-danger-border);
    color: var(--color-danger);
}

.wiki-btn-icon-only {
    width: 32px;
    padding: 0;
}

/* ---------------------------------------------------------------- Sidebar wiki */
.wiki-sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    padding: 0;
    scrollbar-width: thin;
}

.wiki-sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wiki-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0 4px;
}
.wiki-sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--hue-indigo-bg);
    color: var(--hue-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.wiki-sidebar-brand-icon svg { width: 17px; height: 17px; }
.wiki-sidebar-brand-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.wiki-sidebar-brand-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}
.wiki-sidebar-brand-sub {
    font-size: 11.5px;
    color: var(--color-text-dim);
    margin-top: 1px;
}

.wiki-search-box {
    position: relative;
    width: 100%;
    margin-top: 2px;
}
.wiki-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
    color: var(--color-text-dim);
    pointer-events: none;
}
.wiki-search-input {
    width: 100%;
    height: 30px;
    padding: 0 10px 0 28px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    color: var(--color-text);
    outline: none;
    transition: border-color .15s, background .15s;
    font-family: inherit;
}
.wiki-search-input:focus {
    border-color: var(--color-blue);
    background: var(--color-surface);
}

.wiki-sidebar-actions {
    padding: 12px 18px;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}
.wiki-sidebar-new-page {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px dashed var(--color-border-strong);
    background: transparent;
    color: var(--color-text-muted);
    transition: all .15s var(--ease-out);
}
.wiki-sidebar-new-page svg { width: 13px; height: 13px; }
.wiki-sidebar-new-page:hover {
    background: var(--color-surface-alt);
    border-color: var(--color-blue);
    color: var(--color-blue);
    text-decoration: none;
}

.wiki-sidebar-empty {
    padding: 24px 18px;
    font-size: 12.5px;
    color: var(--color-text-dim);
    text-align: center;
}

.wiki-sidebar-editing-hint {
    padding: 16px 20px;
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wiki-sidebar-editing-hint::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-blue);
}

.wiki-sidebar-footer {
    margin-top: auto;
    border-top: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
    padding: 12px 18px;
}
.wiki-sidebar-delete {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-dim);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    width: 100%;
    transition: color .15s, background .15s;
}
.wiki-sidebar-delete svg { width: 13px; height: 13px; }
.wiki-sidebar-delete:hover { color: var(--color-danger); background: var(--color-danger-bg); }

/* ---------------------------------------------------------------- Tree de páginas */
.wiki-sidebar-tree {
    padding: 10px 12px;
    flex: 1;
    overflow-y: auto;
}
.wiki-tree-root, .wiki-tree-children {
    list-style: none;
    padding: 0;
    margin: 0;
}
.wiki-tree-children {
    display: none;
    padding-left: 14px;
    margin-left: 12px;
    border-left: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}
.wiki-tree-children.is-expanded,
.wiki-tree-item.is-expanded > .wiki-tree-children { display: block; }

.wiki-tree-item { margin: 2px 0; }
.wiki-tree-row {
    display: flex;
    align-items: center;
    gap: 3px;
    border-radius: 6px;
    min-height: 30px;
    padding: 2px 4px;
    transition: background .12s;
}
.wiki-tree-row:hover { background: var(--color-surface-alt); }
.wiki-tree-item.is-active > .wiki-tree-row {
    background: color-mix(in srgb, var(--color-blue) 10%, var(--color-surface));
}

.wiki-tree-toggle {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-dim);
    border-radius: 4px;
    transition: color .12s, transform .15s ease;
}
.wiki-tree-toggle svg { width: 9px; height: 9px; }
.wiki-tree-toggle:hover { color: var(--color-text); background: rgba(0,0,0,.05); }
.wiki-tree-item.is-expanded > .wiki-tree-row .wiki-tree-toggle {
    transform: rotate(90deg);
}

.wiki-tree-spacer { width: 14px; height: 20px; flex-shrink: 0; }

.wiki-tree-link {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    padding: 4px 6px 4px 2px;
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 4px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .12s;
}
.wiki-tree-link:hover { color: var(--color-text); text-decoration: none; }
.wiki-tree-link.is-active,
.wiki-tree-item.is-active > .wiki-tree-row .wiki-tree-link {
    color: var(--color-blue);
    font-weight: 600;
}
.wiki-tree-icon { width: 13px; height: 13px; flex-shrink: 0; opacity: .7; }

.wiki-tree-add-child {
    opacity: 0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dim);
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 2px;
    transition: opacity .12s, color .12s, background .12s;
}
.wiki-tree-add-child svg { width: 10px; height: 10px; }
.wiki-tree-row:hover .wiki-tree-add-child { opacity: 1; }
.wiki-tree-add-child:hover {
    color: var(--color-blue);
    background: var(--color-surface-alt);
    text-decoration: none;
}

/* ---------------------------------------------------------------- Main wiki */
.wiki-main {
    padding: 36px 56px 80px;
    min-width: 0;
    max-width: 100%;
}

.wiki-page-container {
    max-width: 960px;
    width: 100%;
}

/* ---------------------------------------------------------------- Welcome screen */
.wiki-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 80px 24px;
    max-width: 540px;
    margin: 0 auto;
}
.wiki-welcome-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    margin-bottom: 22px;
    background: var(--color-surface-alt);
}
.wiki-welcome-icon.hue-indigo { background: var(--hue-indigo-bg); color: var(--hue-indigo); }
.wiki-welcome-icon.hue-coral  { background: var(--hue-coral-bg);  color: var(--hue-coral); }
.wiki-welcome-icon.hue-teal   { background: var(--hue-teal-bg);   color: var(--hue-teal); }
.wiki-welcome-icon.hue-amber  { background: var(--hue-amber-bg);  color: var(--hue-amber); }
.wiki-welcome-icon.hue-rose   { background: var(--hue-rose-bg);   color: var(--hue-rose); }
.wiki-welcome-icon.hue-green  { background: var(--hue-green-bg);  color: var(--hue-green); }
.wiki-welcome-icon svg { width: 32px; height: 32px; }
.wiki-welcome-title { font-size: 24px; font-weight: 700; color: var(--color-text); margin: 0 0 10px; }
.wiki-welcome-desc  { font-size: 14px; color: var(--color-text-muted); line-height: 1.65; margin: 0 0 14px; }
.wiki-welcome-meta  { display: flex; gap: 10px; font-size: 12.5px; color: var(--color-text-dim); }
.wiki-welcome-hint  { font-size: 13px; color: var(--color-text-dim); margin-top: 18px; }

/* ---------------------------------------------------------------- Breadcrumb */
.wiki-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}
.wiki-breadcrumb a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color .12s;
    padding: 3px 6px;
    border-radius: 4px;
}
.wiki-breadcrumb a:hover { color: var(--color-text); background: var(--color-surface-alt); text-decoration: none; }
.wiki-breadcrumb-sep { display: flex; align-items: center; color: var(--color-border-strong); }
.wiki-breadcrumb-sep svg { width: 10px; height: 10px; }
.wiki-breadcrumb-current { color: var(--color-text); font-weight: 600; padding: 3px 6px; }

/* ---------------------------------------------------------------- Cabeçalho de página */
.wiki-page-header { margin-bottom: 28px; }
.wiki-page-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
}
.wiki-page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    margin: 0;
    flex: 1;
    letter-spacing: -.015em;
}
.wiki-page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-top: 2px;
}
.wiki-page-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: var(--color-text-dim);
    flex-wrap: wrap;
    margin-top: 4px;
}
.wiki-page-meta strong { color: var(--color-text); font-weight: 500; }

/* ---------------------------------------------------------------- Corpo da página */
.wiki-page-body {
    border-top: 1px solid var(--color-border);
    padding-top: 32px;
    margin-bottom: 48px;
}
.wiki-page-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 0;
    font-size: 14px;
    color: var(--color-text-muted);
}

/* Tipografia de Markdown na Wiki */
.wiki-page-body .md-content {
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--color-text);
}
.wiki-page-body .md-content h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 36px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
.wiki-page-body .md-content h1:first-child { margin-top: 0; }
.wiki-page-body .md-content h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 30px 0 14px;
    color: var(--color-text);
}
.wiki-page-body .md-content h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 24px 0 10px;
    color: var(--color-text);
}
.wiki-page-body .md-content p {
    margin: 16px 0;
}
.wiki-page-body .md-content ul,
.wiki-page-body .md-content ol {
    margin: 16px 0;
    padding-left: 26px;
}
.wiki-page-body .md-content li {
    margin: 6px 0;
}
.wiki-page-body .md-content blockquote {
    margin: 20px 0;
    padding: 14px 20px;
    border-left: 3px solid var(--color-blue);
    background: var(--color-surface-alt);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-text-muted);
}
.wiki-page-body .md-content pre {
    margin: 20px 0;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
}
.wiki-page-body .md-content code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}
.wiki-page-body .md-content pre code {
    padding: 0;
    background: transparent;
    border: none;
}
.wiki-page-body .md-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 24px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.wiki-page-body .md-content th {
    padding: 12px 16px;
    background: var(--color-surface-alt);
    font-weight: 600;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
.wiki-page-body .md-content td {
    padding: 12px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
.wiki-page-body .md-content tr:last-child td {
    border-bottom: none;
}
.wiki-page-body .md-content hr {
    margin: 32px 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------- Subpáginas */
.wiki-page-children {
    margin-top: 40px;
    border-top: 1px solid var(--color-border);
    padding-top: 24px;
}
.wiki-page-children-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-dim);
    margin: 0 0 14px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.wiki-children-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.wiki-child-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s var(--ease-out);
}
.wiki-child-card svg { width: 14px; height: 14px; color: var(--color-text-dim); flex-shrink: 0; }
.wiki-child-card span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wiki-child-arrow { color: var(--color-text-dim); opacity: .4; transition: transform .15s; }
.wiki-child-card:hover {
    border-color: var(--color-blue);
    background: var(--color-surface-alt);
    color: var(--color-blue);
    text-decoration: none;
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
}
.wiki-child-card:hover .wiki-child-arrow { opacity: 1; transform: translateX(2px); color: var(--color-blue); }

/* ---------------------------------------------------------------- Index de notebooks */
.wiki-notebooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 16px;
}
.wiki-notebook-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    text-decoration: none;
    color: var(--color-text);
    transition: border-color .18s, box-shadow .18s, transform .15s;
    position: relative;
    overflow: hidden;
}
.wiki-notebook-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3.5px;
    background: var(--color-blue);
}
.wiki-notebook-card.hue-indigo::before { background: var(--hue-indigo); }
.wiki-notebook-card.hue-coral::before  { background: var(--hue-coral); }
.wiki-notebook-card.hue-teal::before   { background: var(--hue-teal); }
.wiki-notebook-card.hue-amber::before  { background: var(--hue-amber); }
.wiki-notebook-card.hue-rose::before   { background: var(--hue-rose); }
.wiki-notebook-card.hue-green::before  { background: var(--hue-green); }

.wiki-notebook-card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}
.wiki-notebook-card.hue-indigo:hover { border-color: var(--hue-indigo); }
.wiki-notebook-card.hue-coral:hover  { border-color: var(--hue-coral); }
.wiki-notebook-card.hue-teal:hover   { border-color: var(--hue-teal); }
.wiki-notebook-card.hue-amber:hover  { border-color: var(--hue-amber); }
.wiki-notebook-card.hue-rose:hover   { border-color: var(--hue-rose); }
.wiki-notebook-card.hue-green:hover  { border-color: var(--hue-green); }

.wiki-notebook-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}
.wiki-notebook-card.hue-indigo .wiki-notebook-icon { background: var(--hue-indigo-bg); color: var(--hue-indigo); }
.wiki-notebook-card.hue-coral  .wiki-notebook-icon { background: var(--hue-coral-bg);  color: var(--hue-coral); }
.wiki-notebook-card.hue-teal   .wiki-notebook-icon { background: var(--hue-teal-bg);   color: var(--hue-teal); }
.wiki-notebook-card.hue-amber  .wiki-notebook-icon { background: var(--hue-amber-bg);  color: var(--hue-amber); }
.wiki-notebook-card.hue-rose   .wiki-notebook-icon { background: var(--hue-rose-bg);   color: var(--hue-rose); }
.wiki-notebook-card.hue-green  .wiki-notebook-icon { background: var(--hue-green-bg);  color: var(--hue-green); }
.wiki-notebook-icon svg { width: 22px; height: 22px; }

.wiki-notebook-body { flex: 1; }
.wiki-notebook-name { font-size: 16px; font-weight: 700; margin: 0 0 5px; line-height: 1.3; }
.wiki-notebook-desc { font-size: 13px; color: var(--color-text-muted); margin: 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.wiki-notebook-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--color-text-dim);
    border-top: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
    padding-top: 12px;
    margin-top: auto;
}
.wiki-notebook-pages { display: flex; align-items: center; gap: 5px; }
.wiki-notebook-pages svg { width: 12px; height: 12px; }
.wiki-notebook-author { margin-left: auto; }

/* ---------------------------------------------------------------- Empty state (index wiki) */
.wiki-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 80px 24px;
    max-width: 420px;
    margin: 0 auto;
    gap: 12px;
}
.wiki-empty-icon { color: var(--color-text-dim); opacity: .6; }
.wiki-empty-icon svg { width: 52px; height: 52px; }
.wiki-empty-title { font-size: 20px; font-weight: 600; color: var(--color-text); margin: 0; }
.wiki-empty-desc  { font-size: 13.5px; color: var(--color-text-muted); line-height: 1.55; margin: 0 0 8px; }

/* ---------------------------------------------------------------- Hue picker (notebook form) */
.wiki-hue-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.wiki-hue-option {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 12.5px;
    color: var(--color-text-muted);
    transition: all .15s;
    user-select: none;
}
.wiki-hue-option input { position: absolute; opacity: 0; pointer-events: none; }
.wiki-hue-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--color-border);
}
.wiki-hue-option.hue-indigo .wiki-hue-dot { background: var(--hue-indigo); }
.wiki-hue-option.hue-coral  .wiki-hue-dot { background: var(--hue-coral); }
.wiki-hue-option.hue-teal   .wiki-hue-dot { background: var(--hue-teal); }
.wiki-hue-option.hue-amber  .wiki-hue-dot { background: var(--hue-amber); }
.wiki-hue-option.hue-rose   .wiki-hue-dot { background: var(--hue-rose); }
.wiki-hue-option.hue-green  .wiki-hue-dot { background: var(--hue-green); }

.wiki-hue-option.is-selected,
.wiki-hue-option:has(input:checked) {
    border-color: var(--color-blue);
    color: var(--color-text);
    background: var(--color-surface-alt);
    font-weight: 600;
}

/* ---------------------------------------------------------------- Formulário de página (editor inline e modal de criação) */
.wiki-page-title-input-wrap { margin-bottom: 14px; }
.wiki-page-title-input {
    width: 100%;
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--color-border);
    border-radius: 0;
    padding: 8px 0 10px;
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
}
.wiki-page-title-input::placeholder { color: var(--color-text-dim); font-weight: 400; }
.wiki-page-title-input:focus { border-bottom-color: var(--color-blue); }

/* Linha combinada título + hierarquia no editor inline: lado a lado quando há espaço,
   pra não desperdiçar largura empilhando dois campos que cabem numa linha só. */
.wiki-edit-header-row {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 20px;
}
.wiki-edit-header-row .wiki-page-title-input-wrap { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
.wiki-edit-header-row .wiki-page-parent-row { flex: 0 0 260px; margin-bottom: 0; padding: 0; }

.wiki-page-parent-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.wiki-page-parent-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}
.wiki-page-parent-label svg { width: 12px; height: 12px; }
.wiki-page-parent-select {
    width: 100%;
    height: 34px;
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
}
.wiki-page-parent-select:focus { border-color: var(--color-blue); }

.wiki-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 0;
    border-top: 1px solid var(--color-border);
    position: sticky;
    bottom: 0;
    background: var(--color-bg);
    z-index: 5;
}

/* Painel de edição inline da página: substitui a view no mesmo espaço, sem a moldura de
   "cartão inset" herdada de .card-edit-panel (aqui é o documento inteiro). Enquanto ativo,
   o container da página abandona a largura de leitura (960px) e usa todo o espaço real
   disponível em .wiki-main — só o modo de leitura fica com a coluna estreita e confortável. */
.wiki-edit-panel {
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 48px;
}
.wiki-page-container:has(#wiki-edit-panel:not([hidden])) {
    max-width: none;
}
.wiki-edit-panel .form-wide {
    max-width: none;
    width: 100%;
}
.wiki-edit-panel .lw-editor,
.wiki-create-form .lw-editor {
    min-height: 420px;
}

/* Modal de criação de página: mais largo que o padrão pra caber o editor markdown confortavelmente */
.wd-modal:has(.wiki-create-form) { max-width: 780px; max-height: calc(100vh - 40px); overflow-y: auto; }

/* ---------------------------------------------------------------- Responsivo */
@media (max-width: 899px) {
    .wiki-layout {
        grid-template-columns: 1fr;
    }
    .wiki-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .wiki-main { padding: 22px 18px 48px; }
    .wiki-page-title { font-size: 22px; }
    .wiki-page-title-row { flex-direction: column; gap: 10px; }
    .wiki-notebooks-grid { grid-template-columns: 1fr; }
    .wiki-children-list { grid-template-columns: 1fr; }
    .wiki-edit-header-row { flex-direction: column; align-items: stretch; gap: 14px; }
    .wiki-edit-header-row .wiki-page-parent-row { flex: 1 1 auto; }
}
@media (max-width: 480px) {
    .wiki-page-actions { flex-wrap: wrap; }
}
