/* ---------- Design tokens ---------- */
:root {
    --bg: #0c191c;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-strong: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.09);
    --text: #edf3ed;
    --text-dim: #a3b8b5;
    --radius: 20px;

    --hairline: rgba(255, 255, 255, .05);
    --panel: #122428;
    --slide-grad-a: rgba(255, 255, 255, .05);
    --slide-grad-b: rgba(255, 255, 255, .015);
    --slide-shadow: 0 30px 80px rgba(0, 0, 0, .45);
    --nav-bg: rgba(12, 12, 22, .8);
    --bar-bg: rgba(10, 10, 18, .85);
    --dialog-shadow: 0 40px 100px rgba(0, 0, 0, .6);
    --backdrop: rgba(5, 5, 12, .7);

    --chart-axis: rgba(255, 255, 255, 0.15);
    --chart-split: rgba(255, 255, 255, 0.06);
    --chart-track: rgba(255, 255, 255, 0.08);
    --tooltip-bg: #181826;
    --tooltip-border: rgba(255, 255, 255, 0.1);

    --accent: #70bea5;
    --accent-2: #b4d79b;
}

[data-theme="light"] {
    --bg: #f3f4fb;
    --surface: rgba(18, 20, 46, 0.05);
    --surface-strong: rgba(18, 20, 46, 0.09);
    --border: rgba(18, 20, 46, 0.13);
    --text: #191c2e;
    --text-dim: #5b6178;

    --hairline: rgba(18, 20, 46, .07);
    --panel: #ffffff;
    --slide-grad-a: rgba(255, 255, 255, .8);
    --slide-grad-b: rgba(255, 255, 255, .45);
    --slide-shadow: 0 30px 80px rgba(35, 40, 90, .16);
    --nav-bg: rgba(255, 255, 255, .85);
    --bar-bg: rgba(243, 244, 251, .88);
    --dialog-shadow: 0 40px 100px rgba(35, 40, 90, .25);
    --backdrop: rgba(40, 44, 80, .35);

    --chart-axis: rgba(18, 20, 46, 0.2);
    --chart-split: rgba(18, 20, 46, 0.08);
    --chart-track: rgba(18, 20, 46, 0.08);
    --tooltip-bg: #ffffff;
    --tooltip-border: rgba(18, 20, 46, 0.12);
}

[data-accent="violet"] {
    --accent: #8b5cf6;
    --accent-2: #6366f1;
}

[data-accent="cyan"] {
    --accent: #06b6d4;
    --accent-2: #3b82f6;
}

[data-accent="emerald"] {
    --accent: #10b981;
    --accent-2: #14b8a6;
}

[data-accent="amber"] {
    --accent: #f59e0b;
    --accent-2: #f97316;
}

[data-accent="rose"] {
    --accent: #f43f5e;
    --accent-2: #ec4899;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    overflow: hidden;
    transition: background .3s ease, color .3s ease;
}

body {
    display: flex;
    flex-direction: column;
}

/* ---------- Ambient background ---------- */
#bg-mesh {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(45rem 30rem at 12% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(40rem 28rem at 105% 15%, rgba(6, 182, 212, 0.13), transparent 60%),
        radial-gradient(50rem 35rem at 50% 120%, rgba(99, 102, 241, 0.12), transparent 60%);
    animation: mesh-drift 24s ease-in-out infinite alternate;
}

@keyframes mesh-drift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(-2%, 2%, 0) scale(1.06);
    }
}

/* ---------- Top bar ---------- */
#topbar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--border));
    border-radius: 7px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), transparent 58%),
        var(--surface);
    color: var(--text);
    font-family: 'Newsreader', serif;
    font-size: 1.15rem;
    font-weight: 700;
}

.brand-accent {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.status-pill {
    margin-left: 10px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.status-pill.live {
    color: #34d399;
    border-color: rgba(52, 211, 153, .4);
    background: rgba(52, 211, 153, .08);
    animation: pulse 1.6s infinite;
}

.status-pill.composing, .status-pill.generating {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, .4);
    background: rgba(251, 191, 36, .08);
}

@keyframes pulse {
    50% {
        opacity: .55;
    }
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    color: var(--text-dim);
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: all .2s;
}

.toggle:has(input:checked) {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(139, 92, 246, .12);
}

.toggle input {
    accent-color: var(--accent);
}

#topic-hint {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 999px;
    font-family: inherit;
    font-size: .85rem;
    width: 200px;
    outline: none;
    transition: border-color .2s;
}

#topic-hint:focus {
    border-color: var(--accent);
}

#mic-select,
#design-select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    font-family: inherit;
    font-size: .82rem;
    max-width: 190px;
    outline: none;
    cursor: pointer;
}

#mic-select:focus,
#design-select:focus {
    border-color: var(--accent);
}

#mic-select option,
#design-select option {
    background: var(--panel);
    color: var(--text);
}

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
    font-size: .95rem;
    transition: border-color .2s;
}

.icon-btn:hover {
    border-color: var(--accent);
}

.icon-btn:disabled,
.icon-btn.busy {
    opacity: .55;
    cursor: wait;
}

/* ---------- Toasts ---------- */
#toast-container {
    position: fixed;
    top: 76px;
    right: 22px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 18px;
    box-shadow: var(--dialog-shadow);
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
    transform: translateX(24px);
    opacity: 0;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .3s ease;
    max-width: 340px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    display: grid;
    place-items: center;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: .7rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #10b981, #14b8a6);
}

.toast.error .toast-icon {
    background: linear-gradient(135deg, #ef4444, #f43f5e);
}

.toast.error {
    border-color: rgba(239, 68, 68, .35);
}

.btn {
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all .2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-primary.stop {
    background: linear-gradient(135deg, #ef4444, #f43f5e);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    border-color: var(--accent);
}

/* ---------- Stage ---------- */
#stage {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 40px 70px;
}

#empty-state {
    text-align: center;
    max-width: 640px;
}

#empty-state h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-bottom: 18px;
}

#empty-state p {
    color: var(--text-dim);
    font-size: 1.05rem;
    line-height: 1.7;
}

.grad {
    background: linear-gradient(90deg, var(--accent), #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Slide ---------- */
#slide-host {
    width: 100%;
    height: 100%;
    display: none;
}

#slide-host.active {
    display: block;
}

.slide {
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, var(--slide-grad-a), var(--slide-grad-b));
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: clamp(28px, 4vw, 60px);
    display: flex;
    flex-direction: column;
    gap: 26px;
    overflow: hidden;
    position: relative;
    animation: slide-in .55s cubic-bezier(.2, .8, .2, 1);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: var(--slide-shadow);
    transform-style: preserve-3d;
    will-change: transform;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(26px) scale(.985);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.slide::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), transparent);
    z-index: 2;
}

/* Ambient accent glow: gives every slide a distinct, alive backdrop instead of a flat panel. */
.slide::after {
    content: "";
    position: absolute;
    top: -20%;
    right: -10%;
    width: 70%;
    height: 85%;
    background:
        radial-gradient(circle at 30% 30%, var(--accent), transparent 62%),
        radial-gradient(circle at 70% 70%, var(--accent-2), transparent 58%);
    opacity: .3;
    filter: blur(55px);
    z-index: 0;
    pointer-events: none;
    animation: glow-float 14s ease-in-out infinite alternate;
}

@keyframes glow-float {
    from {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }

    to {
        transform: translate3d(-6%, 8%, 0) scale(1.18) rotate(8deg);
    }
}

.slide-title,
.slide-body {
    position: relative;
    z-index: 1;
}

.slide-title {
    font-size: clamp(1.6rem, 3.2vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.slide-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.slide[data-layout="hero"] {
    justify-content: center;
    text-align: center;
}

.slide[data-layout="hero"] .slide-title {
    font-size: clamp(2.4rem, 5vw, 4.2rem);
}

.slide[data-layout="hero"] .slide-body {
    flex: 0 1 auto;
    align-items: center;
}

.slide[data-layout="two-column"] .slide-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: stretch;
}

.slide[data-layout="grid"] .slide-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: 22px;
}

/* ---------- Components ---------- */
.cmp {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cmp-in .6s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes cmp-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.cmp-title {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-dim);
    margin-bottom: 14px;
}

/* heading */
.cmp-heading {
    background: none;
    border: none;
    padding: 8px 0;
    /* Intrinsically sized: never crush the heading into clipped text. */
    flex: 0 0 auto;
}

.cmp-heading .kicker {
    display: inline-block;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.cmp-heading h2 {
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.cmp-heading .subtitle {
    margin-top: 12px;
    color: var(--text-dim);
    font-size: 1.08rem;
    line-height: 1.6;
    max-width: 60ch;
}

/* bullets */
.cmp-bullets ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cmp-bullets li {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    font-size: 1.05rem;
    line-height: 1.5;
}

.cmp-bullets li::before {
    content: "";
    flex: 0 0 9px;
    height: 9px;
    margin-top: 8px;
    border-radius: 3px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    transform: rotate(45deg);
}

.cmp-bullets .detail {
    display: block;
    color: var(--text-dim);
    font-size: .88rem;
    margin-top: 3px;
}

/* stat cards */
.cmp-statCards {
    background: none;
    border: none;
    padding: 0;
    flex-direction: row;
    gap: 18px;
    /* Bounded height: size to content instead of getting crushed. */
    flex: 0 0 auto;
}

.stat-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease, border-color .3s ease;
}

.stat-card:hover {
    transform: perspective(700px) rotateX(3deg) translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 18px 34px rgba(0, 0, 0, .28);
}

.stat-card .value {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(120deg, var(--text), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-card .label {
    color: var(--text-dim);
    font-size: .85rem;
    font-weight: 500;
}

.stat-card .delta {
    font-size: .82rem;
    font-weight: 700;
}

.stat-card .delta.up {
    color: #34d399;
}

.stat-card .delta.down {
    color: #f87171;
}

/* charts */
.cmp-chart {
    /* Absorb the remaining space and shrink instead of overflowing the slide. */
    flex: 1 1 0;
    min-height: 0;
}

.cmp-chart .chart-canvas {
    flex: 1;
    min-height: 140px;
    min-width: 0;
    overflow: hidden;
}

/* quote */
.cmp-quote {
    justify-content: center;
    border-left: 4px solid var(--accent);
}

.cmp-quote blockquote {
    font-size: clamp(1.15rem, 2.2vw, 1.7rem);
    font-weight: 500;
    font-style: italic;
    line-height: 1.5;
}

.cmp-quote blockquote::before {
    content: "“";
    color: var(--accent);
    font-size: 1.4em;
}

.cmp-quote cite {
    margin-top: 14px;
    color: var(--text-dim);
    font-style: normal;
    font-size: .92rem;
}

.cmp-quote cite strong {
    color: var(--text);
}

/* timeline */
.cmp-timeline {
    flex: 0 0 auto;
}

.cmp-timeline ol {
    list-style: none;
    display: flex;
    gap: 8px;
}

.cmp-timeline li {
    flex: 1;
    position: relative;
    padding-top: 26px;
}

.cmp-timeline li::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px var(--accent);
}

.cmp-timeline li::after {
    content: "";
    position: absolute;
    top: 12px;
    left: 22px;
    right: 8px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.cmp-timeline li:last-child::after {
    display: none;
}

.cmp-timeline .tl-label {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--accent);
}

.cmp-timeline .tl-title {
    font-weight: 700;
    margin-top: 4px;
}

.cmp-timeline .tl-desc {
    color: var(--text-dim);
    font-size: .86rem;
    margin-top: 4px;
    line-height: 1.45;
}

/* comparison */
.cmp-comparison {
    flex-direction: row;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.cmp-comparison .side {
    flex: 1;
    padding: 24px 26px;
}

.cmp-comparison .side+.side {
    border-left: 1px solid var(--border);
}

.cmp-comparison .side h3 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 14px;
    color: var(--accent);
}

.cmp-comparison .side ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cmp-comparison .side li {
    font-size: .95rem;
    line-height: 1.45;
    padding-left: 18px;
    position: relative;
}

.cmp-comparison .side li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* table */
.cmp-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.cmp-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
}

.cmp-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--hairline);
}

.cmp-table tr:last-child td {
    border-bottom: none;
}

/* image */
.cmp-image {
    padding: 0;
    overflow: hidden;
    min-height: 140px;
    /* Absorb remaining space like charts do, instead of pushing siblings out. */
    flex: 1 1 0;
}

.cmp-image figure {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.cmp-image img {
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: cover;
    object-position: center 25%;
}

/* Slow Ken Burns zoom keeps photographic images (not logos) feeling alive rather than static. */
.cmp-image:not(.logo) img {
    animation: kenburns 22s ease-in-out infinite alternate;
}

@keyframes kenburns {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

/* Portraits (wikipedia): never crop faces — show the whole photo. */
.cmp-image.photo img {
    object-fit: contain;
    background: #fff;
}

/* Company logos: contain on a white card so dark logos stay visible in dark mode. */
.cmp-image.logo img {
    object-fit: contain;
    padding: clamp(20px, 4vw, 48px);
    background: #fff;
}

.cmp-image figcaption {
    padding: 12px 18px;
    font-size: .84rem;
    color: var(--text-dim);
}

/* ---------- Auto-fit (compact) mode ----------
   Applied by the renderer when a crowded slide would otherwise clip content:
   tighter paddings, gaps and type so everything stays visible. */
.slide.compact {
    padding: clamp(18px, 2.5vw, 38px);
    gap: 14px;
}

.slide.compact .slide-body {
    gap: 12px;
}

.slide.compact .cmp {
    padding: 12px 16px;
}

.slide.compact .cmp-title {
    margin-bottom: 8px;
}

.slide.compact .slide-title {
    font-size: clamp(1.25rem, 2.2vw, 1.9rem);
}

.slide.compact .cmp-heading h2 {
    font-size: clamp(1.15rem, 2vw, 1.6rem);
}

.slide.compact .cmp-heading .subtitle {
    font-size: .92rem;
    margin-top: 6px;
}

.slide.compact .stat-card {
    padding: 12px 16px;
}

.slide.compact .stat-card .value {
    font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.slide.compact .cmp-bullets ul {
    gap: 8px;
}

.slide.compact .cmp-bullets li {
    font-size: .92rem;
    gap: 10px;
}

.slide.compact .cmp-chart .chart-canvas {
    min-height: 100px;
}

.slide.compact .cmp-image {
    min-height: 100px;
}

.slide.compact .cmp-timeline .tl-desc {
    display: none;
}

/* ---------- Navigation ---------- */
#slide-nav {
    position: fixed;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
}

#slide-nav.hidden {
    display: none;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    transition: background .2s;
}

.nav-btn:hover {
    background: var(--surface-strong);
}

.nav-btn.follow {
    font-size: .95rem;
    opacity: .4;
}

.nav-btn.follow.active {
    opacity: 1;
    color: var(--accent);
}

#nav-counter {
    font-size: .82rem;
    color: var(--text-dim);
    min-width: 52px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

/* ---------- Transcript bar ---------- */
#transcript-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    background: var(--bar-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

#transcript-bar.hidden {
    display: none;
}

#btn-mute {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: .95rem;
    transition: all .2s;
}

#btn-mute:hover {
    border-color: var(--accent);
}

#btn-mute.muted {
    border-color: #ef4444;
    background: rgba(239, 68, 68, .15);
}

#transcript-bar:has(#btn-mute.muted) .mic-dot {
    animation: none;
    background: #6b7280;
}

.mic-dot {
    flex: 0 0 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 1.2s infinite;
}

#transcript-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
    text-align: left;
    color: var(--text-dim);
    font-size: .9rem;
}

/* ---------- Brief dialog ---------- */
dialog {
    margin: auto;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--panel);
    color: var(--text);
    padding: 30px;
    width: min(560px, 92vw);
    box-shadow: var(--dialog-shadow);
}

dialog::backdrop {
    background: var(--backdrop);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

dialog h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 18px;
}

.brief-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

.brief-row label {
    font-size: .88rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brief-row input[type="number"] {
    width: 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 7px 10px;
    font-family: inherit;
}

.brief-actions {
    display: flex;
    gap: 10px;
}

/* ---------- Docs dialog ---------- */
#docs-list,
#decks-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 10px;
}

#docs-list li,
#decks-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: .92rem;
}

#decks-list li {
    cursor: pointer;
    transition: border-color .2s;
}

#decks-list li:hover {
    border-color: var(--accent);
}

#docs-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

#docs-list input {
    accent-color: var(--accent);
}

.doc-thumb {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #fff;
}

.doc-meta {
    color: var(--text-dim);
    font-size: .78rem;
}

.docs-empty {
    color: var(--text-dim);
    font-size: .9rem;
    margin: 8px 0 14px;
}

.hidden {
    display: none;
}

@media (max-width: 1500px) {
    #topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        max-height: 42vh;
        overflow-y: auto;
    }

    .brand {
        justify-content: center;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 700px) {
    #topbar {
        padding: 10px 12px;
    }

    #stage {
        padding: 12px 10px 64px;
    }

    #topic-hint {
        width: 160px;
    }

    .slide {
        padding: 20px;
        border-radius: 8px;
    }
}

/* ---------- Voice-first editor ---------- */
body {
    font-family: 'DM Sans', sans-serif;
    background:
        linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px),
        var(--bg);
    background-size: 32px 32px;
}

#topbar {
    display: grid;
    grid-template-columns: 180px minmax(180px, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 64px;
    max-height: none;
    padding: 10px 18px;
    overflow: visible;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
}

.brand-mark {
    border-radius: 6px;
}

.deck-identity {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

#deck-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .95rem;
}

#save-state {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: .72rem;
}

.deck-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    scrollbar-width: none;
}

.deck-actions::-webkit-scrollbar,
#slide-sidebar::-webkit-scrollbar {
    display: none;
}

.tool-btn,
.deck-actions select,
.workspace-options button,
.workspace-options select {
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    background: var(--surface);
    color: var(--text);
    font: 600 .78rem 'DM Sans', sans-serif;
    cursor: pointer;
}

.tool-btn:hover,
.deck-actions select:hover,
.workspace-options button:hover {
    border-color: var(--accent);
}

.tool-btn.primary {
    border-color: transparent;
    background: var(--text);
    color: var(--bg);
}

.deck-actions .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

#workspace {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 320px;
    /* Pin the single row to the workspace height: content (e.g. a sized HTML
       slide) must never grow the row, or slide sizing feeds back on itself. */
    grid-template-rows: minmax(0, 1fr);
    border-top: 1px solid var(--border);
}

#slide-sidebar,
#voice-panel {
    min-height: 0;
    background: color-mix(in srgb, var(--panel) 90%, transparent);
}

#slide-sidebar {
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    overflow-y: auto;
    scrollbar-width: none;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    padding: 0 6px 12px;
    color: var(--text-dim);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}

#slide-count {
    color: var(--text);
}

#slide-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
}

#slide-list li {
    border: 1px solid transparent;
    border-radius: 6px;
    transition: border-color .18s, background .18s;
}

#slide-list li.active {
    border-color: var(--accent);
    background: var(--surface-strong);
}

#slide-list li.drop-target {
    border-color: #f97316;
}

.slide-list-item {
    width: 100%;
    min-height: 64px;
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: start;
    gap: 8px;
    border: 0;
    padding: 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.slide-number {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-strong);
    color: var(--text-dim);
    font-size: .66rem;
}

.slide-list-title {
    padding-top: 2px;
    font-size: .76rem;
    font-weight: 600;
    line-height: 1.35;
}

#stage {
    height: auto;
    min-height: 0;
    overflow: hidden;
    padding: 22px 26px 62px;
}

#empty-state {
    max-width: 720px;
}

.empty-kicker,
.dialog-kicker {
    display: block;
    margin-bottom: 14px;
    color: #22d3a7;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
}

#empty-state h1 {
    font-family: 'Newsreader', serif;
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    font-weight: 600;
    line-height: .98;
    letter-spacing: 0;
}

#empty-state p {
    margin: 22px auto 24px;
}

#slide-host {
    width: 100%;
    height: 100%;
}

#slide-nav {
    position: absolute;
    bottom: 16px;
}

#voice-panel {
    border-left: 1px solid var(--border);
    padding: 22px 18px;
    overflow-y: auto;
}

.voice-heading {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 12px;
    align-items: start;
}

.voice-heading h2 {
    font-size: 1rem;
}

.voice-heading p {
    margin-top: 5px;
    color: var(--text-dim);
    font-size: .78rem;
    line-height: 1.45;
}

.voice-orbit {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(34, 211, 167, .5);
    border-radius: 50%;
    background: radial-gradient(circle, #22d3a7 0 16%, transparent 18%);
    box-shadow: inset 0 0 18px rgba(34, 211, 167, .18);
}

.voice-button {
    width: 100%;
    height: 54px;
    margin: 22px 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(34, 211, 167, .45);
    border-radius: 6px;
    background: rgba(34, 211, 167, .1);
    color: var(--text);
    font: 700 .9rem 'DM Sans', sans-serif;
    cursor: pointer;
}

.voice-button:hover:not(:disabled) {
    background: rgba(34, 211, 167, .18);
}

.voice-button:disabled {
    cursor: not-allowed;
    opacity: .38;
}

.voice-button.listening {
    border-color: #fb7185;
    background: rgba(251, 113, 133, .12);
    animation: voice-pulse 1.5s ease-in-out infinite;
}

.mic-symbol {
    color: #22d3a7;
    font-size: .72rem;
}

.voice-button.listening .mic-symbol {
    color: #fb7185;
}

@keyframes voice-pulse {
    50% {
        box-shadow: 0 0 0 7px rgba(251, 113, 133, .08);
    }
}

.last-command {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-left: 2px solid var(--accent);
    color: var(--text-dim);
    font-size: .78rem;
    font-style: italic;
    line-height: 1.45;
}

#command-form label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-dim);
    font-size: .72rem;
    font-weight: 600;
}

.command-entry {
    display: grid;
    grid-template-columns: 1fr 38px;
}

.command-entry input {
    min-width: 0;
    height: 40px;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 6px 0 0 6px;
    padding: 0 11px;
    background: var(--surface);
    color: var(--text);
    font: .8rem 'DM Sans', sans-serif;
    outline: 0;
}

.command-entry input:focus {
    border-color: var(--accent);
}

.command-entry button {
    border: 0;
    border-radius: 0 6px 6px 0;
    background: var(--text);
    color: var(--bg);
    font-size: 1.1rem;
    cursor: pointer;
}

.command-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.command-examples button {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 9px;
    background: transparent;
    color: var(--text-dim);
    font: 500 .68rem 'DM Sans', sans-serif;
    cursor: pointer;
}

.command-examples button:hover {
    border-color: var(--accent);
    color: var(--text);
}

.workspace-options {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: .75rem;
}

.workspace-options summary {
    cursor: pointer;
    font-weight: 600;
}

.workspace-options>label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.workspace-options .check {
    justify-content: flex-start;
}

.workspace-options select {
    min-width: 0;
    max-width: 175px;
}

.option-actions {
    display: grid;
    gap: 7px;
    margin-top: 14px;
}

.dialog-hint {
    margin: -8px 0 18px;
    color: var(--text-dim);
    font-size: .8rem;
    line-height: 1.5;
}

/* ---------- Interview dialog ---------- */
.command-entry.with-attach {
    grid-template-columns: 38px 1fr 38px;
}

#interview-attach {
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 6px 0 0 6px;
    background: var(--surface);
    color: var(--text);
    font-size: .95rem;
    cursor: pointer;
    transition: border-color .2s;
}

#interview-attach:hover {
    border-color: var(--accent);
}

.command-entry.with-attach input {
    border-radius: 0;
}

#interview-dialog {
    width: min(660px, 94vw);
}

#generation-recovery {
    position: fixed;
    z-index: 45;
    left: 50%;
    top: 68px;
    transform: translateX(-50%);
    width: min(680px, calc(100vw - 28px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .2);
}

#generation-recovery[hidden] {
    display: none;
}

#generation-recovery-message {
    min-width: 0;
    font-size: .84rem;
    line-height: 1.35;
}

@media (max-width: 560px) {
    #generation-recovery {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    #generation-resume {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

.discuss-button {
    width: 100%;
    margin-top: 8px;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: 600 .8rem 'DM Sans', sans-serif;
    cursor: pointer;
    transition: border-color .2s;
}

.discuss-button:hover:not(:disabled) {
    border-color: var(--accent);
}

.discuss-button:disabled {
    opacity: .45;
    cursor: default;
}

#interview-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    min-height: 320px;
    padding: 14px 8px 8px;
}

#interview-orb {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    position: relative;
    flex: none;
    background: radial-gradient(circle at 32% 28%, var(--accent-2, #67e8f9), var(--accent) 70%);
    box-shadow: 0 0 32px color-mix(in srgb, var(--accent) 40%, transparent);
    transition: transform .35s ease, box-shadow .35s ease, opacity .35s ease;
}

#interview-orb.idle {
    opacity: .75;
    animation: orb-breathe 4.5s ease-in-out infinite;
}

#interview-orb.thinking {
    animation: orb-think 1.3s ease-in-out infinite;
}

#interview-orb.speaking {
    animation: orb-speak .85s ease-in-out infinite;
}

#interview-orb.listening {
    animation: orb-breathe 2.2s ease-in-out infinite;
}

#interview-orb.listening::after {
    content: "";
    position: absolute;
    inset: -12px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: orb-ring 1.6s ease-out infinite;
}

@keyframes orb-breathe {

    0%,
    100% {
        transform: scale(.96);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes orb-think {

    0%,
    100% {
        opacity: .5;
        transform: scale(.92);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

@keyframes orb-speak {

    0%,
    100% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.14);
    }

    65% {
        transform: scale(.95);
    }
}

@keyframes orb-ring {
    from {
        opacity: .8;
        transform: scale(.88);
    }

    to {
        opacity: 0;
        transform: scale(1.55);
    }
}

#interview-agent-text {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.45;
    max-width: 42ch;
    min-height: 3.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

#interview-user-text {
    min-height: 1.6em;
    color: var(--text-dim);
    font-size: .98rem;
    font-style: italic;
    line-height: 1.5;
    max-width: 52ch;
    margin: 0;
}

.swap {
    animation: swap-in .5s cubic-bezier(.2, .8, .2, 1);
}

@keyframes swap-in {
    from {
        opacity: 0;
        transform: translateY(12px);
        filter: blur(3px);
    }

    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

@keyframes typing-pulse {

    0%,
    100% {
        opacity: .35;
    }

    50% {
        opacity: 1;
    }
}

#interview-dialog .brief-row {
    gap: 8px;
}

#interview-status {
    min-height: 16px;
    margin: 0;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
}

#interview-voice {
    margin-right: auto;
}

#interview-voice.listening {
    border-color: var(--accent);
    color: var(--accent);
    animation: typing-pulse 1.1s ease-in-out infinite;
}

/* ---------- Free-form HTML slides ---------- */
#slide-host.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide.html-slide {
    padding: 0;
    flex: none;
}

/* The AI owns the whole canvas: hide the built-in accent glow overlays. */
.slide.html-slide::before,
.slide.html-slide::after {
    display: none;
}

/* Oversized 1280x720 canvas: anchor at the card's center and let the
   translate+scale transform do the centering — grid/flex can't center an
   item bigger than its container (the track overflows instead). */
.html-slide-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1280px;
    height: 720px;
    transform-origin: center center;
}

.html-slide-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: transparent;
}

.deck-row button {
    border: 0;
    background: none;
    color: var(--text);
    font: 600 .88rem 'DM Sans', sans-serif;
    text-align: left;
    cursor: pointer;
}

body.presenting #topbar,
body.presenting #slide-sidebar,
body.presenting #voice-panel {
    display: none;
}

body.presenting #workspace {
    display: block;
    height: 100vh;
}

body.presenting #stage {
    height: 100vh;
    padding: 18px 18px 66px;
}

@media (max-width: 1250px) {
    #topbar {
        grid-template-columns: 150px minmax(120px, 1fr) auto;
    }

    #workspace {
        grid-template-columns: 170px minmax(0, 1fr) 280px;
    }
}

@media (max-width: 1000px) {
    #topbar {
        grid-template-columns: 140px 1fr;
    }

    .deck-actions {
        grid-column: 1 / -1;
        justify-content: center;
        flex-wrap: wrap;
    }

    #workspace {
        grid-template-columns: 150px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
    }

    #voice-panel {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(200px, 1fr) minmax(190px, 280px) minmax(220px, 1fr);
        gap: 14px;
        align-items: center;
        border-top: 1px solid var(--border);
        border-left: 0;
        padding: 12px 18px;
    }

    .voice-button {
        margin: 0;
    }

    .last-command,
    .command-examples,
    .workspace-options {
        display: none;
    }
}

@media (max-width: 700px) {
    #topbar {
        display: grid;
        grid-template-columns: 1fr auto;
        padding: 8px 10px;
    }

    .deck-identity {
        justify-content: flex-end;
    }

    .deck-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }

    #workspace {
        grid-template-columns: 1fr;
        grid-template-rows: 90px minmax(340px, 1fr) auto;
    }

    #slide-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 8px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .panel-heading {
        display: none;
    }

    #slide-list {
        flex-direction: row;
    }

    #slide-list li {
        flex: 0 0 130px;
    }

    .slide-list-item {
        min-height: 70px;
    }

    #stage {
        padding: 10px 10px 58px;
    }

    #voice-panel {
        grid-column: auto;
        grid-template-columns: 1fr;
    }

    .voice-heading {
        display: none;
    }

    #empty-state h1 {
        font-size: 2.6rem;
    }
}

.cmp-customScene {
    flex: 1 1 0;
    padding: 0;
    min-height: 180px;
    background: rgba(4, 10, 18, .42);
}

.cmp-customScene>.cmp-title {
    flex: 0 0 auto;
    margin: 0;
    padding: 12px 16px 0;
}

.custom-scene-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
    background: transparent;
}

/* ---------- Nasqia studio shell (never changes the 16:9 slide sizing contract) ---------- */
[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid #70bea5 !important;
    outline-offset: 4px;
}

button, input, select {
    font-family: inherit;
}

button:disabled {
    opacity: .48;
    cursor: not-allowed;
}

button:not(:disabled), summary, a {
    -webkit-tap-highlight-color: transparent;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: fixed;
    top: -80px;
    left: 18px;
    z-index: 100;
    padding: 12px;
    background: var(--panel);
    color: var(--text);
}

.skip-link:focus {
    top: 8px;
}

body.studio {
    background: radial-gradient(ellipse at 48% 35%, #1b36352e, transparent 70%), var(--bg);
}

.studio #topbar {
    grid-template-columns: 150px minmax(100px, 1fr) auto;
    gap: 16px;
    min-height: 76px;
    padding: 14px 22px;
    background: var(--panel);
}

.studio .brand {
    justify-content: flex-start;
    text-decoration: none;
}

.brand img {
    display: block;
}

.studio .deck-identity {
    display: grid;
    gap: 4px;
    border-left: 1px solid var(--border);
    padding-left: 20px;
}

.studio #deck-title {
    font-size: .82rem;
    font-weight: 500;
}

.studio #save-state {
    font-size: .69rem;
}

.studio .tool-btn, .studio .icon-btn, .studio #design-select {
    border-radius: 9px;
    min-height: 38px;
}

.studio .tool-btn {
    white-space: nowrap;
}

.studio .tool-btn.primary, .studio .btn-primary {
    background: #d5edbc;
    color: #153731;
    border-color: transparent;
}

.studio .btn-primary {
    padding: 13px 23px;
    border-radius: 10px;
}

.studio .btn-ghost {
    border-radius: 10px;
}

.studio .credit-pill {
    color: #b6d8a7;
    background: #70bea50c;
    border-color: #70bea540;
    font-variant-numeric: tabular-nums;
}

.studio #workspace {
    grid-template-columns: 172px minmax(0, 1fr) 292px;
    grid-template-rows: minmax(0, 1fr);
    border-top: 0;
}

.studio #slide-sidebar, .studio #voice-panel {
    background: color-mix(in srgb, var(--panel) 55%, var(--bg));
}

.studio #slide-sidebar {
    padding: 22px 12px;
}

.studio .panel-heading {
    letter-spacing: .12em;
    font-size: .64rem;
}

.studio #slide-list li {
    border-radius: 10px;
}

.studio .slide-list-item {
    min-height: 80px;
    align-items: center;
}

.studio #slide-list:empty::after {
    content: "Your story will unfold here.";
    display: block;
    padding: 30px 10px;
    color: var(--text-dim);
    font-size: .76rem;
    line-height: 1.8;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.studio #stage {
    overflow: hidden;
    min-width: 0;
}

.studio #stage:has(#empty-state:not([hidden])) {
    overflow-y: auto;
    display: block;
    padding: clamp(26px, 5vh, 64px) 28px;
}

.studio #empty-state {
    margin: auto;
    width: 100%;
    max-width: 760px;
}

.welcome-emblem {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.welcome-emblem span {
    font-size: .74rem;
    color: var(--text-dim);
    letter-spacing: .015em;
}

.studio .empty-kicker, .studio .dialog-kicker {
    color: #9dcab6;
    font-size: .65rem;
    letter-spacing: .18em;
}

.studio #empty-state h1 {
    font-size: clamp(2.5rem, 4.7vw, 4.8rem);
    line-height: 1.07;
    letter-spacing: -.025em;
    margin-bottom: 0;
}

.studio #empty-state .grad {
    color: #aacaad;
    background: none;
    font-style: italic;
}

.studio #empty-state p {
    font-size: .91rem;
    max-width: 50ch;
    line-height: 1.75;
    margin: 20px auto 24px;
}

.studio #empty-state .welcome-credit {
    font-size: .7rem;
    margin: 13px auto 32px;
}

.welcome-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    list-style: none;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.welcome-steps li {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.welcome-steps li>span {
    font-size: .66rem;
    color: #aacaad;
    font-variant-numeric: tabular-nums;
}

.welcome-steps strong {
    font-size: .78rem;
    font-weight: 500;
}

.welcome-steps small {
    color: var(--text-dim);
    font-size: .72rem;
    line-height: 1.6;
}

.text-button {
    background: none;
    border: 0;
    color: var(--text-dim);
    padding: 10px 0;
    font-size: .77rem;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
}

#welcome-pricing {
    margin-top: 18px;
    font-size: .7rem;
}

.studio #voice-panel {
    padding: 26px 20px;
}

.studio .voice-heading {
    grid-template-columns: 1fr;
    gap: 14px;
}

.studio .voice-orbit {
    background: url('../brand/nasqia-mark.svg') center / contain no-repeat;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.studio .voice-heading h2 {
    font-size: .96rem;
    font-weight: 500;
}

.studio .voice-heading p {
    font-size: .77rem;
    line-height: 1.7;
}

.studio .voice-button {
    margin: 26px 0 8px;
    border-radius: 12px;
    border-color: #70bea544;
    background: #70bea50d;
    font-size: .82rem;
}

.studio .discuss-button {
    margin: 0 0 24px;
    border-radius: 10px;
    font-weight: 500;
}

.studio .command-entry input {
    height: 46px;
    font-size: .8rem;
}

.studio .command-entry button {
    background: #c4ddb5;
    color: #123c3b;
}

.studio .command-examples {
    gap: 8px;
}

.studio .command-examples button {
    text-align: left;
    line-height: 1.4;
}

.panel-note {
    font-size: .71rem;
    color: var(--text-dim);
    line-height: 1.8;
    margin-top: 28px;
}

.studio .workspace-options {
    margin-top: 28px;
}

.studio dialog {
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 30px;
    border-radius: 22px;
    background: var(--panel);
}

.studio dialog h2 {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 2rem;
    font-weight: 500;
    margin: 12px 0 20px;
}

.studio dialog .brief-row {
    flex-wrap: wrap;
    gap: 10px;
}

.dialog-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.dialog-heading .icon-btn {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.inline-error {
    padding: 12px 14px;
    margin: 12px 0;
    border: 1px solid #efb49b66;
    background: #dc794712;
    border-radius: 10px;
    color: #f6c4af;
    font-size: .82rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

#credits-dialog {
    width: min(590px, 94vw);
}

.balance-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
    background: linear-gradient(115deg, #284b43, #193332);
    border: 1px solid #70bea54d;
    border-radius: 14px;
    color: #edf3ed;
}

.balance-card>span {
    font-size: .75rem;
    color: #c7dccb;
}

.balance-card strong {
    font-size: 2.7rem;
    font-weight: 500;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.balance-card small {
    color: #c7dccb;
    font-size: .72rem;
}

.credit-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 18px 0 24px;
}

.credit-totals dt {
    font-size: .7rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.credit-totals dd {
    font-size: .93rem;
    font-variant-numeric: tabular-nums;
}

.pricing-copy {
    font-size: .78rem;
    color: var(--text-dim);
    line-height: 1.75;
    margin: 14px 0;
}

.credit-actions, .account-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.usage-section {
    border-top: 1px solid var(--border);
    padding-top: 22px;
    margin-top: 24px;
}

.usage-section .dialog-heading {
    margin-bottom: 12px;
}

.usage-section h3 {
    font-size: .86rem;
    font-weight: 500;
}

.usage-section .dialog-heading span, #usage-status {
    font-size: .71rem;
    color: var(--text-dim);
    line-height: 1.6;
}

#usage-list {
    list-style: none;
    margin-top: 12px;
    max-height: 260px;
    overflow-y: auto;
}

.usage-row {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.usage-row>div {
    min-width: 0;
}

.usage-row strong {
    font-size: .78rem;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.usage-row small {
    display: block;
    font-size: .67rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.usage-amount {
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#credits-loading {
    padding: 16px 0;
    color: var(--text-dim);
    font-size: .85rem;
}

#connection-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
    flex-shrink: 0;
}

#exit-presentation {
    position: fixed;
    z-index: 20;
    top: 12px;
    right: 12px;
    background: var(--panel);
}

.studio[data-access="signed-out"] #workspace {
    grid-template-columns: 1fr;
}

.studio[data-access="signed-out"] #slide-sidebar, .studio[data-access="signed-out"] #voice-panel,
.studio[data-access="signed-out"] .deck-identity, .studio[data-access="signed-out"] .deck-actions> :not(#btn-account) {
    display: none;
}

.studio[data-access="signed-out"] #topbar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.studio[data-access="signed-out"] #empty-state {
    max-width: 810px;
}

.studio[data-access="signed-out"] #stage {
    padding-top: clamp(32px, 8vh, 96px);
}

.studio[data-access="signed-out"] #empty-state h1 {
    font-size: clamp(3rem, 6vw, 5.5rem);
}

.studio[data-access="loading"] #workspace {
    opacity: .75;
}

[data-theme="light"] .studio {
    --bg: #f5f5ed;
    --panel: #fdfdf7;
    --text: #183b36;
    --text-dim: #516b64;
    --accent: #387361;
}

[data-theme="light"] .studio .empty-kicker, [data-theme="light"] .studio .dialog-kicker,
[data-theme="light"] .studio #empty-state .grad, [data-theme="light"] .studio .welcome-steps li>span {
    color: #3c7059;
}

[data-theme="light"] .studio .credit-pill {
    color: #315d45;
}

[data-theme="light"] .studio .inline-error {
    color: #8b3a22;
}

.studio.presenting #workspace {
    display: block;
}

@media (max-width: 1250px) {
    .studio #topbar {
        grid-template-columns: 150px 1fr;
    }

    .studio .deck-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .studio .deck-actions>* {
        flex-shrink: 0;
    }

    .studio #workspace {
        grid-template-columns: 144px minmax(0, 1fr) 250px;
    }

    .studio #voice-panel {
        padding: 24px 16px;
    }

    .studio #empty-state h1 {
        font-size: clamp(2.4rem, 4.5vw, 4rem);
    }
}

@media (max-width: 1000px) {
    .studio #workspace {
        grid-template-columns: 126px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .studio #voice-panel {
        display: grid;
        grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr);
        gap: 10px 18px;
        max-height: 220px;
        overflow-y: auto;
        padding: 14px 18px;
    }

    .studio .voice-heading {
        display: none;
    }

    .studio .voice-button, .studio .discuss-button {
        margin: 0;
        min-height: 42px;
        height: 42px;
    }

    .studio .workspace-options {
        display: block;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .studio .panel-note {
        display: none;
    }

    .studio[data-access="signed-out"] #workspace {
        grid-template-rows: minmax(0, 1fr);
    }
}

@media (max-width: 700px) {
    html:has(.studio), body.studio {
        height: 100%;
        height: 100dvh;
    }

    .studio #topbar {
        padding: 10px 14px;
        gap: 10px;
    }

    .studio .deck-identity {
        padding-left: 10px;
        text-align: right;
    }

    .studio .deck-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 2px 0 6px;
    }

    .studio .deck-actions>* {
        flex-shrink: 0;
    }

    .studio #workspace {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 66px minmax(0, 1fr) auto;
    }

    .studio #slide-sidebar {
        padding: 6px 10px;
    }

    .studio .slide-list-item {
        min-height: 50px;
    }

    .studio .slide-list-title {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
    }

    .studio #slide-list:empty::after {
        padding: 12px;
        width: 100%;
        border: 0;
    }

    .studio #stage {
        padding: 10px 10px 52px;
    }

    .studio #stage:has(#empty-state:not([hidden])) {
        padding: 24px 20px;
    }

    .welcome-emblem {
        margin-bottom: 24px;
    }

    .welcome-emblem img {
        width: 44px;
        height: 44px;
    }

    .studio #empty-state h1 {
        font-size: clamp(2.2rem, 8vw, 3.5rem);
    }

    .welcome-steps {
        gap: 12px;
    }

    .welcome-steps small {
        font-size: .67rem;
    }

    .studio #voice-panel {
        grid-column: auto;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        max-height: 158px;
        gap: 8px;
        padding: 10px 14px;
    }

    .studio #command-form {
        grid-column: 1 / -1;
    }

    .studio #voice-panel .workspace-options {
        grid-column: 1 / -1;
    }

    .studio .voice-button, .studio .discuss-button {
        font-size: .74rem;
    }

    .studio dialog {
        padding: 22px;
        max-height: 92dvh;
    }

    #interview-stage {
        min-height: 220px;
    }

    #interview-agent-text {
        font-size: 1.15rem;
    }

    #interview-dialog .brief-row .btn {
        padding: 10px;
        font-size: .75rem;
    }

    #interview-build {
        width: 100%;
        order: -1;
    }

    .studio[data-access="signed-out"] #workspace {
        grid-template-rows: minmax(0, 1fr);
    }

    .studio[data-access="signed-out"] #topbar .deck-actions {
        padding: 0;
    }

    .studio[data-access="signed-out"] #topbar .tool-btn {
        font-size: .7rem;
    }

    .studio[data-access="signed-out"] #topbar .brand img {
        width: 115px;
    }

    #connection-banner {
        align-items: flex-start;
        font-size: .72rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@media (max-height: 600px) and (min-width: 701px) and (max-width: 1000px) {
    .studio #voice-panel {
        max-height: 112px;
        padding: 8px 18px;
    }

    .studio #topbar {
        padding-top: 8px;
        padding-bottom: 8px;
        gap: 8px;
    }
}