/* CineWrite – design "Moderne manus" (variant C). Assembled from sections 01–10. */

/* 01-base: tokens, reset, typography, buttons, utilities, scrollbars (CineWrite variant C "Moderne manus") */

/* Fonts (Schibsted Grotesk, Instrument Serif, Courier Prime) are loaded by the
   Google Fonts <link> in index.html; the old @import of Courier Prime is dropped. */

/* ========================================== */
/* Design tokens                              */
/* ========================================== */

/* Dark theme: ":root" without .light-mode (picked with the theme toggle). */
:root {
    color-scheme: dark;

    --paper: #171612;
    --surface: #201E19;
    --surface-2: #1B1915;
    --fill: #2A2721;
    --line: #3A362E;
    --line-strong: #4A453B;
    --ink: #EDE9E1;
    --muted: #ABA497;
    --on-ink: #171612;
    --red: #E58A7E;
    --red-bg: #3A201C;
    --blue: #9DB2E8;
    --sel: #3A362E;
    --backdrop: rgba(0, 0, 0, .6);

    /* Screenplay page + title page: paper-white with ink text in both themes */
    --page-bg: #FFFFFF;
    --page-ink: #1E1B16;
    --page-muted: #5E5850;
    --page-line: #DAD5CB;

    --font-ui: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-title: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-editor: 'Courier Prime', 'Courier New', Courier, monospace;

    /* Legacy aliases, kept so every older rule keeps resolving */
    --bg-dark: var(--paper);
    --bg-main: var(--paper);
    --bg-card: var(--surface);
    --bg-input: var(--surface);
    --border-color: var(--line);
    --border-hover: var(--line-strong);

    --primary: var(--ink);
    --primary-glow: transparent;
    --accent: var(--ink);
    --accent-glow: transparent;

    --text-main: var(--ink);
    --text-muted: var(--muted);
    --text-dim: var(--muted);
    --error: var(--red);
    --success: var(--ink);

    --font-display: var(--font-title);
    --font-header: var(--font-title);

    --sidebar-width: 320px;
    --ai-sidebar-width: 320px;

    --transition-speed: 0.25s;
    --card-shadow: 0 1px 2px rgba(30, 27, 22, .06);
    --glow-shadow: none;
}

/* Light theme "C": the default look (html.light-mode). Only colour tokens
   change; aliases, fonts and sizes are inherited from :root. */
html.light-mode {
    color-scheme: light;

    --paper: #F3F0EA;
    --surface: #FFFFFF;
    --surface-2: #FAF9F6;
    --fill: #E9E5DD;
    --line: #DAD5CB;
    --line-strong: #D3CDC2;
    --ink: #1E1B16;
    --muted: #5E5850;
    --on-ink: #FFFFFF;
    --red: #962117;
    --red-bg: #F6E7E4;
    --blue: #2E3F6E;
    --sel: #E9E5DD;
    --backdrop: rgba(30, 27, 22, .45);
}

/* Custom Text Selection Styling */
::selection {
    background: var(--sel);
    color: inherit;
}
::-moz-selection {
    background: var(--sel);
    color: inherit;
}
/* The screenplay page / title page is paper-white in both themes, so the dark
   --sel (#3A362E) would put page-ink on near-black. Use the fixed page tint. */
.screenplay-page::selection,
.screenplay-page ::selection {
    background: var(--page-line);
    color: var(--page-ink);
}
.screenplay-page::-moz-selection,
.screenplay-page ::-moz-selection {
    background: var(--page-line);
    color: var(--page-ink);
}

/* ========================================== */
/* Base Styles                                */
/* ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background-color: var(--paper);
}
/* scrollbar-color is inherited and, in Chromium 121+, switches off every
   ::-webkit-scrollbar rule (the 8px scrollbars below). Only give it to
   browsers without ::-webkit-scrollbar support (Firefox). */
@supports not selector(::-webkit-scrollbar) {
    html {
        scrollbar-color: var(--line-strong) transparent;
    }
}

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    overflow-x: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

a {
    color: var(--ink);
    text-decoration: none;
    text-underline-offset: .2em;
    transition: color var(--transition-speed);
}
a:hover {
    color: var(--ink);
    text-decoration: underline;
}
/* Links inside running text are always underlined (not colour-only). */
:where(p, li) a {
    text-decoration: underline;
}

button, input, select, textarea {
    font-family: inherit;
}

/* Zero-specificity baseline so native controls never fall back to the
   browser's black text in dark mode; component sections style the rest. */
:where(input, select, textarea) {
    color: var(--ink);
    accent-color: var(--ink);
}
::placeholder {
    color: var(--muted);
    opacity: 1;
}

/* Focus ring: ink, never red/amber */
:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Glow Orbs: neutralised. Variant C has no glow orbs; selectors kept because
   index.html still renders .glow-orb.orb-1/.orb-2 on login and welcome. */
.glow-orb {
    display: none;
    pointer-events: none;
}
.orb-1 {
    /* neutralised (was a blurred amber orb) */
    display: none;
}
.orb-2 {
    /* neutralised (was a blurred pink orb) */
    display: none;
}
/* html.light-mode .glow-orb: dropped, orbs are hidden in both themes. */

/* ========================================== */
/* Button UI                                  */
/* ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition-speed), border-color var(--transition-speed), color var(--transition-speed), opacity var(--transition-speed);
}
.btn:hover {
    text-decoration: none;
}
.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: .55;
}

/* Primary: ink fill */
.btn-primary {
    background: var(--ink);
    color: var(--on-ink);
    border-color: var(--ink);
}
.btn-primary:hover {
    color: var(--on-ink);
    opacity: .88;
}
.btn-primary:disabled:hover,
.btn-primary[disabled]:hover {
    opacity: .55;
}

/* Secondary: surface with ink border */
.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--ink);
}
.btn-secondary:hover {
    background: var(--fill);
    border-color: var(--ink);
}

/* Active/pressed toggles: ink, never amber. A plain .btn-secondary already has
   an ink border, so the generic active state also takes the --fill tint to
   stay distinguishable; the nav's small toggles are refined below. */
.btn.active, .btn-secondary.active {
    background: var(--fill);
    border-color: var(--ink);
    color: var(--ink);
    font-weight: 600;
    box-shadow: none;
}
.btn.active:hover, .btn-secondary.active:hover {
    background: var(--fill);
}

/* Accent: no pink in variant C; renders as a primary (ink) button,
   matching the "Gem API-indstillinger" button in the artboards. */
.btn-accent {
    background: var(--ink);
    color: var(--on-ink);
    border-color: var(--ink);
}
.btn-accent:hover {
    color: var(--on-ink);
    opacity: .88;
}

.btn-full {
    width: 100%;
}

/* Small: same 44px target, tighter padding and 13px text */
.btn-sm {
    min-height: 44px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 4px;
}
/* Small secondary buttons in toolbars/nav use a quiet line border
   (artboard: "Eksporter PDF", "Mere"); .active above switches to ink. */
.btn-secondary.btn-sm {
    background: transparent;
    border-color: var(--line);
    font-weight: 500;
}
.btn-secondary.btn-sm:hover {
    background: var(--fill);
    border-color: var(--line-strong);
}
/* Artboard (Outline / AI-assistent pressed): surface bg, ink border, 600 */
.btn-secondary.btn-sm.active {
    background: var(--surface);
    border-color: var(--ink);
    font-weight: 600;
}
.btn-secondary.btn-sm.active:hover {
    background: var(--fill);
}

/* Fixed min-width removed: the C nav sizes these buttons to their content.
   The 1350px query in 03-editor-nav still resets it to auto. */
#btn-toggle-outline-nav,
#btn-toggle-ai-nav,
#btn-export-pdf {
    min-width: 0;
}

/* Icon button (welcome theme toggle, back to dashboard). These hold text
   ("Skift tema", "Tilbage", set by app.js), so they size to the label with a
   44px minimum, as in the VC-Velkomst / VC-Editor artboards (line border,
   500 13px, 0 14px padding). */
.btn-icon {
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 4px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn-icon:hover {
    background: var(--fill);
    border-color: var(--line-strong);
}

/* Small icon button (editor theme toggle, text "Skift tema"): borderless
   underlined text button, 44px target (VC-Editor artboard: 500 13px, 0 12px). */
.btn-icon-sm {
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: .2em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--ink);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}
.btn-icon-sm:hover {
    background: var(--fill);
    border-color: var(--line);
}
/* html.light-mode .btn-icon / .btn-icon-sm (+ :hover): dropped, handled by tokens. */

/* ========================================== */
/* Scrollbars                                 */
/* ========================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}
/* html.light-mode ::-webkit-scrollbar-thumb (+ :hover): dropped, handled by tokens. */


/* 02-login-welcome: login screen, welcome dashboard, scripts list, sidebar dashboard sections, profile badge */

/* ==========================================
   Welcome Dashboard
   ========================================== */
.welcome-container {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Horizontal padding moved to header/content so the header rule spans the full width */
    padding: 0;
    z-index: 1;
    overflow-y: auto;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
}

/* The front page has no top bar: the logo opens the page, then the description, then a centred row
   with the user's name and Log ud, Skift tema and the API key status (.hero-controls) */
.welcome-hero .hero-controls {
    margin-top: 28px;
}

/* The logo PNG is white on transparent and sits straight on the page, with no band behind it */
.potemkin-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    padding: 10px 20px;
    background: transparent;
}

.header-controls {
    display: flex;
    flex-wrap: wrap; /* on a narrow window the controls wrap, still centred */
    justify-content: center;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* White in dark mode; inverted to black in light mode. invert() only changes colour, so the
   transparent area stays transparent. */
.logo-img {
    height: 160px;
    width: auto;
    max-width: 100%; /* never wider than the login card or the screen; object-fit keeps the shape */
    object-fit: contain;
    display: block;
    filter: none !important;
}
html.light-mode .logo-img {
    filter: invert(1) !important;
}

/* API status: typed Courier text with a small square marker; no pill */
.api-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    background: transparent;
    border: 0;
    padding: 0 2px;
    border-radius: 0;
    font-family: var(--font-editor);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: .02em;
    color: var(--ink);
}
/* Missing key is an error state: red */
.api-status-badge.disabled {
    background: transparent;
    border: 0;
    color: var(--red);
}
/* Square marker; glow removed */
.status-indicator {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 0;
    background-color: currentColor;
    box-shadow: none;
}

.welcome-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 4rem 2.5rem 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.welcome-hero {
    text-align: center;
    margin-bottom: 1rem;
}
/* The Potemkin logo as the page heading, where "Skriv dit mesterværk." used to be */
.welcome-hero h1.hero-logo {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 0;
    line-height: 0;
}
/* Gradient text removed: plain ink Instrument Serif */
.welcome-hero h1 {
    font-family: var(--font-title);
    font-size: 80px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -.015em;
    margin: 0;
    color: var(--ink);
    background: none;
    -webkit-background-clip: border-box;
    -webkit-text-fill-color: currentColor;
}
.hero-tagline {
    font-size: 17px;
    color: var(--muted);
    max-width: 640px;
    margin: 20px auto 0;
    line-height: 1.55;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    align-items: start;
    gap: 1.5rem;
    margin-bottom: 0;
}

@media screen and (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Plain card: no blur, 4px radius, 1px line */
.card-blur {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 24px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    color: var(--ink);
}

/* Scripts card is sectioned by rules: header / list / actions carry their own padding */
.dashboard-main.card-blur {
    padding: 0;
}
.dashboard-sidebar.card-blur {
    padding: 22px 24px 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
/* Dashboard card header (scoped so the post-it .card-header in 04 cannot leak into it) */
.card-blur > .card-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 18px 20px 18px 24px;
    border-bottom: 1px solid var(--line);
}
.card-header h2 {
    font-family: var(--font-title);
    font-size: 32px;
    font-weight: 400;
    line-height: 1.1;
    margin: 0;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Decorative heading icons removed (design shows plain serif titles) */
.card-header h2 > i,
.sidebar-section h3 > i {
    display: none;
}

/* ==========================================
   Scripts list
   ========================================== */
.scripts-list-container {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    max-height: 400px;
    padding: 0;
}
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 24px 20px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    gap: 1rem;
}
.empty-state p {
    max-width: 260px;
    margin: 0;
}
/* Large folder icon removed (design shows text only) */
.empty-state i {
    display: none;
}

/* Rows separated by 1px rules instead of floating cards; no slide-on-hover */
.script-item-card {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 6px 16px 6px 24px;
    min-height: 54px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    color: var(--ink);
    transition: background-color var(--transition-speed);
}
.script-item-card:last-child {
    border-bottom: 0;
}
.script-item-card:hover {
    background: var(--surface-2);
    border-color: var(--line);
    transform: none;
}
/* Inset focus ring so the scroll container does not clip it */
.script-item-card:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}
.script-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
}
.script-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.script-meta {
    font-size: 13px;
    color: var(--muted);
}
.script-actions {
    flex: none;
    display: flex;
    gap: 6px;
}
/* app.js renders text labels here ("Dupliker", "Slet", "Forlad"), so the buttons size to their label */
.script-actions button {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    cursor: pointer;
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: border-color var(--transition-speed), background-color var(--transition-speed), color var(--transition-speed);
}
.script-actions button:hover {
    background: var(--fill);
    border-color: var(--ink);
    color: var(--ink);
}
/* Delete / leave is destructive: red on hover */
.script-actions button.btn-delete:hover {
    background: var(--red-bg);
    border-color: var(--red);
    color: var(--red);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0;
    padding: 18px 24px 24px;
    border-top: 1px solid var(--line);
}
.quick-actions button {
    flex: 1 1 200px;
}

/* ==========================================
   Sidebar Dashboard Sections
   ========================================== */
.sidebar-section {
    margin-bottom: 1.5rem;
}
.sidebar-section h3 {
    font-family: var(--font-title);
    font-size: 28px;
    font-weight: 400;
    line-height: 1.1;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink);
}
/* Description doubles as the rule above the form fields */
.section-description {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    margin: 8px 0 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}
/* Leading field icons removed (design shows plain fields); replaces the original `.input-with-icon i` */
.input-with-icon > i {
    display: none;
}
/* index.html puts inline padding-left: 2.5rem on some of these inputs for the old icon; reset it */
.input-with-icon input {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 12px !important;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    transition: border-color var(--transition-speed);
}
/* Room for the show/hide button that follows the API-key input */
.input-with-icon input:not(:last-child) {
    padding-right: 60px !important;
}
/* Keys, passwords and URLs are typed values: Courier */
#login-password,
#api-key-input,
#api-proxy-input {
    font-family: var(--font-editor);
}
.input-with-icon input::placeholder {
    color: var(--muted);
    opacity: 1;
}
.input-with-icon input:focus {
    border-color: var(--ink);
    box-shadow: none;
}
.toggle-password-btn {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    min-width: 44px;
    padding: 0 14px;
    background: transparent;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0 4px 4px 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: .2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toggle-password-btn:hover {
    color: var(--ink);
    background: var(--fill);
}

.form-group select {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color var(--transition-speed);
}
.form-group select:focus {
    border-color: var(--ink);
}

/* Shortcut list (not currently in index.html; kept consistent with the typed-label language) */
.features-list {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1.25rem;
}
.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line);
}
.shortcut-item:last-child {
    border-bottom: none;
}
.shortcut {
    font-family: var(--font-editor);
    background: var(--fill);
    border: 1px solid var(--line);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink);
}
.action-desc {
    font-size: 14px;
    color: var(--muted);
}

/* ==========================================
   Login Screen & Local Auth Styles
   ========================================== */
/* The .glow-orb elements inside #login-screen / #welcome-screen are handled (hidden) by 01-base. */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    position: relative;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    overflow: hidden;
    padding: 3rem 1.5rem;
}

/* Card padding lives on the children so the logo band can run edge to edge */
.login-card {
    width: 100%;
    max-width: 440px;
    padding: 0 0 36px;
    text-align: center;
    z-index: 10;
    border-radius: 4px;
    overflow: hidden;
}
.login-card .potemkin-logo {
    padding: 22px 24px;
    border-radius: 0;
}
.login-card .logo-img {
    height: 176px;
}

/* Gradient text removed: plain ink Instrument Serif */
.login-card h2 {
    font-family: var(--font-title);
    font-size: 60px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -.015em;
    margin: 32px 40px 0;
    color: var(--ink);
    background: none;
    -webkit-background-clip: border-box;
    -webkit-text-fill-color: currentColor;
}

.login-card p {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
    max-width: 340px;
    margin: 14px auto 0;
}
/* The invite hint is restyled in 08-sharing, whose margin (-1rem 0 1.5rem) assumes a padded card.
   This card pads its children instead (so the logo band runs edge to edge), so the hint gets the
   same 40px inset as the form, 20px below the intro text (VC-Login). ID-scoped to win over 08. */
#login-screen .login-card p.login-invite-hint {
    max-width: none;
    margin: 20px 40px 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 24px 40px 0;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    text-align: left;
}
.login-form .form-group {
    margin-bottom: 0;
}

/* app.js showLoginError() writes inline colours (red #ef4444 for errors, sky #38bdf8 for info).
   !important maps them onto tokens; the info variant is detected from its inline rgb value. */
.login-error-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    color: var(--red) !important;
    background: var(--surface) !important;
    border: 1px solid var(--red);
    border-color: var(--red) !important;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
    transition: none;
}
.login-error-msg::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-top: .55em;
    background: currentColor;
}
/* Info message (e.g. "Bekræftelseslink sendt"): neutral ink, not blue */
.login-error-msg[style*="56, 189, 248"] {
    color: var(--ink) !important;
    background: var(--surface-2) !important;
    border-color: var(--ink) !important;
}

.login-error-msg.hidden {
    display: none;
}

/* ==========================================
   User Profile Badge & Dropdowns
   ========================================== */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0 4px 0 12px; /* the name now leads the badge, so it needs its own inset */
    border-radius: 4px;
    height: auto;
    min-height: 44px;
}

/* The profile shows the user's name as text; there is no avatar picture */
.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    background: none;
    border: 0;
    border-left: 1px solid var(--line);
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: .2em;
    padding: 0 10px;
    transition: background-color var(--transition-speed);
}

/* Logging out is not destructive: neutral hover, no red */
.btn-logout-icon:hover {
    color: var(--ink);
    background: var(--fill);
}

/* Dropped light-mode variants (colours now come from tokens; nothing else differed):
   html.light-mode .welcome-hero h1      (gradient text, removed)
   html.light-mode .hero-tagline         (-> var(--muted))
   html.light-mode .script-item-card     (-> transparent row with var(--line) rule)
   html.light-mode .script-item-card:hover (-> var(--surface-2))
   html.light-mode .user-profile-badge   (-> var(--surface)) */

/* Narrow screens. 09-mobile (later in the file) pads every .card-blur with !important and stacks
   .quick-actions in a column. This section moved card padding onto the card children (logo band,
   card header, list, actions) and onto .welcome-header / .welcome-content, so keep that structure
   here with higher-specificity !important rules (VC-Mobil-Login / VC-Mobil-Velkomst). */
@media screen and (max-width: 850px) {
    .welcome-content {
        padding: 0 0.25rem;
    }
    .login-card.card-blur {
        padding: 0 0 24px !important;
    }
    .dashboard-main.card-blur {
        padding: 0 !important;
    }
    .card-blur > .card-header {
        margin-bottom: 0 !important;
        padding: 10px 10px 10px 14px;
    }
    .scripts-list-container > .script-item-card {
        padding: 4px 10px 4px 14px !important;
        border-radius: 0 !important;
        gap: 10px;
    }
    .dashboard-main > .quick-actions {
        margin-top: 0 !important;
        padding: 14px;
    }
    /* flex-basis 200px would become a 200px height once 09 turns the row into a column */
    .quick-actions button {
        flex: 0 0 auto;
    }
}

/* Phone sizes (kept last so it wins over the base login/logo rules above) */
@media screen and (max-width: 600px) {
    #login-screen .login-card p.login-invite-hint {
        margin: 16px 20px 0;
    }
    .logo-img {
        height: 112px;
    }
    .potemkin-logo {
        padding: 8px 16px;
    }
    .login-container {
        padding: 1rem;
    }
    .login-card .potemkin-logo {
        padding: 16px 20px;
    }
    .login-card .logo-img {
        height: 128px;
    }
    .login-card h2 {
        margin: 24px 20px 0;
        font-size: 48px;
    }
    .login-card p {
        font-size: 14.5px;
        max-width: 300px;
        margin-top: 10px;
    }
    .login-form {
        margin: 20px 20px 0;
        padding-top: 18px;
        gap: 16px;
    }
    .login-form input {
        font-size: 15px;
    }
}


/* 03-editor-nav: editor screen shell, nav header, view switch, format toolbar, dropdowns, profile menu, workspace layout, 1350px nav query */

/* ========================================== */
/* Editor Workspace Screen                    */
/* ========================================== */
.editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--paper);
    color: var(--ink);
}

/* Editor Navigation Header (two rows: nav-top + format toolbar) */
.editor-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 16px 10px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    z-index: 10;
    gap: 12px;
    font-family: var(--font-ui);
}

.editor-nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 16px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 auto;
    min-width: 0;
}

/* Back button (.btn .btn-icon in base). The icon was replaced by the text "Tilbage" in index.html,
   so it sizes to its label (artboard: min-height 44px, padding 0 14px, 500 13px, hairline border)
   instead of the fixed 44px square of .btn-icon. */
.nav-left .btn-nav-back {
    flex: none;
    width: auto;
    height: 44px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: none;
}
.nav-left .btn-nav-back:hover {
    background: var(--surface);
    border-color: var(--muted);
}

.script-title-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    flex: 0 1 auto;
    padding-left: 6px;
    gap: 2px;
}

/* Screenplay title: Instrument Serif, no bold, underline-only field */
.script-title-input {
    background: transparent;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    color: var(--ink);
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.1;
    padding: 0 2px;
    width: 100%;
    max-width: 260px;
    text-align: left;
    text-overflow: ellipsis;
    transition: border-color var(--transition-speed);
}
.script-title-input:hover {
    border-bottom-color: var(--line-strong);
}
.script-title-input:focus {
    background: transparent;
    border-bottom-color: var(--ink);
}

/* Typed status label ("GEMT" / "GEMMER..." / "KUN GEMT LOKALT") */
.save-status {
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-top: 1px;
    text-align: left;
}
/* Small square status mark (artboard); takes the state colour via currentColor */
.save-status::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    background: currentColor;
}
.save-status i {
    font-size: 11px;
}
.save-status.saving {
    color: var(--ink);
}
/* Local-only / failed cloud save: red is allowed for this state */
.save-status.error {
    color: var(--red);
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* Segmented view switch: one ink-bordered group, active segment ink-filled */
.view-toggle-group {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--ink);
    border-radius: 4px;
    padding: 0;
    overflow: hidden;
}
.view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    background: var(--surface);
    border: 0;
    border-right: 1px solid var(--ink);
    border-radius: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    padding: 0 18px;
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}
.view-btn:last-child {
    border-right: 0;
}
.view-btn:hover {
    background: var(--fill);
    color: var(--ink);
}
.view-btn.active,
.view-btn.active:hover {
    background: var(--ink);
    color: var(--on-ink);
    font-weight: 600;
    box-shadow: none;
}

/* Format toolbar: white hairline box with flat text buttons */
.editor-toolbar {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 3px;
    border-radius: 4px;
    gap: 0;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    align-self: center; /* Center horizontally in column flexbox */
}
.toolbar-group {
    display: flex;
    gap: 0;
    flex-shrink: 0;
}
.toolbar-separator {
    width: 1px;
    height: 22px;
    background-color: var(--line);
    margin: 0 4px;
    flex-shrink: 0;
}
.toolbar-btn {
    min-height: 44px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    padding: 0 14px;
    border-radius: 2px;
    cursor: pointer;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    flex-shrink: 0;
}
.toolbar-btn:hover {
    color: var(--ink);
    background: var(--fill);
}
/* Active element type / title page shown: ink fill (was amber). !important kept so hover/focus never wins */
.toolbar-btn.active,
.toolbar-btn.active:hover,
.toolbar-btn.active:focus,
.toolbar-btn.active:active {
    background: var(--ink) !important;
    background-color: var(--ink) !important;
    color: var(--on-ink) !important;
    border-color: var(--ink) !important;
    box-shadow: none !important;
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
}

/* Nav action buttons: hairline secondary; toggled-on panels (.active) get the ink border */
.nav-right .btn-secondary {
    min-height: 44px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    box-shadow: none;
}
.nav-right .btn-secondary:hover {
    background: var(--surface);
    border-color: var(--muted);
}
.nav-right .btn-secondary.active,
.nav-right .btn-secondary.active:hover {
    background: var(--surface);
    border-color: var(--ink);
    color: var(--ink);
    font-weight: 600;
    box-shadow: none;
}
.nav-right .dropdown-toggle {
    min-width: 44px;
    justify-content: center;
}
/* Theme toggle (.btn-icon-sm in base). Its icon became the text "Skift tema" (app.js updateThemeUI
   also writes that text), so it is a borderless underlined text button sized to its label
   (artboard: min-height 44px, padding 0 12px, 500 13px, underline offset .2em). */
.nav-right .btn-icon-sm {
    flex: none;
    width: auto;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 4px;
    background: transparent;
    border: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: .2em;
    box-shadow: none;
}
.nav-right .btn-icon-sm:hover {
    background: var(--fill);
    text-decoration: underline;
}

/* Dropdown Menu Styles ("Mere" / file operations) */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    padding: 4px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(30, 27, 22, 0.14);
    z-index: 100;
    overflow: hidden;
}
.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 16px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    text-decoration: none;
    transition: background-color var(--transition-speed);
}
.dropdown-menu a i {
    width: 16px;
    text-align: center;
    color: var(--muted);
}
.dropdown-menu a:hover {
    background: var(--fill);
    color: var(--ink);
}
.dropdown.show .dropdown-menu {
    display: block;
}

/* The toolbar's "Mere" menu: section, synopsis, note and dual dialogue. Fixed and placed under its
   button by app.js, since the toolbar scrolls sideways and would clip a menu inside it. */
.toolbar-more-menu {
    position: fixed;
    z-index: 1000;
    min-width: 220px;
    padding: 4px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(30, 27, 22, 0.14);
}
.toolbar-more-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    background: transparent;
    border: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.toolbar-more-menu button:hover,
.toolbar-more-menu button:focus-visible {
    background: var(--fill);
}
.toolbar-more-menu button:disabled {
    color: var(--muted);
    cursor: default;
    background: transparent;
}
.toolbar-more-menu button.active {
    font-weight: 600;
}
.toolbar-more-menu .menu-syntax {
    font-family: var(--font-editor);
    font-size: 12px;
    color: var(--muted);
}
/* View settings in the menu: a check mark when on */
.toolbar-more-menu button[role="menuitemcheckbox"]::after {
    content: "";
    width: 1em;
    font-size: 13px;
    color: var(--ink);
    text-align: right;
}
.toolbar-more-menu button[role="menuitemcheckbox"][aria-checked="true"]::after {
    content: "✓";
}
.toolbar-more-menu .menu-separator {
    height: 1px;
    margin: 4px 0;
    background: var(--line);
}

/* Workspace Layout */
.workspace-body {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

/* Nav at medium widths.
   The original hid .btn-text here to leave icon-only buttons. index.html no longer has icons in
   Del / Outline / AI-assistent / Eksporter PDF (the label IS the button), so hiding .btn-text would
   leave empty, unlabelled buttons. That rule is deliberately neutralised: the labels stay and the
   nav compacts instead (tighter padding, right group may wrap as in the artboard header). */
@media screen and (max-width: 1350px) {
    /* .btn-text { display: none; }  -- neutralised, see above */
    .script-title-input {
        max-width: 200px;
    }
    .editor-nav {
        padding: 8px 12px 10px;
    }
    .nav-right {
        flex-wrap: wrap;
    }
    .nav-right .btn-secondary {
        padding: 0 10px;
    }
    .view-btn {
        padding: 0 14px;
    }
    #btn-toggle-outline-nav,
    #btn-toggle-ai-nav,
    #btn-export-pdf {
        min-width: auto;
        justify-content: center;
    }
}

/* Editor Navbar Dropdown (profile) */
.profile-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

/* The user's name (set by updateUserProfileUI) plus a small CSS caret; long names end in "…" */
.profile-toggle-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-profile-toggle {
    background: none;
    border: none;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 6px;
    min-width: 28px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 4px;
    transition: color var(--transition-speed);
}
.btn-profile-toggle::after {
    content: "";
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-top-color: currentColor;
    margin-top: 4px;
}

.btn-profile-toggle:hover {
    color: var(--muted);
}

/* The profile button sits at the left of the editor bar, so the menu opens to the right from it
   (anchored on its right it ran off the left edge of the screen) and never gets wider than the screen */
.profile-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: auto;
    width: max-content; /* wide enough for the whole email when there is room */
    max-width: min(360px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 0;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(30, 27, 22, 0.14);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    font-family: var(--font-ui);
}

.profile-info {
    padding: 4px 16px 8px 16px;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The whole address must be readable, so a long one wraps rather than ending in "…" */
.profile-email {
    font-size: 13px;
    color: var(--muted);
    margin: 2px 0 0 0;
    overflow-wrap: anywhere;
}

.profile-divider {
    height: 1px;
    background: var(--line);
    margin: 6px 0;
}

.profile-menu-item {
    min-height: 44px;
    padding: 0 16px;
    color: var(--ink);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: background-color var(--transition-speed);
}

.profile-menu-item:hover {
    background: var(--fill);
    color: var(--ink);
}

.profile-menu-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
    color: var(--muted);
}

/* Light mode overrides: neutralised. Colours now come from the tokens in html.light-mode,
   so these old rules are deliberately dropped:
   html.light-mode .editor-container      (bg-dark slate)       -> .editor-container uses var(--paper)
   html.light-mode .editor-nav            (bg-card)             -> .editor-nav uses var(--paper)
   html.light-mode .dropdown-menu         (bg-card)             -> .dropdown-menu uses var(--surface)
   html.light-mode .editor-toolbar        (slate-200)           -> .editor-toolbar uses var(--surface)
   html.light-mode .toolbar-btn(:hover)   (slate text/hover)    -> var(--ink) / var(--fill)
   html.light-mode .toolbar-btn.active... (amber + glow)        -> ink fill, no glow (both themes)
   html.light-mode .user-profile-badge    (faint tint)          -> badge itself is styled in 02-login-welcome
   html.light-mode .profile-menu          (white + soft shadow) -> var(--surface) + spec modal shadow
   html.light-mode .profile-menu-item:hover (faint tint)        -> var(--fill) */


/* 04-sidebars-board: outline-board, post-it cards + colours, editor sidebar (tabs, outliner, projects list), help panel */

/* ==========================================
   Beat Board Module (VC-Board / VC-Mobil-Board)
   ========================================== */
.board-canvas-container {
    flex-grow: 1;
    background-color: var(--fill);
    /* Dot grid from the approved VC-Board artboard: a flat 1px dot pattern in a
       token colour (not a decorative colour gradient). Replaces the old dark
       corkboard pattern and the html.light-mode slate override. */
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    position: relative;
    padding: 2rem;
    color: var(--ink);
    font-family: var(--font-ui);
}

.board-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px 24px;
    padding-bottom: 20px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--line-strong);
}

.board-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 6px 6px 6px 14px;
    border-radius: 4px;
}

.board-controls label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

#board-zoom-slider {
    width: 120px;
    height: 44px;
    margin: 0 8px 0 0;
    accent-color: var(--ink);
    cursor: pointer;
}

.board-title-area {
    min-width: 0;
}

.board-title-area h2 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 44px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -.01em;
    color: var(--ink);
}

.board-subtitle {
    margin: 8px 0 0;
    font-size: 15px;
    color: var(--muted);
}

.board-grid {
    display: grid;
    /* Use a CSS variable for the card width, defaulting to 250px */
    grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width, 250px), 1fr));
    gap: 24px;
    align-items: start;
    padding-bottom: 4rem;
}

/* Post-it card: white paper card with a 6px colour strip on top (VC-Board).
   --card-tint is set per colour variant below. */
.post-it-card {
    --card-tint: var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    min-width: 0;
    min-height: calc(var(--card-min-width, 250px) * 0.8);
    padding: 0;
    border: 1px solid var(--line-strong);
    border-top: 6px solid var(--card-tint);
    border-radius: 0 0 3px 3px; /* square top corners under the colour strip */
    box-shadow: var(--card-shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    font-family: var(--font-ui);
    transition: border-color 0.2s, min-height 0.2s;
}

/* Scoped to the board card: .card-header is also used by the dashboard
   (section 02), which must not inherit the post-it divider. */
.post-it-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 0;
    padding: 6px 4px 8px 12px;
    border-bottom: 1px solid var(--line);
}

.card-title {
    flex-grow: 1;
    min-width: 0;
    padding-top: 12px;
    outline: none;
    font-family: var(--font-editor);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.card-title[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--muted);
}

.card-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: .2em;
    white-space: nowrap;
}
.card-btn:hover {
    color: var(--ink);
    background: var(--fill);
}

.card-body {
    flex-grow: 1;
    padding: 12px 14px 16px;
    outline: none;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
    white-space: pre-wrap;
}

.card-body[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--muted);
}

.card-title:focus-visible,
.card-body:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* Card Color Variants: tint strip colours from the approved VC-Board artboard
   (the only non-token colours in this section; they are decorative, never behind text). */
.post-it-card.color-yellow { --card-tint: #E9D78E; }
.post-it-card.color-blue { --card-tint: #B5C4DA; }
.post-it-card.color-pink { --card-tint: #E2BDC6; }
.post-it-card.color-green { --card-tint: #B7CFB0; }

/* ==========================================
   Editor Sidebars (VC-Editor left panel / VC-Mobil-Outline)
   ========================================== */
.editor-sidebar {
    width: var(--sidebar-width);
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-speed) ease;
}
.editor-sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar-tabs {
    display: flex;
    flex: none;
    border-bottom: 1px solid var(--line);
}
.tab-btn {
    flex-grow: 1;
    flex-basis: 0;
    min-height: 46px;
    margin-bottom: -1px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    padding: 0 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition-speed), border-color var(--transition-speed);
    text-align: center;
    white-space: nowrap;
}
.tab-btn:hover {
    color: var(--ink);
    background: transparent;
}
.tab-btn.active {
    color: var(--ink);
    font-weight: 600;
    border-bottom: 2px solid var(--ink);
}

.tab-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
}
/* Old faint divider (and its light-mode colour override) removed: the artboard
   header sits directly on the panel with no rule. */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 8px 6px 16px;
    border-bottom: none;
}
/* Right-hand group (scene count / "Nyt" + "Luk"); unstyled before, now laid out
   as in the VC-Editor / VC-Mobil-Outline header row. */
.sidebar-header-right {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
}
.sidebar-header h4 {
    margin: 0;
    flex: 1;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
}
.scene-count {
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    white-space: nowrap;
}

/* Outliner List */
.outline-list {
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
    gap: 2px;
}
.outline-empty {
    margin: 8px 8px 0;
    padding: 20px 16px;
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: 4px;
    text-align: center;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}
.outline-empty p {
    margin: 0;
}
.outline-empty .subtext {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--muted);
}
/* A short line under a sidebar list, e.g. which analyses a viewer sees */
.sidebar-list-note {
    margin: 6px 8px 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}
.outline-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--font-editor);
    font-size: 13px;
    cursor: pointer;
    color: var(--ink);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}
.outline-item:hover {
    background: var(--fill);
    color: var(--ink);
}
.outline-item.active {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
    font-weight: 700;
}
.outline-item-number {
    flex: none;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 2px;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
}
.outline-item.active .outline-item-number {
    background: var(--ink);
    color: var(--on-ink);
}
.outline-item-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* A scene's synopsis (the first "= ..." under its heading) as a quiet second line */
.outline-item.has-synopsis {
    padding-top: 6px;
    padding-bottom: 6px;
}
.outline-item-title,
.outline-item-synopsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.outline-item-synopsis {
    margin-top: 2px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-style: italic;
    font-weight: 400;
    color: var(--muted);
}
/* Sections (# Akt 1, ## Sekvens) as group headers between the scenes, indented by their depth */
.outline-section {
    padding: 14px 10px 4px calc(10px + var(--section-depth, 0) * 14px);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    border-radius: 4px;
}
.outline-section:hover,
.outline-section.active {
    color: var(--ink);
}
.outline-section-text {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.outline-section .outline-item-title {
    white-space: nowrap;
}
.outline-section .outline-item-synopsis {
    text-transform: none;
    letter-spacing: 0;
}

/* Scene-outline rows can be dragged to move a scene or section (app.js: outlineDrag), show the
   page and length of each scene, and mark the scene the caret is in ("current") */
#outline-container {
    position: relative; /* the drop line is placed in the list */
}
#outline-container .outline-item,
#outline-container .outline-section {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
#outline-container .outline-item.current {
    background: var(--surface);
    border-color: var(--line);
}
#outline-container .outline-item.current .outline-item-number {
    background: var(--ink);
    color: var(--on-ink);
}
#outline-container .outline-section.current {
    color: var(--ink);
}
.outline-item-meta {
    flex: none;
    margin-left: auto;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
}
.outline-item-meta:empty {
    display: none;
}
/* The grip: a quiet cue on hover with a mouse (the whole row drags), a real handle on touch */
.outline-drag-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 10px;
    cursor: grab;
    opacity: 0;
    touch-action: none;
    transition: opacity var(--transition-speed);
}
.outline-drag-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 2px;
    width: 6px;
    height: 12px;
    margin-top: -6px;
    background-image: radial-gradient(circle, var(--muted) 1px, transparent 1.3px);
    background-size: 3px 4px;
}
#outline-container .outline-item:hover .outline-drag-handle,
#outline-container .outline-section:hover .outline-drag-handle {
    opacity: .8;
}
#outline-container.is-dragging,
#outline-container.is-dragging * {
    cursor: grabbing;
}
#outline-container .is-dragged {
    opacity: .4;
}
.outline-drop-line {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--ink);
    pointer-events: none;
    z-index: 1;
}
.outline-drop-line[hidden] {
    display: none;
}
@media (hover: none) {
    #outline-container .outline-item {
        padding-left: 32px;
    }
    #outline-container .outline-section {
        padding-left: calc(32px + var(--section-depth, 0) * 14px);
    }
    .outline-drag-handle {
        width: 32px;
        opacity: .7;
    }
    .outline-drag-handle::before {
        left: 13px;
    }
}

/* Projects tab: same row, but titles are UI text and the number box holds an icon */
.sidebar-script-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-ui);
    font-size: 14px;
    padding-right: 2px;
}
.sidebar-script-item .outline-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-grow: 1;
}
/* Holds the typed label "Delt" (or nothing), so it may grow past 24px. */
.sidebar-script-item .outline-item-number {
    width: auto;
    min-width: 24px;
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.sidebar-script-item.active .outline-item-number {
    background: transparent;
    color: var(--muted);
}
.sidebar-script-item .outline-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}
.outline-item-actions {
    display: flex;
    gap: 0;
    opacity: 0;
    transition: opacity var(--transition-speed);
    flex-shrink: 0;
}
.sidebar-script-item:hover .outline-item-actions,
.sidebar-script-item:focus-within .outline-item-actions {
    opacity: 1;
}
.outline-item-actions button {
    background: transparent;
    border: none;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: color var(--transition-speed), background-color var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Text labels ("Dupliker", "Slet", "Forlad"), so width follows the label */
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    white-space: nowrap;
}
.outline-item-actions button:hover {
    color: var(--ink);
    background: var(--fill);
}
.outline-item-actions button.btn-sidebar-delete:hover {
    color: var(--red);
    background: var(--red-bg);
}

/* Light mode support: old html.light-mode hover overrides for
   .outline-item-actions button(.btn-sidebar-delete) dropped; tokens cover both themes. */

/* ==========================================
   Help panel and shortcuts inside editor
   ========================================== */
.help-section {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.help-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.help-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.help-group h4 {
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.help-group h4 i {
    color: var(--muted);
    font-size: 13px;
}

.help-desc {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

/* Typed key label (spec: Courier 12px 700 uppercase, muted) */
kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 12px;
    font-family: var(--font-editor);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    background-color: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    box-shadow: none;
    white-space: nowrap;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    margin: 4px 0;
}

.help-table td {
    padding: 8px 4px;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.help-table tr:last-child td {
    border-bottom: none;
}

.help-table td strong {
    color: var(--ink);
}

.arrow-cell {
    text-align: center;
    color: var(--muted);
    width: 28px;
    font-size: 12px;
}

/* Element badge: same boxed typed label as the element status ("HANDLING") */
.badge-el {
    display: inline-block;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    padding: 2px 6px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--ink);
}

/* Per-element colour coding (blue/grey/amber/purple/green/pink) neutralised:
   colour is reserved for errors and conflicts. Selectors kept on purpose. */
.badge-scene { background: transparent; color: var(--ink); border-color: var(--ink); }
.badge-act { background: transparent; color: var(--ink); border-color: var(--ink); }
.badge-char { background: transparent; color: var(--ink); border-color: var(--ink); }
.badge-paren { background: transparent; color: var(--ink); border-color: var(--ink); }
.badge-dial { background: transparent; color: var(--ink); border-color: var(--ink); }
.badge-trans { background: transparent; color: var(--ink); border-color: var(--ink); }

.help-tip {
    font-size: 13px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 8px 10px;
    border-radius: 4px;
    line-height: 1.5;
    margin: 4px 0 0 0;
}
.help-tip i {
    color: var(--ink);
}

.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
}

.shortcuts-table td {
    padding: 8px 4px;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.shortcuts-table tr:last-child td {
    border-bottom: none;
}

.shortcuts-table tr td:first-child {
    width: 48%;
}

.help-bullets {
    padding-left: 18px;
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.55;
}

.help-bullets li {
    margin-bottom: 8px;
}

.help-bullets li:last-child {
    margin-bottom: 0;
}

.help-bullets strong {
    color: var(--ink);
}

.help-bullets code {
    font-family: var(--font-editor);
    background: var(--fill);
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 13px;
    color: var(--ink);
}

/* Light mode overrides for Help Tab (html.light-mode .help-group, kbd,
   .help-table td, .shortcuts-table td, .help-tip, .help-bullets code) dropped:
   they only changed colours, which the tokens now handle in both themes.
   Same for html.light-mode .editor-sidebar, .sidebar-header,
   .board-canvas-container and .post-it-card from the old light-mode block. */


/* 05-page: screenplay page, element indicator, scene heading picker, zoom/status pills, title page */

/* ========================================== */
/* Screenplay Page Layout                     */
/* ========================================== */
.editor-canvas-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden; /* Prevent controls from scrolling up */
    background-color: var(--fill); /* C: the desk behind the paper */
    position: relative;
    align-items: center;
}

.editor-scroll-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Zoom control: flat segmented box (- | 100% | +), no blur, no pill */
.zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 2rem;
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--line);
    /* backdrop-filter removed (no glassmorphism) */
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(30, 27, 22, .06);
    padding: 0;
    gap: 0;
    /* no overflow:hidden: it would clip the buttons' 2px :focus-visible ring;
       the outer button corners are rounded below instead */
    z-index: 5;
}
.zoom-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-height: 42px;
    background: transparent;
    border: none;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    padding: 0;
    transition: background-color var(--transition-speed) ease;
}
.zoom-controls button:first-child {
    border-right: 1px solid var(--line);
    border-radius: 3px 0 0 3px;
}
.zoom-controls button:last-child {
    border-left: 1px solid var(--line);
    border-radius: 0 3px 3px 0;
}
.zoom-controls button:hover {
    background: var(--fill);
    color: var(--ink);
}
.zoom-controls span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-editor);
    font-size: 13px;
    font-weight: 400;
    min-width: 56px;
    text-align: center;
    color: var(--ink);
}

.page-viewport {
    padding: 3rem 1rem 5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
    transition: transform var(--transition-speed) ease, margin-bottom var(--transition-speed) ease;
    transform-origin: top center;
}

/* The Paper Sheet (geometry unchanged; paper-white in both themes) */
.screenplay-page {
    width: 210mm;
    max-width: 96vw;
    height: 297mm;
    background-color: var(--page-bg);
    color: var(--page-ink);
    box-shadow: 0 1px 2px rgba(30, 27, 22, .06); /* was a large dark drop shadow */
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    padding: 25.4mm 19.5mm 25.4mm 38.1mm;
    box-sizing: border-box;
    font-family: var(--font-editor);
    font-size: 12pt;
    line-height: 1;
    position: relative;
    overflow: visible;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    font-variant-ligatures: none;
    font-kerning: normal;
}

/* No blank lines above the first block on a page (the page number div comes first, so
   :first-of-type never matched and every page started about two lines low) */
.screenplay-page > .page-number-header + .element,
.screenplay-page > .element:first-child {
    margin-top: 0 !important;
}

.page-number-header {
    position: absolute;
    top: 12.7mm;
    right: 19.5mm;
    font-family: var(--font-editor);
    font-size: 12pt;
    color: var(--page-ink);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Screenplay Content Areas & Indentations */
.editor-text-area {
    outline: none; /* the whole contenteditable writing surface; caret shows focus */
    word-break: break-word;
    overflow: visible;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Clean, standard block-level spacing and layout */
.editor-text-area p, .editor-text-area div.element {
    margin: 0;
    padding: 0;
    font-family: var(--font-editor);
    font-size: 12pt;
    line-height: 1;
    position: relative;
    white-space: pre-wrap; /* Preserve spaces and tab visuals */
    word-wrap: break-word;
    min-height: 1em; /* Ensure empty lines are visible */
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    font-variant-ligatures: none;
    font-kerning: normal;
}

.editor-text-area div.element * {
    font-family: var(--font-editor) !important;
    font-size: 12pt !important;
    line-height: 1 !important;
    color: inherit !important;
    background: transparent !important;
}

/* Precise formatting margins inside editor (based on US Letter content area width of 6.0in) */
.element.scene-heading {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 2em !important;
    margin-bottom: 1em !important;
    margin-left: 0;
    color: var(--page-ink);
}
.element.scene-heading:empty:before {
    content: "INT. eller EXT. - SCENENAVN - TID";
    color: var(--page-muted); /* was #94a3b8 at 60% opacity: below 4.5:1 on white */
    font-style: italic;
    font-weight: normal;
    opacity: 1;
    pointer-events: none;
}

/* Floating Scene Heading Picker Widget
   Buttons stay compact (deliberate exception to 44px): app.js places the picker
   40px above the heading, so a taller widget would cover the line being typed. */
.scene-heading-picker {
    position: absolute;
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: 0 1px 2px rgba(30, 27, 22, .06);
    border-radius: 4px;
    padding: 3px;
    z-index: 1000;
    /* backdrop-filter removed (no glassmorphism) */
}
.scene-heading-picker button {
    min-height: 30px;
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--ink);
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 0 10px;
    border-radius: 2px;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}
.scene-heading-picker button:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--on-ink);
}
/* Ensure the first scene heading doesn't push down too much */
.editor-text-area div.element:first-child.scene-heading {
    margin-top: 0 !important;
}

.element.action {
    margin-top: 1em !important;
    margin-bottom: 1em !important;
    margin-left: 0;
}

.element.character {
    text-transform: uppercase;
    margin-top: 1em !important;
    margin-bottom: 0 !important;
    margin-left: 2.2in !important; /* Starts 3.7in from left paper edge (1.5in padding + 2.2in indent) */
    width: 3.8in;
}

.element.parenthetical {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: 1.6in !important; /* Starts 3.1in from left edge (1.5in padding + 1.6in indent) */
    margin-right: 2.0in !important; /* Ends 3.0in from right edge (1.0in padding + 2.0in indent) */
    width: 2.4in;
}

.element.dialogue {
    margin-top: 0 !important;
    margin-bottom: 1em !important;
    margin-left: 1.0in !important; /* Starts 2.5in from left edge (1.5in padding + 1.0in indent) */
    margin-right: 1.5in !important; /* Ends 2.5in from right edge (1.0in padding + 1.5in indent) */
    width: 3.5in;
}

.element.transition {
    text-transform: uppercase;
    margin-top: 1em !important;
    margin-bottom: 1em !important;
    margin-left: 4.0in !important; /* Placed towards the right */
    text-align: right;
    width: 2.0in;
}

/* Writer-only blocks: Fountain sections (# Akt 1, the #'s are the depth), synopses (= ...) and
   notes ([[...]]). Quiet and set apart from the script on screen; never printed, and they take no
   room on the PDF's pages (buildPrintBlocks in app.js leaves them out). */
.editor-text-area div.element.section {
    font-family: var(--font-ui);
    font-size: 10.5pt;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.3;
    color: var(--page-muted);
    margin-top: 2em !important;
    margin-bottom: .5em !important;
}
.editor-text-area div.element.synopsis {
    font-style: italic;
    color: var(--page-muted);
    margin-top: .5em !important;
    margin-bottom: .5em !important;
    padding-left: .75em;
    border-left: 2px solid var(--page-line);
}
.editor-text-area div.element.note {
    font-family: var(--font-ui);
    font-size: 10.5pt;
    line-height: 1.35;
    color: #5C4A1E;
    background: #FBF3D6;
    margin-top: .5em !important;
    margin-bottom: .5em !important;
    padding: .25em .6em;
    border-radius: 2px;
}
.element.synopsis:empty::before,
.element.note:empty::before {
    color: var(--page-muted);
    font-style: italic;
    pointer-events: none;
}
.element.synopsis:empty::before { content: "Synopsis: hvad sker der?"; }
.element.note:empty::before { content: "Note"; }

/* Dual dialogue: the cue keeps its name as typed; the flag shows as a small label after it.
   The speeches stay stacked in the editor and are put side by side only in the PDF. */
.editor-text-area div.element.character[data-dual="true"]::after {
    content: "samtidig";
    margin-left: .75em;
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    vertical-align: middle;
    color: var(--page-muted);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Dual dialogue in the PDF (print copies only, made by buildPrintBlocks in app.js): the two
   speeches side by side in two narrower columns, laid out and paginated as one block. Applies in
   the layout frame (screen media) and in print alike. */
.element.dual-dialogue {
    display: flex;
    gap: 0.2in;
    width: 6.0in;
    margin-top: 1em !important;
    margin-bottom: 1em !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    page-break-inside: avoid;
    break-inside: avoid;
}
.element.dual-dialogue .dual-speech {
    flex: 1 1 0;
    min-width: 0;
}
.editor-text-area .dual-speech div.element.character {
    margin: 0 0 0 0.9in !important;
    width: auto !important;
}
.editor-text-area .dual-speech div.element.parenthetical {
    margin: 0 0.45in !important;
    width: auto !important;
}
.editor-text-area .dual-speech div.element.dialogue {
    margin: 0 0.1in 1em !important;
    width: auto !important;
}
.editor-text-area .dual-speech div.element:last-child {
    margin-bottom: 0 !important;
}

/* Automatic "(FORTS.)" after a cue (data-cont, set by updateScriptMarks in app.js). Display only:
   the block's text is the name as typed. Quiet, so it reads as added by the app; the PDF prints it
   as real text (buildPrintBlocks drops the attribute from its copies). */
.editor-text-area div.element.character[data-cont="true"]::after {
    content: " (FORTS.)";
    color: var(--page-muted);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* "Vis scenenumre" (the toolbar's Mere menu): the scene's number in both margins of its heading,
   as in a numbered PDF. From data-scene-no; the heading's text is never changed. */
#editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::before,
#editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::after {
    content: attr(data-scene-no);
    position: absolute;
    top: 0;
    white-space: nowrap;
    font-weight: normal;
    color: var(--page-muted);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
#editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::before {
    right: calc(100% + 0.5in);
}
#editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::after {
    left: calc(100% + 0.3in);
}
@media screen and (max-width: 850px) {
    /* A phone's page margins are too narrow for it: the number goes once, before the heading */
    #editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::before {
        position: static;
        margin-right: 0.75em;
    }
    #editor.show-scene-numbers div.element.scene-heading[data-scene-no]:not(:empty)::after {
        content: none;
    }
}

/* PDF page breaks (print copies only, made by breakPrintPage in app.js): "(MERE)" in the cue's
   place right under the part of a speech that ends a page. Applies in the layout frame (screen
   media) and in print alike, so the measured pages are the printed ones. */
.editor-text-area div.element.print-before-more {
    margin-bottom: 0 !important;
}
.editor-text-area div.element.print-more {
    margin: 0 0 0 2.2in !important;
    width: 3.8in !important;
    text-transform: uppercase;
}

/* Elements indicator at bottom: flat surface box, typed labels */
.element-status-bar {
    position: absolute;
    bottom: 1rem;
    left: 2rem;
    /* Two short rows instead of one long one: the element and the word count on top,
       the page and the minutes below */
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: start;
    row-gap: 4px;
    min-height: 44px;
    box-sizing: border-box;
    background: var(--surface);
    border: 1px solid var(--line);
    /* backdrop-filter removed (no glassmorphism) */
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(30, 27, 22, .06);
    padding: 7px 12px;
    column-gap: 1rem;
    z-index: 5;
}
.element-status-bar .page-count {
    grid-column: 1 / -1;
}
.element-badge {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--ink);
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 2px;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.word-count {
    font-family: var(--font-editor);
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums; /* the bar keeps its width while the numbers change */
}
/* Phones: the bar shares the bottom edge with the zoom buttons, so it keeps only the page
   ("Side 3 af 12"), which is how a script's length is read anyway */
@media screen and (max-width: 600px) {
    .element-status-bar #editor-word-count,
    .element-status-bar .page-count-minutes {
        display: none;
    }
    /* What is left (element and page) fits on one line */
    .element-status-bar {
        grid-template-columns: auto auto;
        padding: 0 12px;
    }
    .element-status-bar .page-count {
        grid-column: auto;
    }
}

/* ========================================== */
/* Title Page Layout (geometry unchanged)     */
/* ========================================== */
.title-page-sheet {
    display: flex;
    flex-direction: column;
    height: 297mm; /* Exact A4 height to match screenplay page */
    padding: 50.8mm 25.4mm 25.4mm 25.4mm !important;
    position: relative;
    box-sizing: border-box;
}
.title-page-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    flex-grow: 1;
    width: 100%;
}
.tp-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    margin-top: 1.5in;
}
.tp-field {
    outline: none; /* focus is shown by the dashed underline below */
    border-bottom: 1px dashed transparent;
    transition: border-bottom-color var(--transition-speed);
    white-space: pre-wrap;
    width: 100%;
}
.tp-field:hover {
    border-bottom-color: var(--page-line);
}
.tp-field:focus {
    border-bottom-color: var(--page-muted);
}
.tp-field[contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: var(--page-muted);
    font-style: italic;
    font-weight: normal;
}
.tp-title {
    font-size: 12pt;
    font-weight: bold;
    text-transform: uppercase;
    text-decoration: underline;
    letter-spacing: 1.0px;
    margin-bottom: 2.5rem;
    text-align: center;
}
.tp-credit {
    font-size: 12pt;
    margin-bottom: 0.5rem;
}
.tp-author {
    font-size: 12pt;
    text-transform: uppercase;
}
/* "Baseret på": under the author, centred like the rest of the title block */
.tp-source {
    font-size: 12pt;
    margin-top: 1rem;
}
/* Notes above the contact and draft lines, copyright small at the very bottom */
.tp-bottom-group {
    position: absolute;
    bottom: 25.4mm;
    left: 25.4mm;
    right: 25.4mm;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
    width: auto;
}
.tp-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.tp-notes {
    font-size: 12pt;
    line-height: 1.15;
    text-align: left;
}
.tp-copyright {
    font-size: 10pt;
    line-height: 1.15;
    text-align: center;
}
/* A read-only script has no placeholder to show, so an empty optional field takes no room */
.tp-optional:empty:not([contenteditable="true"]) {
    display: none;
}
.tp-contact-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    max-width: 3.0in;
    gap: 0;
}
.tp-contact-line {
    font-size: 12pt;
    min-height: 1.25em;
    line-height: 1.15;
    width: 100%;
}
.tp-draft-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    max-width: 2.5in;
    gap: 0;
}
.tp-draft-line {
    font-size: 12pt;
    min-height: 1.25em;
    line-height: 1.15;
    width: 100%;
}

/* Light mode: the old html.light-mode overrides for .zoom-controls,
   .element-status-bar, .zoom-controls button/span and .word-count were colour-only
   (translucent white bg, slate text, soft shadow) and are now carried by the tokens. */


/* 06-ai-modals: AI co-writer panel, loading dots, chat action buttons, modals, origin warning */
/* Old html.light-mode overrides for .ai-sidebar, .ai-input-container, .ai-message.system,
   .ai-message.assistant, .preset-btn(:hover), .message-actions, .msg-action-btn(:hover) and
   .modal-dialog were colour-only and are dropped on purpose: the tokens handle both themes. */

/* ========================================== */
/* Right Sidebar (AI Co-Writer Panel)         */
/* ========================================== */
.ai-sidebar {
    width: var(--ai-sidebar-width);
    background: var(--surface-2);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-speed) ease;
}
.ai-sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-left: none;
}

.ai-header {
    flex: none;
    min-height: 56px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 0 8px 0 20px;
    border-bottom: 1px solid var(--line);
}
.ai-header h4 {
    flex: 1;
    min-width: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.1;
    color: var(--ink);
    /* Gradient text neutralised: plain ink title */
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
}
.ai-header h4 i {
    /* Decorative wand icon hidden: the C artboard uses the serif title alone */
    display: none;
}

/* Text "Luk" close button, underlined like the artboard (also used by the left sidebar's .mobile-close-left) */
.btn-close-sidebar {
    flex: none;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
    transition: text-decoration-thickness var(--transition-speed);
}
.btn-close-sidebar:hover {
    color: var(--ink);
    background: transparent;
    text-decoration-thickness: 2px;
}

.ai-actions-shelf {
    flex: none;
    padding: 14px 20px 16px;
    border-bottom: 1px solid var(--line);
}
.ai-actions-shelf h5 {
    margin: 0 0 10px;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}
.preset-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.preset-btn {
    min-height: 52px;
    box-sizing: border-box;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 4px;
    padding: 8px 12px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-align: left;
    transition: border-color var(--transition-speed), background-color var(--transition-speed);
}
.preset-btn:hover {
    background: var(--surface);
    border-color: var(--ink);
    color: var(--ink);
}
.preset-btn i {
    /* Icons hidden: the C artboard shows text-only preset buttons */
    display: none;
}

.ai-chat-container {
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 18px 20px;
    gap: 16px;
}
.ai-chat-history {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.ai-message {
    padding: 10px 12px;
    border-radius: 4px;
    max-width: 90%;
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
}
/* Intro / system note: centred, unboxed, ruled off below */
.ai-message.system {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    color: var(--muted);
    align-self: center;
    max-width: 100%;
    padding: 0 6px 14px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}
.ai-message.user {
    background: var(--fill);
    border: 1px solid var(--fill);
    color: var(--ink);
    align-self: flex-end;
    max-width: 85%;
}
.ai-message.assistant {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    align-self: flex-start;
    max-width: 94%;
}
.message-sender {
    margin-bottom: 6px;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.ai-message.user .message-sender {
    /* Was accent-coloured; now the same muted typed label, right-aligned like the artboard */
    color: var(--muted);
    text-align: right;
}
.message-text {
    white-space: pre-line;
}

/* AI Chat Card Action Buttons (merged from both original definitions) */
.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0 16px;
    margin-top: 8px;
    padding-top: 0;
    border-top: 1px solid var(--line);
}
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
    transition: text-decoration-thickness var(--transition-speed);
}
.msg-action-btn:hover {
    background: transparent;
    border-color: transparent;
    color: var(--ink);
    text-decoration-thickness: 2px;
}
.msg-action-btn i {
    font-size: 12px;
}
/* html.light-mode .message-actions / .msg-action-btn / .msg-action-btn:hover:
   dropped on purpose; the tokens above cover both themes. */

.ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    color: var(--muted);
    font-family: var(--font-editor);
    font-size: 13px;
    padding: 0 0 0 12px;
}

/* Loading dots: three small ink squares that fade in turn */
.dot-flashing {
    position: relative;
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 0;
    background-color: var(--ink);
    color: var(--ink);
    animation: dot-flashing 1s infinite linear alternate;
    animation-delay: .5s;
}
.dot-flashing::before, .dot-flashing::after {
    content: '';
    display: inline-block;
    position: absolute;
    top: 0;
}
.dot-flashing::before {
    left: -10px;
    width: 6px;
    height: 6px;
    border-radius: 0;
    background-color: var(--ink);
    color: var(--ink);
    animation: dot-flashing 1s infinite linear alternate;
    animation-delay: 0s;
}
.dot-flashing::after {
    left: 10px;
    width: 6px;
    height: 6px;
    border-radius: 0;
    background-color: var(--ink);
    color: var(--ink);
    animation: dot-flashing 1s infinite linear alternate;
    animation-delay: 1s;
}
@keyframes dot-flashing {
    0% { background-color: var(--ink); }
    50%, 100% { background-color: var(--line-strong); }
}
@media (prefers-reduced-motion: reduce) {
    .dot-flashing,
    .dot-flashing::before,
    .dot-flashing::after {
        animation: none;
    }
    .dot-flashing { background-color: var(--muted); }
    .dot-flashing::before { background-color: var(--ink); }
    .dot-flashing::after { background-color: var(--line-strong); }
}

.ai-input-container {
    flex: none;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--line);
    /* Same colour as the panel it sits in (the original repeated the sidebar colour);
       transparent so it also follows 09-mobile's drawer background */
    background: transparent;
}
.selection-status {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 0 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.selection-status span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.selection-status button {
    flex: none;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--line);
    border-radius: 0 3px 3px 0;
    color: var(--ink);
    font-family: var(--font-ui);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}
.selection-status button:hover {
    background: var(--fill);
}

.ai-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.ai-form textarea {
    flex-grow: 1;
    min-width: 0;
    box-sizing: border-box;
    min-height: 64px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    /* outline left to the global :focus-visible rule */
    transition: border-color var(--transition-speed);
}
.ai-form textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}
.ai-form textarea:focus {
    border-color: var(--ink);
}
/* Primary (ink) button; the HTML label is the text "Send", so the width follows the text
   (was a fixed 40px icon square) */
.btn-send-ai {
    flex: none;
    background: var(--ink);
    border: 1px solid var(--ink);
    color: var(--on-ink);
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-speed);
}
.btn-send-ai:hover {
    background: var(--ink);
    opacity: .88;
    /* lift-on-hover transform removed */
    transform: none;
}

/* ========================================== */
/* Modals                                     */
/* ========================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    box-sizing: border-box;
    padding: 16px;
    background: var(--backdrop);
    /* backdrop blur removed (no glassmorphism) */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--ink);
    border-radius: 4px;
    width: 500px;
    max-width: 90%;
    box-shadow: 0 8px 24px rgba(30, 27, 22, .14);
    display: flex;
    flex-direction: column;
    color: var(--ink);
}
/* html.light-mode .modal-dialog (white background): dropped, --surface is white in light mode. */
.modal-header {
    padding: 14px 8px 14px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.modal-header h3 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-family: var(--font-title);
    font-size: 28px;
    font-weight: 400;
    line-height: 1.1;
    color: var(--ink);
}
/* Text "Luk" close button, underlined like the VC-Import / VC-AI-Indstillinger artboards */
.modal-close {
    flex: none;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
    transition: text-decoration-thickness var(--transition-speed);
}
.modal-close:hover {
    color: var(--ink);
    background: transparent;
    text-decoration-thickness: 2px;
}
.modal-body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.modal-body p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}
.modal-body textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 260px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-editor);
    font-size: 14px;
    line-height: 1.4;
    padding: 12px 14px;
    resize: vertical;
    /* outline left to the global :focus-visible rule */
    transition: border-color var(--transition-speed);
}
.modal-body textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}
.modal-body textarea:focus {
    border-color: var(--ink);
}

/* Settings dialog fields (AI-assistent indstillinger) */
.modal-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}
.modal-body .form-group label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}
.modal-body .form-group input,
.modal-body .form-group select {
    width: 100%;
    box-sizing: border-box;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    text-overflow: ellipsis;
    box-shadow: none;
    transition: border-color var(--transition-speed);
}
.modal-body .form-group input {
    /* key and URL fields are typed values */
    font-family: var(--font-editor);
}
.modal-body .form-group input::placeholder {
    color: var(--muted);
    opacity: 1;
}
.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
    border-color: var(--ink);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 3px 3px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* Origin Warning Box (file:// means AI calls fail: an error state, so red is allowed) */
.origin-warning-box {
    background: var(--red-bg);
    border: 1px solid var(--red);
    border-radius: 4px;
    padding: 16px 18px;
    color: var(--red);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.origin-warning-box i {
    font-size: 20px;
}
.origin-warning-box h4 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 700;
    color: var(--red);
}
.origin-warning-box p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
}
.origin-warning-box code {
    font-family: var(--font-editor);
    font-size: 13px;
}
.origin-warning-box a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}
.origin-warning-box a:hover {
    color: var(--ink);
    text-decoration-thickness: 2px;
}


/* ===== 07-analysis: Screenplay Analysis View (report card, tables, dialogue cards) ===== */

/* ------------------------------------------
 * Canvas + wrapper
 * The canvas is a size container so the two-column layout from the
 * VC-Analyse artboard reacts to the space left by the sidebars. Without
 * container-query support it stays the original single centred column.
 * ------------------------------------------ */
.analysis-canvas-container {
    flex-grow: 1;
    background: var(--fill);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    padding: 2rem;
    box-sizing: border-box;
    container-type: inline-size;
    container-name: analysis;
    font-family: var(--font-ui);
    color: var(--ink);
}

.analysis-wrapper {
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header card: title, description and actions (also carries .card-blur;
   these rules come later in the cascade and neutralise its blur/radius). */
.analysis-header-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 24px 24px 20px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;           /* old blur removed (no glassmorphism) */
    -webkit-backdrop-filter: none;
    box-sizing: border-box;
}

.analysis-title-group {
    text-align: left;
    width: 100%;
}

.analysis-title-group h2 {
    font-family: var(--font-title);
    font-size: 38px;
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--ink);
    text-align: left;
}

.analysis-title-group p {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--muted);
    margin: 12px 0 0;
    line-height: 1.5;
    text-align: left;
}

.analysis-title-group p.analysis-subtitle {
    margin-top: 4px;
}

.analysis-actions-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    width: 100%;
}

.analysis-actions-bar .btn {
    min-height: 44px;
}

.analysis-actions-bar .btn-primary {
    flex: 1 1 auto;
}

.analysis-actions-bar .btn-secondary {
    flex: none;
}

/* Locked "Analyserer..." state of #btn-run-analysis */
.analysis-actions-bar .btn:disabled,
.analysis-actions-bar .btn[disabled] {
    background: var(--fill);
    color: var(--muted);
    border-color: var(--line);
    opacity: 1;
    cursor: not-allowed;
}

/* app.js rewrites #btn-run-analysis with a fa-spinner (running) and a
   fa-wand-magic-sparkles icon (after a run); the artboard and the initial
   HTML show text only, and the progress line carries the busy state. */
.analysis-actions-bar .btn > i {
    display: none;
}

/* Results card (also carries .card-blur) */
.analysis-results-card {
    padding: 44px 56px 52px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;           /* old blur removed (no glassmorphism) */
    -webkit-backdrop-filter: none;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: 0;
}

/* ------------------------------------------
 * Empty + loading states
 * index.html no longer ships the fa-chart-pie / fa-spinner icons in these
 * blocks, so the artboard's page outline and progress line are drawn with
 * pseudo-elements on the state containers. If an icon is ever put back it
 * is hidden so nothing is drawn twice.
 * ------------------------------------------ */
.analysis-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    color: var(--muted);
    margin: auto 0;
    padding: 3rem 1rem;
}

/* Small blank page outline (VC-Analyse "Foer foerste analyse") */
.analysis-empty-state::before {
    content: "";
    display: block;
    flex: none;
    width: 34px;
    height: 44px;
    box-sizing: border-box;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
}

.analysis-empty-state i {
    display: none;
}

.analysis-empty-state p {
    font-family: var(--font-ui);
    font-size: 15px;
    max-width: 400px;
    line-height: 1.5;
    margin: 0;
    color: var(--muted);
}

.analysis-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: var(--muted);
    margin: auto 0;
    padding: 3rem 1rem;
}

/* Thin indeterminate progress line: ::after is the ink bar (moved first
   with order:-1), ::before is the fill track pulled up underneath it. */
.analysis-loading-state::after {
    content: "";
    display: block;
    flex: none;
    order: -1;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    height: 2px;
    background: var(--ink);
    clip-path: inset(0 66% 0 0);
    animation: analysis-progress 1.4s ease-in-out infinite;
}

.analysis-loading-state::before {
    content: "";
    display: block;
    flex: none;
    width: 100%;
    max-width: 480px;
    height: 2px;
    margin-top: -14px;               /* 12px gap + 2px bar: sits under the bar */
    background: var(--fill);
}

@keyframes analysis-progress {
    0%   { clip-path: inset(0 100% 0 0); }
    35%  { clip-path: inset(0 66% 0 0); }
    65%  { clip-path: inset(0 0 0 66%); }
    100% { clip-path: inset(0 0 0 100%); }
}

@media (prefers-reduced-motion: reduce) {
    .analysis-loading-state::after {
        animation: none;
        clip-path: inset(0 44% 0 22%);
    }
}

.analysis-loading-state i {
    display: none;
}

.analysis-loading-state p {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    color: var(--muted);
}

/* ------------------------------------------
 * Rendered report
 * ------------------------------------------ */
.analysis-content {
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--ink);
    line-height: 1.6;
    overflow-wrap: break-word;
}

.analysis-content h1,
.analysis-content h2,
.analysis-content h3,
.analysis-content h4 {
    font-family: var(--font-title);
    font-weight: 400;
    color: var(--ink);
    margin-top: 28px;
    margin-bottom: 12px;
}

.analysis-content > :first-child {
    margin-top: 0;
}

.analysis-content h1 {
    font-size: 38px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.analysis-content h2 {
    font-size: 26px;
    line-height: 1.15;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.analysis-content h3 {
    font-size: 21px;
    line-height: 1.2;
    font-style: italic;
    margin-top: 18px;
    margin-bottom: 6px;
}

.analysis-content h4 {
    font-size: 18px;
    line-height: 1.25;
    margin-top: 16px;
    margin-bottom: 6px;
}

.analysis-content p {
    margin-top: 0;
    margin-bottom: 12px;
}

.analysis-content ul,
.analysis-content ol {
    margin-top: 6px;
    margin-bottom: 14px;
    padding-left: 1.25rem;
}

.analysis-content li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.analysis-content li.sub-bullet {
    margin-left: 1.25rem;
    color: var(--muted);
    font-size: 0.93em;
    list-style-type: circle;
}

.analysis-content li.sub-bullet strong {
    color: var(--ink);
}

.analysis-content blockquote,
.analysis-content blockquote.analysis-quote {
    margin: 14px 0;
    padding: 12px 16px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font-family: var(--font-editor);
    font-size: 15px;
    line-height: 1.55;
    border-radius: 2px;
    box-shadow: none;
}

.analysis-content strong {
    color: var(--ink);
    font-weight: 700;
}

/* html.light-mode .analysis-content strong / blockquote / h2:
   colour-only overrides, now handled by the tokens (intentionally empty). */
html.light-mode .analysis-content strong {}
html.light-mode .analysis-content blockquote,
html.light-mode .analysis-content blockquote.analysis-quote {}
html.light-mode .analysis-content h2 {}

/* Tables */
.analysis-content table.analysis-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 15px;
    background: var(--surface);
    border-radius: 0;
    overflow: visible;
    border: 1px solid var(--line);
}

.analysis-content table.analysis-table th {
    background: var(--surface-2);
    color: var(--ink);
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    vertical-align: bottom;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
}

.analysis-content table.analysis-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--fill);
    color: var(--ink);
    line-height: 1.5;
    vertical-align: top;
}

.analysis-content table.analysis-table td:first-child {
    font-weight: 600;
}

.analysis-content table.analysis-table tr:last-child td {
    border-bottom: none;
}

.analysis-content table.analysis-table tr:hover {
    background: var(--surface-2);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin: 12px 0 14px;
}

/* Code */
.analysis-code-block {
    position: relative;
    margin: 14px 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 16px;
    overflow-x: auto;
    box-shadow: none;
}

.analysis-code-block pre {
    margin: 0;
    font-family: var(--font-editor);
    font-size: 14px;
    color: var(--ink);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

code.inline-code {
    background: var(--fill);
    color: var(--ink);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    font-family: var(--font-editor);
    font-size: 0.9em;
}

.analysis-hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 24px 0;
}

/* Light-mode table & code overrides: colour-only, now handled by tokens
   (intentionally empty). */
html.light-mode .analysis-content table.analysis-table {}
html.light-mode .analysis-content table.analysis-table th {}
html.light-mode .analysis-content table.analysis-table td {}
html.light-mode .analysis-code-block {}
html.light-mode .analysis-code-block pre {}
html.light-mode code.inline-code {}

/* ------------------------------------------
 * Dialogue cards: small screenplay-like blocks in Courier
 * ------------------------------------------ */
.analysis-dialogue-card {
    margin: 14px 0;
    padding: 14px 16px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 2px;
    font-family: var(--font-editor);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
}

.analysis-dialogue-card .character-name {
    display: block;
    text-align: center;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    font-size: 15px;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

/* Comment icon injected by app.js; the artboard shows a bare cue name. */
.analysis-dialogue-card .character-name i {
    display: none;
}

.analysis-dialogue-card .dialogue-text {
    display: block;
    max-width: 35ch;
    margin: 0 auto;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    font-style: normal;
}

/* Light-mode dialogue card overrides: colour-only, now handled by tokens
   (intentionally empty). */
html.light-mode .analysis-dialogue-card {}
html.light-mode .analysis-dialogue-card .character-name {}
html.light-mode .analysis-dialogue-card .dialogue-text {}

/* ------------------------------------------
 * Wide canvas: artboard two-column layout (sticky header card left,
 * report right). Narrower canvases keep the single stacked column.
 * ------------------------------------------ */
@container analysis (min-width: 1040px) {
    .analysis-wrapper {
        max-width: 1188px;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
        justify-content: center;
        gap: 24px;
    }

    .analysis-header-card {
        flex: 0 1 344px;
        min-width: 300px;
        position: sticky;
        top: 24px;
    }

    .analysis-results-card {
        flex: 1 1 600px;
        max-width: 820px;
    }
}

/* Narrow canvas (phones, or squeezed between sidebars): VC-Mobil-Analyse */
@container analysis (max-width: 600px) {
    .analysis-wrapper {
        gap: 12px;
    }

    .analysis-header-card {
        padding: 18px 16px 16px;
    }

    .analysis-title-group h2 {
        font-size: 32px;
    }

    .analysis-title-group p {
        margin-top: 8px;
    }

    .analysis-title-group p.analysis-subtitle {
        margin-top: 2px;
    }

    .analysis-actions-bar {
        flex-wrap: nowrap;
        margin-top: 14px;
        padding-top: 14px;
    }

    .analysis-actions-bar .btn-primary {
        flex: 1 1 auto;
        min-width: 0;
    }

    .analysis-results-card {
        padding: 22px 16px 28px;
    }

    .analysis-content {
        font-size: 16px;
        line-height: 1.55;
    }

    .analysis-content h1 {
        font-size: 30px;
        padding-bottom: 10px;
    }

    .analysis-content h2 {
        font-size: 23px;
        margin-top: 24px;
        margin-bottom: 10px;
        padding-bottom: 6px;
    }

    .analysis-content h3 {
        font-size: 20px;
        margin-top: 16px;
        margin-bottom: 4px;
    }

    .analysis-content table.analysis-table th,
    .analysis-content table.analysis-table td {
        padding: 8px 10px;
    }

    .analysis-content blockquote,
    .analysis-content blockquote.analysis-quote {
        padding: 10px 12px;
    }

    .analysis-dialogue-card {
        padding: 12px 12px 14px;
    }

    .analysis-dialogue-card .dialogue-text {
        max-width: none;
        margin: 0 2%;
    }
}

@media screen and (max-width: 600px) {
    .analysis-canvas-container {
        padding: 12px 8px 24px;
    }
}


/* 08-sharing: sharing & collaboration (presence, pen banner, read-only, share badge, invite hint, share dialog) */

/* ==========================================
   Sharing & collaboration
   ========================================== */

/* People in the open script */
.collab-presence {
    display: inline-flex;
    align-items: center;
    margin-right: 0.25rem;
}
.collab-avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    box-sizing: border-box;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--fill);
    /* Paper-coloured ring separates overlapping chips on the nav background */
    border: 2px solid var(--paper);
}
.collab-presence .collab-avatar + .collab-avatar {
    margin-left: -6px;
}
/* The person holding the pen: ink fill (old coloured glow removed) */
.collab-avatar.is-writing {
    background: var(--ink);
    color: var(--on-ink);
    box-shadow: none;
}
/* Neutralised (dropped on purpose, colour-only light-mode overrides; the tokens
   handle both themes):
   - html.light-mode .collab-avatar (white ring): the ring is var(--paper) above.
   - html.light-mode .modal-dialog (white dialog): .modal-dialog in 06-ai-modals
     already uses var(--surface); re-declaring it here at higher specificity
     would only risk overriding modal variants in light mode.
   - html.light-mode .share-invite / .share-member (faint tint): the base rule
     below uses var(--surface-2) in both themes. */

/* Who holds the pen */
.collab-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.5rem;
    min-height: 44px;
    box-sizing: border-box;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
}
.collab-banner > i {
    color: var(--ink);
    flex: 0 0 auto;
}
.collab-banner > span {
    flex: 1 1 auto;
    min-width: 0;
}
.collab-banner .btn {
    flex: 0 0 auto;
    min-height: 44px;
}

/* Read-only: controls that would change the script are switched off. A new analysis doesn't
   change the script, so only those who can't edit at all (.cannot-edit) lose it, not an
   editor who is waiting for the pen. */
.is-read-only #editor-toolbar,
.is-read-only #btn-import-fountain-editor,
.is-read-only #btn-add-board-card,
.is-read-only #btn-board-from-script,
.is-read-only #btn-board-to-script,
.is-read-only #btn-board-template,
.is-read-only #btn-board-acts,
.is-read-only #btn-board-undo,
.is-read-only #btn-board-redo,
.cannot-edit #btn-run-analysis,
.is-read-only #ai-btn-next,
.is-read-only #ai-btn-rewrite,
.is-read-only #ai-btn-expand,
.is-read-only .board-lane-add,
.is-read-only .board-lane-remove {
    opacity: 0.45;
    pointer-events: none;
}
.is-read-only .script-title-input {
    cursor: default;
}

/* Dashboard badge: typed Courier text in ink, no pill */
.script-share-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.75rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-editor);
    font-weight: 400;
    white-space: nowrap;
}
.script-share-badge i {
    font-size: 0.85em;
    color: var(--ink);
}

/* Login screen note when an invite link was opened */
.login-card p.login-invite-hint {
    margin: -1rem 0 1.5rem;
    padding: 10px 14px 12px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--ink);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
}
/* Typed label from the VC-Login artboard (decorative; the sentence carries the meaning) */
.login-card p.login-invite-hint::before {
    content: "Invitation";
    content: "Invitation" / ""; /* empty alt text: screen readers skip the label (artboard: aria-hidden) */
    display: block;
    margin-bottom: 3px;
    font-family: var(--font-editor);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink);
}
/* Neutralised: the artboard shows no icon, the typed label replaces it */
.login-card p.login-invite-hint > i {
    display: none;
}

/* Share dialog */
#modal-share .modal-dialog {
    width: 540px;
    max-height: 90vh;
}
#modal-share .modal-body {
    overflow-y: auto;
    gap: 1.25rem;
}
#modal-share .modal-header h3 i {
    color: var(--ink);
    font-size: 0.7em;
    vertical-align: 0.15em;
    margin-right: 0.35rem;
}
.modal-body p.share-script-title {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.share-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.share-section h4 {
    margin: 0;
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.modal-body p.share-hint {
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}
.share-invite-row,
.share-link-row {
    display: flex;
    gap: 0.5rem;
}
.share-invite-row select,
.share-link-row input,
.share-role-select {
    box-sizing: border-box;
    min-height: 44px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    box-shadow: none;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    padding: 0 12px;
}
.share-invite-row select {
    flex: 1 1 auto;
    cursor: pointer;
}
.share-link-row input {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-editor);
    font-size: 14px;
}
.share-invite-row select:focus,
.share-link-row input:focus,
.share-role-select:focus {
    border-color: var(--ink);
    outline: none;
}
.share-invite-row select:focus-visible,
.share-link-row input:focus-visible,
.share-role-select:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
.share-invite-row .btn,
.share-link-row .btn {
    flex: 0 0 auto;
    min-height: 44px;
}
.share-invites-list,
.share-members-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.share-invite,
.share-member {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.4rem 0.4rem 0.75rem;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.share-invite-info {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    color: var(--muted);
}
.share-invite-info i {
    margin-right: 0.3rem;
    color: var(--muted);
}
.share-member .collab-avatar {
    border: none;
}
.share-member-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.share-member-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-member-email {
    font-size: 13px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-role-label {
    font-family: var(--font-editor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    white-space: nowrap;
    padding-right: 0.35rem;
}
.share-role-select {
    padding: 0 10px;
    font-size: 14px;
    cursor: pointer;
}
.btn-remove-member,
.btn-copy-invite,
.btn-revoke-invite {
    width: auto;
    min-width: 44px;
    height: 44px;
    flex: 0 0 auto;
    padding: 0 10px;
    font: 500 13px var(--font-ui);
    text-decoration: underline;
    text-underline-offset: .2em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color var(--transition-speed), border-color var(--transition-speed), background-color var(--transition-speed);
}
/* Destructive: red is allowed here */
.btn-remove-member:hover,
.btn-revoke-invite:hover {
    color: var(--red);
    border-color: var(--red);
    background: var(--red-bg);
}
.btn-copy-invite:hover {
    color: var(--ink);
    border-color: var(--line-strong);
    background: var(--surface);
}
.btn-remove-member:focus-visible,
.btn-copy-invite:focus-visible,
.btn-revoke-invite:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
.modal-body p.share-empty {
    font-size: 14px;
    color: var(--muted);
    padding: 0.25rem 0.1rem;
}
#modal-share .modal-footer {
    justify-content: space-between;
}
#modal-share .modal-footer #btn-done-share {
    margin-left: auto;
}

@media screen and (max-width: 600px) {
    .collab-banner {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
    }
    .share-invite-row,
    .share-link-row {
        flex-direction: column;
    }
    #modal-share .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    #modal-share .modal-footer #btn-done-share {
        margin-left: 0;
    }
}

@media print {
    .collab-banner,
    .collab-presence {
        display: none !important;
    }
}


/* 09-mobile: narrow viewports and mobile scaling rules (max-width 850px) */

/* ==========================================
   Narrow Viewports & Mobile Scaling Rules
   Restyled to variant C (VC-Mobil-Velkomst / -Editor / -Outline / -AI).
   Layout behaviour of the original block is kept; only the look changes.
   Colours come from tokens only, so no html.light-mode overrides are needed:
   the old light-mode colour rules for .editor-nav, .editor-sidebar,
   .ai-sidebar, .welcome-hero h1, .hero-tagline, .script-item-card(:hover)
   and .editor-toolbar are covered by the tokens and are not repeated here.
   ========================================== */

@media screen and (max-width: 850px) {
    /* 1. Mobile Splashscreen / Welcome Screen Layout */
    .welcome-container {
        padding: 1rem 0.75rem 2.5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .potemkin-logo {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        /* Shrink to the logo so a framed logo block (02) stays compact, as in the artboard */
        width: auto !important;
        max-width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    .logo-img {
        max-height: 128px !important;
        height: auto !important;
        width: auto !important;
        display: block !important;
        margin: 0 auto !important;
        /* Old drop-shadow removed (no soft shadows in variant C) */
        filter: none !important;
    }
    #welcome-logo {
        max-height: 150px !important;
    }

    /* Controls sit in normal flow under the logo (position: static removes the absolute overlap) */
    .header-controls {
        position: static !important;
        transform: none !important;
        right: auto !important;
        top: auto !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.375rem !important;
        width: 100% !important;
        margin-top: 15px !important;
        margin-bottom: 10px !important;
    }
    .api-status-badge {
        min-height: 44px !important;
        box-sizing: border-box !important;
        padding: 0 0.125rem !important;
        font-family: var(--font-editor) !important;
        font-size: 0.75rem !important;
    }
    .user-profile-badge {
        padding: 0 0.125rem 0 0.625rem !important;
        height: auto !important;
        min-height: 44px !important;
        box-sizing: border-box !important;
        border-radius: 4px !important;
    }

    /* Hero: "Skriv dit mesterværk." in Instrument Serif, plain ink (gradient text removed) */
    .welcome-hero {
        text-align: center !important;
        margin-bottom: 1.5rem !important;
        padding: 0 0.5rem !important;
        width: 100% !important;
    }
    .welcome-hero h1 {
        font-family: var(--font-title) !important;
        font-weight: 400 !important;
        font-size: 2.25rem !important;
        line-height: 1.05 !important;
        letter-spacing: -0.015em !important;
        margin-bottom: 0.625rem !important;
        color: var(--ink) !important;
        /* Old gradient text neutralised */
        background: none !important;
        -webkit-background-clip: border-box !important;
        background-clip: border-box !important;
        -webkit-text-fill-color: currentColor !important;
    }
    .hero-tagline {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
        color: var(--muted) !important;
    }

    /* "Dine filmmanuskripter" & "Indstillinger for AI-assistent" fill the width */
    .welcome-content {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        gap: 1rem !important;
    }
    .dashboard-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
        margin-bottom: 1.5rem !important;
    }
    .dashboard-main,
    .dashboard-sidebar,
    .card-blur {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 1.125rem 0.875rem !important;
        border-radius: 4px !important;
    }
    /* The scripts card is sectioned by rules (02): header / list / actions carry their own
       padding, so the card itself stays flush (artboard VC-Mobil-Velkomst). */
    .dashboard-main.card-blur {
        padding: 0 !important;
    }
    /* Login card keeps its flush ink logo band; inner blocks carry the side margins (02) */
    .login-card.card-blur {
        padding: 0 0 1.5rem !important;
    }
    .card-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 1rem !important;
        gap: 0.5rem !important;
    }
    /* Dashboard card header is a ruled band, not a spaced heading (post-it .card-header unaffected) */
    .card-blur > .card-header {
        margin-bottom: 0 !important;
        padding: 10px 10px 10px 14px !important;
    }
    .card-header h2 {
        font-family: var(--font-title) !important;
        font-weight: 400 !important;
        font-size: 1.45rem !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    #btn-create-script {
        font-size: 0.8125rem !important;
        font-weight: 600 !important;
        min-height: 44px !important;
        padding: 0 0.75rem !important;
        border-radius: 4px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    .scripts-list-container {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .script-item-card {
        width: 100% !important;
        box-sizing: border-box !important;
        /* Flat ruled rows as in 02 / the artboard (no card radius) */
        padding: 4px 10px 4px 14px !important;
        min-height: 54px !important;
        border-radius: 0 !important;
        touch-action: manipulation !important;
    }
    .quick-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        /* Sits directly under the list's rule (02 border-top), so no outer gap */
        margin-top: 0 !important;
        padding: 14px !important;
    }
    .quick-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        font-size: 0.875rem !important;
        font-weight: 600 !important;
        min-height: 44px !important;
        padding: 0 1rem !important;
        border-radius: 4px !important;
    }
    .form-group input,
    .form-group select {
        width: 100% !important;
        box-sizing: border-box !important;
        min-height: 44px !important;
        /* 16px keeps iOS from zooming in on focus */
        font-size: 1rem !important;
        border-radius: 4px !important;
    }

    /* 2. Editor Navigation Header: three stacked rows (level 1, 2 and 3) */
    .editor-nav {
        padding: 0.375rem 0.5rem 0.5rem !important;
        gap: 0.375rem !important;
    }
    .editor-nav-top {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.375rem !important;
        width: 100% !important;
    }

    /* LEVEL 1 (TOP): back, profile, title */
    .nav-left {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 0.375rem !important;
        order: 1 !important;
    }
    .script-title-wrapper {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        min-width: 0 !important;
        margin: 0 0.25rem !important;
    }
    .script-title-input {
        font-family: var(--font-title) !important;
        font-size: 1.3125rem !important;
        font-weight: 400 !important;
        line-height: 1.1 !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 180px !important;
        padding: 0.1rem 0.25rem !important;
    }

    /* LEVEL 2 (MIDDLE): view switch (Outline-board, Manuskript, Analyse), one ink-bordered segmented group */
    .nav-center {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        order: 2 !important;
    }
    .view-toggle-group {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }
    .view-btn {
        flex: 1 !important;
        min-height: 44px !important;
        padding: 0 0.25rem !important;
        font-size: 0.75rem !important;
        border-radius: 0 !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }

    /* LEVEL 3 (BOTTOM): theme, outline, AI, PDF, file menu */
    .nav-right {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 0.25rem !important;
        order: 3 !important;
        flex-wrap: wrap !important;
    }
    /* The long part of each label sits in .btn-text in index.html ("AI<span>-assistent</span>",
       "<span>Eksporter </span>PDF"), so hiding it leaves the short label: Del / Outline / AI / PDF. */
    .btn-text {
        display: none !important;
    }
    .btn-toggle-outline-nav,
    #btn-toggle-outline-nav,
    #btn-toggle-ai-nav,
    #btn-export-pdf,
    #btn-back-dashboard,
    #btn-toggle-theme {
        height: 44px !important;
        min-height: 44px !important;
        width: auto !important;
        min-width: 44px !important;
        box-sizing: border-box !important;
        padding: 0 0.45rem !important;
        font-size: 0.75rem !important;
        font-weight: 500 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent !important;
        color: var(--ink) !important;
        border: 1px solid var(--line) !important;
        border-radius: 4px !important;
        box-shadow: none !important;
        margin: 0 !important;
        flex: 1 0 auto !important; /* grow to share the row, never shrink below the label */
    }
    /* Back button keeps its natural width so the title gets the row (artboard: flex none) */
    #btn-back-dashboard {
        flex: none !important;
        padding: 0 12px !important;
        font-size: 13px !important;
    }
    /* Panel toggles: surface fill; ink edge while their panel is open (.active set by app.js) */
    .btn-toggle-outline-nav,
    #btn-toggle-outline-nav,
    #btn-toggle-ai-nav {
        background: var(--surface) !important;
        font-weight: 600 !important;
    }
    .btn-toggle-outline-nav.active,
    #btn-toggle-outline-nav.active,
    #btn-toggle-ai-nav.active {
        border-color: var(--ink) !important;
    }
    /* File-operations menu toggle matches the row and gets a 44px touch target */
    #btn-file-ops {
        height: 44px !important;
        min-height: 44px !important;
        min-width: 44px !important;
        box-sizing: border-box !important;
        padding: 0 0.45rem !important;
        background: transparent !important;
        color: var(--ink) !important;
        border: 1px solid var(--line) !important;
        border-radius: 4px !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    /* 3. Fluid Paper Padding & Indentations for Narrow Screens
       (geometry unchanged from the original mobile rules: hard rule 2) */
    .screenplay-page {
        padding: 16px 12px 24px 14px !important;
        height: auto !important;
        min-height: 360px !important;
        font-size: 13.5px !important;
    }

    /* Title page stays a whole A4 sheet (210 x 297) at phone width instead of shrinking to its
       text. Margins are the desktop millimetres as a share of the 210 mm page width (cqw = 1% of
       the sheet's width), so the layout keeps the same proportions as on paper. */
    .screenplay-page.title-page-sheet {
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 210 / 297;
        padding: 0 !important;
        container-type: inline-size;
    }
    .title-page-sheet .title-page-content {
        padding: 24.19cqw 12.1cqw 12.1cqw; /* 50.8 mm top, 25.4 mm sides and bottom */
        box-sizing: border-box;
    }
    .title-page-sheet .tp-title-group {
        margin-top: 18.14cqw; /* 1.5 in */
        gap: 0.75rem;
    }
    .title-page-sheet .tp-title {
        margin-bottom: 1.25rem;
    }
    .title-page-sheet .tp-bottom-group {
        bottom: 12.1cqw;
        left: 12.1cqw;
        right: 12.1cqw;
        gap: 12px;
    }
    .title-page-sheet .tp-bottom-row {
        gap: 12px;
    }
    .title-page-sheet .tp-field {
        /* Same size as the script pages on a phone, a little smaller on the narrowest screens */
        font-size: clamp(11px, 3.75cqw, 13.5px);
    }
    .title-page-sheet .tp-copyright {
        font-size: clamp(9px, 3.1cqw, 11.25px); /* 10pt beside the 12pt fields */
    }
    .title-page-sheet .tp-source {
        margin-top: 0.5rem;
    }
    .title-page-sheet .tp-contact-group,
    .title-page-sheet .tp-draft-group {
        max-width: 50%;
    }
    .element.character {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        text-align: center !important;
    }
    .element.parenthetical {
        margin-left: 5% !important;
        margin-right: 5% !important;
        width: 90% !important;
        text-align: center !important;
    }
    .element.dialogue {
        margin-left: 2% !important;
        margin-right: 2% !important;
        width: 96% !important;
    }
    .element.action,
    .element.scene-heading,
    .element.transition {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    /* Format toolbar: every button visible at once, nothing to scroll. Titelblad stands apart on
       the left across both rows; the six element types sit in two rows of three:
       Scene · Handling · Karakter, and Parentes · Dialog · Overgang.
       Not !important on display, so the inline display:none of the Outline-board and Analyse
       views still hides it. */
    .editor-toolbar {
        display: grid;
        grid-template-columns: auto repeat(3, minmax(0, 1fr)) auto;
        grid-template-rows: auto auto;
        gap: 2px;
        overflow: visible !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 4px !important;
    }
    .editor-toolbar .toolbar-group {
        display: contents;
    }
    .editor-toolbar .toolbar-separator {
        display: none;
    }
    .editor-toolbar .toolbar-btn {
        min-height: 44px !important;
        min-width: 0;
        padding: 0 6px;
        text-align: center;
        white-space: nowrap;
    }
    .editor-toolbar #btn-toggle-title-page {
        grid-column: 1;
        grid-row: 1 / span 2;
        padding: 0 12px;
        margin-right: 4px;
        border-right: 1px solid var(--line);
        border-radius: 2px 0 0 2px;
    }
    .editor-toolbar .toolbar-btn[data-type="scene-heading"] { grid-column: 2; grid-row: 1; }
    .editor-toolbar .toolbar-btn[data-type="action"]        { grid-column: 3; grid-row: 1; }
    .editor-toolbar .toolbar-btn[data-type="character"]     { grid-column: 4; grid-row: 1; }
    .editor-toolbar .toolbar-btn[data-type="parenthetical"] { grid-column: 2; grid-row: 2; }
    .editor-toolbar .toolbar-btn[data-type="dialogue"]      { grid-column: 3; grid-row: 2; }
    .editor-toolbar .toolbar-btn[data-type="transition"]    { grid-column: 4; grid-row: 2; }
    /* "Mere" (section, synopsis, note, dual dialogue) stands apart on the right across both rows */
    .editor-toolbar #btn-toolbar-more {
        grid-column: 5;
        grid-row: 1 / span 2;
        padding: 0 10px;
        margin-left: 4px;
        border-left: 1px solid var(--line);
        border-radius: 0 2px 2px 0;
    }

    /* Sidebars overlay as drawers on narrow viewports */
    .editor-sidebar {
        width: 85vw !important;
        max-width: 320px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1500 !important;
        /* Same panel tone as the desktop sidebar (04) and the artboard drawer (#FAF9F6) */
        background: var(--surface-2) !important;
        border-right: 1px solid var(--ink) !important;
        box-shadow: none !important;
    }
    .ai-sidebar {
        width: 85vw !important;
        max-width: 320px !important;
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: auto !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1500 !important;
        background: var(--surface-2) !important;
        border-left: 1px solid var(--ink) !important;
        box-shadow: none !important;
    }
    .editor-sidebar.collapsed,
    .left-sidebar.collapsed {
        transform: translateX(-105%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }
    .ai-sidebar.collapsed,
    .right-sidebar.collapsed {
        transform: translateX(105%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }
    .editor-sidebar:not(.collapsed),
    .ai-sidebar:not(.collapsed) {
        transform: translateX(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        visibility: visible !important;
    }

    /* Drawer backdrop: app.js un-hides #mobile-sidebar-backdrop (MOBILE_QUERY, <=850px) while a drawer is open
       and closes the drawers on click. It sits just under the drawers (1500). */
    .mobile-sidebar-backdrop {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1400;
        background: var(--backdrop);
    }
}

/* Phones: the page number sat on top of the first scene heading. Tuck it into the page's 16px
   top padding instead of adding padding, which would move the page breaks. */
@media screen and (max-width: 850px) {
    .page-number-header {
        top: 2px;
        right: 14px;
        font-size: 11px;
    }
    /* Shared-script badge wraps inside the row instead of sliding under Dupliker/Forlad */
    .script-share-badge {
        display: inline;
        margin-left: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Touch screens have no hover, so the Projects list actions stay visible there */
@media (hover: none) {
    .sidebar-script-item .outline-item-actions {
        opacity: 1;
    }
}

/* Share dialog on phones: name on the first line, role and Fjern on the second */
@media screen and (max-width: 600px) {
    .share-member {
        flex-wrap: wrap;
    }
    .share-member-info {
        flex: 1 1 calc(100% - 28px - .6rem);
    }
    .share-member .share-role-select,
    .share-member .share-role-label {
        margin-left: calc(28px + .6rem);
    }
}


/* 10-print: print / PDF rules, copied verbatim from the previous styles.css */
/* ========================================== */
/* Print Style (High Fidelity Screenplay PDF) */
/* ========================================== */
/* PRINT / PDF EXPORT                         */
/* ========================================== */
@media print {
    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    #app { height: auto !important; overflow: visible !important; }
    
    /* Hide all UI chrome */
    #welcome-screen,
    .editor-nav,
    .editor-sidebar,
    .ai-sidebar,
    .zoom-controls,
    .element-status-bar,
    .modal-backdrop,
    .origin-warning-box,
    .no-print {
        display: none !important;
    }
    
    .editor-container {
        height: auto !important;
        background: #ffffff !important;
        overflow: visible !important;
        display: block !important;
    }
    .editor-canvas-container {
        background: #ffffff !important;
        padding: 0 !important;
        overflow: visible !important;
        display: block !important;
    }
    .editor-scroll-container {
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
        display: block !important;
    }
    .page-viewport {
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        transform: none !important;
        overflow: visible !important;
        display: block !important;
    }
    .workspace-body {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    /* ---- @page: zero browser margins, screenplay-page padding handles all spacing ---- */
    @page {
        size: A4;
        margin: 0;
    }
    
    /* Title page */
    .title-page-sheet:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        page-break-after: always !important;
        break-after: always !important;
        width: 210mm !important;
        height: 297mm !important;
        box-sizing: border-box !important;
        padding: 50.8mm 25.4mm 25.4mm 25.4mm !important;
        margin: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
        position: relative !important;
    }
    .title-page-content {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        height: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .tp-title-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 1.5rem !important;
        text-align: center !important;
        margin-top: 1.5in !important;
    }
    .tp-bottom-group {
        position: absolute !important;
        bottom: 25.4mm !important;
        left: 25.4mm !important;
        right: 25.4mm !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1.5rem !important;
        width: auto !important;
        margin-top: 0 !important;
        padding-bottom: 0 !important;
    }
    .tp-bottom-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-end !important;
    }
    .tp-contact-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        max-width: 3.0in !important;
        gap: 0 !important;
    }
    .tp-contact-line {
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 12pt !important;
        color: #000000 !important;
        min-height: 1.25em !important;
        line-height: 1.15 !important;
        width: 100% !important;
    }
    .tp-draft-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        text-align: right !important;
        max-width: 2.5in !important;
        gap: 0 !important;
    }
    .tp-draft-line {
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 12pt !important;
        color: #000000 !important;
        min-height: 1.25em !important;
        line-height: 1.15 !important;
        width: 100% !important;
    }
    .title-page-sheet .tp-field {
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 12pt !important;
        color: #000000 !important;
    }
    .title-page-sheet .tp-copyright {
        font-size: 10pt !important;
    }
    /* An empty optional field (Baseret på, Noter, Copyright) prints nothing and takes no room */
    .title-page-sheet .tp-optional:empty {
        display: none !important;
    }

    /* Page header (the PDF's "Sidehoved" option): top left in the margin, level with the page
       number, so it never moves a line. Added to the PDF's pages after they are laid out. */
    .print-running-header {
        display: block !important;
        position: absolute !important;
        top: 12.7mm !important;
        left: 38.1mm !important;
        max-width: 110mm !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 10pt !important;
        line-height: 12pt !important;
        color: #000000 !important;
        pointer-events: none !important;
    }

    /* Script pages: keep existing padding, add height and page break rules */
    .screenplay-page {
        width: 210mm !important;
        height: 297mm !important;
        padding: 25.4mm 19.5mm 25.4mm 38.1mm !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        overflow: visible !important;
        box-sizing: border-box !important;
        display: block !important;
        page-break-after: always !important;
        break-after: always !important;
        position: relative !important;
    }
    
    /* Page number header: shown top-right of each A4 page sheet */
    .page-number-header {
        display: block !important;
        position: absolute !important;
        top: 12.7mm !important;
        right: 19.5mm !important;
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 12pt !important;
        color: #000000 !important;
        background: transparent !important;
        pointer-events: none !important;
        user-select: none !important;
    }

    /* ---- Element formatting ---- */
    .editor-text-area div.element {
        color: #000000 !important;
        background: transparent !important;
        font-family: 'Courier Prime', Courier, monospace !important;
        font-size: 12pt !important;
        line-height: 1 !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        box-sizing: border-box !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        text-rendering: geometricPrecision !important;
        -webkit-font-smoothing: antialiased !important;
        font-variant-ligatures: none !important;
        font-kerning: normal !important;
    }
    .element.scene-heading {
        margin-top: 2em !important;
        margin-bottom: 1em !important;
        margin-left: 0 !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        text-transform: uppercase !important;
    }
    .element.action {
        margin-top: 1em !important;
        margin-bottom: 1em !important;
        margin-left: 0 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .element.character {
        margin-top: 1em !important;
        margin-bottom: 0 !important;
        margin-left: 2.2in !important;
        width: 3.8in !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        text-transform: uppercase !important;
    }
    .element.parenthetical {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        margin-left: 1.6in !important;
        margin-right: 2.0in !important;
        width: 2.4in !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }
    .element.dialogue {
        margin-top: 0 !important;
        margin-bottom: 1em !important;
        margin-left: 1.0in !important;
        margin-right: 1.5in !important;
        width: 3.5in !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .element.transition {
        margin-top: 1em !important;
        margin-bottom: 1em !important;
        margin-left: 4.0in !important;
        text-align: right !important;
        width: 2.0in !important;
        page-break-before: avoid !important;
        break-before: avoid !important;
    }
    /* Sections, synopses and notes are never printed (the PDF's own pages leave them out; this
       covers printing the editor's pages when the PDF layout fails), nor the dual-dialogue label */
    .editor-text-area div.element.section,
    .editor-text-area div.element.synopsis,
    .editor-text-area div.element.note {
        display: none !important;
    }
    .editor-text-area div.element.character[data-dual="true"]::after {
        content: none !important;
    }
    /* The same fallback: the editor's scene numbers are a view setting (the PDF has its own
       option), and an automatic (FORTS.) prints in the script's ink */
    #editor.show-scene-numbers div.element.scene-heading[data-scene-no]::before,
    #editor.show-scene-numbers div.element.scene-heading[data-scene-no]::after {
        content: none !important;
    }
    .editor-text-area div.element.character[data-cont="true"]::after {
        color: #000000 !important;
    }
    /* Emphasis from Fountain's marks (buildPrintBlocks turns them into b, i and u) */
    .editor-text-area div.element b { font-weight: bold !important; }
    .editor-text-area div.element i { font-style: italic !important; }
    .editor-text-area div.element u { text-decoration: underline !important; }

    /* Hide empty placeholder text */
    .tp-field[contenteditable="true"]:empty::before {
        content: "" !important;
    }
    
    /* Clean up editor wrapper in print */
    #editor {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}


/* PDF Export & Print Styling */
.pdf-export-container {
    color: #1e293b !important;
    background: #ffffff !important;
    font-family: var(--font-ui) !important;
}
.pdf-export-container h1, 
.pdf-export-container h2, 
.pdf-export-container h3, 
.pdf-export-container h4 {
    color: #0f172a !important;
    border-bottom-color: rgba(15, 23, 42, 0.1) !important;
}
.pdf-export-container blockquote, 
.pdf-export-container blockquote.analysis-quote {
    background: rgba(217, 119, 6, 0.06) !important;
    border-left-color: #d97706 !important;
    color: #1e293b !important;
}
.pdf-export-container table.analysis-table {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
}
.pdf-export-container table.analysis-table th {
    background: rgba(217, 119, 6, 0.12) !important;
    color: #b45309 !important;
}
.pdf-export-container table.analysis-table td {
    border-bottom-color: #e2e8f0 !important;
    color: #334155 !important;
}
.pdf-export-container code.inline-code {
    background: rgba(217, 119, 6, 0.1) !important;
    color: #b45309 !important;
}

/* Print: the redesign's screen colours for the empty scene-heading hint and the focused title-page
   field must not reach the PDF */
@media print {
    .element.scene-heading:empty:before {
        content: "" !important;
    }
    .tp-field,
    .tp-field:hover,
    .tp-field:focus {
        border-bottom-color: transparent !important;
    }
}

/* PDF pages: exportPDF() lays the script out on A4 in a desktop-width frame and puts the pages in
   #print-pages, so the PDF has the same page breaks on a phone as on a computer. They are never
   shown on screen; while html.pdf-pages is set they are printed instead of the editor's pages. */
.print-pages {
    display: none;
}
@media print {
    /* The room added for jumping to the last scene (scrollSceneToTop) is screen-only */
    .editor-scroll-container {
        padding-bottom: 0 !important;
    }
    html.pdf-pages #editor {
        display: none !important;
    }
    html.pdf-pages .print-pages {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    /* A title page that is switched off stays out of the PDF: the print rule for
       .screenplay-page above sets display:block !important and would otherwise beat .hidden */
    .screenplay-page.hidden,
    .title-page-sheet.hidden {
        display: none !important;
    }
    /* No forced break after the last page, or the PDF ends with an empty page */
    .print-pages > .screenplay-page:last-child,
    #editor > .screenplay-page:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }
}

/* Analyser tab (renderAnalysesList): one row per analysis of the open script, newest first.
   Same row as the Projects list; the number box shows the analysis number, and the text holds
   the date, the verdict and the model on separate lines. */
.sidebar-analysis-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-ui);
    font-size: 14px;
    /* Three lines of text need room above and below, unlike the one-line rows */
    padding: 8px 2px 8px 10px;
}
.sidebar-analysis-item .outline-item-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    flex-grow: 1;
}
.sidebar-analysis-item .outline-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: normal;
}
.analysis-item-date {
    font-weight: 600;
    color: var(--ink);
}
.analysis-item-verdict,
.analysis-item-meta {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.analysis-item-verdict {
    color: var(--ink);
}
.sidebar-analysis-item:hover .outline-item-actions,
.sidebar-analysis-item:focus-within .outline-item-actions {
    opacity: 1;
}
@media (hover: none) {
    .sidebar-analysis-item .outline-item-actions {
        opacity: 1;
    }
}

/* Picker in the analysis view: which of the script's analyses is shown */
.analysis-picker-wrap {
    flex: 1 1 260px;
    min-width: 0;
}
/* Same look as the app's other dropdowns (.form-group select) */
.analysis-picker-wrap select {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--muted);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color var(--transition-speed);
}
.analysis-picker-wrap select:focus {
    border-color: var(--ink);
}

/* Text for screen readers only */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* In a narrow analysis view the picker gets its own line above the buttons */
@container analysis (max-width: 600px) {
    .analysis-actions-bar {
        flex-wrap: wrap;
    }
    .analysis-picker-wrap {
        flex: 1 1 100%;
    }
}

/* API key fields: text fields with hidden characters instead of type="password", so browsers
   don't take the settings for a login (offering to save a password and filling the email into
   the proxy field). "Vis" adds .revealed. */
.secret-input:not(.revealed) {
    -webkit-text-security: disc;
    text-security: disc;
}

/* ==========================================
   Login page: scrolling and the wide desktop layout
   ========================================== */
/* The login area grows with its card and the page scrolls. It used to be squeezed to the screen
   height and centred with overflow hidden, so a card taller than the screen (the larger logo) was
   cut off top and bottom with no way to scroll. "safe center" starts at the top when it can't fit. */
#login-screen.login-container {
    flex-shrink: 0;
    overflow: visible;
    align-items: safe center;
}

/* Desktop: one wide card in two columns instead of the narrow phone-like column. Left: the logo,
   CineWrite and the intro on a light tint; right: the form. Phones and small tablets keep the
   single column. */
@media screen and (min-width: 900px) {
    #login-screen .login-card.card-blur {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: minmax(48px, 1fr) auto auto auto auto minmax(48px, 1fr);
        max-width: 980px;
        min-height: 560px;
        padding: 0;
        text-align: left;
        background: linear-gradient(to right, var(--surface-2) 50%, var(--surface) 50%);
    }
    /* The left column is centred: logo, CineWrite and the intro */
    #login-screen .login-card .potemkin-logo {
        grid-column: 1;
        grid-row: 2;
        justify-content: center;
        padding: 0 48px;
    }
    #login-screen .login-card h2 {
        grid-column: 1;
        grid-row: 3;
        margin: 36px 48px 0;
        font-size: 72px;
        text-align: center;
    }
    #login-screen .login-card p:not(.login-invite-hint) {
        grid-column: 1;
        grid-row: 4;
        justify-self: center;
        margin: 16px 48px 0;
        max-width: 400px;
        text-align: center;
    }
    #login-screen .login-card p.login-invite-hint {
        grid-column: 1;
        grid-row: 5;
        margin: 20px 48px 0;
        text-align: center;
    }
    #login-screen .login-card .login-form {
        grid-column: 2;
        grid-row: 1 / -1;
        justify-content: center;
        margin: 0;
        padding: 56px 56px;
        border-top: 0;
        border-left: 1px solid var(--line);
    }
}

/* Front page: the logo sits close under the top bar and the description close under the logo.
   The logo PNG has empty transparent space above and below the letters (141 and 156 of its 720 px),
   so the hero logo cancels it with negative margins sized to its height: 240 px on desktop,
   150 px on phones. */
@media screen and (min-width: 851px) {
    .welcome-content {
        padding-top: 3.5rem;
    }
}
@media screen and (max-width: 850px) {
    .welcome-content {
        padding-top: 1.75rem;
    }
}
#welcome-logo {
    height: 240px; /* 50% larger than the other logos */
    margin-top: -47px !important;
    margin-bottom: -52px !important;
}
.welcome-hero .hero-tagline {
    margin-top: 12px;
}
@media screen and (max-width: 850px) {
    #welcome-logo {
        margin-top: -29px !important;
        margin-bottom: -33px !important;
    }
    .welcome-hero h1.hero-logo {
        margin-bottom: 0.5rem !important;
    }
}

/* Login page: CineWrite and the intro sit close under the logo. The logo PNG has empty transparent
   space above and below the letters (141 and 156 of its 720 px), so the login logo cancels it with
   negative margins sized to its height (176 px, 128 px on phones), and the heading gets less space. */
#login-logo {
    margin-top: -34px !important;
    margin-bottom: -38px !important;
}
#login-screen .login-card h2 {
    margin-top: 20px;
}
@media screen and (min-width: 900px) {
    #login-screen .login-card h2 {
        margin-top: 20px;
    }
}
@media screen and (max-width: 850px) {
    #login-logo {
        margin-top: -25px !important;
        margin-bottom: -28px !important;
    }
    #login-screen .login-card h2 {
        margin-top: 16px;
    }
}
/* API key: where the key is kept (or why it is locked), under the key field in the settings card
   and the settings modal, and the button that removes the key from this device */
.api-key-note {
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted);
    margin: 8px 0 0;
}
.api-key-forget {
    margin-top: 8px;
    width: auto;
    align-self: flex-start; /* the modal's form groups are flex columns that stretch buttons */
}
