/* ────────────────────────────────────────────────────────────────
   MD to PPT – Design System
   ──────────────────────────────────────────────────────────────── */

:root {
    /* Palette */
    --bg: #f7f5f2;
    --panel: #ffffff;
    --panel-hover: #faf9f7;
    --ink: #221f1a;
    --ink-secondary: #4a4439;
    --muted: #8a8279;
    --line: #e5e0d8;
    --line-light: #f0ece6;
    --accent: #d7643b;
    --accent-hover: #c4552f;
    --accent-soft: rgba(215, 100, 59, 0.1);
    --accent-softer: rgba(215, 100, 59, 0.06);

    /* Surfaces */
    --surface-raised: #fffdf8;
    --surface-sunken: #f3efe7;
    --surface-overlay: rgba(255, 255, 255, 0.96);

    /* Stage (slide preview) */
    --stage-bg: linear-gradient(
        140deg,
        rgba(255, 255, 255, 0.94),
        rgba(247, 241, 232, 0.95)
    );
    --stage-ink: #221f1a;
    --stage-muted: #6f665a;
    --stage-accent: #d7643b;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(56, 43, 24, 0.06);
    --shadow-md: 0 4px 16px rgba(56, 43, 24, 0.08);
    --shadow-lg: 0 12px 40px rgba(56, 43, 24, 0.1);
    --shadow-dropdown:
        0 8px 30px rgba(56, 43, 24, 0.12), 0 2px 8px rgba(56, 43, 24, 0.06);

    /* Radii */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 999px;

    /* Typography */
    --font-sans:
        "Figtree", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

/* ── Reset & Base ─────────────────────────────────────────────── */

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

html,
body {
    height: 100%;
    min-height: 100vh;
}

body {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
label,
textarea,
select {
    font: inherit;
    color: inherit;
}

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

code {
    font-size: 0.82em;
    padding: 0.1em 0.4em;
    background: var(--accent-soft);
    border-radius: var(--radius-xs);
    color: var(--accent);
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* ── Icon Utility ─────────────────────────────────────────────── */

.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.chevron {
    width: 10px;
    height: 6px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform 150ms ease;
}

[data-open] .chevron {
    transform: rotate(180deg);
}

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--ink-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        box-shadow 150ms ease,
        transform 100ms ease;
}

.btn:hover {
    background: var(--panel-hover);
    border-color: #d0c9be;
    color: var(--ink);
}

.btn:active {
    transform: scale(0.97);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
}

.btn-ghost:hover {
    background: var(--surface-sunken);
    border-color: transparent;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-nav {
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-full);
    border: 1px solid var(--line);
    background: var(--panel);
}

.btn-nav:hover:not(:disabled) {
    background: var(--surface-sunken);
    border-color: #d0c9be;
}

.btn-tiny {
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
}

.btn-tiny:hover {
    color: var(--ink);
    background: var(--surface-sunken);
}

/* ── App Shell ────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

/* ── Top Bar ──────────────────────────────────────────────────── */

.top-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    z-index: 100;
}

.top-bar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.75rem;
}

.brand-mark {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(22, 23, 19, 0.08);
}

.brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-text {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--ink);
    letter-spacing: -0.01em;
}

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

.top-bar-spacer {
    flex: 1;
}

/* ── Dropdowns ────────────────────────────────────────────────── */

.dropdown {
    position: relative;
}

.dropdown-trigger {
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    max-width: calc(100vw - 1.5rem);
    background: var(--surface-overlay);
    backdrop-filter: blur(20px);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-dropdown);
    padding: 0.35rem;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition:
        opacity 120ms ease,
        transform 120ms ease,
        visibility 120ms ease;
}

.dropdown-align-end .dropdown-menu {
    right: 0;
    left: auto;
    min-width: max-content;
}

.dropdown[data-open] .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section-title {
    padding: 0.45rem 0.7rem 0.3rem;
    color: var(--ink-muted);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    transition:
        background 100ms ease,
        color 100ms ease;
}

.dropdown-item:hover {
    background: var(--accent-softer);
    color: var(--ink);
}

.theme-item-label {
    flex: 1;
}

.theme-check {
    width: 0.95rem;
    height: 0.95rem;
    margin-left: auto;
    color: var(--accent);
    opacity: 0;
    transform: scale(0.86);
    transition:
        opacity 120ms ease,
        transform 120ms ease;
}

.theme-item[aria-current="true"] {
    color: var(--ink);
}

.theme-item[aria-current="true"] .theme-check {
    opacity: 1;
    transform: scale(1);
}

.dropdown-item code {
    font-size: 0.78em;
    padding: 0.05em 0.35em;
}

.dropdown-divider {
    height: 1px;
    margin: 0.3rem 0.5rem;
    background: var(--line);
}

/* Select inside dropdown */
.select-field .select-trigger {
    cursor: pointer;
}

.select-field select {
    border: 0;
    background: transparent;
    color: var(--ink-secondary);
    outline: none;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    padding-right: 0.25rem;
}

.select-field select option {
    font-size: 0.82rem;
}

/* ── Main Content (Editor + Preview) ──────────────────────────── */

.main-content {
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Editor Panel ─────────────────────────────────────────────── */

.editor-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--panel);
    min-height: 0;
    overflow: hidden;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--line-light);
    flex-shrink: 0;
}

.editor-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

/* ── Help Panel ───────────────────────────────────────────────── */

.help-panel {
    padding: 0.65rem 0.85rem;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--line-light);
    flex-shrink: 0;
}

.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.85rem;
}

.help-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.help-item code {
    font-size: 0.72em;
    padding: 0.1em 0.35em;
    background: rgba(34, 31, 26, 0.06);
    color: var(--ink-secondary);
    border-radius: 4px;
    white-space: nowrap;
}

.help-item span {
    color: var(--muted);
    font-size: 0.74rem;
}

/* ── Drop Zone / Textarea ─────────────────────────────────────── */

.drop-zone {
    flex: 1;
    display: flex;
    min-height: 0;
    padding: 0.65rem;
    transition: background 150ms ease;
}

.drop-zone.drag-over {
    background: var(--accent-softer);
}

#markdown-file,
#session-file {
    display: none;
}

#markdown-input {
    width: 100%;
    height: 100%;
    resize: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    background: var(--surface-raised);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.7;
    outline: none;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

#markdown-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

#markdown-input:focus {
    border-color: rgba(215, 100, 59, 0.4);
    box-shadow: 0 0 0 3px var(--accent-softer);
}

/* ── Presentation Panel ───────────────────────────────────────── */

.presentation-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--surface-sunken);
}

.preview-stack {
    flex: 1 1 auto;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-content: end;
    min-height: 0;
    padding-bottom: 48px;
}

.stage-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.15rem 1.25rem 0.5rem;
    min-height: 0;
    overflow: hidden;
}

.slide-stage {
    width: min(100%, 960px);
    aspect-ratio: 16 / 9;
    container-type: inline-size;
    border-radius: var(--radius-xl);
    background: var(--stage-bg), var(--panel);
    color: var(--stage-ink);
    border: 1px solid rgba(34, 31, 26, 0.06);
    box-shadow: var(--shadow-lg);
    padding: clamp(1.4rem, 4cqw, 4.75rem);
    overflow: hidden;
}

/* Theme variants for stage */
.slide-stage[data-theme="spruce"] {
    --stage-bg: linear-gradient(
        145deg,
        rgba(234, 245, 238, 0.98),
        rgba(215, 234, 225, 0.94)
    );
    --stage-ink: #1d372b;
    --stage-muted: #557061;
    --stage-accent: #2f8d61;
}

.slide-stage[data-theme="hypepedia"] {
    --stage-bg: linear-gradient(145deg, #d5fff6 0%, #d6f1eb 100%);
    --stage-ink: #1f473d;
    --stage-muted: #47776b;
    --stage-accent: #8ecebe;
    font-family: "Sora", var(--font-sans);
}

.slide-stage[data-theme="cobalt"] {
    --stage-bg: linear-gradient(
        145deg,
        rgba(234, 240, 255, 0.98),
        rgba(210, 224, 255, 0.94)
    );
    --stage-ink: #1e2c52;
    --stage-muted: #5d6f9a;
    --stage-accent: #3b6ef3;
}

.slide-stage[data-theme="clay"] {
    --stage-bg: linear-gradient(
        145deg,
        rgba(248, 238, 231, 0.98),
        rgba(237, 218, 205, 0.94)
    );
    --stage-ink: #40241c;
    --stage-muted: #876357;
    --stage-accent: #c86d4a;
}

.slide-stage[data-theme="nocturne"] {
    --stage-bg: linear-gradient(
        150deg,
        rgba(20, 24, 38, 0.98),
        rgba(35, 41, 60, 0.94)
    );
    --stage-ink: #eef2ff;
    --stage-muted: rgba(238, 242, 255, 0.72);
    --stage-accent: #8d7dff;
}

/* ── Slide Inline Nav ─────────────────────────────────────────── */

.slide-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: -1rem;
    padding: 0.35rem 1.25rem 0.25rem;
    flex-shrink: 0;
}

.slide-counter {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-secondary);
    min-width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Speaker Notes ────────────────────────────────────────────── */

.speaker-notes-section {
    flex-shrink: 0;
    border-top: 1px solid var(--line-light);
    background: var(--panel);
}

.speaker-notes-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1.25rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: color 150ms ease;
}

.speaker-notes-toggle:hover {
    color: var(--ink-secondary);
}

.speaker-notes-body {
    padding: 0 1.25rem 0.85rem;
    max-height: 120px;
    overflow-y: auto;
}

.speaker-notes-body .support-empty {
    color: var(--muted);
    font-size: 0.82rem;
    font-style: italic;
}

.speaker-notes-body .speaker-notes-copy p {
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--ink-secondary);
    margin-bottom: 0.35rem;
}

/* ── Slide Strip ──────────────────────────────────────────────── */

.slide-strip-wrap {
    flex-shrink: 0;
    border-top: 1px solid var(--line);
    background: var(--panel);
    padding: 0.55rem 0.85rem;
    overflow-x: auto;
}

.slide-strip {
    display: flex;
    gap: 0.45rem;
}

.slide-thumb {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 120px;
    max-width: 160px;
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    background: var(--surface-sunken);
    cursor: pointer;
    transition:
        border-color 150ms ease,
        background 150ms ease,
        box-shadow 150ms ease;
}

.slide-thumb:hover {
    border-color: #d0c9be;
    background: var(--panel-hover);
}

.slide-thumb.active {
    border-color: var(--accent);
    background: var(--accent-softer);
    box-shadow: 0 0 0 2px var(--accent-softer);
}

.slide-thumb[data-theme="spruce"] {
    background: linear-gradient(
        160deg,
        rgba(225, 241, 232, 0.96),
        rgba(203, 228, 214, 0.92)
    );
}

.slide-thumb[data-theme="hypepedia"] {
    background: linear-gradient(160deg, #d5fff6 0%, #d6f1eb 100%);
    color: #1f473d;
}

.slide-thumb[data-theme="cobalt"] {
    background: linear-gradient(
        160deg,
        rgba(230, 238, 255, 0.96),
        rgba(201, 218, 255, 0.92)
    );
    color: #1e2c52;
}

.slide-thumb[data-theme="clay"] {
    background: linear-gradient(
        160deg,
        rgba(248, 238, 231, 0.96),
        rgba(236, 216, 203, 0.92)
    );
    color: #40241c;
}

.slide-thumb[data-theme="nocturne"] {
    background: linear-gradient(
        160deg,
        rgba(20, 24, 38, 0.96),
        rgba(42, 49, 71, 0.9)
    );
    color: #eef2ff;
}

.slide-thumb-index {
    font-size: 0.68rem;
    color: inherit;
    opacity: 0.6;
    font-weight: 500;
}

.slide-thumb-title {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Slide Content Styles ─────────────────────────────────────── */

.slide {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.35rem;
    overflow: hidden;
    color: var(--stage-ink);
}

.slide h1,
.slide h2,
.slide h3,
.slide h4,
.slide h5,
.slide h6 {
    margin: 0 0 0.5rem;
    line-height: 1.05;
}

.slide h1 {
    font-size: clamp(2.25rem, 3.35cqw, 4.2rem);
}
.slide h2 {
    font-size: clamp(1.6rem, 2.25cqw, 2.85rem);
}
.slide h3 {
    font-size: clamp(1.1rem, 1.58cqw, 2rem);
}
.slide h4,
.slide h5,
.slide h6 {
    font-size: clamp(0.95rem, 1.18cqw, 1.5rem);
}

.slide p,
.slide li,
.slide blockquote {
    font-size: clamp(0.9rem, 1.14cqw, 1.44rem);
    line-height: 1.4;
}

.slide p,
.slide ul,
.slide ol,
.slide pre,
.slide blockquote,
.slide table,
.slide img {
    margin: 0.45rem 0 0;
}

.slide ul,
.slide ol {
    list-style-position: outside;
    padding-left: clamp(1.65rem, 2.6cqw, 3.4rem);
}

.slide li + li {
    margin-top: 0.22rem;
}

.slide pre {
    flex-shrink: 0;
    max-height: 42%;
    padding: clamp(0.65rem, 0.88cqw, 1.1rem) clamp(0.75rem, 1cqw, 1.3rem);
    border-radius: var(--radius-sm);
    background: rgba(26, 23, 20, 0.96);
    color: #f8efe5;
    overflow: auto;
    font-size: clamp(0.75rem, 0.94cqw, 1.2rem);
    line-height: 1.45;
}

.slide pre.diagram-code {
    align-self: center;
    width: max-content;
    max-width: 100%;
    max-height: 82%;
    flex: 0 1 auto;
    font-size: clamp(0.62rem, 0.86cqw, 1.08rem);
    line-height: 1.08;
    white-space: pre;
}

.slide .mermaid {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 78%;
    padding: clamp(0.75rem, 1.15cqw, 1.45rem);
    border-radius: var(--radius-sm);
    background: rgba(255, 253, 248, 0.72);
    border: 1px solid rgba(34, 31, 26, 0.08);
    overflow: auto;
}

.slide .mermaid svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
}

.slide .mermaid-fallback {
    font-family: var(--font-mono);
    white-space: pre;
    color: var(--stage-muted);
}

.slide:has(pre, .mermaid) {
    gap: clamp(0.16rem, 0.38cqw, 0.48rem);
}

.slide:has(pre, .mermaid) h2,
.slide:has(pre, .mermaid) h3 {
    margin-bottom: clamp(0.14rem, 0.32cqw, 0.4rem);
}

.slide:has(pre, .mermaid) p {
    margin-top: clamp(0.18rem, 0.36cqw, 0.45rem);
}

.slide:has(pre, .mermaid) table {
    margin-top: clamp(0.28rem, 0.5cqw, 0.62rem);
}

.slide:has(pre, .mermaid) pre:not(.diagram-code) {
    max-height: 24%;
}

.slide:has(pre):has(table) pre:not(.diagram-code) {
    max-height: 16%;
}

.slide:has(pre):has(table) table {
    font-size: clamp(0.68rem, 0.82cqw, 1rem);
}

.slide:has(pre, .mermaid) .mermaid + p,
.slide:has(pre, .mermaid) pre + p {
    margin-top: clamp(0.22rem, 0.44cqw, 0.55rem);
}

.slide blockquote {
    padding-left: 0.8rem;
    border-left: 3px solid var(--stage-accent);
    color: var(--stage-muted);
}

.slide img {
    display: block;
    max-width: 100%;
    max-height: 48vh;
    object-fit: contain;
    border-radius: 14px;
}

.slide table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid rgba(34, 31, 26, 0.1);
    font-size: clamp(0.78rem, 1.02cqw, 1.3rem);
}

.slide th,
.slide td {
    padding: 0.65rem 0.8rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(34, 31, 26, 0.08);
}

.slide th {
    background: rgba(34, 31, 26, 0.04);
    font-weight: 600;
}

.slide tbody tr:last-child td {
    border-bottom: 0;
}

.slide a {
    color: var(--stage-accent);
}

.slide hr {
    border: 0;
    border-top: 1px solid rgba(34, 31, 26, 0.12);
    margin: 0.7rem 0 0;
}

.slide > :first-child,
.slide-column > :first-child,
.slide-copy > :first-child,
.slide-media-layout > :first-child {
    margin-top: 0;
}

.slide strong {
    font-weight: 700;
}

.slide code {
    font-size: 0.9em;
}

.slide-stage[data-theme="hypepedia"] .slide pre {
    background: rgba(31, 71, 61, 0.08);
    color: var(--stage-ink);
    border: 1px solid rgba(31, 71, 61, 0.12);
}

.slide-stage[data-theme="hypepedia"] .slide code {
    background: rgba(31, 71, 61, 0.08);
    color: var(--stage-ink);
}

.slide-stage[data-theme="hypepedia"] .slide table {
    border-color: rgba(31, 71, 61, 0.14);
}

.slide-stage[data-theme="hypepedia"] .slide th {
    background: rgba(31, 71, 61, 0.08);
}

.slide-stage[data-theme="hypepedia"] .slide th,
.slide-stage[data-theme="hypepedia"] .slide td {
    border-bottom-color: rgba(31, 71, 61, 0.12);
}

.inline-image-fallback {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(34, 31, 26, 0.08);
    color: var(--stage-muted);
    font-size: 0.85em;
}

.slide[data-density="busy"] {
    gap: 0.25rem;
}

.slide[data-density="busy"] h1 {
    font-size: clamp(1.95rem, 2.82cqw, 3.55rem);
}

.slide[data-density="busy"] h2 {
    font-size: clamp(1.35rem, 1.92cqw, 2.4rem);
}

.slide[data-density="busy"] h3 {
    font-size: clamp(1rem, 1.34cqw, 1.7rem);
}

.slide[data-density="busy"] p,
.slide[data-density="busy"] li,
.slide[data-density="busy"] blockquote {
    font-size: clamp(0.78rem, 1cqw, 1.25rem);
    line-height: 1.32;
}

.slide[data-density="busy"] pre {
    max-height: 34%;
    padding: clamp(0.48rem, 0.66cqw, 0.82rem) clamp(0.58rem, 0.78cqw, 1rem);
    font-size: clamp(0.64rem, 0.82cqw, 1.02rem);
    line-height: 1.34;
}

.slide[data-density="busy"] pre.diagram-code {
    max-height: 82%;
    flex: 0 1 auto;
    font-size: clamp(0.56rem, 0.78cqw, 0.98rem);
    line-height: 1.08;
}

.slide[data-density="busy"] th,
.slide[data-density="busy"] td {
    padding: 0.46rem 0.55rem;
}

.slide[data-density="crowded"] {
    gap: 0.18rem;
}

.slide[data-density="crowded"] h1 {
    font-size: clamp(1.7rem, 2.42cqw, 3.05rem);
}

.slide[data-density="crowded"] h2 {
    font-size: clamp(1.15rem, 1.64cqw, 2.05rem);
}

.slide[data-density="crowded"] h3 {
    font-size: clamp(0.88rem, 1.16cqw, 1.45rem);
}

.slide[data-density="crowded"] h4,
.slide[data-density="crowded"] h5,
.slide[data-density="crowded"] h6 {
    font-size: clamp(0.78rem, 1cqw, 1.25rem);
}

.slide[data-density="crowded"] p,
.slide[data-density="crowded"] li,
.slide[data-density="crowded"] blockquote {
    font-size: clamp(0.68rem, 0.86cqw, 1.08rem);
    line-height: 1.24;
}

.slide[data-density="crowded"] p,
.slide[data-density="crowded"] ul,
.slide[data-density="crowded"] ol,
.slide[data-density="crowded"] pre,
.slide[data-density="crowded"] blockquote,
.slide[data-density="crowded"] table {
    margin-top: 0.28rem;
}

.slide[data-density="crowded"] li + li {
    margin-top: 0.12rem;
}

.slide[data-density="crowded"] pre {
    max-height: 30%;
    padding: clamp(0.38rem, 0.52cqw, 0.65rem) clamp(0.48rem, 0.66cqw, 0.82rem);
    font-size: clamp(0.56rem, 0.7cqw, 0.88rem);
    line-height: 1.25;
}

.slide[data-density="crowded"] pre.diagram-code {
    max-height: 82%;
    flex: 0 1 auto;
    font-size: clamp(0.5rem, 0.68cqw, 0.86rem);
    line-height: 1.08;
}

.slide[data-density="crowded"] code {
    padding: 0.08em 0.32em;
}

.slide[data-density="crowded"] th,
.slide[data-density="crowded"] td {
    padding: 0.34rem 0.44rem;
}

/* ── Slide Layouts ────────────────────────────────────────────── */

.slide-layout-title {
    justify-content: center;
    align-items: flex-start;
    gap: 0.2rem;
}

.slide-layout-title h1:first-child,
.slide-layout-title h2:first-child {
    max-width: 14ch;
    font-size: clamp(2.8rem, 4.12cqw, 5.2rem);
    line-height: 0.98;
}

.slide-layout-title p {
    max-width: 44ch;
    font-size: clamp(0.95rem, 1.18cqw, 1.5rem);
    line-height: 1.28;
    color: var(--stage-muted);
}

.slide-layout-title[data-density="busy"] h1:first-child,
.slide-layout-title[data-density="busy"] h2:first-child,
.slide-layout-title[data-density="crowded"] h1:first-child,
.slide-layout-title[data-density="crowded"] h2:first-child {
    font-size: clamp(2.25rem, 3.35cqw, 4.2rem);
    max-width: 18ch;
}

.slide-layout-title[data-density="busy"] p,
.slide-layout-title[data-density="crowded"] p {
    font-size: clamp(0.82rem, 1.04cqw, 1.3rem);
}

.slide-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(1rem, 2vw, 2.2rem);
    height: 100%;
}

.slide-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.slide-layout-quote {
    justify-content: center;
    gap: 1rem;
}

.slide-layout-quote blockquote {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: clamp(1.5rem, 3vw, 3rem);
    line-height: 1.12;
    color: var(--stage-ink);
}

.slide-layout-quote p:last-child {
    color: var(--stage-muted);
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}

.slide-media-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(1rem, 2vw, 2.2rem);
    align-items: center;
    height: 100%;
}

.slide-media,
.slide-copy {
    min-width: 0;
}

.slide-media img {
    width: 100%;
    max-height: 60vh;
    object-fit: cover;
}

.slide-full-bleed {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    height: 100%;
    margin: calc(clamp(1.4rem, 3vw, 3rem) * -1);
}

.slide-full-bleed img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    margin: 0;
}

/* ── Empty / Onboarding State ─────────────────────────────────── */

.empty-state {
    height: 100%;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    border: 1px dashed rgba(34, 31, 26, 0.14);
    border-radius: var(--radius-lg);
}

.onboarding-state {
    padding: clamp(1.2rem, 2vw, 2rem);
}

.onboarding-state strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: clamp(1.1rem, 1.6vw, 1.4rem);
    color: var(--stage-ink);
}

.onboarding-state p {
    margin: 0 auto;
    max-width: 44ch;
    font-size: 0.88rem;
}

.onboarding-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 1rem;
    text-align: left;
}

.onboarding-card {
    padding: 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(34, 31, 26, 0.06);
}

.onboarding-label {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.onboarding-card pre {
    margin: 0;
    padding: 0.5rem 0.6rem;
    background: rgba(34, 31, 26, 0.9);
    color: #f8efe5;
    border-radius: 8px;
    overflow: auto;
    font-size: 0.72rem;
}

/* ── Print Deck (hidden, used for print) ──────────────────────── */

.print-deck {
    display: none;
}

/* ── Present Mode ─────────────────────────────────────────────── */

body.presenting .top-bar {
    display: none;
}

body.presenting .main-content {
    grid-template-columns: 1fr;
    height: 100vh;
}

body.presenting .editor-panel {
    display: none;
}

body.presenting .presentation-panel {
    height: 100vh;
}

body.presenting .preview-stack {
    display: flex;
    flex: 1 1 auto;
}

body.presenting .stage-wrap {
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

body.presenting .slide-stage {
    width: min(calc(100vw - 3rem), calc((100vh - 3rem) * 16 / 9));
    max-width: none;
    height: auto;
    max-height: calc(100vh - 3rem);
    aspect-ratio: 16 / 9;
}

body.presenting .slide h1 {
    font-size: clamp(2.9rem, 4.55cqw, 5.6rem);
}

body.presenting .slide h2 {
    font-size: clamp(2.1rem, 3.35cqw, 4.15rem);
}

body.presenting .slide h3 {
    font-size: clamp(1.42rem, 2.2cqw, 2.75rem);
}

body.presenting .slide p,
body.presenting .slide li,
body.presenting .slide blockquote {
    font-size: clamp(1.12rem, 1.72cqw, 2.05rem);
}

body.presenting .slide table {
    font-size: clamp(1.02rem, 1.6cqw, 1.88rem);
}

body.presenting .slide[data-density="busy"] h1 {
    font-size: clamp(2.65rem, 4.35cqw, 5.35rem);
}

body.presenting .slide[data-density="busy"] h2 {
    font-size: clamp(2.05rem, 3.65cqw, 4.35rem);
}

body.presenting .slide[data-density="busy"] h3 {
    font-size: clamp(1.38rem, 2.18cqw, 2.7rem);
}

body.presenting .slide[data-density="busy"] p,
body.presenting .slide[data-density="busy"] li,
body.presenting .slide[data-density="busy"] blockquote {
    font-size: clamp(1.08rem, 1.72cqw, 2.02rem);
}

body.presenting .slide[data-density="busy"] table {
    font-size: clamp(0.98rem, 1.58cqw, 1.82rem);
}

body.presenting .slide pre {
    max-height: 48%;
    font-size: clamp(0.95rem, 1.18cqw, 1.45rem);
    line-height: 1.38;
}

body.presenting .slide[data-density="busy"] pre {
    max-height: 42%;
    font-size: clamp(0.82rem, 1.05cqw, 1.28rem);
    line-height: 1.28;
}

body.presenting .slide[data-density="crowded"] pre {
    max-height: 38%;
    font-size: clamp(0.72rem, 0.92cqw, 1.12rem);
}

body.presenting .slide pre.diagram-code {
    max-height: 82%;
    font-size: clamp(0.9rem, 1.15cqw, 1.38rem);
    line-height: 1.08;
}

body.presenting .slide[data-density="busy"] pre.diagram-code {
    max-height: 82%;
    font-size: clamp(0.78rem, 1.02cqw, 1.22rem);
}

body.presenting .slide[data-density="crowded"] pre.diagram-code {
    max-height: 82%;
    font-size: clamp(0.68rem, 0.9cqw, 1.08rem);
}

body.presenting .slide:has(pre):has(table) table {
    font-size: clamp(0.76rem, 0.96cqw, 1.16rem);
}

body.presenting .slide-strip-wrap {
    display: none;
}

body.presenting .speaker-notes-section {
    display: none;
}

body.presenting .slide-nav {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-full);
    padding: 0.4rem 0.85rem;
    gap: 0.85rem;
    opacity: 0;
    transition: opacity 200ms ease;
}

body.presenting:hover .slide-nav,
body.presenting .slide-nav:focus-within {
    opacity: 1;
}

body.presenting .slide-nav .slide-counter {
    color: #fff;
}

body.presenting .slide-nav .btn-nav {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.presenting .slide-nav .btn-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .editor-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        max-height: 40vh;
    }

    .top-bar-brand {
        display: none;
    }

    .help-grid {
        grid-template-columns: 1fr;
    }

    .onboarding-grid {
        grid-template-columns: 1fr 1fr;
    }

    .slide-columns,
    .slide-media-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Print ────────────────────────────────────────────────────── */

@media print {
    @page {
        size: 13.333in 7.5in;
        margin: 0;
    }

    body {
        background: #fff;
    }

    .app-shell {
        display: block;
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .top-bar,
    .editor-panel,
    .slide-strip-wrap,
    .slide-nav,
    .speaker-notes-section {
        display: none !important;
    }

    .main-content {
        display: block;
    }

    .presentation-panel {
        background: transparent;
    }

    .app-shell {
        display: none;
    }

    .print-deck {
        display: block;
    }

    .print-slide {
        break-after: page;
        page-break-after: always;
        width: 13.333in;
        height: 7.5in;
        min-height: 0;
        padding: 1.25cm;
        box-sizing: border-box;
        border: 0;
        box-shadow: none;
        background: var(--stage-bg), #ffffff;
        color: var(--stage-ink);
        border-radius: 0;
        overflow: hidden;
    }

    .print-slide .slide h1 {
        font-size: clamp(2.9rem, 4.55cqw, 5.6rem);
    }

    .print-slide .slide h2 {
        font-size: clamp(2.1rem, 3.35cqw, 4.15rem);
    }

    .print-slide .slide h3 {
        font-size: clamp(1.42rem, 2.2cqw, 2.75rem);
    }

    .print-slide .slide p,
    .print-slide .slide li,
    .print-slide .slide blockquote {
        font-size: clamp(1.12rem, 1.72cqw, 2.05rem);
    }

    .print-slide .slide table {
        font-size: clamp(1.02rem, 1.6cqw, 1.88rem);
    }

    .print-slide .slide[data-density="busy"] h1 {
        font-size: clamp(2.65rem, 4.35cqw, 5.35rem);
    }

    .print-slide .slide[data-density="busy"] h2 {
        font-size: clamp(2.05rem, 3.65cqw, 4.35rem);
    }

    .print-slide .slide[data-density="busy"] h3 {
        font-size: clamp(1.38rem, 2.18cqw, 2.7rem);
    }

    .print-slide .slide[data-density="busy"] p,
    .print-slide .slide[data-density="busy"] li,
    .print-slide .slide[data-density="busy"] blockquote {
        font-size: clamp(1.08rem, 1.72cqw, 2.02rem);
    }

    .print-slide .slide[data-density="busy"] table {
        font-size: clamp(0.98rem, 1.58cqw, 1.82rem);
    }

    .print-slide .slide pre {
        max-height: 48%;
        font-size: clamp(0.95rem, 1.18cqw, 1.45rem);
        line-height: 1.38;
    }

    .print-slide .slide[data-density="busy"] pre {
        max-height: 42%;
        font-size: clamp(0.82rem, 1.05cqw, 1.28rem);
        line-height: 1.28;
    }

    .print-slide .slide[data-density="crowded"] pre {
        max-height: 38%;
        font-size: clamp(0.72rem, 0.92cqw, 1.12rem);
    }

    .print-slide .slide pre.diagram-code {
        max-height: 82%;
        font-size: clamp(0.9rem, 1.15cqw, 1.38rem);
        line-height: 1.08;
    }

    .print-slide .slide[data-density="busy"] pre.diagram-code {
        max-height: 82%;
        font-size: clamp(0.78rem, 1.02cqw, 1.22rem);
    }

    .print-slide .slide[data-density="crowded"] pre.diagram-code {
        max-height: 82%;
        font-size: clamp(0.68rem, 0.9cqw, 1.08rem);
    }

    .print-slide .slide:has(pre):has(table) table {
        font-size: clamp(0.76rem, 0.96cqw, 1.16rem);
    }

    .print-slide[data-theme="spruce"] {
        --stage-bg: linear-gradient(
            145deg,
            rgba(234, 245, 238, 0.98),
            rgba(215, 234, 225, 0.94)
        );
        --stage-ink: #1d372b;
        --stage-muted: #557061;
        --stage-accent: #2f8d61;
    }

    .print-slide[data-theme="hypepedia"] {
        --stage-bg: linear-gradient(145deg, #d5fff6 0%, #d6f1eb 100%);
        --stage-ink: #1f473d;
        --stage-muted: #47776b;
        --stage-accent: #8ecebe;
        font-family: "Sora", var(--font-sans);
    }

    .print-slide[data-theme="cobalt"] {
        --stage-bg: linear-gradient(
            145deg,
            rgba(234, 240, 255, 0.98),
            rgba(210, 224, 255, 0.94)
        );
        --stage-ink: #1e2c52;
        --stage-muted: #5d6f9a;
        --stage-accent: #3b6ef3;
    }

    .print-slide[data-theme="clay"] {
        --stage-bg: linear-gradient(
            145deg,
            rgba(248, 238, 231, 0.98),
            rgba(237, 218, 205, 0.94)
        );
        --stage-ink: #40241c;
        --stage-muted: #876357;
        --stage-accent: #c86d4a;
    }

    .print-slide[data-theme="nocturne"] {
        --stage-bg: linear-gradient(
            150deg,
            rgba(20, 24, 38, 0.98),
            rgba(35, 41, 60, 0.94)
        );
        --stage-ink: #eef2ff;
        --stage-muted: rgba(238, 242, 255, 0.72);
        --stage-accent: #8d7dff;
    }

    .print-slide:last-child {
        break-after: auto;
        page-break-after: auto;
    }
}
