:root {
    /* workspace (light, restrained — operate mode) */
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-surface-alt: #f0f2f8;
    --color-border: #e4e6f0;
    --color-border-strong: #d2d5e5;
    --color-text: #171a24;
    --color-text-muted: #6b7183;
    --color-text-dim: #9298a8;

    /* aliases — nomes legados usados em telas mais antigas (comentários, modal, project-card-box);
       mantidos como aliases pros tokens reais pra nunca divergir do resto do design system */
    --color-brand: var(--color-blue);
    --color-bg-card: var(--color-surface);
    --color-bg-subtle: var(--color-surface-alt);
    --bg-surface: var(--color-surface);
    --bg-secondary: var(--color-surface-alt);
    --border-color: var(--color-border);
    --color-text-main: var(--color-text);

    /* brand accent — reserved for actions, not backgrounds */
    --color-blue: #1f6feb;
    --color-blue-bright: #3f7ff2;
    --color-violet: #7c4eea;
    --color-violet-bright: #9566f0;
    --color-violet-bg: #f1eefe;
    --color-violet-border: #ded4fb;
    --gradient-brand: linear-gradient(135deg, var(--color-blue) 0%, var(--color-violet) 100%);
    --color-signal-indigo: #5b5bd6;

    /* links inline */
    --link-underline-offset: 3px;
    --link-underline-thickness: 1px;
    --link-underline-color: color-mix(in srgb, var(--color-blue) 36%, transparent);

    /* signal palette — multi-hue tags/categories, deliberately excludes brand blue/violet */
    --hue-indigo: #4f5bd5; --hue-indigo-bg: rgba(79, 91, 213, .1);
    --hue-coral: #e8590c; --hue-coral-bg: rgba(232, 89, 12, .1);
    --hue-teal: #0d9488; --hue-teal-bg: rgba(13, 148, 136, .1);
    --hue-amber: #b8790a; --hue-amber-bg: rgba(184, 121, 10, .1);
    --hue-rose: #d6336c; --hue-rose-bg: rgba(214, 51, 108, .1);
    --hue-green: #2b8a3e; --hue-green-bg: rgba(43, 138, 62, .1);

    --color-danger: #d6394a;
    --color-danger-bg: #fdecee;
    --color-danger-border: #f6c4cb;
    --color-success: #16874f;
    --color-success-bg: #e7f7ee;
    --color-success-border: #b9e8cd;
    --color-warning: #a3630a;
    --color-warning-bg: #fdf1e0;

    /* sidebar (dark — same world as the auth gate) */
    --sidebar-bg: #0b0e18;
    --sidebar-border: #1d2233;
    --sidebar-text: #a9aec2;
    --sidebar-text-dim: #6b7590;
    --accent-blue-dark-bg: #5b9dff;
    --accent-violet-dark-bg: #ab8bff;

    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(20, 22, 35, .06);
    --shadow-md: 0 10px 26px -10px rgba(20, 22, 40, .16), 0 2px 8px -2px rgba(20, 22, 40, .08);
    --shadow-lg: 0 26px 52px -18px rgba(20, 22, 40, .24);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --ease-out: cubic-bezier(.23, 1, .32, 1);
    --sidebar-width: 232px;
    --topbar-h: 46px;
}

/* Dark workspace — opt-in via the theme toggle, persisted in localStorage. */
:root[data-theme="dark"] {
    --color-bg: #0a0d18;
    --color-surface: #121729;
    --color-surface-alt: #171d33;
    --color-border: #262d47;
    --color-border-strong: #343d5e;
    --color-text: #eef0fa;
    --color-text-muted: #9aa1bd;
    --color-text-dim: #6d7594;

    --color-violet-bg: rgba(149, 102, 240, .16);
    --color-violet-border: rgba(149, 102, 240, .4);

    --color-danger-bg: rgba(214, 57, 74, .16);
    --color-danger-border: rgba(214, 57, 74, .38);
    --color-success-bg: rgba(22, 135, 79, .18);
    --color-success-border: rgba(22, 135, 79, .4);
    --color-warning-bg: rgba(163, 99, 10, .22);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 10px 26px -10px rgba(0, 0, 0, .5), 0 2px 8px -2px rgba(0, 0, 0, .35);
    --shadow-lg: 0 26px 52px -18px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-blue);
    text-decoration: none;
    transition: color .12s var(--ease-out);
}

a:hover,
a:focus-visible,
.link-button:hover,
.link-button:focus-visible {
    color: color-mix(in srgb, var(--color-blue) 82%, var(--color-violet));
    text-decoration: underline;
    text-underline-offset: var(--link-underline-offset);
    text-decoration-thickness: var(--link-underline-thickness);
    text-decoration-color: var(--link-underline-color);
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 700; margin: 28px 0 10px; letter-spacing: -.005em; }
h3 { font-size: 12px; margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); font-weight: 700; }

.app-shell { display: flex; min-height: 100vh; }

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

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--sidebar-bg);
    background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .035) 1px, transparent 0);
    background-size: 22px 22px;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    border-right: 1px solid var(--sidebar-border);
    scrollbar-width: thin; scrollbar-color: var(--sidebar-border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background-color: var(--sidebar-border); border-radius: 99px; }

.sidebar-brand {
    display: block;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 500;
    color: var(--accent-blue-dark-bg);
    padding: 4px 10px 26px;
    letter-spacing: -.01em;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand strong { font-weight: 600; color: var(--accent-violet-dark-bg); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 9px;
    color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .045); color: #fff; text-decoration: none; }
.sidebar-nav a.is-active {
    background: linear-gradient(135deg, rgba(31, 111, 235, .24), rgba(132, 87, 240, .24));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(158, 141, 255, .3);
}
.sidebar-nav a.is-active svg { opacity: 1; color: var(--accent-violet-dark-bg); }

/* Cartão de dica no rodapé da sidebar -- eco do promo card da referência, reaproveitado honestamente (dica, não blog) */
.sidebar-promo {
    background: rgba(255, 255, 255, .035); border: 1px solid var(--sidebar-border); border-radius: var(--radius-lg);
    padding: 14px 14px 12px; margin-top: 4px;
}
.sidebar-promo-eyebrow { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-violet-dark-bg); }
.sidebar-promo-text { margin: 7px 0 10px; font-size: 12px; line-height: 1.5; color: var(--sidebar-text); }
.sidebar-promo-next {
    font: inherit; font-size: 11.5px; font-weight: 700; color: var(--accent-blue-dark-bg);
    background: none; border: none; padding: 0; cursor: pointer;
}
.sidebar-promo-next:hover { color: #fff; }

/* Identidade (avatar + nome + cargo) isolada -- não disputa espaço com os toggles, nome nunca corta */
.sidebar-identity {
    display: flex; align-items: center; gap: 10px;
    border-top: 1px solid var(--sidebar-border);
    padding-top: 14px; margin-top: 10px;
}
.sidebar-user-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--gradient-brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #e7e9f3; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-text-dim); font-size: 11.5px; margin-top: 1px; }

/* Trilho de ações (tema/som/sair) em linha própria -- sobrevive ao colapso mobile (ver breakpoint) */
.sidebar-icon-rail { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.sidebar-logout { margin: 0; flex: 1; }
.sidebar-logout .icon-button { width: 100%; }

.icon-button {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    height: 30px; padding: 0 8px; border-radius: 8px; flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    color: var(--sidebar-text-dim); font: inherit; font-size: 11px; font-weight: 600; text-decoration: none;
    transition: background-color .15s var(--ease-out), color .15s var(--ease-out), transform .12s var(--ease-out);
}
.icon-button:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.icon-button:active { transform: scale(.94); }
.icon-button svg { width: 16px; height: 16px; flex-shrink: 0; }

#wd-theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] #wd-theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] #wd-theme-toggle .icon-moon { display: block; }

#wd-sound-toggle .icon-sound-off { display: none; }
#wd-sound-toggle.is-muted .icon-sound-on { display: none; }
#wd-sound-toggle.is-muted .icon-sound-off { display: block; }

.link-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: var(--color-blue);
    text-decoration: none;
    transition: color .12s var(--ease-out);
}

.content { flex: 1; display: flex; flex-direction: column; padding: 16px 36px 36px; max-width: 100%; overflow-x: auto; background: var(--color-bg); }
.content-auth { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; }
