/* SPDX-License-Identifier: AGPL-3.0-or-later
 * Copyright (C) 2025-2026 Kaspar Bredahl Rasmussen
 * This file is part of Canvas Designer. See LICENSE.md for terms.
 *
 * upload/designer-ui.css — the app redesign B, "Paper and ink"
 * (docs/APP_REDESIGN_PLAN.md). Every rule of the new chrome lives here, loaded
 * after canvas-designer.css, so the redesign can be read in one place and
 * rolled back by removing one <link> plus the markup commits.
 *
 * This file styles the designer's interface only. Nothing here reaches the
 * exported HTML (it is inline-styled), and the page on the canvas keeps
 * Canvas's own Lato on white.
 */

/* ---- 0.2 Tokens -------------------------------------------------------------
 * Contrast (WCAG 2.1): ink on paper 16.0:1; ink-soft 7.2:1 on paper, 6.6:1 on
 * paper-deep, 7.7:1 on white; red 6.1:1 on paper and paper on red 6.1:1;
 * red-deep 8.8:1 on paper; field borders 3.8:1 on white, 3.6:1 on paper
 * (1.4.11). rule and rule-soft are decorative hairlines only. */
:root {
    --ui-paper: #FAF7F2;       /* top bar, panel, dialog headers */
    --ui-paper-deep: #F2EEE6;  /* work area around the page */
    --ui-white: #FFFFFF;       /* page card, fields, chips */
    --ui-ink: #1E1B18;         /* text, icons, selection outline, toast */
    --ui-ink-soft: #5A524B;    /* secondary text, tags, inactive tabs */
    --ui-red: #B51F2E;         /* the main action, the active tab, "new" */
    --ui-red-deep: #8A1822;    /* hover on red, links */
    --ui-rule: #D9D2C5;        /* hairlines between rows and areas */
    --ui-rule-soft: #E4DDD0;   /* row separators */
    --ui-field: #8C8174;       /* borders of inputs, selects, checkboxes */

    --ui-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --ui-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --ui-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ui-radius: 6px;          /* buttons and fields */
    --ui-radius-card: 4px;     /* the page card */
    --ui-radius-chip: 999px;   /* chips */
    --ui-shadow-card: 0 14px 36px rgba(60, 40, 20, 0.08);
    --ui-shadow-pop: 0 6px 18px rgba(60, 40, 20, 0.12);
}

/* ---- 0.1 Fonts --------------------------------------------------------------
 * Fraunces (headings), Inter (interface), JetBrains Mono (small labels): the
 * latin and latin-ext subsets, self-hosted (upload/fonts/, SIL OFL 1.1, see
 * upload/fonts/OFL.txt). Not the landing site's /fonts/ path: the designer
 * must keep working when it is installed somewhere else. */
@font-face {
    font-family: 'Fraunces';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('fonts/fraunces-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Fraunces';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('fonts/fraunces-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Fraunces';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/fraunces-italic-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Fraunces';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/fraunces-italic-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Shared ----------------------------------------------------------------- */
.ui-icon { display: block; flex: none; }
[data-ui-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* The work area has no toolbar of its own any more (1.1): it fills the
   height under the one bar */
.canvas-wrapper { height: auto; min-height: 0; }

/* ---- 1.1 One top bar --------------------------------------------------------
 * wordmark · Canvas menu | Undo Redo Clear | Page frame Preview Desktop
 * … Save My designs Export | Help Settings NB/EN account */
.app-bar {
    position: relative;
    z-index: 60;
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 3px;
    min-height: 64px;
    padding: 10px 18px;
    box-sizing: border-box;
    background: var(--ui-paper);
    border-bottom: 1px solid var(--ui-rule);
    color: var(--ui-ink);
    font-family: var(--ui-sans);
    font-size: 14px;
}
.app-bar > * { flex-shrink: 0; }
.app-bar-brand { display: flex; align-items: center; gap: 12px; margin-right: 8px; }
.app-wordmark {
    margin: 0;
    font-family: var(--ui-serif);
    font-size: 23px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--ui-ink);
    white-space: nowrap;
}
.app-bar-group { display: flex; align-items: center; gap: 2px; }
.app-bar-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--ui-rule); flex: none; }
.app-bar > .app-bar-spacer { flex: 1 1 0; min-width: 8px; }

/* Buttons: text buttons and icon buttons, no boxes */
.app-bar .toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--ui-radius);
    background: transparent;
    color: var(--ui-ink);
    font: 500 14px/1 var(--ui-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.app-bar .toolbar-btn:hover { background: var(--ui-paper-deep); border-color: transparent; }
.app-bar .toolbar-btn:focus-visible,
.app-bar .lang-btn:focus-visible,
.app-bar .account-avatar-btn:focus-visible,
.app-bar .account-login-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.app-bar .toolbar-btn .icon { display: inline-flex; font-size: 1em; }
.app-bar .toolbar-btn-icon { width: 44px; padding: 0; justify-content: center; color: var(--ui-ink-soft); }
.app-bar .toolbar-btn-icon:hover { color: var(--ui-ink); }
.app-bar .toolbar-btn:disabled { color: var(--ui-ink-soft); opacity: 0.45; cursor: default; background: transparent; }
.app-bar .toolbar-btn.active,
.app-bar .toolbar-btn[aria-pressed="true"],
.app-bar #preview-toggle.active { background: var(--ui-ink); color: var(--ui-paper); }
.app-bar #preview-toggle.active .icon { color: inherit; }
.app-bar .toolbar-btn.frame-active { box-shadow: inset 0 -2px 0 var(--ui-ink); background: transparent; color: var(--ui-ink); }
.app-bar .toolbar-btn.frame-active .icon { color: inherit; }
.app-bar-caret { color: var(--ui-ink-soft); }

/* Export: the one red action */
.app-bar .toolbar-btn.primary {
    margin-left: 6px;
    padding: 0 20px;
    background: var(--ui-red);
    color: var(--ui-paper);
    font-weight: 600;
}
.app-bar .toolbar-btn.primary:hover { background: var(--ui-red-deep); color: var(--ui-paper); }

/* The Canvas menu beside the wordmark (connection, import, publish) */
.app-bar .app-bar-canvas {
    height: 28px;
    gap: 6px;
    padding: 0 8px;
    border: 1px solid var(--ui-rule);
    border-radius: var(--ui-radius-card);
    color: var(--ui-ink-soft);
    font: 500 11px/1 var(--ui-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.app-bar .app-bar-canvas:hover { border-color: var(--ui-ink); color: var(--ui-ink); background: transparent; }
.app-bar .canvas-conn-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--ui-field); }
.app-bar .canvas-conn-indicator::after { content: none; }
.app-bar .canvas-conn-indicator.connected { background: #007041; }
.app-bar .canvas-menu-dropdown { left: 0; right: auto; }

/* The bar's dropdowns and popovers: paper, a hairline, a soft shadow */
.app-bar .canvas-menu-dropdown,
.app-bar .frame-selector-dropdown,
.app-bar .account-menu-dropdown,
.app-menu,
.app-popover {
    background: var(--ui-paper);
    border: 1px solid var(--ui-rule);
    border-radius: 8px;
    box-shadow: var(--ui-shadow-pop);
    color: var(--ui-ink);
    font-family: var(--ui-sans);
}
.app-bar .frame-selector-dropdown { left: 0; right: auto; }

/* Language: mono, the active one underlined in red */
.app-bar .lang-toggle-compact {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0 6px;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: var(--ui-mono);
}
.app-bar .lang-toggle-icon { display: none; }
.app-bar .lang-btn {
    height: 40px;
    min-width: 32px;
    padding: 0 6px;
    border: 0;
    border-radius: var(--ui-radius);
    background: transparent;
    color: var(--ui-ink-soft);
    font: 400 12px/1 var(--ui-mono);
    cursor: pointer;
}
.app-bar .lang-btn:hover { color: var(--ui-ink); background: transparent; }
.app-bar .lang-btn.active {
    /* (canvas-designer.css paints the old pill with !important) */
    background: transparent !important;
    box-shadow: none;
    color: var(--ui-ink) !important;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--ui-red);
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
}
.app-bar .lang-sep { color: var(--ui-ink-soft); font-size: 12px; }

/* Account: "Log in" as a text button; signed in, a Fraunces initial in an ink ring */
.app-bar .account-login-btn {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--ui-ink);
    border-radius: var(--ui-radius);
    background: transparent;
    color: var(--ui-ink);
    font: 500 14px/1 var(--ui-sans);
    cursor: pointer;
}
.app-bar .account-login-btn i { display: none; }
.app-bar .account-login-btn:hover { background: var(--ui-paper-deep); }
.app-bar .account-avatar-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--ui-ink);
    border-radius: 50%;
    background: transparent;
    color: var(--ui-ink);
    font: 600 17px/1 var(--ui-serif);
}
.app-bar .account-avatar-btn:hover { transform: none; background: var(--ui-paper-deep); }

/* ---- 1.2 Help menu and 1.3 Settings popover ---------------------------------- */
.app-menu-wrapper { position: relative; }
.app-menu,
.app-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 70;
}
.app-menu[hidden],
.app-popover[hidden] { display: none; }
.app-menu { min-width: 240px; padding: 4px; }
.app-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 0;
    border-radius: var(--ui-radius);
    background: transparent;
    color: var(--ui-ink);
    font: 400 14px/1.3 var(--ui-sans);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.app-menu-item:hover,
.app-menu-item:focus { background: var(--ui-paper-deep); outline: none; }
.app-menu-item:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: -2px; }
.app-menu-hint { color: var(--ui-ink-soft); }
.app-menu-sep { height: 1px; margin: 4px 8px; background: var(--ui-rule-soft); }

.app-popover { width: 300px; padding: 16px 18px 18px; box-sizing: border-box; }
.app-popover-title { margin: 0 0 12px; font: 600 17px/1.2 var(--ui-serif); color: var(--ui-ink); }
.app-setting + .app-setting { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--ui-rule-soft); }
.app-setting-label { margin: 0 0 8px; font: 500 11px/1.2 var(--ui-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-ink-soft); }
.app-setting-row { display: flex; align-items: center; gap: 8px; }
.app-setting-check { display: flex; align-items: center; gap: 10px; min-height: 32px; margin: 0; font-size: 14px; cursor: pointer; }
.app-setting-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ui-ink); cursor: pointer; }
.app-popover .icon-mode-toggle { display: inline-flex; gap: 0; padding: 0; border: 1px solid var(--ui-field); border-radius: var(--ui-radius); overflow: hidden; background: var(--ui-white); }
.app-popover .icon-mode-btn {
    min-width: 52px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ui-ink);
    font: 500 13px/1 var(--ui-sans);
    cursor: pointer;
}
/* The rule sits on the left so a hidden last button (FA, off) leaves no stray line */
.app-popover .icon-mode-btn + .icon-mode-btn { border-left: 1px solid var(--ui-field); }
.app-popover .icon-mode-btn[hidden] { display: none; }
.app-popover .icon-mode-btn svg { display: block; margin: 0 auto; }
.app-setting-check-sub { margin-top: 8px; }
.app-setting-help { margin: 2px 0 0 28px; font-size: 12px; line-height: 1.4; color: var(--ui-ink-soft); }
.app-popover .icon-mode-btn.active { background: var(--ui-ink) !important; color: var(--ui-paper) !important; box-shadow: none; }
.app-popover .icon-mode-btn:focus-visible,
.app-popover .app-setting-info:focus-visible,
.app-popover .app-setting-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.app-setting-info { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--ui-ink-soft); cursor: pointer; }
.app-setting-info:hover { color: var(--ui-ink); background: var(--ui-paper-deep); }
.app-setting-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 14px/1 var(--ui-sans);
    cursor: pointer;
}
.app-setting-btn:hover { border-color: var(--ui-ink); }

@media (prefers-reduced-motion: reduce) {
    .app-bar .toolbar-btn, .sidebar-mobile-toggle-icon { transition: none; }
}

/* ---- 1.5 Narrow widths ---------------------------------------------------------
 * appBar.js measures: the full bar first, then .is-compact, then also
 * .is-tight, until it fits on one row (labels are longer in Norwegian, so
 * fixed breakpoints would not do). Compact: Save, My designs become icon
 * buttons (the label stays for screen readers, the title is the tooltip)
 * and the carets go. Tight: the Canvas menu and Help are icons too and
 * everything closes up; snug (since the KI menu) drops the separators. That
 * gives one row at 1024px in both languages;
 * if even the tight bar doesn't fit, it wraps to two rows rather than
 * scrolling sideways (below 900px). */
.app-bar { flex-wrap: wrap; row-gap: 6px; }
.app-bar:not(.is-compact) .app-bar-collapsible .icon { display: none; }

.app-bar.is-compact { padding: 10px 10px; gap: 2px; }
.app-bar.is-compact .app-wordmark { font-size: 21px; }
.app-bar.is-compact .toolbar-btn { padding: 0 9px; }
.app-bar.is-compact .toolbar-btn.primary { padding: 0 14px; }
.app-bar.is-compact .app-bar-brand { margin-right: 6px; gap: 8px; }
.app-bar.is-compact .app-bar-sep { margin: 0 2px; }
.app-bar.is-compact .app-bar-collapsible { width: 44px; padding: 0; justify-content: center; }
.app-bar.is-compact #help-menu-btn { width: auto; padding: 0 9px; }
.app-bar.is-compact #help-menu-btn .icon { display: none; }
.app-bar.is-compact .app-bar-collapsible:not(#help-menu-btn) .label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.app-bar.is-compact .toolbar-btn .app-bar-caret { display: none; }
.app-bar.is-compact .app-bar-canvas .app-bar-caret { display: inline-flex; }

.app-bar.is-tight { gap: 0; padding: 10px 6px; }
.app-bar.is-tight .toolbar-btn { padding: 0 5px; gap: 4px; }
.app-bar.is-tight .toolbar-btn.primary { padding: 0 10px; margin-left: 2px; }
.app-bar.is-tight .toolbar-btn.primary .icon { display: none; }
.app-bar.is-tight .toolbar-btn-icon,
.app-bar.is-tight .app-bar-collapsible,
.app-bar.is-tight #help-menu-btn { width: 40px; padding: 0; justify-content: center; }
.app-bar.is-tight #help-menu-btn .icon { display: inline-flex; }
.app-bar.is-tight #help-menu-btn .label,
.app-bar.is-tight .app-bar-canvas .label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.app-bar.is-tight .app-bar-canvas { padding: 0 6px; }
.app-bar.is-tight .app-bar-sep { margin: 0 1px; }
.app-bar.is-tight .app-wordmark { font-size: 17px; }
.app-bar.is-tight .app-bar-brand { margin-right: 2px; }
.app-bar.is-tight .lang-toggle-compact { margin: 0 2px; }
.app-bar.is-tight .lang-btn { min-width: 28px; padding: 0 4px; }
.app-bar.is-tight .account-login-btn { padding: 0 7px; }
/* Snug, the last step before wrapping (since the KI menu): the separators
   and the spacer's minimum go, and the text buttons close up. !important
   because canvas-designer.css gives every .toolbar-btn "padding: 6px 10px
   !important", which the compact and tight paddings above don't beat */
.app-bar.is-snug .app-bar-sep { display: none; }
.app-bar.is-snug > .app-bar-spacer { min-width: 0; }
.app-bar.is-snug .toolbar-btn { padding-left: 4px !important; padding-right: 4px !important; }
/* The icon buttons narrow too (still 36 by 44). With 6px and 40px the
   Norwegian bar had 14px to spare at 1024px on macOS and wrapped on Linux,
   where the same font is drawn a little wider; now it has about 66px */
.app-bar.is-snug .toolbar-btn-icon,
.app-bar.is-snug .app-bar-collapsible,
.app-bar.is-snug #help-menu-btn { width: 36px; }

@media (max-width: 899px) {
    .app-bar-spacer { display: none; }
    .app-bar-end { margin-left: auto; }
}

/* ---- Stage 2 Element panel B5 ------------------------------------------------------
 * Start from template, search, Recent, the text tabs with the line under
 * them, the list of plain rows, and the credit at the bottom. */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--ui-paper);
    border-right: 1px solid var(--ui-rule);
    color: var(--ui-ink);
    font-family: var(--ui-sans);
}
/* Trimmed for 13-inch screens (2026-10-28): the template button beside the
   search, the tabs on two rows, the description for screen readers only,
   36px rows, mono group labels and the credit in the Help menu. On a
   1440×780 window the list went from 327px (about 5 rows) to about 600px. */
.sidebar .element-selector { gap: 10px; padding-top: 14px; }
.sidebar .templates-section-toggle {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--ui-ink);
    border-radius: var(--ui-radius);
    background: transparent;
    color: var(--ui-ink);
    font: 500 13px/1 var(--ui-sans);
    white-space: nowrap;
    cursor: pointer;
}
.sidebar .templates-section-toggle:hover { background: var(--ui-paper-deep); border-color: var(--ui-ink); }
.sidebar .templates-section-toggle:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }

.sidebar .search-container { display: flex; align-items: center; gap: 8px; padding: 0 16px; border: 0; background: transparent; margin: 0; }
.sidebar .search-input-wrapper { position: relative; flex: 1; min-width: 0; }
.sidebar .search-input {
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    padding: 0 72px 0 12px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 400 14px/1 var(--ui-sans);
}
.sidebar .search-input::placeholder { color: var(--ui-ink-soft); opacity: 1; }
.sidebar .search-input::-webkit-search-cancel-button { display: none; }
.sidebar .search-input:focus { outline: 2px solid var(--ui-ink); outline-offset: 1px; border-color: var(--ui-ink); box-shadow: none; }
.sidebar .search-icon { position: absolute; right: 12px; top: 11px; color: var(--ui-ink-soft); pointer-events: none; font-size: 1em; }
.sidebar .search-clear {
    position: absolute;
    right: 34px;
    top: 4px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ui-ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar .search-clear:hover { color: var(--ui-ink); background: var(--ui-paper-deep); }

/* Recent (2.3) */
.recent-elements { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; padding: 0 16px; overflow: hidden; }
.recent-elements[hidden] { display: none; }
.recent-label { flex: none; margin-right: 2px; font: 500 11px/1 var(--ui-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-ink-soft); }
.recent-chips { display: contents; }
.recent-chip {
    height: 28px;
    padding: 0 9px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius-chip);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 12px/1 var(--ui-sans);
    white-space: nowrap;
    flex: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: grab;
}
.recent-chip[hidden] { display: none; }
.recent-chip:hover { border-color: var(--ui-ink); }
.recent-chip:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }

/* The tabs (2.1) and the line under them (2.2) */
.sidebar .sidebar-content-row { flex-direction: column; min-height: 0; overflow: hidden; }
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    margin: 0 16px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--ui-rule);
}
.category-tabs .category-btn {
    height: 30px;
    margin: 0 11px 0 0;
    padding: 0 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ui-ink-soft);
    font: 500 13px/1 var(--ui-sans);
    cursor: pointer;
}
.category-tabs .category-btn:hover { color: var(--ui-ink); background: transparent; }
.category-tabs .category-btn.active,
.category-tabs .category-btn[aria-selected="true"] {
    color: var(--ui-ink);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--ui-red);
    background: transparent;
}
.category-tabs .category-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.category-tabs .category-btn .icon { display: none; }
.category-tabs.is-dimmed,
.category-description.is-dimmed { opacity: 0.45; }
.category-tabs.is-dimmed .category-btn { cursor: default; }
/* (screen readers only since the trim: .sr-only in canvas-designer.css) */
.category-description { margin: 0; }

/* The list (2.4): plain rows, hairlines, group labels in mono capitals */
.sidebar .element-list-panel { flex: 1; min-height: 0; overflow: hidden; }
.sidebar .sub-elements,
.sidebar .search-results {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 2px 16px 12px;
}
.sidebar .element-item {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 36px;
    margin: 0;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px solid var(--ui-rule-soft);
    border-radius: 0;
    background: transparent;
    color: var(--ui-ink);
    font: 400 14px/1.3 var(--ui-sans);
    cursor: grab;
    overflow: visible;
    transition: none;
}
.sidebar .element-item::before { content: none; }
.sidebar .element-item:hover { background: var(--ui-paper-deep); transform: none; box-shadow: none; border-color: var(--ui-rule-soft); }
.sidebar .element-item:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: -2px; }
.sidebar .element-item .tag { width: 38px; flex: none; font: 500 12px/1 var(--ui-mono); color: var(--ui-ink-soft); }
.sidebar .element-item .icon { display: none; }
.sidebar .element-item .name { flex: 1; min-width: 0; font-size: 14px; color: var(--ui-ink); }
.sidebar .element-item .sub-label { margin-left: 6px; font-size: 12px; color: var(--ui-ink-soft); }
.sidebar .element-item .new { margin-left: 8px; font: 500 11px/1 var(--ui-mono); color: var(--ui-red); }
.sidebar .element-item .badge { margin-left: 6px; }
.sidebar .element-item .badge.web-only { background: transparent; border: 0; padding: 0; font-size: 12px; }
.sidebar .element-section-divider,
.sidebar .search-results .section-title {
    display: block;
    margin: 14px 0 0;
    padding: 0 0 5px;
    border-bottom: 1px solid var(--ui-rule-soft);
    background: transparent;
    font: 500 11px/1.2 var(--ui-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ui-ink-soft);
    text-align: left;
}
.sidebar .element-section-divider::before,
.sidebar .element-section-divider::after { content: none; }
.sidebar .element-section-divider span { padding: 0; }
.sidebar .element-section-divider:first-child { margin-top: 6px; }
.sidebar .no-results { padding: 18px 0; color: var(--ui-ink-soft); }
/* The activities' settings above their list */
.sidebar .activity-settings-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 10px 0 4px;
    padding: 8px 12px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 13px/1.2 var(--ui-sans);
}
.sidebar .activity-settings-btn:hover { border-color: var(--ui-ink); background: var(--ui-white); }
.sidebar .activity-defaults-hint { margin: 4px 0 6px; font-size: 12px; color: var(--ui-ink-soft); }
.sidebar .sidebar-zone-indicator { margin: 8px 0 0; }
/* My elements */
.sidebar .my-element-item .icon { display: none; }

/* canvas-designer.css's "laptop optimization" pins these with !important */
.sidebar .search-container { padding: 0 16px !important; }
.sidebar .search-input { padding: 0 34px 0 12px !important; font-size: 14px !important; }
.sidebar .search-input:not(:placeholder-shown) { padding-right: 70px !important; }
.sidebar .search-icon { top: 11px; transform: none; }
.sidebar .sub-elements,
.sidebar .search-results { max-height: none !important; padding-bottom: 12px !important; }
.sidebar .element-item { padding: 0 4px !important; margin: 0 !important; gap: 0 !important; }
.sidebar .element-item .name { font-weight: 400; line-height: 1.3; }
.sidebar .element-item .badge { font-size: 11px !important; padding: 0 !important; }
.category-tabs .category-btn { width: auto; display: inline-flex; flex-direction: row; align-items: center; padding: 0 2px !important; }
.category-tabs .category-btn .label {
    max-width: none;
    overflow: visible;
    font-size: 13px !important;
    font-weight: inherit;
    line-height: 1;
    white-space: nowrap;
}

/* Reflow (5.1): narrow windows and 200% zoom stack the panel over the
   page at full width; the list scrolls inside it */
.sidebar-mobile-toggle { display: none; }

@media (max-width: 768px) {
    .sidebar { width: 100%; height: 46vh; border-right: 0; border-bottom: 1px solid var(--ui-rule); }
    /* The panel folds to one row on phones (appBar.js setupMobilePanel) */
    .sidebar-mobile-toggle {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 44px;
        padding: 0 16px;
        border: 0;
        border-bottom: 1px solid var(--ui-rule-soft);
        background: transparent;
        color: var(--ui-ink);
        font: 500 12px/1 var(--ui-mono);
        letter-spacing: 0.08em;
        text-transform: uppercase;
        cursor: pointer;
    }
    .sidebar-mobile-toggle:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: -2px; }
    .sidebar-mobile-toggle-icon { display: inline-flex; transition: transform 0.15s ease; }
    .sidebar-mobile-toggle[aria-expanded="false"] .sidebar-mobile-toggle-icon { transform: rotate(-90deg); }
    .sidebar.is-collapsed { height: auto; }
    .sidebar.is-collapsed .sidebar-mobile-toggle { border-bottom: 0; }
    .sidebar.is-collapsed .element-selector { display: none; }
    /* Preview on a phone is the page alone: no bar, no panel; the Exit
       preview pill (and Esc) bring them back */
    body.preview-mode .app-bar,
    body.preview-mode .sidebar { display: none; }
    body.preview-mode .preview-exit-pill { top: 12px; right: 12px; }
    .sidebar .element-selector { padding-top: 12px; gap: 10px; }
    .canvas-wrapper { padding: 16px 12px 64px; }
}

/* ---- Stage 3 Work area -------------------------------------------------------------
 * 3.1 The work area is paper-deep; the page card is the one white thing on
 * the screen, still Lato on white inside like Canvas. */
.preview-container { background: var(--ui-paper-deep); }
.canvas-wrapper { padding: 36px 36px 96px; }
/* The empty canvas keeps its minimum height but grows with the welcome
   screen. canvas-designer.css gives it a fixed height and centres the
   content, so on a phone (narrow, text wraps, the draft card shows) the
   content spilled over the white card at the top and the bottom (iPhone
   Air, 16 Nov 2026). */
.canvas.empty { height: auto; }
.canvas {
    background: var(--ui-white);
    border: 1px solid var(--ui-rule-soft);
    border-radius: var(--ui-radius-card);
    box-shadow: var(--ui-shadow-card);
}
/* The breadcrumb (when a column is entered): top left of the work area, mono */
.container-breadcrumb-wrapper {
    padding: 10px 36px 0;
    background: transparent;
    border: 0;
    font: 500 11px/1.4 var(--ui-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ui-ink-soft);
}
.container-breadcrumb-wrapper .breadcrumb-label { color: var(--ui-ink-soft); font-size: inherit; }
.container-breadcrumb-wrapper .breadcrumb-item { color: var(--ui-ink); }

/* 3.2 "+ Section" lines: a dotted hairline with a mono text button; the
   column "+" and the drop line in ink */
.section-gap::before { border-top: 1px dotted #B9AE9C; }
.section-gap-btn {
    gap: 4px;
    padding: 4px 10px;
    border: 0;
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink-soft);
    font: 500 11px/1.4 var(--ui-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.section-gap-btn i { font-size: 0.9em; }
.section-gap-btn:hover,
.section-gap.is-open .section-gap-btn { background: var(--ui-white); color: var(--ui-ink); }
.section-gap-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.container-zone > .column-add { border-color: var(--ui-rule); color: var(--ui-ink-soft); }
.container-zone > .column-add:hover { border-color: var(--ui-ink); color: var(--ui-ink); background: var(--ui-paper); }
.container-zone > .column-add:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.drop-indicator { background: var(--ui-ink); height: 3px; }

/* 3.3 The selected block: a 2px ink outline 10px out, its name in mono on
   the outline (selectionMixin.drawSelectionLabel), and a paper toolbar */
.canvas-element.is-selected { outline: 2px solid var(--ui-ink); outline-offset: 10px; }
.cd-select-label {
    position: absolute;
    top: -19px;
    left: 4px;
    z-index: 4;
    padding: 0 6px;
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 11px/1.3 var(--ui-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}
body.preview-mode .cd-select-label { display: none; }
.element-controls,
.element-controls[data-toolbar="v2"] {
    background: var(--ui-paper);
    border: 1px solid var(--ui-rule);
    border-radius: 8px;
    box-shadow: var(--ui-shadow-pop);
}
.element-controls .control-btn,
.element-controls[data-toolbar="v2"] > .control-btn { background: transparent; color: var(--ui-ink); border-radius: var(--ui-radius); }
.element-controls .control-btn:hover { background: var(--ui-paper-deep); color: var(--ui-ink); }
.element-controls .control-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 1px; }
.element-controls .ctl-handle { color: var(--ui-ink-soft); }
.element-controls[data-toolbar="v2"] > .control-btn.ctl-variant { color: var(--ui-ink); font-family: var(--ui-sans); }
.ctl-menu { background: var(--ui-paper); border-color: var(--ui-rule); box-shadow: var(--ui-shadow-pop); }
.ctl-menu .ctl-item:hover { background: var(--ui-paper-deep); }

/* 3.4 The toast: ink, paper text, 6px radius; the icon colours per type stay */
.toast {
    background: var(--ui-ink);
    color: var(--ui-paper);
    border-radius: var(--ui-radius);
    box-shadow: 0 8px 24px rgba(30, 20, 10, 0.25);
    font-family: var(--ui-sans);
}

/* Exit preview, over the page: ink with paper text like the toast, a 6px
   radius like the bar's buttons (it was a teal pill) */
.preview-exit-pill {
    background: var(--ui-ink);
    color: var(--ui-paper);
    border: 1px solid var(--ui-ink);
    border-radius: var(--ui-radius);
    padding: 10px 16px;
    font: 600 14px/1.2 var(--ui-sans);
    box-shadow: var(--ui-shadow-pop);
}
.preview-exit-pill:hover { background: #3A342E; border-color: #3A342E; transform: none; }
.preview-exit-pill:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }

/* 3.5 The welcome card: Fraunces, "Welcome to" in italic, both actions
   outlined; with a draft, the draft card holds the one red button */
.empty-state h3 {
    margin: 0 0 12px;
    font: 500 44px/1.1 var(--ui-serif);
    letter-spacing: -0.015em;
    color: var(--ui-ink);
}
.empty-state h3 em { font-style: italic; font-weight: 400; }
.empty-state p { color: var(--ui-ink-soft); font-family: var(--ui-sans); }
.empty-state-btn,
.empty-state-btn-primary,
.empty-state.has-draft .empty-state-actions .empty-state-btn-primary {
    height: 48px;
    padding: 0 20px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 15px/1 var(--ui-sans);
}
.empty-state-btn:hover,
.empty-state-btn-primary:hover,
.empty-state.has-draft .empty-state-actions .empty-state-btn-primary:hover { background: var(--ui-paper); border-color: var(--ui-ink); }
.empty-state-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.empty-state-draft {
    max-width: 540px;
    margin: 4px auto 22px;
    padding: 18px 20px;
    background: var(--ui-paper);
    border: 1px solid var(--ui-rule);
    border-radius: var(--ui-radius);
}
.empty-state-draft-text { gap: 4px; color: var(--ui-ink-soft); font: 400 14px/1.45 var(--ui-sans); }
.empty-state-draft-when { font: 500 11px/1.3 var(--ui-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-ink-soft); }
.empty-state-draft-text strong { font: 500 19px/1.25 var(--ui-serif); color: var(--ui-ink); }
.empty-state-draft-actions .empty-state-btn { height: 44px; padding: 0 16px; border-color: var(--ui-ink); }
.empty-state-draft-actions #draft-restore-btn {
    padding: 0 18px;
    border-color: var(--ui-red);
    background: var(--ui-red);
    color: var(--ui-paper);
    font-weight: 600;
}
.empty-state-draft-actions #draft-restore-btn:hover { background: var(--ui-red-deep); border-color: var(--ui-red-deep); }

/* ---- Stage 4 One editing pattern: the dialogs' look ----------------------------------
 * Every dialog (the fourteen editors on editorDialog.js, the older
 * builders and the other dialogs, which get this look from here): a paper
 * header with a Fraunces title and a hairline, a white body, one red main
 * action in the footer, outlined secondary buttons, fields with
 * --ui-field borders and a 2px ink focus ring, segmented choices in ink.
 * Block previews inside the dialogs keep their own inline styles. */
.modal { background: rgba(30, 27, 24, 0.45); }
.modal .modal-content {
    border: 1px solid var(--ui-rule);
    border-radius: 8px;
    background: var(--ui-white);
    box-shadow: 0 24px 60px rgba(30, 20, 10, 0.22);
    color: var(--ui-ink);
    font-family: var(--ui-sans);
}
.modal .modal-header {
    background: var(--ui-paper);
    border-bottom: 1px solid var(--ui-rule);
    border-radius: 8px 8px 0 0;
}
.modal .modal-title {
    font: 600 21px/1.25 var(--ui-serif);
    letter-spacing: -0.005em;
    color: var(--ui-ink);
}
/* The coloured icons in the old titles go: the title says what it is */
.modal .modal-title > i:first-child,
.modal .modal-title > .fa-solid:first-child { display: none; }
.modal .modal-close { color: var(--ui-ink-soft); border-radius: var(--ui-radius); width: 40px; height: 40px; }
.modal .modal-close:hover { background: var(--ui-paper-deep); color: var(--ui-ink); }
.modal .modal-close:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.modal .modal-footer { border-top: 1px solid var(--ui-rule); background: var(--ui-white); border-radius: 0 0 8px 8px; }

.modal .btn { border-radius: var(--ui-radius); font-family: var(--ui-sans); font-weight: 500; min-height: 40px; }
.modal .btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.modal .btn-primary { background: var(--ui-ink); color: var(--ui-paper); border: 1px solid var(--ui-ink); }
.modal .btn-primary:hover { background: #3A342E; border-color: #3A342E; }
.modal .modal-footer .btn-primary { background: var(--ui-red); border-color: var(--ui-red); color: var(--ui-paper); font-weight: 600; }
.modal .modal-footer .btn-primary:hover { background: var(--ui-red-deep); border-color: var(--ui-red-deep); }
.modal .btn-secondary { background: var(--ui-white); color: var(--ui-ink); border: 1px solid var(--ui-ink); }
.modal .btn-secondary:hover { background: var(--ui-paper); }

.modal .form-control,
.modal input[type="text"],
.modal input[type="url"],
.modal input[type="number"],
.modal input[type="search"],
.modal select,
.modal textarea {
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    color: var(--ui-ink);
}
.modal .form-control:focus,
.modal input:focus-visible,
.modal select:focus-visible,
.modal textarea:focus-visible {
    outline: 2px solid var(--ui-ink);
    outline-offset: 1px;
    border-color: var(--ui-ink);
    box-shadow: none;
}
/* Segmented choices and chips: ink on white, the chosen one filled ink */
.modal .be-chip,
.modal .be-seg button { border-color: var(--ui-field); color: var(--ui-ink); border-radius: var(--ui-radius-chip); }
.modal .be-chip[aria-checked="true"],
.modal .be-seg button[aria-checked="true"],
.modal .be-chip[aria-pressed="true"] { background: var(--ui-ink); border-color: var(--ui-ink); color: var(--ui-paper); }
.modal .be-chip:focus-visible,
.modal .be-seg button:focus-visible,
.modal .be-swatch:focus-visible,
.modal .be-icon:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.modal .be-swatch[aria-checked="true"] { border-color: var(--ui-ink); }
.modal .be-icon { border-color: var(--ui-field); color: var(--ui-ink); }
.modal .be-icon[aria-checked="true"] { border-color: var(--ui-ink); background: var(--ui-paper); }
.modal .be-label { color: var(--ui-ink); }
.modal .be-preview { border-color: var(--ui-rule); }

/* The shell's own pieces (editorDialog.js) */
.ed-discard {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 16px;
    padding: 12px 20px;
    background: var(--ui-paper);
    border-top: 1px solid var(--ui-rule);
}
.ed-discard[hidden] { display: none; }
.ed-discard-text { margin: 0 auto 0 0; font: 500 15px/1.4 var(--ui-sans); color: var(--ui-ink); }
.ed-discard-actions { display: flex; gap: 8px; }
.ed-error { margin: 6px 0 0; font-size: 13px; line-height: 1.4; color: var(--ui-red-deep); }
.modal [aria-invalid="true"] { border-color: var(--ui-red) !important; outline: 1px solid var(--ui-red); outline-offset: 0; }
.ed-row-flag { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--ui-radius); background: #FBEFEF; color: var(--ui-red-deep); font-size: 13px; }
.ed-linkask {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid var(--ui-rule);
    border-radius: var(--ui-radius);
    background: var(--ui-paper);
}
.ed-linkask-label { flex: 1 0 100%; font-size: 13px; color: var(--ui-ink); }
.ed-linkask input { flex: 1 1 200px; height: 36px; }

/* Colour theme (Settings): two groups with the panel's mono labels; fields
   with a visible edge (3.8:1) and an ink focus ring (the accent ring was
   2.15:1); the readout says which shade the blocks use */
#brand-color-modal .brand-color-group {
    margin: 18px 0 2px;
    font: 500 11px/1.4 var(--ui-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ui-ink-soft);
}
#brand-color-modal .brand-color-note { margin: 0 0 4px; font-size: 13px; line-height: 1.45; color: var(--ui-ink-soft); }
#brand-color-modal .brand-color-row { border-bottom-color: var(--ui-rule-soft); }
#brand-color-modal .brand-color-label { color: var(--ui-ink); }
#brand-color-modal .brand-color-swatch { border: 1px solid var(--ui-rule); border-radius: var(--ui-radius); }
#brand-color-modal .brand-color-hex { font-family: var(--ui-mono); color: var(--ui-ink); background: var(--ui-white); border-color: var(--ui-field); }
#brand-color-modal .brand-color-hex:focus { outline: 2px solid var(--ui-ink); outline-offset: 1px; border-color: var(--ui-ink); background: var(--ui-white); }
#brand-color-modal .brand-color-picker { border: 1px solid var(--ui-field); border-radius: var(--ui-radius); }
#brand-color-modal .brand-color-picker:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
#brand-color-modal .brand-color-contrast { font-family: var(--ui-mono); text-align: right; }
#brand-color-modal .brand-color-contrast.is-decor { color: var(--ui-ink-soft); }
#brand-color-modal .brand-color-contrast.is-adjusted { color: var(--ui-ink); white-space: normal; max-width: 170px; line-height: 1.4; }
#brand-color-modal .brand-color-used {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin: 0 4px -1px 2px;
    border: 1px solid var(--ui-rule);
    border-radius: 3px;
}

/* ---- AI prompt round trip (docs/AI_PROMPT_ROUNDTRIP.md) ----------------------------
 * The KI menu's dialogs (aiPromptDialogs.js) and the line on the empty
 * canvas. Choices are native radios in fieldsets; the prompt and the
 * answer are mono text fields; a check's places are text, its details
 * mono and soft. The error heading is red-deep (8.8:1 on paper). */
.empty-state-ai { margin: 18px 0 0; font-size: 14px; }
.empty-state-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ui-red-deep);
    font: 500 14px/1.4 var(--ui-sans);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.empty-state-link:hover { color: var(--ui-ink); }
.empty-state-link:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; border-radius: 2px; }

.ai-prompt-dialog .modal-body { font-size: 14px; line-height: 1.5; color: var(--ui-ink); }
.ai-prompt-dialog .aip-intro { margin: 0 0 14px; }
.aip-fieldset { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.aip-fieldset:disabled .aip-choice { color: var(--ui-ink-soft); cursor: default; }
.aip-legend { display: block; margin: 0 0 6px; padding: 0; font: 500 11px/1.2 var(--ui-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-ink-soft); }
.aip-row { display: flex; flex-wrap: wrap; gap: 0 22px; }
.aip-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; }
@media (max-width: 640px) { .aip-two { grid-template-columns: minmax(0, 1fr); } }
.aip-choice { display: flex; align-items: flex-start; gap: 10px; min-height: 32px; padding: 4px 0; cursor: pointer; }
.aip-choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--ui-ink); cursor: pointer; }
.aip-choice input:disabled { cursor: default; }
.aip-choice input:disabled + span { color: var(--ui-ink-soft); }
.aip-choice input:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.aip-choice small { display: block; color: var(--ui-ink-soft); font-size: 13px; }
.aip-facts { margin: 4px 0 14px; padding: 12px 14px; border: 1px solid var(--ui-rule); border-radius: var(--ui-radius); background: var(--ui-paper); }
.aip-facts p { margin: 0 0 6px; }
.aip-facts p:last-child { margin-bottom: 0; }
.aip-facts ul { margin: 2px 0 6px; padding-left: 20px; }
.aip-note { margin: 6px 0; color: var(--ui-ink-soft); font-size: 13px; }
.aip-privacy { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--ui-ink); background: var(--ui-paper-deep); }
.aip-privacy a, .aip-about a, .aip-result a { color: var(--ui-red-deep); }
/* summary keeps its native marker: the only open/closed cue */
.aip-preview summary, .aip-details summary { display: list-item; min-height: 32px; line-height: 32px; cursor: pointer; font-weight: 500; }
.aip-preview summary:focus-visible, .aip-details summary:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.aip-code {
    display: block;
    width: 100%;
    min-height: 200px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 400 12px/1.5 var(--ui-mono);
    resize: vertical;
}
.aip-answer { min-height: 180px; }
.aip-message { min-height: 140px; margin: 8px 0 0; }
.aip-size { margin: 6px 0 0; color: var(--ui-ink-soft); font: 400 12px/1.4 var(--ui-mono); }
.aip-status { margin: 10px 0 0; font-weight: 500; }
.aip-status:empty { display: none; }
.aip-status.is-ok::before { content: '✓ '; }
.aip-result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--ui-rule-soft); }
.aip-result[hidden] { display: none; }
.aip-result-title { margin: 0 0 8px; font: 600 17px/1.3 var(--ui-serif); color: var(--ui-ink); }
.aip-result-title.is-bad { color: var(--ui-red-deep); }
.aip-issues { margin: 0 0 10px; padding-left: 22px; }
.aip-issues li { margin-bottom: 8px; }
.aip-place { display: block; font-weight: 500; }
.aip-detail { display: block; margin-top: 2px; color: var(--ui-ink-soft); font: 400 12px/1.45 var(--ui-mono); overflow-wrap: anywhere; }
.aip-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.aip-details { margin: 8px 0; }
.aip-details ul { margin: 6px 0 0; padding-left: 20px; }
.aip-details a { overflow-wrap: anywhere; }
.aip-how { margin-top: 12px; }
.ai-prompt-dialog .modal-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aip-spacer { flex: 1 1 auto; }
.ai-prompt-dialog .btn[hidden] { display: none; }
.aip-about ul { margin: 8px 0 0; padding-left: 20px; }
.aip-about li { margin-bottom: 6px; }

/* ---- Template browser ("Velg en mal") -----------------------------------------------
 * The overview over the work area, in the panel's language: paper-deep
 * around white cards, a Fraunces title, mono group labels on a hairline, an
 * outlined back button. Each card's name is a button stretched over the card
 * (templateManager.js), so a template can be picked with the keyboard; "Se
 * eksempel" sits above it. The preview and the insert question are .modal
 * dialogs and get Stage 4's look; the preview's body is the page as Canvas
 * shows it (Lato on white). Contrast: ink-soft on white 7.7:1, on paper 7.2:1. */
.template-browser {
    padding: 40px 32px;
    background: var(--ui-paper-deep);
    color: var(--ui-ink);
    font-family: var(--ui-sans);
}
.template-browser-header { margin-bottom: 28px; }
.template-browser-header h2 {
    margin: 0 0 6px;
    font: 600 32px/1.2 var(--ui-serif);
    letter-spacing: -0.01em;
    color: var(--ui-ink);
}
.template-browser-header p { margin: 0 0 18px; font-size: 15px; color: var(--ui-ink-soft); }
.template-browser-close {
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid var(--ui-ink);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 14px/1 var(--ui-sans);
}
.template-browser-close:hover { border-color: var(--ui-ink); background: var(--ui-paper); color: var(--ui-ink); }
.template-browser-close:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.template-browser-grid { gap: 20px; }

.template-group {
    grid-column: 1 / -1;
    margin: 20px 0 -4px;
    padding: 0 0 6px;
    border-bottom: 1px solid var(--ui-rule);
    font: 500 12px/1.2 var(--ui-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ui-ink-soft);
}
.template-group:first-child { margin-top: 0; }
/* With one category chosen, its heading is the first thing in the grid */
.template-browser-grid.is-filtered .template-group { margin-top: 0; }
.template-group[hidden],
.template-card[hidden] { display: none; }

/* The chips: "All" and one per category, the chosen one filled ink (as the
   segmented choices in the dialogs) */
.template-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 1200px;
    margin: 0 auto 28px;
}
.template-chip {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--ui-field);
    border-radius: var(--ui-radius-chip);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 14px/1 var(--ui-sans);
    cursor: pointer;
}
.template-chip:hover { border-color: var(--ui-ink); }
.template-chip[aria-pressed="true"] { border-color: var(--ui-ink); background: var(--ui-ink); color: var(--ui-paper); }
.template-chip:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }

.template-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px 24px;
    border: 1px solid var(--ui-rule);
    border-radius: 8px;
    background: var(--ui-white);
    color: var(--ui-ink);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.template-card:hover { border-color: var(--ui-ink-soft); box-shadow: var(--ui-shadow-pop); }
/* The icon row: a fixed height, so the titles line up whatever the icon's
   own height; "Anbefalt" on the right in the panel's mono */
.template-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 28px; margin-bottom: 14px; }
.template-card-icon { display: flex; align-items: center; font-size: 26px; line-height: 1; color: var(--ui-ink); }
.template-card-badge {
    padding: 3px 8px;
    border: 1px solid var(--ui-rule);
    border-radius: var(--ui-radius-chip);
    background: var(--ui-paper);
    font: 500 11px/1.2 var(--ui-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ui-ink-soft);
}
.template-card-title { margin: 0 0 6px; font: 600 20px/1.25 var(--ui-serif); letter-spacing: -0.005em; color: var(--ui-ink); }
.template-card-pick {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
/* The name's button covers the card: a click anywhere is a click on it */
.template-card-pick::after { content: ''; position: absolute; inset: 0; border-radius: 8px; }
.template-card-pick:focus-visible { outline: none; }
.template-card-pick:focus-visible::after { outline: 2px solid var(--ui-ink); outline-offset: 2px; }
.template-card-desc { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--ui-ink-soft); }
.template-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 16px; }
.template-card-count { font: 500 12px/1.2 var(--ui-mono); color: var(--ui-ink-soft); }
.template-card-tag {
    padding: 2px 8px;
    border: 1px solid var(--ui-rule);
    border-radius: var(--ui-radius-chip);
    background: var(--ui-paper);
    font-size: 12px;
    line-height: 1.4;
    color: var(--ui-ink-soft);
}
/* "Se eksempel" at the foot of every card, above the name's button */
.template-card-actions { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--ui-rule-soft); }
.template-example-btn {
    position: relative;
    z-index: 1;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--ui-ink);
    border-radius: var(--ui-radius);
    background: var(--ui-white);
    color: var(--ui-ink);
    font: 500 13px/1 var(--ui-sans);
    cursor: pointer;
}
.template-example-btn:hover { background: var(--ui-paper); }
.template-example-btn:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; }

/* The preview and the insert question */
.template-dialog .modal-content { max-width: 520px; }
.template-preview-dialog .modal-content { max-width: 800px; max-height: 85vh; }
.template-dialog .modal-header { gap: 16px; }
.template-dialog-sub { margin: 4px 0 0; font-size: 14px; color: var(--ui-ink-soft); }
.template-dialog .modal-footer { flex-wrap: wrap; }
.template-insert-dialog .modal-body p { margin: 0; line-height: 1.6; color: var(--ui-ink); }
.template-preview-dialog .modal-body {
    padding: 30px;
    background: #ffffff;
    font-family: "Lato Extended", "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #2D3B45;
}

/* KI menu → Koble til KI-assistent: the address, the steps per assistant,
   an example request (cloudSaveMixin.renderConnectGuide) */
.ai-connect #ai-connect-section { margin: 0 0 18px 0; padding: 0 0 16px 0; border-bottom: 1px solid #e2dccf; }
.ai-connect h4 { margin: 0 0 6px 0; }
.ai-connect #ai-connect-section > p { margin: 0 0 12px 0; color: #4a5568; line-height: 1.55; }
.ai-connect-copyrow { display: flex; gap: 8px; align-items: flex-start; }
.ai-connect-copyrow .form-control { flex: 1; min-width: 0; font-family: monospace; font-size: 0.9em; }
.ai-connect-copyrow textarea.form-control { font-family: inherit; resize: none; }
.ai-connect-status { min-height: 1.3em; margin: 4px 0 8px 0; font-size: 0.9em; color: #4a5568; }
.ai-connect-steps { margin: 0 0 8px 0; border: 1px solid #e2dccf; border-radius: 8px; padding: 8px 12px; }
.ai-connect-steps > summary { cursor: pointer; font-weight: 600; }
.ai-connect-steps ol { margin: 10px 0 6px 0; padding-left: 1.4em; line-height: 1.55; }
.ai-connect-steps li { margin: 0 0 6px 0; }
.ai-connect-note { margin: 6px 0 0 0; font-size: 0.9em; color: #5f574b; line-height: 1.5; }
.ai-connect-note:empty { display: none; }
.ai-connect-try { margin: 14px 0 0 0; }
.ai-connect-signin { margin: 0 0 8px 0; }
.ai-connect-signin p { margin: 0 0 10px 0; color: #4a5568; line-height: 1.55; }

/* Upload an image to Canvas Files (imageUpload.js) */
.cd-upload { margin: 6px 0 10px 0; }
.cd-upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cd-upload-course { font-size: 0.9em; color: #4a5568; }
.cd-upload .btn-link { background: none; border: 0; padding: 0; color: #00636b; text-decoration: underline; cursor: pointer; font: inherit; }
.cd-upload .btn-link:focus-visible { outline: 2px solid #00636b; outline-offset: 2px; }
.cd-upload-pick { margin-top: 8px; max-width: 420px; }
.cd-upload-status { display: block; margin-top: 6px; line-height: 1.5; }
.cd-upload-status:empty { display: none; }
.cd-upload-status[data-kind="error"] { color: #a12a1f; }
.cd-upload-status[data-kind="warn"] { color: #7c4a12; }
.cd-upload-status[data-kind="ok"] { color: #1f5e3a; }
.cd-upload-thumb { float: left; width: 48px; height: 48px; object-fit: cover; border-radius: 6px; margin: 0 10px 4px 0; border: 1px solid #d4e3e6; }
.cd-upload[aria-busy="true"] .cd-upload-btn { opacity: 0.7; cursor: progress; }
