:root {
    --bg-dark: #0f172a; /* Deepest dark for studio bg */
    --bg-panel: #1E3A8A; /* WireWave Navy */
    --accent: #0EA5E9; /* WireWave Cyan */
    --text-main: #E5E7EB; /* WireWave Silver */
    --success: #10B981; /* WireWave Emerald */
    --border: rgba(229, 231, 235, 0.1);
}

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

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Roboto', sans-serif;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4 { font-family: 'Montserrat', sans-serif; }

.studio-layout {
    display: flex;
    height: 100vh;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: #fff;
    padding: 10px 16px;
    z-index: 10000;
    border-radius: 0 0 6px 0;
    font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.brand-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.nav-list {
    list-style: none;
    flex-grow: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    padding: 15px 25px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 15px;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(14, 165, 233, 0.15);
    border-left: 4px solid var(--accent);
}

.sidebar-footer {
    padding: 20px;
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}
.status-indicator.online { background-color: var(--success); box-shadow: 0 0 8px var(--success); }

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    height: 60px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

.panel-container {
    padding: 30px;
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-gutter: stable; /* This prevents the 15px shifting jump */
}

/* Base Widget Card */
.studio-card {
    background-color: rgba(30, 58, 138, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

/* ====================================================================
   ACCESSIBILITY
   ==================================================================== */

/* Clear keyboard focus everywhere */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}
body.high-contrast button:focus-visible,
body.high-contrast input:focus-visible,
body.high-contrast select:focus-visible,
body.high-contrast [tabindex]:focus-visible {
    outline: 3px solid #FFD400;
}

/* Easy Mode: bigger text, bigger buttons, more room to click */
body.easy-mode { font-size: 18px; }
body.easy-mode .btn-primary { padding: 14px 22px; font-size: 16px; }
body.easy-mode .nav-item { padding: 20px 25px; font-size: 18px; }
body.easy-mode .studio-card { padding: 26px; }
body.easy-mode input, body.easy-mode select { font-size: 16px; }
body.easy-mode input[type="range"] { height: 30px; }
body.easy-mode .top-bar { height: 72px; }
body.easy-mode h3 { font-size: 1.35em; }
body.easy-mode .vault-cat { padding: 15px 10px; font-size: 16px; }

/* High Contrast: black background, bright text, strong borders */
body.high-contrast {
    --bg-dark: #000000;
    --bg-panel: #0a0a14;
    --accent: #4FC3F7;
    --text-main: #FFFFFF;
    --success: #2EE6A8;
    --border: rgba(255, 255, 255, 0.45);
}
body.high-contrast .studio-card { background-color: #05050a; border-width: 2px; }
body.high-contrast .btn-primary { border: 2px solid #fff; }
body.high-contrast .nav-item:hover, body.high-contrast .nav-item.active {
    background-color: #10233a;
    border-left: 6px solid var(--accent);
}

/* Calm Mode: no flashing or pulsing for people who prefer still screens */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
    }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
}

/* Help tab styles */
.help-section { margin-bottom: 28px; }
.help-section h3 { color: var(--accent); margin-bottom: 10px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-table th, .help-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.help-table th { color: #94a3b8; font-size: 12px; }
.help-table td:first-child { font-weight: 600; white-space: nowrap; }
body.easy-mode .help-table { font-size: 17px; }

/* Settings rows */
.setting-row {
    display: flex; justify-content: space-between; align-items: center; gap: 20px;
    padding: 14px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.setting-row .setting-label { font-weight: 600; }
.setting-row .setting-help { font-size: 12px; color: #94a3b8; margin-top: 4px; max-width: 460px; }
body.easy-mode .setting-row .setting-help { font-size: 15px; }

/* Big friendly toggle switch */
.ww-toggle { position: relative; width: 58px; height: 30px; flex-shrink: 0; }
.ww-toggle input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; z-index: 2; margin: 0; }
.ww-toggle .slider {
    position: absolute; inset: 0; background: #334155; border-radius: 15px; transition: 0.2s;
    border: 1px solid var(--border);
}
.ww-toggle .slider::before {
    content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
    background: #E5E7EB; top: 3px; left: 4px; transition: 0.2s;
}
.ww-toggle input:checked + .slider { background: var(--success); }
.ww-toggle input:checked + .slider::before { transform: translateX(27px); background: #fff; }
.ww-toggle input:focus-visible + .slider { outline: 3px solid var(--accent); outline-offset: 2px; }
