:root {
    --navy: #183153;
    --navy-light: #2b5278;
    --gold: #d4a017;
    --gold-light: #f4df9a;
    --ink: #263442;
    --muted: #667381;
    --line: #d7dee6;
    --paper: #ffffff;
    --background: #f4f7fa;
    --stage: #ffffff;
    --sidebar-bg: #ffffff;
    --topbar-bg: #183153;
    --topbar-text: #ffffff;
    --topbar-muted: #cbd7e5;
    --active-bg: #e8eef5;
    --placeholder-bg: #f0f4f8;
    --placeholder-border: #c5d0dc;
    --focus: #2674c5;
    --shadow: 0 12px 30px rgba(24, 49, 83, 0.1);
    --sidebar-width: 280px;
    --transition: 180ms ease;
}

[data-theme="dark"] {
    --navy: #9eb6d4;
    --navy-light: #b8cce0;
    --gold: #e0b84a;
    --gold-light: #f4df9a;
    --ink: #e6edf5;
    --muted: #9aabbc;
    --line: #2f4054;
    --paper: #152233;
    --background: #0f1824;
    --stage: #152233;
    --sidebar-bg: #121c2a;
    --topbar-bg: #0c1420;
    --topbar-text: #e6edf5;
    --topbar-muted: #9aabbc;
    --active-bg: #1e2f44;
    --placeholder-bg: #1a2838;
    --placeholder-border: #3a4f66;
    --focus: #5b9fd4;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

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

html {
    height: 100%;
}

body {
    min-width: 280px;
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

button {
    font: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 1rem;
    background: var(--gold);
    color: var(--navy);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    left: 0.75rem;
    top: 0.75rem;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    padding: 0.85rem clamp(0.75rem, 2vw, 1.5rem);
    color: var(--topbar-text);
    background: var(--topbar-bg);
    border-bottom: 5px solid var(--gold);
    flex-shrink: 0;
}

.top-bar-start {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    min-width: 0;
}

.brand {
    min-width: 0;
}

.home-link {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--gold-light);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
}

.home-link:hover {
    color: #fff;
    text-decoration: underline;
}

[data-theme="dark"] .home-link:hover {
    color: var(--gold);
}

.eyebrow {
    margin: 0 0 0.1rem;
    color: var(--topbar-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.brand h1 {
    margin: 0;
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--topbar-text);
}

.deck-subtitle {
    margin: 0.2rem 0 0;
    color: var(--topbar-muted);
    font-size: 0.88rem;
}

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

.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    transition: margin-left var(--transition), transform var(--transition);
    z-index: 20;
}

.app.nav-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.sidebar-close {
    display: none;
}

.toc {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.65rem 1rem;
}

.toc-section {
    margin-bottom: 0.35rem;
}

.toc-section-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0.55rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
    font-size: 0.9rem;
    text-align: left;
}

.toc-section-toggle:hover {
    background: var(--active-bg);
}

.toc-chevron {
    display: inline-block;
    width: 0.65rem;
    flex-shrink: 0;
    transition: transform var(--transition);
    color: var(--muted);
}

.toc-section[data-expanded="true"] .toc-chevron {
    transform: rotate(90deg);
}

.toc-slides {
    list-style: none;
    margin: 0;
    padding: 0 0 0.25rem 0.35rem;
}

.toc-section[data-expanded="false"] .toc-slides {
    display: none;
}

.toc-slide {
    display: block;
    width: 100%;
    margin: 0.1rem 0;
    padding: 0.4rem 0.55rem 0.4rem 1.1rem;
    border: none;
    border-radius: 6px;
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--ink);
    font-size: 0.86rem;
    text-align: left;
}

.toc-slide:hover {
    background: var(--active-bg);
}

.toc-slide[aria-current="true"] {
    background: var(--active-bg);
    border-left-color: var(--gold);
    font-weight: 700;
    color: var(--navy);
}

[data-theme="dark"] .toc-slide[aria-current="true"] {
    color: var(--gold-light);
}

.stage-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.slide-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: clamp(0.75rem, 2vw, 1.25rem);
    padding: clamp(1rem, 2.5vw, 1.75rem);
    background: var(--stage);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: auto;
    opacity: 1;
    transition: opacity var(--transition);
}

.slide-stage.is-transitioning {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .slide-stage,
    .sidebar,
    .toc-chevron,
    .nav-backdrop {
        transition: none;
    }

    .slide-stage.is-transitioning {
        opacity: 1;
    }
}

.slide-section-label {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.slide-title {
    margin: 0 0 0.35rem;
    color: var(--navy);
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    border-bottom: 3px solid var(--gold);
    padding-bottom: 0.5rem;
}

[data-theme="dark"] .slide-title {
    color: var(--gold-light);
}

.slide-subtitle {
    margin: 0.65rem 0 1rem;
    color: var(--muted);
    font-size: 1.05rem;
}

.slide-content {
    flex: 1;
    min-height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: var(--placeholder-bg);
    border: 2px dashed var(--placeholder-border);
    border-radius: 10px;
}

.content-placeholder {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.speaker-notes {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: var(--placeholder-bg);
    border-left: 5px solid var(--gold);
    border-radius: 0 8px 8px 0;
}

.notes-heading {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.notes-body {
    color: var(--ink);
    font-size: 0.92rem;
    white-space: pre-wrap;
}

.notes-body:empty::before {
    content: "No speaker notes for this slide.";
    color: var(--muted);
    font-style: italic;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.75rem clamp(0.75rem, 2vw, 1.25rem) 1rem;
    border-top: 1px solid var(--line);
    background: var(--sidebar-bg);
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.toolbar-button,
.icon-button {
    border: 2px solid var(--navy);
    border-radius: 6px;
    background: transparent;
    color: var(--navy);
    font-weight: 700;
    font-size: 0.88rem;
}

.toolbar-button {
    padding: 0.45rem 0.85rem;
}

.toolbar-button:hover:not(:disabled),
.icon-button:hover {
    background: var(--active-bg);
    border-color: var(--gold);
}

.toolbar-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    flex-shrink: 0;
    color: var(--topbar-text);
    border-color: rgba(255, 255, 255, 0.35);
    background: transparent;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
}

.sidebar .icon-button {
    color: var(--ink);
    border-color: var(--line);
}

.icon-menu,
.icon-close {
    display: block;
    width: 1.1rem;
    height: 1.1rem;
    position: relative;
}

.icon-menu::before,
.icon-menu::after,
.icon-close::before,
.icon-close::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.icon-menu::before {
    top: 0.2rem;
    box-shadow: 0 0.35rem 0 currentColor;
}

.icon-menu::after {
    bottom: 0.2rem;
}

.icon-close::before {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.icon-close::after {
    top: 50%;
    transform: translateY(-50%) rotate(-45deg);
}

.slide-counter {
    margin: 0;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.nav-backdrop {
    display: none;
}

.message-panel {
    margin: 2rem auto;
    max-width: 36rem;
    padding: 1.5rem;
    background: var(--stage);
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 10px;
}

.message-panel h2 {
    margin: 0 0 0.5rem;
    color: var(--navy);
}

.app.fullscreen-mode .top-bar {
    display: none;
}

.app.fullscreen-mode .sidebar,
.app.fullscreen-mode .nav-backdrop {
    display: none !important;
}

.app.fullscreen-mode .toolbar {
    background: var(--stage);
}

.app.fullscreen-mode .slide-stage {
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    min-height: calc(100vh - 4rem);
    min-height: calc(100dvh - 4rem);
}

@media (max-width: 900px) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        margin-left: 0;
        transform: translateX(-105%);
        box-shadow: var(--shadow);
    }

    .app.nav-open .sidebar {
        transform: translateX(0);
    }

    .app.nav-collapsed .sidebar {
        margin-left: 0;
        transform: translateX(-105%);
    }

    .app.nav-open.nav-collapsed .sidebar {
        transform: translateX(0);
    }

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

    .nav-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 15;
        background: rgba(15, 24, 36, 0.45);
        border: none;
        padding: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition);
    }

    .app.nav-open .nav-backdrop {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 560px) {
    .toolbar {
        justify-content: center;
    }

    .slide-counter {
        order: -1;
        width: 100%;
        text-align: center;
    }

    .toolbar-group {
        flex: 1 1 auto;
        justify-content: center;
    }
}
