/* =========================================================================
   ShareYourNotes — design system
   Neutro, editorial, técnico. Tokens → base → componentes → shell → páginas.
   ========================================================================= */

/* ---------- 1. Tokens ---------- */

:root {
    color-scheme: light;

    --font-sans: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

    --bg: #f8f9fb;
    --bg-soft: #f1f3f6;
    --sidebar: #f1f3f6;
    --surface: #ffffff;
    --surface-2: #f5f7fa;
    --surface-hover: #f7f8fb;

    --text: #17191f;
    --muted: #737985;
    --muted-strong: #565d69;

    --border: #e5e8ee;
    --border-strong: #d4d9e2;

    --accent: #5965e8;
    --accent-hover: #4652d4;
    --accent-soft: #eef0ff;
    --accent-ring: rgba(89, 101, 232, 0.22);
    --accent-text: #4652d4;

    --danger: #d92d20;
    --danger-soft: #fee4e2;
    --warning: #b54708;
    --warning-soft: #fef0c7;
    --ok: #067647;
    --ok-soft: #dcfae6;

    --type-txt: #475467;
    --type-txt-bg: #eef1f5;
    --type-md: #1d4ed8;
    --type-md-bg: #eaf0ff;
    --type-csv: #067647;
    --type-csv-bg: #e6f9ef;
    --type-json: #b54708;
    --type-json-bg: #fff4e5;
    --type-log: #be123c;
    --type-log-bg: #ffeef2;
    --type-yml: #6941c6;
    --type-yml-bg: #f3eeff;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.14);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    --sidebar-w: 248px;
    --topbar-h: 56px;
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #101216;
    --bg-soft: #15181d;
    --sidebar: #15181d;
    --surface: #1b1f25;
    --surface-2: #20252c;
    --surface-hover: #242a31;

    --text: #f2f4f8;
    --muted: #9198a5;
    --muted-strong: #b6bcc7;

    --border: #2b3038;
    --border-strong: #3a4048;

    --accent: #8b93ff;
    --accent-hover: #a6acff;
    --accent-soft: rgba(139, 147, 255, 0.14);
    --accent-ring: rgba(139, 147, 255, 0.3);
    --accent-text: #b3b8ff;

    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, 0.16);
    --warning: #fdb022;
    --warning-soft: rgba(253, 176, 34, 0.16);
    --ok: #47cd89;
    --ok-soft: rgba(71, 205, 137, 0.16);

    --type-txt: #c3c9d4;
    --type-txt-bg: #262c34;
    --type-md: #9cb4ff;
    --type-md-bg: rgba(80, 110, 255, 0.18);
    --type-csv: #6ce9a6;
    --type-csv-bg: rgba(50, 213, 131, 0.16);
    --type-json: #fdb022;
    --type-json-bg: rgba(253, 176, 34, 0.16);
    --type-log: #fda29b;
    --type-log-bg: rgba(249, 112, 102, 0.16);
    --type-yml: #c3b5fd;
    --type-yml-bg: rgba(155, 138, 251, 0.18);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: dark;

        --bg: #101216;
        --bg-soft: #15181d;
        --sidebar: #15181d;
        --surface: #1b1f25;
        --surface-2: #20252c;
        --surface-hover: #242a31;
        --text: #f2f4f8;
        --muted: #9198a5;
        --muted-strong: #b6bcc7;
        --border: #2b3038;
        --border-strong: #3a4048;
        --accent: #8b93ff;
        --accent-hover: #a6acff;
        --accent-soft: rgba(139, 147, 255, 0.14);
        --accent-ring: rgba(139, 147, 255, 0.3);
        --accent-text: #b3b8ff;
        --danger: #f97066;
        --danger-soft: rgba(249, 112, 102, 0.16);
        --warning: #fdb022;
        --warning-soft: rgba(253, 176, 34, 0.16);
        --ok: #47cd89;
        --ok-soft: rgba(71, 205, 137, 0.16);
    }
}

/* ---------- 2. Base ---------- */

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

/* O atributo hidden tem de ganhar a qualquer display definido abaixo. */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4 {
    margin: 0 0 0.6rem;
    font-weight: 600;
    line-height: 1.22;
    letter-spacing: -0.017em;
    color: var(--text);
}

h1 { font-size: 1.72rem; }
h2 { font-size: 1.16rem; letter-spacing: -0.012em; }
h3 { font-size: 0.98rem; letter-spacing: -0.008em; }
h4 { font-size: 0.9rem; }

p { margin: 0 0 0.9rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent-text);
    text-decoration: none;
    transition: color 0.15s var(--ease);
}

a:hover { text-decoration: underline; text-underline-offset: 2px; }

ul, ol { margin: 0 0 0.9rem; padding-left: 1.15rem; }
li { margin-bottom: 0.25rem; }

hr,
.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

code, kbd, pre, .mono { font-family: var(--font-mono); }

code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.08em 0.35em;
    font-size: 0.86em;
}

img { max-width: 100%; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- 3. Utilitários ---------- */

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.stack > * + * { margin-top: 0.75rem; }
.hint { color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.sep { color: var(--border-strong); padding: 0 0.1rem; }

/* ---------- 4. Botões ---------- */

.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-border: var(--border-strong);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 36px;
    padding: 0 0.85rem;
    border: 1px solid var(--btn-border);
    border-radius: var(--radius);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: inherit;
    font-size: 0.855rem;
    font-weight: 550;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
                color 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
    --btn-bg: var(--accent);
    --btn-fg: #fff;
    --btn-border: var(--accent);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-border: var(--accent-hover); }
html[data-theme="dark"] .btn-primary { --btn-fg: #11131a; }
html[data-theme="dark"] .btn-primary:hover { --btn-fg: #11131a; }

.btn-secondary {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-border: var(--border-strong);
}
.btn-secondary:hover { --btn-bg: var(--surface-hover); --btn-border: var(--muted); }

.btn-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--muted-strong);
    --btn-border: transparent;
}
.btn-ghost:hover { --btn-bg: var(--surface-2); --btn-fg: var(--text); }

.btn-danger {
    --btn-bg: var(--danger-soft);
    --btn-fg: var(--danger);
    --btn-border: transparent;
}
.btn-danger:hover { --btn-bg: var(--danger); --btn-fg: #fff; }

.btn-sm {
    height: 30px;
    padding: 0 0.6rem;
    font-size: 0.79rem;
    border-radius: var(--radius-sm);
    gap: 0.3rem;
}

.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.btn svg,
.icon-btn svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.icon-stroke { flex: none; }

.inline-form { display: inline-flex; margin: 0; }

/* ---------- 5. Formulários ---------- */

.field { margin-bottom: 1rem; }

.label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-strong);
    letter-spacing: 0.01em;
}

.input,
.select,
.textarea {
    width: 100%;
    height: 36px;
    padding: 0 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.textarea {
    height: auto;
    min-height: 110px;
    padding: 0.55rem 0.7rem;
    line-height: 1.6;
    resize: vertical;
}

.input::placeholder,
.textarea::placeholder { color: var(--muted); }

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.select {
    appearance: none;
    padding-right: 2rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.input.has-error,
.textarea.has-error,
.select.has-error { border-color: var(--danger); }

.error-text {
    margin-top: 0.3rem;
    color: var(--danger);
    font-size: 0.78rem;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.86rem;
    cursor: pointer;
}
.checkbox input { margin-top: 0.2rem; accent-color: var(--accent); }

.form-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.9rem;
}

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

.input-narrow { max-width: 140px; }
.code-input { font-family: var(--font-mono); font-size: 0.85rem; }

input[type="file"] { font-size: 0.82rem; color: var(--muted); }

input[type="file"]::file-selector-button {
    margin-right: 0.6rem;
    padding: 0.32rem 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 550;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

input[type="file"]::file-selector-button:hover {
    background: var(--surface-2);
    border-color: var(--muted);
}

/* ---------- 6. Alertas e toast ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.855rem;
}

.alert strong { flex: none; font-weight: 700; }
.alert > div { flex: 1; }
.alert-info { border-left-color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.alert-success { border-left-color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.alert-warning { border-left-color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.alert-error { border-left-color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.alert-dismiss {
    flex: none;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.05rem;
    line-height: 1;
    padding: 0 0.1rem;
    opacity: 0.6;
    cursor: pointer;
}
.alert-dismiss:hover { opacity: 1; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translate(-50%, 12px);
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius);
    background: var(--text);
    color: var(--bg);
    font-size: 0.82rem;
    font-weight: 550;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
    z-index: 90;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Aviso de cookies (informativo: só existe o cookie de sessão) */

.cookie-notice {
    position: fixed;
    left: 1.25rem;
    bottom: 1.25rem;
    z-index: 60;
    display: flex;
    align-items: flex-end;
    gap: 0.9rem;
    width: min(430px, calc(100vw - 2.5rem));
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: cookie-in 0.22s var(--ease);
}

@keyframes cookie-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.cookie-notice-text p {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.55;
    color: var(--muted-strong);
}

.cookie-notice-title {
    margin-bottom: 0.25rem !important;
    font-size: 0.68rem !important;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text) !important;
}

.cookie-notice-text a { display: inline-block; margin-top: 0.4rem; font-size: 0.75rem; }
.cookie-notice .btn { flex: none; }

html.cookies-accepted .cookie-notice { display: none; }

@media (max-width: 560px) {
    .cookie-notice {
        left: 0.85rem;
        right: 0.85rem;
        bottom: 0.85rem;
        width: auto;
        flex-direction: column;
        align-items: stretch;
    }
    .cookie-notice .btn { align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-notice { animation: none; }
}

/* ---------- 7. Shell ---------- */

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

.app-shell.is-guest { grid-template-columns: minmax(0, 1fr); }

/* Barra lateral */

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0.85rem 0.7rem 0.7rem;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    z-index: 30;
    transition: width 0.18s var(--ease);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.1rem 0.3rem 0.9rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text);
    font-weight: 650;
    font-size: 0.92rem;
    letter-spacing: -0.015em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    flex: none;
}
html[data-theme="dark"] .brand-mark { color: #11131a; }

.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-collapse { display: inline-flex; }

.sidebar-new {
    height: 34px;
    margin-bottom: 1.1rem;
    font-size: 0.83rem;
    justify-content: flex-start;
    padding-left: 0.6rem;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }

.sidebar-label {
    padding: 0 0.55rem;
    margin-bottom: 0.35rem;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.42rem 0.55rem;
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    font-size: 0.865rem;
    font-weight: 500;
    transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.sidebar-link svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
    opacity: 0.85;
}

.sidebar-link:hover { background: rgba(120, 130, 150, 0.1); color: var(--text); text-decoration: none; }

.sidebar-link.is-active {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.sidebar-link.is-active svg { color: var(--accent); opacity: 1; }

.sidebar-foot { margin-top: auto; padding-top: 0.9rem; }

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.55rem 0.6rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
}
.sidebar-stats:hover { text-decoration: none; border-color: var(--border-strong); }
.sidebar-stats-hint { color: var(--muted); font-size: 0.72rem; font-weight: 500; }

.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.45rem;
    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
    transition: background-color 0.14s var(--ease);
}
.user-menu-trigger::-webkit-details-marker { display: none; }
.user-menu-trigger:hover { background: rgba(120, 130, 150, 0.12); }

.user-menu-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-menu-title {
    font-size: 0.82rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-mail {
    font-size: 0.71rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-chevron { margin-left: auto; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.8; }

.user-menu-pop {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    z-index: 40;
}

.user-menu-pop a,
.user-menu-pop .menu-button {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.42rem 0.5rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}
.user-menu-pop a:hover,
.user-menu-pop .menu-button:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-pop svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Moldura e topbar */

.app-frame {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.app-topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}

.app-topbar-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    max-width: 1176px;
    height: 100%;
    margin: 0 auto;
    padding: 0 1.75rem;
}

.topbar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 0.2rem; margin-left: auto; }

.sidebar-toggle { display: none; }

.topbar-guest-nav { display: flex; align-items: center; gap: 0.35rem; margin-left: 0.6rem; }
.nav-link {
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius-sm);
    color: var(--muted-strong);
    font-size: 0.855rem;
    font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { color: var(--text); font-weight: 600; }

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1176px;
    margin: 0 auto;
    padding: 1.6rem 1.75rem 2.5rem;
}

/* Tema */

html[data-theme="dark"] .theme-icon-sun,
html[data-theme="light"] .theme-icon-moon { display: none; }
html[data-theme="system"] .theme-icon-sun { display: none; }
@media (prefers-color-scheme: light) {
    html[data-theme="system"] .theme-icon-moon { display: none; }
    html[data-theme="system"] .theme-icon-sun { display: block; }
}

/* Seletor de idioma */

.lang-menu { position: relative; }
.lang-toggle { width: auto; padding: 0 0.4rem; gap: 0.25rem; }
.lang-toggle::-webkit-details-marker { display: none; }
.lang-current { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; color: var(--muted); }

.lang-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 190px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    z-index: 50;
}

.lang-title {
    display: block;
    padding: 0.3rem 0.45rem 0.45rem;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.45rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.84rem;
}
.lang-option:hover { background: var(--surface-2); text-decoration: none; }
.lang-option.is-active { background: var(--accent-soft); }
.lang-code { font-size: 0.65rem; font-weight: 700; color: var(--muted); min-width: 1.5rem; }
.lang-name { flex: 1; }
.lang-check { color: var(--accent); font-weight: 700; }

/* Rodapé */

.footer {
    padding: 1.1rem 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    width: 100%;
    max-width: 1176px;
    margin: 0 auto;
    padding: 0 1.75rem;
}

.footer-links { display: inline-flex; align-items: center; gap: 0.8rem; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }

.footer-support { display: inline-flex; align-items: center; gap: 0.3rem; }
.footer-heart { color: #e11d48; line-height: 1; }

.sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 16, 0.45);
    z-index: 25;
}

/* Barra lateral recolhida (desktop) */

@media (min-width: 901px) {
    .app-shell.is-collapsed { --sidebar-w: 68px; }
    .app-shell.is-collapsed .sidebar-label,
    .app-shell.is-collapsed .brand-name,
    .app-shell.is-collapsed .sidebar-link span,
    .app-shell.is-collapsed .sidebar-stats,
    .app-shell.is-collapsed .user-menu-name,
    .app-shell.is-collapsed .user-menu-chevron,
    .app-shell.is-collapsed .sidebar-new span { display: none; }
    .app-shell.is-collapsed .sidebar-new,
    .app-shell.is-collapsed .sidebar-link,
    .app-shell.is-collapsed .user-menu-trigger { justify-content: center; padding-left: 0; padding-right: 0; }
    .app-shell.is-collapsed .sidebar-head { justify-content: center; }
    .app-shell.is-collapsed .user-menu-pop { left: 100%; right: auto; bottom: 0; width: 200px; }
}

/* ---------- 8. Superfícies ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.card-pad { padding: 1.15rem 1.25rem; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.card-header h2,
.card-header h3 { margin: 0; font-size: 0.92rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
}
.panel-head h3 { margin: 0; font-size: 0.84rem; font-weight: 600; }
.panel-body { padding: 0.85rem 0.9rem; }

/* ---------- 9. Cabeçalhos de página ---------- */

.crumbs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.55rem;
    font-size: 0.76rem;
    color: var(--muted);
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}
.page-head h1 { margin-bottom: 0.2rem; }

.donate-list { list-style: none; padding: 0; margin: 0 0 0.9rem; }
.donate-list li {
    display: grid;
    gap: 0.15rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.donate-list li:first-child { padding-top: 0; }
.donate-list li:last-child { border-bottom: 0; }
.page-head p { color: var(--muted); font-size: 0.87rem; }

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

.meta-row {
    display: flex;
    align-items: center;
    gap: 0.35rem 0.75rem;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.78rem;
}

/* ---------- 10. Explorador de ficheiros ---------- */

.workspace-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
}
.workspace-header h1 { margin-bottom: 0.15rem; font-size: 1.55rem; }
.workspace-header .sub { color: var(--muted); font-size: 0.875rem; }
.workspace-actions { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }

.workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.search {
    position: relative;
    flex: 1 1 260px;
    max-width: 380px;
}
.search svg {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    pointer-events: none;
}
.search .input { padding-left: 2rem; height: 34px; font-size: 0.85rem; }

.workspace-toolbar .sort { margin: 0; }
.workspace-toolbar .sort .select { height: 34px; width: auto; min-width: 168px; font-size: 0.83rem; }

.sidebar { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }

.view-toggle {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-left: auto;
}
.view-toggle button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.is-active { background: var(--surface-2); color: var(--text); }
.view-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.filters {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 26px;
    padding: 0 0.55rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 550;
    transition: background-color 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.chip:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.chip-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.list-summary {
    color: var(--muted);
    font-size: 0.76rem;
    margin: 0 0 0.5rem;
    font-variant-numeric: tabular-nums;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: visible;
}
.file-list > .file-row:last-child { border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }

.file-list-head {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 66px 132px 76px 36px;
    align-items: center;
    gap: 0.7rem;
    padding: 0.42rem 0.75rem;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
.file-list-head .size { text-align: right; }

.file-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 66px 132px 76px 36px;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-top: 1px solid var(--border);
    position: relative;
    transition: background-color 0.13s var(--ease);
}
.file-row:first-child { border-top: 0; }
.file-row:hover { background: var(--surface-hover); }
.file-row:focus-within { background: var(--surface-hover); }

.type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--type-txt-bg);
    color: var(--type-txt);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    flex: none;
}
.type-md { background: var(--type-md-bg); color: var(--type-md); }
.type-csv { background: var(--type-csv-bg); color: var(--type-csv); }
.type-json { background: var(--type-json-bg); color: var(--type-json); }
.type-log { background: var(--type-log-bg); color: var(--type-log); }
.type-yml,
.type-yaml { background: var(--type-yml-bg); color: var(--type-yml); }
.type-txt,
.type-markdown { background: var(--type-txt-bg); color: var(--type-txt); }

.file-main { min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }

.file-name {
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-name:hover { color: var(--accent-text); text-decoration: none; }

.file-sub {
    display: none;
    color: var(--muted);
    font-size: 0.73rem;
}

.file-col {
    color: var(--muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-col.format { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.file-col.size { text-align: right; }

.file-row-actions { display: flex; justify-content: flex-end; }

.menu { position: relative; }
.menu > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    list-style: none;
    transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover,
.menu[open] > summary { background: var(--surface-2); color: var(--text); }
.menu > summary svg { fill: none; stroke: currentColor; stroke-width: 2; }

.menu-pop {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    min-width: 186px;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    z-index: 45;
}

.menu-pop a,
.menu-pop button {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.81rem;
    text-align: left;
    cursor: pointer;
}
.menu-pop a:hover,
.menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop svg {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.menu-pop form { margin: 0; }
.menu-pop .danger { color: var(--danger); }
.menu-pop .menu-sep { height: 1px; margin: 0.25rem 0.2rem; background: var(--border); }

/* Grelha */

.file-list[data-view="grid"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.7rem;
    border: 0;
    background: transparent;
}
.file-list[data-view="grid"] .file-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 148px;
}
.file-list[data-view="grid"] .file-row:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm); }
.file-list[data-view="grid"] .file-col { display: none; }
.file-list[data-view="grid"] .file-list-head { display: none; }
.file-list[data-view="grid"] .file-sub { display: block; }
.file-list[data-view="grid"] .file-main { width: 100%; }
.file-list[data-view="grid"] .file-name { white-space: normal; word-break: break-word; }
.file-list[data-view="grid"] .file-row-actions {
    position: absolute;
    top: 0.6rem;
    right: 0.55rem;
    margin-left: auto;
}
.file-list[data-view="grid"] .type-icon { width: 34px; height: 34px; }

/* Estados vazios */

.empty {
    padding: 3rem 1.5rem;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--muted);
}
.empty h3 { margin-bottom: 0.35rem; }
.empty p { color: var(--muted); font-size: 0.875rem; max-width: 46ch; margin: 0 auto 1rem; }
.empty-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 0.8rem;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
}
.empty-icon svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Paginação */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1.2rem;
}
.pagination-status { color: var(--muted); font-size: 0.79rem; font-variant-numeric: tabular-nums; }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }

/* Compatibilidade com o painel antigo */

.list-toolbar { margin-bottom: 1rem; }
.toolbar-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.8rem; }
.toolbar-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 150px; }
.toolbar-field .label { margin: 0; }
.toolbar-search { flex: 1 1 260px; }
.toolbar-actions { display: flex; gap: 0.4rem; margin-left: auto; }

.upload-card,
.create-card {
    margin-bottom: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
}
.upload-card { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; }
.upload-card h2 { font-size: 0.95rem; margin-bottom: 0.15rem; }
.upload-card p { color: var(--muted); font-size: 0.8rem; margin: 0; }
.upload-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.file-input {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 36px;
    padding: 0 0.8rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.file-input:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-input input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input .file-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.create-card { padding: 1.25rem; }
.create-head { margin-bottom: 1rem; }
.create-head h2 { font-size: 1rem; margin-bottom: 0.2rem; }
.create-head p { color: var(--muted); font-size: 0.83rem; margin: 0; }
.create-form .form-grid { grid-template-columns: minmax(0, 2fr) minmax(130px, 1fr); }
.create-form .textarea { min-height: 150px; font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6; }

@media (max-width: 720px) {
    .create-form .form-grid { grid-template-columns: 1fr; }
    .upload-card { align-items: flex-start; }
}

/* ---------- 11. Diálogos ---------- */

dialog.dialog {
    width: min(560px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text);
    overflow: visible;
}

dialog.dialog-wide { width: min(760px, calc(100vw - 2rem)); }

dialog.dialog::backdrop {
    background: rgba(10, 12, 16, 0.5);
    backdrop-filter: blur(2px);
}

.dialog-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: dialog-in 0.18s var(--ease);
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to { opacity: 1; transform: none; }
}

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 1rem 1.15rem 0.7rem;
}
.dialog-head h2 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 0.81rem; }

.dialog-close {
    flex: none;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}
.dialog-close:hover { background: var(--surface-2); color: var(--text); }

.dialog-body { padding: 0 1.15rem 0.4rem; overflow-y: auto; }

.dialog-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--border);
    margin-top: 0.6rem;
}
.dialog-foot .dialog-hint { margin-right: auto; }

/* Zona de largar */

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.6rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.dropzone:hover,
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-title { font-size: 0.9rem; font-weight: 600; }
.dropzone-sub { font-size: 0.79rem; color: var(--muted); }
.dropzone-icon { color: var(--muted); margin-bottom: 0.35rem; }
.dropzone-icon svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-file {
    margin-top: 0.5rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dropzone-limits { margin-top: 0.6rem; font-size: 0.75rem; color: var(--muted); }
.dropzone-limits code { background: transparent; border: 0; padding: 0; color: var(--muted-strong); }

/* ---------- 12. Documento e editor ---------- */

.doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.1rem;
    align-items: start;
}

.doc-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.doc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
}
.doc-toolbar a { color: var(--muted-strong); }

.doc {
    padding: 1rem 1.1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
    overflow-x: auto;
    max-height: 68vh;
    overflow-y: auto;
}

.doc .line { display: flex; gap: 0.9rem; white-space: pre; }
.doc .line-no {
    flex: none;
    min-width: 2.4rem;
    text-align: right;
    color: var(--muted);
    user-select: none;
    opacity: 0.65;
}
.doc .line-text { flex: 1; }

.editor-wrap { display: flex; flex-direction: column; }

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.editor-toolbar .file-type {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-strong);
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.editor-filename {
    font-size: 0.83rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.editor-toolbar-actions { display: flex; align-items: center; gap: 0.45rem; margin-left: auto; flex-wrap: wrap; }

.editor-area {
    width: 100%;
    min-height: 52vh;
    padding: 1rem 1.1rem;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.84rem;
    line-height: 1.7;
    resize: vertical;
    tab-size: 4;
}
.editor-area:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
.editor-area[readonly] { background: var(--surface-2); }

.editor-surface { position: relative; }
.editor-highlight {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--surface);
    pointer-events: none;
}
.editor-highlight-code {
    margin: 0;
    padding: 1rem 1.1rem;
    font-family: var(--font-mono);
    font-size: 0.84rem;
    line-height: 1.7;
    tab-size: 4;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    color: var(--text);
}
.editor-surface .editor-area { display: block; }
.editor-wrap.has-highlight .editor-area {
    position: relative;
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    -webkit-text-fill-color: transparent;
}
.editor-wrap.has-highlight.is-composing .editor-area {
    background: var(--surface);
    color: var(--text);
    -webkit-text-fill-color: currentColor;
}
.editor-wrap.has-highlight.is-composing .editor-highlight { visibility: hidden; }

.editor-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.editor-status {
    font-size: 0.76rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.editor-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
}
.editor-status.is-dirty::before { background: var(--warning); }
.editor-status.is-saving::before { background: var(--accent); }
.editor-status.is-ok::before { background: var(--ok); }
.editor-status.is-error::before { background: var(--danger); }
.editor-status.is-error { color: var(--danger); }

.editor-count { font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-bar .btn[type="submit"] { margin-left: auto; }

/* ---------- 12.1 Vistas por tipo de ficheiro ---------- */

.editor-wrap[hidden] { display: none; }

.doc-switch {
    display: flex;
    gap: 0.2rem;
    padding: 0.35rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.doc-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.77rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.doc-tab:hover { background: var(--surface-2); color: var(--text); }
.doc-tab.is-active { background: var(--accent-soft); color: var(--accent-text); }
.doc-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.doc-view { max-height: 68vh; overflow: auto; }
.doc-view[hidden] { display: none; }
.doc-view-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.doc-view-bar:empty { display: none; }
.doc-view-bar .btn { height: 27px; font-size: 0.76rem; }
.doc-view-body { padding: 1rem 1.1rem; }

.doc-note {
    margin: 0 0 0.8rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted-strong);
    font-size: 0.8rem;
}
.doc-note:last-child { margin-bottom: 0; }
.doc-note.is-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.doc-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 60vh;
}
.doc-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.79rem;
}
.doc-table th,
.doc-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: pre;
}
.doc-table th:last-child,
.doc-table td:last-child { border-right: 0; }
.doc-table tbody tr:last-child td { border-bottom: 0; }
.doc-table th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    font-weight: 600;
    z-index: 1;
}

.doc-table.is-editable th,
.doc-table.is-editable td { padding: 0; }
.doc-table.is-editable th .doc-cell { padding-right: 1.9rem; }
.doc-cell {
    display: block;
    width: 100%;
    min-width: 7ch;
    min-height: 2.1em;
    height: auto;
    margin: 0;
    padding: 0.35rem 0.55rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.4;
    resize: none;
    overflow: auto;
    field-sizing: content;
}
.doc-cell:focus { outline: 2px solid var(--accent-ring); outline-offset: -2px; background: var(--surface); }
.doc-table-tools { width: 1%; padding: 0 0.2rem; text-align: center; }
.doc-remove {
    appearance: none;
    border: 0;
    padding: 0.25rem 0.45rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.55;
}
.doc-table.is-editable th .doc-remove { position: absolute; top: 2px; right: 2px; }
.doc-remove:hover { background: var(--danger-soft); color: var(--danger); opacity: 1; }
.doc-remove:focus-visible { outline: 2px solid var(--accent); opacity: 1; }

.json-tree { font-family: var(--font-mono); font-size: 0.79rem; line-height: 1.65; }
.json-branch { margin: 0; }
.json-branch > summary {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    list-style: none;
    border-radius: var(--radius-sm);
}
.json-branch > summary::-webkit-details-marker { display: none; }
.json-branch > summary::before {
    content: "▸";
    flex: none;
    width: 0.7rem;
    color: var(--muted);
    font-size: 0.68rem;
}
.json-branch[open] > summary::before { content: "▾"; }
.json-branch > summary:hover { background: var(--surface-2); }
.json-children {
    margin-left: 0.42rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
}
.json-leaf { display: flex; gap: 0.3rem; align-items: baseline; }
.json-key { color: var(--muted-strong); }
.json-punct { color: var(--muted); }
.json-count { color: var(--muted); font-size: 0.72rem; }
.json-value.is-string { color: var(--ok); }
.json-value.is-number { color: var(--accent-text); }
.json-value.is-boolean,
.json-value.is-null { color: var(--warning); }

.md-preview {
    max-width: 72ch;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text);
}
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview h1,
.md-preview h2,
.md-preview h3,
.md-preview h4,
.md-preview h5,
.md-preview h6 { margin: 1.3em 0 0.5em; line-height: 1.25; }
.md-preview h1 { font-size: 1.35rem; }
.md-preview h2 { font-size: 1.15rem; }
.md-preview h3 { font-size: 1rem; }
.md-preview h4,
.md-preview h5,
.md-preview h6 { font-size: 0.92rem; }
.md-preview p { margin: 0.65em 0; }
.md-preview ul,
.md-preview ol { margin: 0.65em 0; padding-left: 1.35rem; }
.md-preview li { margin: 0.2em 0; }
.md-preview blockquote {
    margin: 0.85em 0;
    padding-left: 0.9rem;
    border-left: 3px solid var(--border-strong);
    color: var(--muted-strong);
}
.md-preview code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface-2);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
}
.md-preview pre {
    margin: 0.85em 0;
    padding: 0.8rem 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow: auto;
}
.md-preview pre code { background: none; padding: 0; font-size: 0.82rem; }
.md-preview a { color: var(--accent); }
.md-preview hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--border); }
.md-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0.8em 0;
    border-radius: var(--radius);
}
.md-preview .md-table-wrap { margin: 0.9em 0; overflow-x: auto; }
.md-preview table { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
.md-preview th,
.md-preview td {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.md-preview th { background: var(--surface-2); font-weight: 600; }
.md-preview .is-center { text-align: center; }
.md-preview .is-right { text-align: right; }

.doc-filter { max-width: 16rem; height: 30px; font-size: 0.8rem; }

/* Tarefas: vista de listas de verificação em Markdown */
.task-bar { justify-content: flex-start; flex-wrap: wrap; }
.task-toggle { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted-strong); cursor: pointer; }
.task-add { display: flex; gap: 0.4rem; margin-left: auto; flex: 1 1 16rem; max-width: 24rem; }
.task-add .input { height: 30px; font-size: 0.8rem; min-width: 0; }
.task-group { margin: 1.1rem 0 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--muted-strong); }
.task-group:first-child { margin-top: 0; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.4rem 0 0.4rem calc(var(--task-depth, 0) * 1.4rem);
    border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: 0; }
.task-label { display: flex; align-items: flex-start; gap: 0.55rem; flex: 1; min-width: 0; cursor: pointer; font-size: 0.86rem; line-height: 1.45; }
.task-check { margin-top: 0.2rem; width: 1rem; height: 1rem; flex: none; accent-color: var(--accent); cursor: pointer; }
.task-check:disabled { cursor: default; }
.task-text { overflow-wrap: anywhere; }
.task-text a { color: var(--accent); }
.task-item.is-done .task-text { color: var(--muted); text-decoration: line-through; }
.task-due {
    flex: none;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted-strong);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}
.task-due.is-today { background: var(--warning-soft); color: var(--warning); }
.task-due.is-late { background: var(--danger-soft); color: var(--danger); }
.task-item.is-done .task-due { background: var(--surface-2); color: var(--muted); }
.md-preview li.md-task { list-style: none; margin-left: -1.2rem; }
.md-preview li.md-task > input { margin: 0 0.35rem 0 0; vertical-align: -0.1em; }

.file-title-row { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.task-badge {
    flex: none;
    padding: 0.02rem 0.4rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.task-badge.is-done { background: var(--ok-soft); color: var(--ok); }
.doc-view-bar .doc-filter { margin-right: auto; }
.doc-count { font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.log-list { font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6; }
.log-line {
    display: flex;
    gap: 0.8rem;
    padding: 0.08rem 0.35rem;
    border-left: 2px solid transparent;
    border-radius: 3px;
}
.log-line:hover { background: var(--surface-2); }
.log-line.is-error { border-left-color: var(--danger); }
.log-line.is-warn { border-left-color: var(--warning); }
.log-line.is-info { border-left-color: var(--accent); }
.log-line.is-debug { border-left-color: var(--border-strong); }
.log-no {
    flex: none;
    min-width: 2.6rem;
    text-align: right;
    color: var(--muted);
    opacity: 0.7;
    user-select: none;
}
.log-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.log-tag { font-weight: 700; }
.log-tag.is-error { color: var(--danger); }
.log-tag.is-warn { color: var(--warning); }
.log-tag.is-info { color: var(--accent-text); }
.log-tag.is-debug { color: var(--muted); }

.yaml-list { font-family: var(--font-mono); font-size: 0.79rem; line-height: 1.65; }
.yaml-line {
    display: flex;
    gap: 0.8rem;
    padding: 0.02rem 0.3rem;
    border-radius: 3px;
}
.yaml-line:hover { background: var(--surface-2); }
.yaml-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.yaml-key { color: var(--accent-text); }
.yaml-punct { color: var(--muted); }
.yaml-string { color: var(--ok); }
.yaml-number { color: var(--accent-text); }
.yaml-bool { color: var(--warning); }
.yaml-placeholder { color: var(--warning); }
.yaml-tag { color: var(--muted-strong); }
.yaml-flow { color: var(--muted-strong); }
.yaml-comment { color: var(--muted); font-style: italic; }
.yaml-marker { color: var(--accent); font-weight: 700; }

.conflict-banner { margin: 0.8rem; }

.share-highlight {
    margin-bottom: 1.1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent-soft);
}
.share-highlight .label {
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.67rem;
    color: var(--accent-text);
}
.share-highlight .hint { color: var(--muted-strong); margin-top: 0.45rem; }

.copy-row { display: flex; gap: 0.4rem; }
.copy-row .input { font-family: var(--font-mono); font-size: 0.78rem; }

/* ---------- 13. Comentários ---------- */

.comment-list { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 1rem; }

.comment { display: flex; gap: 0.65rem; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.76rem;
    font-weight: 700;
    flex: none;
    overflow: hidden;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.72rem; }
.avatar-photo { object-fit: cover; }
.avatar.guest { background: var(--ok-soft); color: var(--ok); }
.avatar-initial { background: var(--accent-soft); color: var(--accent-text); }

.comment-main { min-width: 0; flex: 1; }
.comment-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.15rem; }
.comment-author { font-size: 0.82rem; font-weight: 600; }
.comment-time { font-size: 0.71rem; color: var(--muted); margin-left: auto; }
.comment-body {
    margin: 0;
    font-size: 0.855rem;
    color: var(--muted-strong);
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-form { border-top: 1px solid var(--border); padding-top: 0.85rem; }

/* ---------- 14. IA ---------- */

.ai-panel .panel-head h3 { display: flex; align-items: center; gap: 0.35rem; }

.ai-panel-head { cursor: pointer; list-style: none; }
.ai-panel-head::-webkit-details-marker { display: none; }
.ai-panel-head:hover { background: var(--surface-2); }
.ai-panel-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ai-panel[open] > .ai-panel-head { border-bottom: 1px solid var(--border); }
.ai-caret {
    width: 6px;
    height: 6px;
    margin-right: 0.25rem;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex: none;
}
.ai-panel[open] .ai-caret { transform: rotate(-135deg); }
.ai-settings-link { align-self: flex-start; font-size: 0.75rem; color: var(--muted); }
.ai-settings-link:hover { color: var(--accent); }

.ai-quick { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ai-quick .btn { height: 27px; font-size: 0.76rem; border: 1px solid var(--border); background: var(--surface); }
.ai-quick .btn:hover { border-color: var(--border-strong); }

.ai-output { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ai-output-text {
    border: 0;
    border-radius: 0;
    min-height: 130px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--surface-2);
}
.ai-output-actions {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    padding: 0.35rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.ai-chat { margin: 0; }
.ai-prompt-area {
    min-height: 0;
    max-height: 240px;
    font-size: 0.84rem;
    line-height: 1.5;
}
.ai-prompt-foot { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; margin-top: 0.4rem; }
.ai-prompt-foot .hint { flex: 1; margin: 0; min-width: 0; }

.ai-log {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 260px;
    overflow-y: auto;
    padding: 0.1rem;
}

.ai-bubble {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 92%;
}
.ai-bubble.user { align-self: flex-end; background: var(--accent-soft); color: var(--text); }
.ai-bubble.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }
.ai-bubble.is-pending { opacity: 0.7; }

.ai-draft {
    margin-bottom: 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.ai-settings-card,
.ai-share-card,
.ai-help-card { margin-bottom: 1rem; }
.ai-settings-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ai-help-list { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.83rem; color: var(--muted-strong); }
.ai-help-list li { margin-bottom: 0.3rem; }

.model-picker { display: flex; gap: 0.4rem; align-items: center; }
.model-picker .select { flex: 1; }

/* ---------- 15. Partilhas e estatísticas ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.7rem;
    margin-bottom: 1.1rem;
}

.stat,
.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.stat-value { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; }

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.table th {
    padding: 0.55rem 0.7rem;
    text-align: left;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding: 0.8rem 0.2rem;
    border-bottom: 1px solid var(--border);
}
.share-item:last-child { border-bottom: 0; }
.share-item-top { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.share-meta { display: flex; align-items: center; gap: 0.4rem 0.9rem; flex-wrap: wrap; color: var(--muted); font-size: 0.77rem; }

.kv { margin: 0; }
.kv-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.3rem 0;
    font-size: 0.81rem;
}
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; font-weight: 550; text-align: right; }

.version-list { list-style: none; margin: 0; padding: 0; }
.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0.9rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
}
.version-item:first-child { border-top: 0; }
.version-item.is-current { background: var(--accent-soft); }
.version-main { display: flex; align-items: center; gap: 0.5rem; }
.version-no {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted-strong);
}

.chart {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    height: 130px;
    padding: 0.6rem 0.2rem 0;
    overflow-x: auto;
}
.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    flex: 1 1 22px;
    min-width: 22px;
    height: 100%;
}
.chart-bar { width: 100%; max-width: 22px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: 0.85; min-height: 2px; }
.chart-value { font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-label { font-size: 0.64rem; color: var(--muted); white-space: nowrap; }

/* ---------- 16. Definições ---------- */

.settings-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.theme-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; margin-bottom: 0.9rem; }

.theme-option {
    display: block;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.theme-option:hover { border-color: var(--accent); }
.theme-option input { position: absolute; opacity: 0; }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.theme-option-body { display: flex; flex-direction: column; gap: 0.15rem; }
.theme-option-body strong { font-size: 0.85rem; }

.avatar-settings { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-settings-body { flex: 1; min-width: 220px; }
.avatar-preview {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-2);
    flex: none;
}
.avatar-preview-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent-soft);
}

/* ---------- 17. Autenticação ---------- */

.auth-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 3rem;
    align-items: center;
    max-width: 980px;
    margin: 2.5rem auto;
}

.auth-wrap.auth-narrow { grid-template-columns: minmax(0, 400px); justify-content: center; margin: 3rem auto; }

.auth-aside .eyebrow { margin-bottom: 0.6rem; }
.auth-aside h1 { font-size: 2rem; letter-spacing: -0.03em; margin-bottom: 0.6rem; }
.auth-aside p { color: var(--muted); font-size: 0.92rem; max-width: 42ch; }

.auth-points { list-style: none; margin: 1.2rem 0 0; padding: 0; }
.auth-points li {
    position: relative;
    padding-left: 1.4rem;
    margin-bottom: 0.55rem;
    font-size: 0.85rem;
    color: var(--muted-strong);
}
.auth-points li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: -0.05rem;
    color: var(--accent);
    font-weight: 700;
}

.auth-card {
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}
.auth-card h2 { margin-bottom: 0.25rem; }
.auth-card .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.1rem; }
.auth-alt { margin-top: 1rem; font-size: 0.83rem; color: var(--muted); text-align: center; }
.center-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.text-center .error-code { text-align: center; }

.error-code {
    font-size: 3.4rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--accent);
    margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
}

/* ---------- 18. Etiquetas editoriais (usadas nas páginas de autenticação) ---------- */

.eyebrow {
    display: inline-block;
    margin-bottom: 0.9rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--accent-text);
}

/* ---------- 19. Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.14rem 0.45rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted-strong);
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-ext { background: var(--accent-soft); color: var(--accent-text); font-family: var(--font-mono); text-transform: uppercase; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-off { background: var(--surface-2); color: var(--muted); }

/* ---------- 20. Responsivo ---------- */

@media (max-width: 1100px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .hero { grid-template-columns: minmax(0, 1fr); gap: 2rem; padding-top: 2.5rem; }
    .hero-art { max-width: 420px; margin: 0.25rem 0 0; }
}

@media (max-width: 900px) {
    .app-shell,
    .app-shell.is-guest { grid-template-columns: minmax(0, 1fr); }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 280px);
        transform: translateX(-100%);
        transition: transform 0.2s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .app-shell.is-sidebar-open .app-sidebar { transform: none; }
    .app-shell.is-sidebar-open .sidebar-scrim { display: block; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-collapse { display: none !important; }

    .app-main { padding: 1.25rem 1.1rem 2rem; }
    .app-topbar-inner { padding: 0 1.1rem; }
    .footer-inner { padding: 0 1.1rem; }

    .auth-wrap { grid-template-columns: 1fr; gap: 1.8rem; margin: 1.5rem auto; }
    .auth-aside { display: none; }
    .auth-wrap.auth-narrow { margin: 1.5rem auto; }

    .hero-art { display: none; }

    .list-toolbar,
    .toolbar-actions { margin-left: 0; }
}

@media (max-width: 720px) {
    h1 { font-size: 1.42rem; }
    .workspace-header h1 { font-size: 1.32rem; }

    .file-row {
        grid-template-columns: 32px minmax(0, 1fr) 34px;
        gap: 0.55rem;
        padding: 0.6rem 0.7rem;
    }
    .file-list-head { display: none; }
    .file-col { display: none; }
    .file-sub { display: block; }
    .file-list[data-view="grid"] { grid-template-columns: 1fr; }

    .view-toggle { margin-left: 0; }
    .search { max-width: none; flex-basis: 100%; }

    .dialog { width: calc(100vw - 1.2rem); }
    .dialog-foot { flex-wrap: wrap; }
    .dialog-foot .btn { flex: 1; }

    .editor-area { min-height: 46vh; font-size: 0.82rem; }
    .editor-highlight-code { font-size: 0.82rem; }
    .editor-bar .btn[type="submit"] { margin-left: 0; }
    .editor-toolbar-actions { margin-left: 0; width: 100%; }

    .page-head { gap: 0.6rem; }
    .page-head .actions { width: 100%; }

    .meta-row { font-size: 0.74rem; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .app-main { padding: 1rem 0.85rem 1.75rem; }
    .app-topbar-inner { padding: 0 0.85rem; }
    .footer-inner { padding: 0 0.85rem; }
    .topbar-title { display: none; }
    .topbar-guest-nav .nav-link { display: none; }
    .btn { height: 34px; }
    .btn-sm { height: 30px; }
    .card-pad { padding: 0.95rem; }
    .stat-value { font-size: 1.2rem; }
}

/* ---------- 21. Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
