:root {
    --sn-border: #e2e6ee;
    --sn-border-strong: #b6bac0;
    --sn-muted: #64748b;
    --sn-ink: #1e2530;
    --sn-canvas: #eceff5;
    --sn-accent: #2563eb;
    --sn-accent-soft: #eef4ff;
    --sn-panel: #f7f9fc;
    --sn-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --sn-shadow-md: 0 6px 18px rgba(16, 24, 40, 0.08);
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--sn-ink);
    background: #f4f7fb;
}

h1:focus {
    outline: none;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--sn-accent);
    outline-offset: 1px;
}

/* ---------- Landing / upload ---------- */

.landing {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.25rem 3rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.16), transparent 55%),
        linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.landing-card {
    width: min(36rem, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.landing-logo {
    width: 8.5rem;
    height: 8.5rem;
    border-radius: 1.35rem;
    object-fit: cover;
    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.06),
        0 18px 40px rgba(37, 99, 235, 0.22);
    margin-bottom: 1.5rem;
}

.landing h1 {
    font-size: clamp(1.45rem, 3vw, 1.85rem);
    font-weight: 650;
    letter-spacing: -0.03em;
    margin: 0 0 0.45rem;
    color: #111827;
}

.upload-lede {
    color: var(--sn-muted);
    margin: 0 0 1.75rem;
    max-width: 28rem;
    line-height: 1.5;
}

.landing-steps {
    display: flex;
    gap: 0.6rem;
    list-style: none;
    padding: 0;
    margin: 1.35rem 0 0;
    color: var(--sn-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.landing-steps li {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.landing-steps li:not(:last-child)::after {
    content: "";
    width: 1.25rem;
    height: 1px;
    background: var(--sn-border);
}

.landing-ready {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    text-align: left;
}

.landing-ready-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 12.5rem;
    padding: 2rem 1.5rem;
    text-align: center;
    border: 1.5px dashed #c5d0e0;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
    backdrop-filter: blur(8px);
    transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.dropzone.is-active {
    border-color: var(--sn-accent);
    background: #eff4ff;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.12);
}

.dropzone.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.dropzone-icon {
    font-size: 1.9rem;
    line-height: 1;
}

.dropzone-title {
    font-weight: 600;
}

.dropzone-hint {
    color: var(--sn-muted);
    font-size: 0.875rem;
}

/* The file input covers the whole zone so native click-to-browse and drag-and-drop both work. */
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.progress-card {
    width: 100%;
    margin-top: 1.25rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--sn-border);
    border-radius: 0.9rem;
    background: #ffffff;
    text-align: left;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* ---------- Editor screen ---------- */

.editor-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100dvh;
}

.editor {
    display: grid;
    grid-template-columns: 19rem minmax(0, 1fr);
    flex: 1;
    min-height: 0;
}

/* ---------- Sidebar ---------- */

.editor-sidebar {
    border-right: 1px solid var(--sn-border);
    background: #ffffff;
    padding: 1rem 1rem 3rem;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
}

.editor-sidebar-toggle {
    display: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
}

.editor-sidebar-toggle::-webkit-details-marker {
    display: none;
}

.control-group {
    border: 1px solid var(--sn-border);
    border-radius: 0.85rem;
    background: var(--sn-panel);
    padding: 0.9rem 0.85rem 0.75rem;
    margin-bottom: 0.75rem;
}

.control-group h2 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 650;
    color: var(--sn-muted);
    margin: 0 0 0.8rem;
}

.control {
    margin-bottom: 0.9rem;
}

.control:last-child {
    margin-bottom: 0.15rem;
}

.control > label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 550;
    margin-bottom: 0.4rem;
}

.control-value {
    flex: none;
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--sn-accent);
    background: var(--sn-accent-soft);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.control-nested {
    padding-left: 0.1rem;
    margin-top: -0.2rem;
}

.editor-sidebar .form-select,
.editor-sidebar .form-control {
    border-color: var(--sn-border);
    border-radius: 0.55rem;
    background-color: #ffffff;
    font-size: 0.82rem;
}

/* Slider: thin neutral track with an accent thumb, instead of Bootstrap's solid blue puck. */
.editor-sidebar .form-range {
    height: 1.1rem;
    padding: 0;
}

.editor-sidebar .form-range::-webkit-slider-runnable-track {
    height: 0.3rem;
    border-radius: 999px;
    background: #dbe1ec;
}

.editor-sidebar .form-range::-moz-range-track {
    height: 0.3rem;
    border-radius: 999px;
    background: #dbe1ec;
}

.editor-sidebar .form-range::-webkit-slider-thumb {
    width: 0.95rem;
    height: 0.95rem;
    margin-top: -0.325rem;
    background: #ffffff;
    border: 2px solid var(--sn-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
    transition: transform 120ms ease;
}

.editor-sidebar .form-range::-moz-range-thumb {
    width: 0.95rem;
    height: 0.95rem;
    background: #ffffff;
    border: 2px solid var(--sn-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
}

.editor-sidebar .form-range:active::-webkit-slider-thumb {
    transform: scale(1.15);
}

.segmented {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    border: 1px solid var(--sn-border);
    border-radius: 0.65rem;
    background: #ffffff;
}

.segmented button {
    flex: 1;
    padding: 0.3rem 0;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--sn-muted);
    font-size: 0.85rem;
    font-weight: 550;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.segmented button:hover:not(.is-selected) {
    background: var(--sn-panel);
    color: var(--sn-ink);
}

.segmented button.is-selected {
    background: var(--sn-accent);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.35);
}

/* Label on the left, switch on the right, in a tappable row. */
.toggle.form-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem;
    margin: 0 0 0.15rem;
    border-radius: 0.55rem;
    min-height: 2rem;
    transition: background-color 120ms ease;
}

.toggle.form-check:hover {
    background: #ffffff;
}

.toggle .form-check-label {
    order: -1;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
}

.toggle .form-check-input {
    float: none;
    flex: none;
    margin: 0;
    width: 2.1rem;
    height: 1.1rem;
    cursor: pointer;
    border-color: #cbd3e1;
}

.toggle .form-check-input:checked {
    background-color: var(--sn-accent);
    border-color: var(--sn-accent);
}

/* ---------- Toolbar ---------- */

.editor-chrome {
    position: sticky;
    top: 0;
    z-index: 50;
    flex: none;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 var(--sn-border), 0 4px 14px rgba(16, 24, 40, 0.05);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
}

.editor-brand {
    display: inline-flex;
    flex: none;
    border-radius: 0.6rem;
    line-height: 0;
    transition: transform 140ms ease;
}

.editor-brand:hover {
    transform: translateY(-1px);
}

.editor-brand img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.6rem;
    object-fit: cover;
    box-shadow: var(--sn-shadow-sm);
}

.doc-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.editor-toolbar .spacer {
    flex: 1;
}

.doc-name {
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-meta {
    color: var(--sn-muted);
    font-size: 0.76rem;
}

.chip {
    flex: none;
    font-size: 0.74rem;
    font-weight: 550;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    border: 1px solid transparent;
}

.chip-warn {
    color: #92400e;
    background: #fef3c7;
    border-color: #fcd34d;
}

.chip-danger {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fca5a5;
}

.btn-soft {
    color: var(--sn-ink);
    background: #ffffff;
    border: 1px solid var(--sn-border);
}

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

.editor-toolbar .btn {
    flex: none;
    border-radius: 0.55rem;
    font-weight: 550;
    font-size: 0.82rem;
    padding: 0.35rem 0.85rem;
}

.editor-toolbar .btn-primary {
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3), 0 4px 12px rgba(37, 99, 235, 0.22);
}

/* ---------- Canvas ---------- */

.editor-canvas {
    background-color: var(--sn-canvas);
    background-image: radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.07) 1px, transparent 0);
    background-size: 22px 22px;
    overflow: auto;
    padding: 1.75rem 1rem 4rem;
    min-height: 0;
}

.page-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Keeps the left edge reachable when a sheet is wider than the canvas. */
    align-items: safe center;
    gap: 1.5rem;
    zoom: var(--page-zoom, 1);
}

.page-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex: none;
}

.page-caption {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--sn-muted);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
}

.page-sheet {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 2px;
    box-shadow:
        0 0 0 1px rgba(16, 24, 40, 0.06),
        0 2px 4px rgba(16, 24, 40, 0.06),
        0 14px 34px rgba(16, 24, 40, 0.13);
    flex: none;
}

.page-header,
.page-footer {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
    font-size: 9pt;
    color: var(--sn-ink);
    overflow: hidden;
}

.page-header {
    font-weight: 600;
    align-items: flex-end;
}

.page-footer {
    color: var(--sn-muted);
    font-size: 8pt;
}

.page-footer .page-number {
    margin-left: auto;
}

.page-rows {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.page-row {
    display: grid;
    box-sizing: border-box;
    flex: none;
    min-height: 0;
}

.slide-cell {
    container-type: size;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

/* Tight box around the rendered slide — not the leftover letterbox in the cell. */
.slide-frame {
    position: relative;
    aspect-ratio: var(--slide-aspect, 16 / 9);
    width: min(100cqw, calc(100cqh * var(--slide-aspect, 1.777)));
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    background: #ffffff;
    border: 0.4px solid var(--sn-border-strong);
    transition: box-shadow 140ms ease;
}

.slide-cell:hover .slide-frame {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.slide-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.slide-number {
    position: absolute;
    top: 1.4mm;
    left: 1.4mm;
    z-index: 1;
    font-size: 7.5pt;
    font-weight: 600;
    color: #475569;
    background: rgba(255, 255, 255, 0.85);
    padding: 0 0.4em;
    border-radius: 999px;
    pointer-events: none;
}

.notes-cell {
    position: relative;
    box-sizing: border-box;
    border: 0.4px solid var(--sn-border-strong);
    min-width: 0;
    min-height: 0;
    display: flex;
    /* Nothing inside a cell may spill onto the printed page. */
    overflow: hidden;
    font-size: var(--notes-size, 10pt);
    transition: box-shadow 140ms ease;
    cursor: text;
}

.notes-cell:hover:not(.is-editing) {
    box-shadow: inset 0 0 0 1.5px rgba(37, 99, 235, 0.22);
}

.notes-cell.is-overflowing {
    border-color: #d97706;
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.35);
}

.notes-body {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    outline: none;
    line-height: 1.35;
    padding: var(--notes-pad, 3mm);
}

.notes-body p,
.notes-body ul,
.notes-body ol {
    margin: 0 0 0.35em;
}

.notes-body p:last-child,
.notes-body ul:last-child,
.notes-body ol:last-child {
    margin-bottom: 0;
}

.notes-body ul,
.notes-body ol {
    padding-left: 1.6em;
}

/*
 * Quill 2 emits every list as <ol> and records the real kind on the item, so the marker has to be
 * drawn from data-list instead of the list tag.
 */
.notes-body ol {
    list-style: none;
    counter-reset: notes-list;
}

.notes-body ol > li {
    position: relative;
    counter-increment: notes-list;
}

.notes-body ol > li::before {
    content: counter(notes-list) ".";
    position: absolute;
    left: -1.6em;
    width: 1.3em;
    text-align: right;
}

.notes-body ol > li[data-list="bullet"] {
    counter-increment: none;
}

.notes-body ol > li[data-list="bullet"]::before {
    content: "•";
}

/* Quill's checkbox affordance; it carries no note content. */
.notes-body .ql-ui {
    display: none;
}

/* Quill writes these classes into the HTML; they only apply inside .ql-editor unless repeated. */
.notes-body .ql-align-center {
    text-align: center;
}

.notes-body .ql-align-right {
    text-align: right;
}

.notes-body .ql-align-justify {
    text-align: justify;
}

.notes-body .ql-indent-1 { padding-left: 3em; }
.notes-body .ql-indent-2 { padding-left: 6em; }
.notes-body .ql-indent-3 { padding-left: 9em; }
.notes-body .ql-indent-4 { padding-left: 12em; }
.notes-body .ql-indent-5 { padding-left: 15em; }
.notes-body .ql-indent-6 { padding-left: 18em; }
.notes-body .ql-indent-7 { padding-left: 21em; }
.notes-body .ql-indent-8 { padding-left: 24em; }

.notes-body .ql-size-small {
    font-size: 0.75em;
}

.notes-body .ql-size-large {
    font-size: 1.5em;
}

.notes-body .ql-size-huge {
    font-size: 2.5em;
}

.notes-body:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.notes-placeholder::before {
    content: "Speaker notes…";
    color: #adb5bd;
}

.overflow-badge {
    position: absolute;
    right: 1mm;
    bottom: 1mm;
    font-size: 7pt;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 3px;
    padding: 0 0.35em;
    pointer-events: none;
}

.row-empty {
    border: 0.4px dashed var(--sn-border);
    box-sizing: border-box;
    grid-column: 1 / -1;
}

/* ---------- Quill overrides ---------- */

/* Quill turns the element it is given into .ql-container, so both classes are the same node. */
.notes-cell .notes-quill {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.35;
}

.notes-cell .ql-editor {
    flex: 1;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding: var(--notes-pad, 3mm);
}

.notes-cell .ql-editor.ql-blank::before {
    left: var(--notes-pad, 3mm);
    right: var(--notes-pad, 3mm);
    font-style: normal;
    color: #adb5bd;
}

.notes-cell.is-editing {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.45);
}

/*
 * Floats beside the cell being edited and is anchored by JS. It lives in <body>, outside the page
 * sheet, so edit mode cannot change the printed layout — and nothing clips its dropdown menus.
 */
.notes-toolbar-floating {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    max-width: calc(100vw - 1rem);
}

.notes-toolbar-floating.is-hidden {
    display: none;
}

.notes-toolbar-floating .ql-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.1rem;
    border: 1px solid var(--sn-border);
    border-radius: 0.7rem;
    background: #ffffff;
    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.08),
        0 10px 28px rgba(16, 24, 40, 0.18);
    padding: 0.25rem 0.4rem;
}

.notes-toolbar-floating .ql-formats {
    margin-right: 0.4rem;
}

.notes-toolbar-floating .ql-toolbar button:hover,
.notes-toolbar-floating .ql-toolbar .ql-picker-label:hover {
    background: var(--sn-panel);
    border-radius: 0.35rem;
}

.notes-toolbar-floating .ql-toolbar button.ql-active,
.notes-toolbar-floating .ql-toolbar .ql-picker-label.ql-active {
    background: var(--sn-accent-soft);
    border-radius: 0.35rem;
}

.notes-toolbar-floating .ql-picker-options {
    border-radius: 0.5rem;
    border-color: var(--sn-border);
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16);
}

@media (max-width: 900px) {
    .landing {
        align-items: flex-start;
        padding: 2rem 1rem 2.5rem;
    }

    .landing-logo {
        width: 6.5rem;
        height: 6.5rem;
        border-radius: 1.1rem;
        margin-bottom: 1.15rem;
    }

    .dropzone {
        min-height: 11rem;
        padding: 1.25rem;
    }

    .editor-shell {
        height: auto;
        min-height: 100%;
    }

    .editor {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    .editor-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--sn-border);
        padding: 0.75rem 1rem 1rem;
        max-height: none;
        overflow: visible;
    }

    .editor-sidebar-toggle {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.35rem 0 0.6rem;
    }

    .editor-sidebar-toggle::after {
        content: "▾";
        color: var(--sn-muted);
        font-size: 0.8rem;
    }

    .editor-sidebar[open] .editor-sidebar-toggle::after {
        content: "▴";
    }

    .editor-sidebar:not([open]) {
        padding-bottom: 0.75rem;
    }

    .editor-sidebar:not([open]) > :not(summary) {
        display: none;
    }

    .editor-toolbar {
        padding: 0.55rem 0.75rem;
        gap: 0.5rem;
    }

    .doc-info {
        flex: 1 1 8rem;
        min-width: 0;
    }

    .editor-canvas {
        padding: 0.75rem 0.5rem 3rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-stack {
        zoom: min(var(--page-zoom, 1), 0.48);
    }

    .notes-toolbar-floating .ql-toolbar {
        max-width: calc(100vw - 1rem);
    }
}

@media (max-width: 640px) {
    .landing-ready,
    .landing-ready-actions {
        width: 100%;
    }

    .landing-ready-actions .btn {
        flex: 1;
    }

    .landing-steps {
        flex-wrap: wrap;
        justify-content: center;
    }

    .editor-toolbar .btn {
        flex: 1 1 auto;
    }
}
