html {
    transition: background-color 160ms ease, color 160ms ease;
    --bg: #f5f7fb;
    --panel: #fff;
    --text: #1d2433;
    --muted: #667085;
    --accent: #475467;
    --accent-dark: #344054;
    --ok: #344054;
    --border: #d9e0ea;
    --error: #b42318;
    --error-dark: #d92d20;
    --ok: #344054;
    --nav-button-text: #175cd3;
}

html[data-theme="dark"] {
    --bg: #0b1220;
    --panel: #111827;
    --text: #f2f4f7;
    --muted: #98a2b3;
    --accent: #2dd4bf;
    --accent-dark: #14b8a6;
    --border: #344054;
    --error: #f97066;
    --error-dark: #d92d20;
    --ok: #6ce9a6;
    --nav-button: #1d2939;
    --nav-button-text: #7dd3fc;
}

html[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}

html[data-theme="dark"] .sitebar,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .audio-item {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] input:not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .login-inline input {
    background: #182230;
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="dark"] input:disabled {
    background: #101828;
    color: #667085;
}

html[data-theme="dark"] .voice-control,
html[data-theme="dark"] .generation-progress,
html[data-theme="dark"] .message {
    background: #182230;
    border-color: var(--border);
}

html[data-theme="dark"] .voice-value {
    background: #344054;
    color: #e4e7ec;
}

/* Player e parametros usam cores claras por padrao. */
.parameter-chip {
    border-color: #cfd8e6 !important;
    background: #f2f4f7 !important;
    color: #344054 !important;
}

.custom-player {
    border-color: #d0d5dd !important;
    background: #f8fafc !important;
    color: #101828 !important;
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08) !important;
}

.custom-player .player-button {
    border: 1px solid #d0d5dd !important;
    background: #ffffff !important;
    color: #101828 !important;
}

.custom-player .player-button:hover { background: #e4e7ec !important; }
.custom-player .waveform:hover { background: rgba(16, 24, 40, 0.05); }
.custom-player .waveform-base { color: #98a2b3; }
.custom-player .waveform-bar.is-played { color: var(--accent); }
.custom-player .player-time,
.custom-player .player-status,
.custom-player .volume-label { color: #667085; }

html[data-theme="dark"] .parameter-chip {
    border-color: #344054 !important;
    background: #1d2939 !important;
    color: #d0d5dd !important;
}

html[data-theme="dark"] .custom-player {
    border-color: #344054 !important;
    background: #101828 !important;
    color: #f2f4f7 !important;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24) !important;
}

html[data-theme="dark"] .custom-player .player-button {
    border-color: transparent !important;
    background: #f9fafb !important;
    color: #101828 !important;
}

html[data-theme="dark"] .custom-player .player-button:hover { background: #d0d5dd !important; }
html[data-theme="dark"] .custom-player .waveform:hover { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] .custom-player .waveform-base { color: #667085; }
html[data-theme="dark"] .custom-player .waveform-bar.is-played { color: #2dd4bf; }
html[data-theme="dark"] .custom-player .player-time,
html[data-theme="dark"] .custom-player .player-status,
html[data-theme="dark"] .custom-player .volume-label { color: #98a2b3; }

html[data-theme="dark"] th,
html[data-theme="dark"] td,
html[data-theme="dark"] .audio-head,
html[data-theme="dark"] .card-footer {
    border-color: var(--border);
}

html[data-theme="dark"] .audio-text,
html[data-theme="dark"] .brand,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] label {
    color: var(--text);
}

html[data-theme="dark"] .error {
    color: #fda29b;
}

html[data-theme="dark"] .ok {
    color: #6ce9a6;
}

.theme-toggle {
    flex: 0 0 auto;
    width: 38px !important;
    height: 38px;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--border, #d9e0ea) !important;
    border-radius: 999px !important;
    background: var(--panel, #fff) !important;
    color: var(--text, #1d2433) !important;
    box-shadow: 0 3px 10px rgba(16, 24, 40, 0.10);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    border-color: var(--accent, #0f766e) !important;
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(45, 212, 191, 0.30);
    outline-offset: 2px;
}

.theme-icon {
    font-size: 20px;
    line-height: 1;
}

.login-theme {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10;
}

/* Cabecalho compartilhado: marca a esquerda, navegacao central e conta a direita. */
.sitebar-inner {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    min-height: 68px !important;
    padding: 10px clamp(16px, 3vw, 48px) !important;
    display: grid !important;
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
    align-items: center !important;
    gap: 18px !important;
}

.sitebar-inner .brand {
    justify-self: start;
    white-space: nowrap;
}

.main-nav {
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.main-nav .nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 7px 14px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.main-nav .nav-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12);
}

.main-nav .nav-home { color: #a15c00; background: #fff8df; }
.main-nav .nav-firewall { color: #175cd3; background: #eff8ff; }
.main-nav .nav-users { color: #6938ef; background: #f4f3ff; }
.main-nav .nav-system { color: #067647; background: #ecfdf3; }
.main-nav .nav-pill[aria-current="page"] { box-shadow: inset 0 0 0 1px currentColor; }

.sitebar-inner .account {
    justify-self: end;
    justify-content: flex-end;
    margin: 0 !important;
}

.account {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.account .account-name {
    color: var(--muted);
}

.account .account-name a,
.account .logout-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.account .logout-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 14px;
    border: 1px solid #d92d20;
    border-radius: 999px;
    background: #fff1f0;
    color: #b42318;
    font-size: 13px;
    line-height: 1;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.account .account-name a:hover,
.account .logout-link:hover {
    text-decoration: underline;
}

.account .logout-link:hover {
    background: #fee4e2;
    color: #912018;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(180, 35, 24, 0.18);
}

html[data-theme="dark"] .main-nav .nav-home { color: #fdb022; background: #332b17; }
html[data-theme="dark"] .main-nav .nav-firewall { color: #84caff; background: #102a43; }
html[data-theme="dark"] .main-nav .nav-users { color: #bdb4fe; background: #29215a; }
html[data-theme="dark"] .main-nav .nav-system { color: #6ce9a6; background: #123226; }
html[data-theme="dark"] .account .logout-link { color: #fda29b; background: #3b1717; border-color: #f97066; }
html[data-theme="dark"] .account .logout-link:hover { color: #fecaca; background: #551b1b; }

@media (max-width: 920px) {
    .sitebar-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 10px 16px !important;
    }

    .sitebar-inner .main-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }
}

@media (max-width: 560px) {
    .sitebar-inner {
        grid-template-columns: 1fr !important;
        align-items: start !important;
        gap: 10px !important;
    }

    .sitebar-inner .brand,
    .sitebar-inner .account,
    .sitebar-inner .main-nav {
        justify-self: stretch;
    }

    .sitebar-inner .account {
        justify-content: space-between;
        flex-wrap: wrap;
        white-space: normal;
    }

    .sitebar-inner .main-nav {
        grid-row: auto;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .main-nav .nav-pill {
        flex: 0 0 auto;
    }
}
