:root {
    --sn-border: #d7dbe0;
    --sn-border-strong: #b6bac0;
    --sn-muted: #6c757d;
    --sn-ink: #212529;
    --sn-canvas: #eef0f3;
    --sn-accent: #2563eb;
}

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: #ffffff;
}

h1:focus {
    outline: none;
}

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

/* ---------- Upload screen ---------- */

.upload-screen {
    max-width: 42rem;
    margin: 0 auto;
    padding: 3rem 1.25rem 4rem;
}

.upload-screen h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.upload-lede {
    color: var(--sn-muted);
    margin-bottom: 1.75rem;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 14rem;
    padding: 2rem;
    text-align: center;
    border: 2px dashed var(--sn-border-strong);
    border-radius: 0.9rem;
    background: #fafbfc;
    transition: border-color 120ms ease, background-color 120ms ease;
}

.dropzone.is-active {
    border-color: var(--sn-accent);
    background: #eff4ff;
}

.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 {
    margin-top: 1.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--sn-border);
    border-radius: 0.75rem;
    background: #ffffff;
}

.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;
    height: 100%;
    min-height: 0;
}

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

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

.editor-sidebar h2 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sn-muted);
    margin: 1.35rem 0 0.6rem;
}

.editor-sidebar h2:first-of-type {
    margin-top: 0.25rem;
}

.control {
    margin-bottom: 0.85rem;
}

.control > label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.control-value {
    color: var(--sn-muted);
    font-weight: 400;
}

.segmented {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.segmented button {
    flex: 1 0 2.4rem;
    padding: 0.35rem 0;
    border: 1px solid var(--sn-border);
    border-radius: 0.4rem;
    background: #ffffff;
    font-size: 0.85rem;
    cursor: pointer;
}

.segmented button.is-selected {
    border-color: var(--sn-accent);
    background: #eff4ff;
    color: var(--sn-accent);
    font-weight: 600;
}

.editor-canvas {
    background: var(--sn-canvas);
    overflow: auto;
    padding: 1.75rem 1rem 4rem;
    min-height: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.6rem 1rem;
    background: #ffffff;
    border-bottom: 1px solid var(--sn-border);
    flex: none;
    z-index: 30;
}

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

.doc-name {
    font-weight: 600;
}

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

.page-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
}

.page-sheet {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 12px 28px rgba(16, 24, 40, 0.14);
    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 {
    border-bottom: 0.4px solid var(--sn-border-strong);
    font-weight: 600;
    align-items: flex-end;
    padding-bottom: 1mm;
}

.page-footer {
    border-top: 0.4px solid var(--sn-border-strong);
    color: var(--sn-muted);
    font-size: 8pt;
    padding-top: 1mm;
}

.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 {
    position: relative;
    box-sizing: border-box;
    border: 0.4px solid var(--sn-border-strong);
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.slide-number {
    position: absolute;
    top: 1.4mm;
    left: 1.4mm;
    font-size: 7.5pt;
    color: var(--sn-muted);
    background: rgba(255, 255, 255, 0.78);
    padding: 0 0.35em;
    border-radius: 2px;
    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);
}

.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.4em;
}

.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);
}

/*
 * The toolbar is moved out of the cell into this strip while editing. Keeping it outside the
 * page sheet means switching a cell into edit mode never changes the printed layout.
 */
.notes-toolbar-host {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    justify-content: center;
    background: #ffffff;
    border-bottom: 1px solid var(--sn-border);
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.06);
}

.notes-toolbar-host:empty {
    display: none;
}

.notes-toolbar-host .ql-toolbar {
    border: none;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .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);
    }
}
