/* 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. */
/* Nord Canvas Designer Styles */

/* CSS Variables */
:root {
    --nord-primary: #003D4C;
    --nord-secondary: #165C7D;
    --nord-accent: #94B7BB;
    --nord-light-turquoise: #8FD6BD;
    --nord-web-turquoise: #00B0B9;
    --nord-light-green: #A9C47F;
    --nord-red: #EC5742;
    --nord-orange: #FFA300;
    --nord-background: #f8f9fa;
    --nord-border: #e0e0e0;
    --nord-text: #333;
    --nord-text-light: #666;
    --nord-white: #ffffff;

     /* NORD Colors */
      
            /* NORD Secondary Colors */
            --nord-sekund1: #003D4C; /* Mørk blå (Dark Blue) */
            --nord-sekund2: #165C7D; /* Medium blå (Medium Blue) */
            --nord-sekund3: #115E67; /* Mørk turkis (Dark Turquoise) */
            --nord-sekund4: #007041; /* Mørk grønn (Dark Green) */
            --nord-sekund5: #6CC24A; /* Lys grønn (Light Green - Secondary) */
            --nord-sekund6: #94B7BB; /* Grå blå (Grey Blue) */
            --nord-sekund7: #009FDF; /* Lys blå (Light Blue - Secondary) */
            /* NORD Primary Colors */
            --nord-prima1: #8FD6BD; /* Lys turkis (Light Turquoise) */
            --nord-prima3: #A9C47F; /* Lys grønn (Light Green - Primary) */
            /* NORD Contrast Colors */
            --nord-kontrast1: #EC5742; /* Rød (Red) */
            --nord-kontrast2: #FFA300; /* Oransje (Orange) */
            /* Basic Colors */
            --tekst-standard: #2D3B45;
            --tekst-lys: #34495e;
       
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-round: 50%;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.1);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--nord-text);
    background-color: #f5f5f5;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    background: var(--nord-white);
    border-bottom: 2px solid var(--nord-accent);
    padding: 6px var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-left h1 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--nord-primary);
    font-weight: 700;
}

.header-left p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--nord-text-light);
}

.compatibility-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 176, 185, 0.06);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 176, 185, 0.2);
}


/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative; /* Positioning parent for floating panels */
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--nord-white);
    border-right: 1px solid var(--nord-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.element-selector {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar Header Row */
.sidebar-header-row {
    padding: 8px 10px;
    border-bottom: 1px solid var(--nord-border);
    background: var(--nord-background);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Tool Launchers */
.tool-launchers {
    display: flex;
    gap: 6px;
}

.tool-launcher-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    background: var(--nord-white);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--nord-text-light);
    transition: all var(--transition-fast);
}

.tool-launcher-btn i {
    font-size: 0.9rem;
    color: var(--nord-secondary);
}

.tool-launcher-btn:hover {
    border-color: var(--nord-accent);
    background: rgba(148, 183, 187, 0.08);
    color: var(--nord-primary);
}

.tool-launcher-btn.active {
    border-color: var(--nord-web-turquoise);
    background: rgba(0, 176, 185, 0.08);
    color: var(--nord-primary);
}

/* Sidebar Compatibility Filter */
.sidebar-compat-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    background: rgba(0, 176, 185, 0.04);
    border-bottom: 1px solid var(--nord-border);
    font-size: 0.78rem;
    color: var(--nord-text-light);
    font-weight: 500;
}

/* Sidebar Content Row (icon strip + element list) */
.sidebar-content-row {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Vertical Category Icon Strip */
.category-icon-strip {
    width: 52px;
    flex-shrink: 0;
    background: var(--nord-background);
    border-right: 1px solid var(--nord-border);
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    gap: 2px;
    align-items: center;
    overflow-y: auto;
}

.category-btn {
    width: 42px;
    height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 0;
    border: 2px solid transparent;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.category-btn:hover {
    background: rgba(148, 183, 187, 0.15);
    border-color: var(--nord-accent);
}

.category-btn.active {
    background: var(--nord-primary);
    color: var(--nord-white);
    border-color: var(--nord-primary);
    box-shadow: 0 2px 6px rgba(0, 61, 76, 0.25);
}

.category-btn .icon {
    font-size: 1.1rem;
    line-height: 1;
}

.category-btn .label {
    font-size: 0.55rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40px;
    text-align: center;
}

.category-btn .count {
    display: none;
}

/* Element List Panel */
.element-list-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Page-specific elements section */
.page-specific-elements {
    padding: var(--spacing-md);
    background: var(--nord-background);
    border-bottom: 2px solid var(--nord-accent);
    margin-bottom: var(--spacing-md);
}

.page-specific-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--nord-primary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.page-specific-items {
    display: grid;
    gap: var(--spacing-sm);
}

/* =============================================
   Tool Mode Tab Bar
   ============================================= */

.tool-mode-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 var(--spacing-lg);
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border-bottom: 2px solid var(--nord-border);
    flex-shrink: 0;
}

.tool-mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--nord-text-light);
    transition: all var(--transition-fast);
    font-family: inherit;
}

.tool-mode-tab i {
    font-size: 1rem;
}

.tool-mode-tab:hover {
    color: var(--nord-primary);
    background: rgba(0, 176, 185, 0.06);
}

.tool-mode-tab.active {
    color: var(--nord-primary);
    border-bottom-color: var(--nord-web-turquoise);
    font-weight: 600;
}

.tool-mode-separator {
    width: 1px;
    height: 20px;
    background: var(--nord-border);
    margin: 0 8px;
}

.tool-mode-label {
    font-size: 0.7rem;
    color: #5c6878;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 6px;
}

/* Tool panels in sidebar */
.tool-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.tool-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

/* =============================================
   Floating panels (legacy, kept for CSS reference)
   ============================================= */

.floating-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50%;
    min-width: 500px;
    max-width: 700px;
    z-index: 100;
    background: var(--nord-white);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--nord-border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.floating-panel.open {
    transform: translateX(0);
}

/* Split layout inside the drawer: preview on top, controls below */
.floating-panel-body {
    display: flex;
    flex-direction: column;
}

.drawer-preview-area {
    flex-shrink: 0;
    padding: 20px;
    background: #f5f5f5;
    border-bottom: 1px solid var(--nord-border);
    min-height: 180px;
    max-height: 40vh;
    overflow-y: auto;
}

.drawer-preview-area h4 {
    margin: 0 0 12px 0;
    color: var(--nord-primary);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-controls-area {
    flex: 1;
    overflow-y: auto;
}

.floating-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--nord-primary);
    color: white;
    user-select: none;
    flex-shrink: 0;
}

.floating-panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.floating-panel-title i {
    font-size: 1rem;
    opacity: 0.85;
}

.floating-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.floating-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.floating-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.floating-panel-body::-webkit-scrollbar {
    width: 6px;
}

.floating-panel-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.floating-panel-body::-webkit-scrollbar-thumb {
    background: var(--nord-accent);
    border-radius: 3px;
}



/* Preview Container */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    overflow: hidden;
}

/* Toolbar */
.preview-toolbar {
    background: var(--nord-white);
    border-bottom: 1px solid var(--nord-border);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.toolbar-left {
    flex: 1;
    min-width: 0;
}

.toolbar-right {
    flex-shrink: 0;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--nord-border);
    background: var(--nord-white);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.toolbar-btn:hover {
    background: var(--nord-background);
    border-color: var(--nord-accent);
}

.toolbar-btn.active {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-color: var(--nord-accent);
}

.toolbar-btn.active:hover {
    background: #6FA8AC;
}

.toolbar-btn.primary {
    background: var(--nord-primary);
    color: var(--nord-white);
    border-color: var(--nord-primary);
}

.toolbar-btn.primary:hover {
    background: var(--nord-secondary);
    border-color: var(--nord-secondary);
}

.toolbar-btn.active {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-color: var(--nord-accent);
}

/* Grid Layout Selector — now inline in grid header, old floating styles removed */

.grid-selector-label {
    font-size: 0.7rem;
    color: var(--nord-text-light);
    font-weight: 600;
    white-space: nowrap;
    padding-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Unified 3x3 grid for all layout options */
.grid-layout-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
}

.grid-layout-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.grid-layout-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 6px;
    border: 2px solid var(--nord-border);
    background: var(--nord-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 44px;
}

.grid-layout-option:hover {
    border-color: var(--nord-accent);
    background: rgba(148, 183, 187, 0.1);
}

.grid-layout-option.active {
    border-color: var(--nord-secondary);
    background: rgba(22, 92, 125, 0.1);
    box-shadow: 0 0 0 2px rgba(22, 92, 125, 0.2);
}

.layout-preview {
    display: flex;
    gap: 2px;
    width: 40px;
    height: 20px;
}

.layout-preview .preview-col {
    background: var(--nord-accent);
    border-radius: 2px;
    min-width: 4px;
}

.grid-layout-option.active .layout-preview .preview-col {
    background: var(--nord-secondary);
}

.grid-layout-option:hover .layout-preview .preview-col {
    background: var(--nord-secondary);
}

.layout-label {
    font-size: 0.65rem;
    color: var(--nord-text-light);
    white-space: nowrap;
}

.grid-layout-option.active .layout-label {
    color: var(--nord-secondary);
    font-weight: 600;
}

/* Grid layout dropdown for advanced options */
.grid-layout-more {
    position: relative;
}

.grid-layout-more-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 2px solid var(--nord-border);
    background: var(--nord-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--nord-text-light);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.grid-layout-more-btn:hover {
    border-color: var(--nord-accent);
    background: rgba(148, 183, 187, 0.1);
    color: var(--nord-secondary);
}

.grid-layout-more-btn.active {
    border-color: var(--nord-secondary);
    background: rgba(22, 92, 125, 0.1);
}

.grid-layout-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--nord-white);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    min-width: 200px;
}

.grid-layout-dropdown.show {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.grid-layout-dropdown .grid-layout-option {
    min-width: auto;
}

/* Legacy grid-option support (for backwards compatibility) */
.grid-option {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--nord-border);
    background: var(--nord-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.grid-option:hover {
    background: var(--nord-background);
}

.grid-option.active {
    background: var(--nord-secondary);
    color: var(--nord-white);
    border-color: var(--nord-secondary);
}

/* Canvas */
/* FLEXIBLE CANVAS THAT GROWS WITH CONTENT */

.canvas {
    background: var(--nord-white);
    /* Remove fixed heights - let content determine height */
    min-height: calc(100vh - 200px); /* Minimum height for empty state */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    transition: all var(--transition-normal);
    
    /* Allow canvas to grow with content */
    width: 100%;
    /* No max-height or fixed height */
}

/* Responsive viewport preview modes */
.canvas.viewport-tablet {
    max-width: 768px;
    margin: 0 auto;
    transition: max-width 0.3s ease;
}
.canvas.viewport-mobile {
    max-width: 375px;
    margin: 0 auto;
    transition: max-width 0.3s ease;
}

/* Mobile warning badges (editor-only, stripped on export) */
.mobile-warning-badge {
    position: absolute;
    top: 4px;
    right: 40px;
    background: #f0ad4e;
    color: #fff;
    font-size: 0.7em;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
}

/* Canvas-matching typography — match Canvas LMS native rendering */
.canvas h1, .canvas h2 {
    font-size: 1.8em;
    line-height: 1.5;
    font-weight: bold;
    font-family: "Lato Extended","Lato","Helvetica Neue",Helvetica,Arial,sans-serif;
}
.canvas h3 {
    font-size: 1.5em;
    line-height: 1.5;
    font-weight: bold;
    font-family: "Lato Extended","Lato","Helvetica Neue",Helvetica,Arial,sans-serif;
}
.canvas h4 {
    font-size: 1.125em;
    line-height: 1.5;
    font-weight: bold;
    font-family: "Lato Extended","Lato","Helvetica Neue",Helvetica,Arial,sans-serif;
}
.canvas p {
    margin: 12px 0;
    line-height: 1.5;
}

.canvas.empty {
    /* Only apply fixed height when empty */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    height: calc(100vh - 200px); /* Fixed height only for empty state */
}

/* When canvas has content, remove the fixed height */
.canvas:not(.empty) {
    /* Let content determine height naturally */
    height: auto;
    min-height: 400px; /* Just a reasonable minimum */
}

/* Canvas wrapper - scrollable container */
.canvas-wrapper {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto; /* Allow scrolling when content exceeds viewport */
    overflow-x: hidden;
    
    /* Ensure scrolling works properly */
    height: calc(100vh - 120px); /* Account for header + toolbar */
}

/* =============================================================================
   Review banner: a page an AI assistant made (designer/pageSpecMixin.js)
   Over the canvas, outside #canvas, so it is never part of the page
   ============================================================================= */

.assistant-review-banner {
    margin: 0 0 var(--spacing-md) 0;
    padding: 16px 20px;
    background: var(--nord-white);
    border: 1px solid #d4e3e6;
    border-left: 4px solid var(--nord-web-turquoise);
    border-radius: var(--radius-lg);
    color: var(--nord-primary);
    font-size: 0.92em;
    line-height: 1.5;
}
.assistant-review-head {
    display: flex;
    align-items: center;
    gap: 12px;
}
.assistant-review-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e5f7f8;
    color: #007a82;
    display: flex;
    align-items: center;
    justify-content: center;
}
.assistant-review-title {
    margin: 0;
    font-size: 1.05em;
    color: var(--nord-primary);
}
.assistant-review-by,
.assistant-review-check {
    margin: 2px 0 0 0;
    color: #4a5568;
}
.assistant-review-summary {
    margin: 12px 0 0 0;
    padding: 10px 14px;
    background: #f4f8f9;
    border-radius: var(--radius-md);
    white-space: pre-line;
}
.assistant-review-check { margin-top: 10px; }
.assistant-review-fa {
    margin: 10px 0 0 0;
    padding: 10px 14px;
    background: #fdf6e7;
    border-left: 3px solid #b7791f;
    border-radius: var(--radius-md);
    color: #3d2c0b;
}
.assistant-review-list { margin: 10px 0 0 0; }
.assistant-review-list summary { cursor: pointer; color: var(--nord-primary); }
.assistant-review-list ul { margin: 6px 0 0 0; padding-left: 22px; }
.assistant-review-list li { margin: 2px 0; overflow-wrap: anywhere; }
.assistant-review-list a { color: #165c7d; }
.assistant-review-fix { color: #5c6878; }
.assistant-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}
.assistant-review-actions button {
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}
.assistant-review-done {
    background: var(--nord-primary);
    color: var(--nord-white);
    border: 1px solid var(--nord-primary);
}
.assistant-review-hide {
    background: transparent;
    color: #4a5568;
    border: 1px solid #d4e3e6;
}
.assistant-review-actions button:focus-visible,
.assistant-review-list summary:focus-visible,
.assistant-review-list a:focus-visible {
    outline: 3px solid var(--nord-web-turquoise);
    outline-offset: 2px;
}
body.preview-mode .assistant-review-banner { display: none; }

/* =============================================================================
   Activity Colour Picker
   ============================================================================= */

.activity-color-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    border: 1px solid #e8e8e8;
}

.activity-color-label {
    font-size: 0.8em;
    color: #666;
    font-weight: 500;
    margin-right: 4px;
}

.activity-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.activity-color-swatch:hover {
    transform: scale(1.15);
}

.activity-color-swatch.active {
    border-color: #003D4C;
    outline: 2px solid white;
}

/* Activity Color Settings Modal */
.activity-type-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.activity-type-row:last-child { border-bottom: none; }

.activity-type-label {
    width: 130px;
    flex-shrink: 0;
    font-size: 0.9em;
    color: #003D4C;
    font-weight: 600;
}

.activity-type-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.activity-type-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s;
}
.activity-type-swatch:hover { transform: scale(1.15); }
.activity-type-swatch.active {
    border-color: #003D4C;
    outline: 2px solid white;
}

.activity-type-custom {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid #d4e3e6;
    border-radius: 50%;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}
.activity-type-custom::-webkit-color-swatch-wrapper { padding: 0; }
.activity-type-custom::-webkit-color-swatch { border: none; border-radius: 50%; }
.activity-type-custom::-moz-color-swatch { border: none; border-radius: 50%; }

.activity-type-preview {
    width: 22px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Color dot on sidebar activity items */
.activity-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: auto;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Activity override popover (shift+click) */
.activity-override-popover {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #d4e3e6;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 280px;
}
.activity-override-popover .activity-type-swatch { width: 24px; height: 24px; }

/* Tilpass button in sidebar */
.activity-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border: 1px dashed #94B7BB;
    border-radius: var(--radius-md);
    color: #165C7D;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.15s;
}
.activity-settings-btn:hover { background: #f0f4f5; }

/* Sidestil (page-style) picker — sidebar variant.
   Lives above the sub-categories tabs when page-types is the active
   category. Matches the visual weight of .activity-settings-btn. */
.sidebar-page-style-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    margin: 0;
    background: #f8f9fa;
    border: 1px dashed #94B7BB;
    border-radius: var(--radius-md);
    color: #165C7D;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.15s;
}
.sidebar-page-style-btn:hover { background: #f0f4f5; }
/* Wrapper spans full panel width and matches the sub-categories background
   so the Page-style row reads as part of the same control strip. */
#sidebar-page-style-wrapper {
    margin: 0;
    padding: 10px 15px 0 15px;
    background: #f0f4f7;
}

/* Section divider inside a sub-category element list (e.g. modul → Simple / Visual). */
.element-section-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px 0;
    font-size: 0.72em;
    color: #5c6878;
    letter-spacing: 0.5px;
}
.element-section-divider::before,
.element-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #d4e3e6;
}
.element-section-divider span { padding: 0 2px; }
.element-section-divider:first-child { margin-top: 2px; }

/* Brand Color Settings Modal */
.brand-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.brand-color-row:last-child { border-bottom: none; }

.brand-color-label {
    width: 120px;
    flex-shrink: 0;
    font-size: 0.9em;
    color: #003D4C;
    font-weight: 600;
}

.brand-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid #d4e3e6;
    flex-shrink: 0;
}

.brand-color-hex {
    font-family: monospace;
    font-size: 0.85em;
    color: #003D4C;
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #d4e3e6;
    border-radius: 6px;
    background: #f8f9fa;
    text-align: center;
}
.brand-color-hex:focus {
    outline: none;
    border-color: #94B7BB;
    background: white;
}

.brand-color-picker {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 2px solid #d4e3e6;
    border-radius: 8px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.brand-color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.brand-color-picker::-webkit-color-swatch { border: none; border-radius: 4px; }
.brand-color-picker::-moz-color-swatch { border: none; border-radius: 4px; }

/* Contrast readout per brand colour (pageStyleMixin.renderBrandContrast) */
.brand-color-contrast {
    margin-left: auto;
    font-size: 0.8em;
    font-family: monospace;
    color: #2f6b45;
    white-space: nowrap;
}
.brand-color-contrast.is-decor { color: #5c6878; }
.brand-color-contrast.is-low { color: #b42318; }

/* Visually hidden, still read by screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.brand-preview-card {
    margin-top: 16px;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #d4e3e6;
    background: white;
}

/* =============================================================================
   Templates - Sidebar button + Canvas browser
   ============================================================================= */

.templates-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #f0f7f4, #e8f4f8);
    border: 1px solid #d4e3e8;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    color: #003d4c;
    transition: all 0.2s;
}

.templates-section-toggle:hover {
    background: linear-gradient(135deg, #e4f0ea, #dceef4);
    border-color: #94B7BB;
}

/* Template browser - full canvas area overlay */
.template-browser {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f4f6f8;
    z-index: 20;
    overflow-y: auto;
    padding: 40px;
}

.template-browser-header {
    text-align: center;
    margin-bottom: 32px;
}

.template-browser-header h2 {
    margin: 0 0 8px 0;
    color: #003d4c;
    font-size: 1.8em;
    font-weight: 700;
}

.template-browser-header p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 1.05em;
}

.template-browser-close {
    background: none;
    border: 2px solid #ccc;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
}

.template-browser-close:hover {
    border-color: #003d4c;
    color: #003d4c;
}

.template-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* =============================================================================
   Page Frame (Sideramme)
   ============================================================================= */

.page-frame-header {
    background: linear-gradient(135deg, var(--frame-fill, #007a82) 0%, var(--frame-deep, #006268) 100%);
    padding: 24px var(--spacing-xl);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    position: relative;
}

/* Match frame header padding to canvas padding at wider breakpoints */
@media (min-width: 1200px) {
    .page-frame-header {
        padding: 28px 48px;
    }
}
@media (min-width: 1600px) {
    .page-frame-header {
        padding: 32px 60px;
        max-width: 1400px;
        margin: 0 auto;
    }
}

.page-frame-header-content {
    position: relative;
    z-index: 1;
}

.page-frame-title {
    margin: 0;
    color: #ffffff;
    font-size: 1.6em;
    font-weight: 600;
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
    line-height: 1.3;
}

.page-frame-title:hover,
.page-frame-title:focus {
    border-bottom-color: rgba(255, 255, 255, 0.4);
}

.page-frame-subtitle {
    margin: 8px 0 0 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1em;
    font-weight: 400;
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.page-frame-subtitle:hover,
.page-frame-subtitle:focus {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.page-frame-header-hint {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.7em;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transition: opacity 0.2s;
}

.page-frame-header:hover .page-frame-header-hint {
    opacity: 0;
}

/* Frame active state - header and canvas form a visual unit */
.canvas-wrapper.frame-active .page-frame-header {
    border: 2px solid var(--frame-soft, #94B7BB);
    border-bottom: none;
}

.canvas-wrapper.frame-active .canvas {
    border: 2px solid var(--frame-soft, #94B7BB);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.canvas-wrapper.frame-active .page-frame-header + .canvas {
    margin-top: 0;
}

/* Frame Selector Dropdown */
.frame-selector-wrapper {
    position: relative;
}

.frame-selector-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--nord-white);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 50;
    min-width: 180px;
}

.frame-selector-dropdown.show {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.frame-selector-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: 2px solid var(--nord-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-width: 56px;
    background: white;
    transition: all 0.15s;
}

.frame-selector-option:hover {
    border-color: var(--nord-accent);
}

.frame-selector-option.active {
    border-color: var(--nord-secondary);
    background: rgba(22, 92, 125, 0.06);
}

.frame-option-preview {
    width: 48px;
}

/* The menu's small previews, in the page theme's colour */
.frame-preview-border { height: 36px; border: 2px solid var(--frame-line, #00B0B9); border-radius: 4px; background: white; }
.frame-preview-fill { height: 14px; border-radius: 4px 4px 0 0; background: linear-gradient(135deg, var(--frame-fill, #007a82), var(--frame-deep, #006268)); }
.frame-preview-tint { height: 14px; border-radius: 4px 4px 0 0; background: var(--frame-tint, #f0f4f5); border: 1px solid var(--frame-soft, #d4e3e6); border-bottom: 2px solid var(--frame-soft, #94B7BB); }
.frame-preview-body { height: 22px; background: white; border: 1px solid var(--frame-soft, #d4e3e6); border-top: none; border-radius: 0 0 4px 4px; }
.frame-preview-accent { height: 36px; background: white; border: 1px solid #d4e3e6; border-left: 4px solid var(--frame-fill, #003d4c); border-radius: 4px; }

.frame-option-label {
    font-size: 0.65em;
    color: var(--nord-text-light);
}

.frame-selector-option.active /* The menu's small previews, in the page theme's colour */
.frame-preview-border { height: 36px; border: 2px solid var(--frame-line, #00B0B9); border-radius: 4px; background: white; }
.frame-preview-fill { height: 14px; border-radius: 4px 4px 0 0; background: linear-gradient(135deg, var(--frame-fill, #007a82), var(--frame-deep, #006268)); }
.frame-preview-tint { height: 14px; border-radius: 4px 4px 0 0; background: var(--frame-tint, #f0f4f5); border: 1px solid var(--frame-soft, #d4e3e6); border-bottom: 2px solid var(--frame-soft, #94B7BB); }
.frame-preview-body { height: 22px; background: white; border: 1px solid var(--frame-soft, #d4e3e6); border-top: none; border-radius: 0 0 4px 4px; }
.frame-preview-accent { height: 36px; background: white; border: 1px solid #d4e3e6; border-left: 4px solid var(--frame-fill, #003d4c); border-radius: 4px; }

.frame-option-label {
    color: var(--nord-secondary);
}

.frame-selector-divider {
    width: 1px;
    background: var(--nord-border);
    align-self: stretch;
    margin: 0 2px;
}

.frame-selector-off {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

/* Frame toggle button active state */
.toolbar-btn.frame-active {
    background: var(--frame-fill, #003d4c);
    color: white;
}

/* Frame style: accent (left border) */
.page-frame-header[data-frame-style="accent"] {
    background: transparent;
    border-left: 5px solid var(--frame-fill, #003d4c);
    border-radius: 0;
    padding: 16px 24px;
}

.page-frame-header[data-frame-style="accent"] .page-frame-title {
    color: var(--frame-fill, #003d4c);
    font-size: 1.4em;
}

.page-frame-header[data-frame-style="accent"] .page-frame-subtitle {
    color: #4a5568;
}

/* Frame style: light (soft top banner) */
.page-frame-header[data-frame-style="light"] {
    background: var(--frame-tint, #f0f4f5);
    border-bottom: 3px solid var(--frame-soft, #94B7BB);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px 32px;
}

.page-frame-header[data-frame-style="light"] .page-frame-title {
    color: var(--frame-on-tint, #003d4c);
    font-size: 1.4em;
}

.page-frame-header[data-frame-style="light"] .page-frame-subtitle {
    color: #4a5568;
}

.page-frame-header[data-frame-style="light"] .page-frame-header-hint {
    color: rgba(0, 61, 76, 0.3);
}

/* Accent frame: canvas gets left border too */
.canvas-wrapper.frame-active.frame-style-accent .canvas {
    border-left: 5px solid var(--frame-fill, #003d4c);
    border-radius: 0;
    border-top: none;
    border-right: none;
    border-bottom: none;
}

.canvas-wrapper.frame-active.frame-style-accent .page-frame-header {
    border: none;
    border-left: 5px solid var(--frame-fill, #003d4c);
}

/* Border frame: a line round the page, no header of its own */
.canvas-wrapper.frame-active.frame-style-border .canvas {
    border: 2px solid var(--frame-line, #00B0B9);
    border-radius: var(--radius-lg);
}

/* Light frame: canvas border matches */
.canvas-wrapper.frame-active.frame-style-light .canvas {
    border: 1px solid #d4e3e6;
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.canvas-wrapper.frame-active.frame-style-light .page-frame-header {
    border: 1px solid #d4e3e6;
    border-bottom: 3px solid #94B7BB;
}

/* Custom/imported frame: subtle dashed border indicates an imported
   page frame is active. No page-frame-header is shown (the imported
   content has its own header as a canvas element). The dashed style
   distinguishes it from the built-in solid-border frames. */
.canvas-wrapper.frame-active.frame-style-custom .canvas {
    border: 2px dashed #94B7BB;
    border-radius: var(--radius-lg);
}

/* Responsive frame padding for accent and light styles */
@media (min-width: 1200px) {
    .page-frame-header[data-frame-style="accent"],
    .page-frame-header[data-frame-style="light"] {
        padding-left: 48px;
        padding-right: 48px;
    }
}
@media (min-width: 1600px) {
    .page-frame-header[data-frame-style="accent"],
    .page-frame-header[data-frame-style="light"] {
        padding-left: 60px;
        padding-right: 60px;
        max-width: 1400px;
        margin: 0 auto;
    }
}

.toolbar-btn.frame-active .icon {
    filter: none;
}

/* Responsive adjustments */
@media (min-width: 1200px) {
    /* Large desktop screens */
    .canvas {
        padding: 48px;
        min-height: calc(100vh - 180px);
    }
    
    .canvas.empty {
        min-height: calc(100vh - 180px);
        height: calc(100vh - 180px);
    }
    
    .canvas:not(.empty) {
        min-height: 500px; /* Larger minimum on big screens */
    }
    
    .canvas-wrapper {
        padding: 32px;
        height: calc(100vh - 100px);
    }
}

@media (min-width: 1600px) {
    /* Extra large screens */
    .canvas {
        padding: 60px;
        margin: 0 auto;
        max-width: 1400px; /* Optional: limit max width for readability */
    }
    
    .canvas.empty {
        min-height: calc(100vh - 160px);
        height: calc(100vh - 160px);
    }
}

@media (max-width: 1024px) {
    /* Tablet screens */
    .canvas {
        padding: var(--spacing-lg);
        min-height: calc(100vh - 220px);
    }
    
    .canvas.empty {
        min-height: calc(100vh - 220px);
        height: calc(100vh - 220px);
    }
    
    .canvas:not(.empty) {
        min-height: 300px;
    }
    
    .canvas-wrapper {
        padding: var(--spacing-md);
        height: calc(100vh - 140px);
    }
}

@media (max-width: 768px) {
    /* Mobile screens */
    .canvas {
        padding: var(--spacing-md);
        border-radius: var(--radius-md);
        min-height: calc(100vh - 240px);
    }
    
    .canvas.empty {
        min-height: calc(100vh - 240px);
        height: calc(100vh - 240px);
    }
    
    .canvas:not(.empty) {
        min-height: 250px;
    }
    
    .canvas-wrapper {
        padding: var(--spacing-sm);
        height: calc(100vh - 160px);
    }
}

/* Improved scrollbar styling for canvas wrapper */
.canvas-wrapper::-webkit-scrollbar {
    width: 8px;
}

.canvas-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.canvas-wrapper::-webkit-scrollbar-thumb {
    background: var(--nord-accent);
    border-radius: 4px;
}

.canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--nord-secondary);
}

/* Canvas elements spacing improvements */
.canvas-element:last-child {
    margin-bottom: var(--spacing-lg); /* Extra space at bottom */
}

/* Visual indicator when canvas is scrollable */
.canvas-wrapper.scrollable::after {
    content: '';
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--nord-accent);
    border-radius: 50%;
    opacity: 0.7;
    pointer-events: none;
    z-index: 100;
    
    /* Scroll indicator icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px;
}

/* Hide scroll indicator when at bottom */
.canvas-wrapper.at-bottom::after {
    display: none;
}

/* Empty state improvements */
.empty-state {
    text-align: center;
    color: var(--nord-text-light);
    max-width: 600px;
    margin: 0 auto;
}

.empty-state h3 {
    color: var(--nord-primary);
    margin-bottom: var(--spacing-md);
    font-size: 1.8rem;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: var(--spacing-lg);
}

/* Preview Container */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    overflow: hidden;
}

.preview-toolbar {
    background: var(--nord-white);
    border-bottom: 1px solid var(--nord-border);
    padding: 6px var(--spacing-xl) 6px var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
    min-height: 44px;
    overflow: visible;
    gap: 6px;
    position: relative;
    z-index: 10;
}


/* Canvas Elements */
.canvas-element {
    position: relative;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    border: 2px dashed transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.canvas-element:hover {
    border-color: var(--nord-accent);
    background: rgba(148, 183, 187, 0.05);
}

.canvas-element.dragging {
    opacity: 0.5;
}

.canvas-element.drag-over {
    border-color: var(--nord-secondary);
    background: rgba(22, 92, 125, 0.1);
}

/* Selected block / section (selectionMixin). The outline sits outside the
   block so it doesn't change the layout; its toolbar stays visible. */
.canvas-element.is-selected {
    outline: 2px solid var(--nord-secondary, #165c7d);
    outline-offset: 2px;
}
.canvas-element.is-selected > .element-controls {
    display: flex;
}
body.preview-mode .canvas-element.is-selected {
    outline: none;
}

/* Empty page actions (canvasOpsMixin.renderEmptyState) */
.empty-state-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 8px 0 4px;
}
.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid #c6d6da;
    background: #ffffff;
    color: #003D4C;
    font-size: 0.95rem;
    cursor: pointer;
}
.empty-state-btn:hover { background: #f0f6f7; }
.empty-state-btn-primary {
    background: #003D4C;
    border-color: #003D4C;
    color: #ffffff;
}
.empty-state-btn-primary:hover { background: #165C7D; }
.empty-state-btn:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}

/* Unsaved draft, offered in the welcome card (core.js
   maybeOfferDraftRecovery). While it shows, Restore is the one filled
   button and "Add section" steps back to an outline. */
.empty-state-draft {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    max-width: 520px;
    margin: 4px auto 20px;
    padding: 14px 18px;
    text-align: left;
    background: #f0f7f8;
    border: 1px solid #d4e3e6;
    border-radius: 10px;
}
.empty-state-draft-text {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #4a5568;
    font-size: 0.92rem;
    line-height: 1.45;
}
.empty-state-draft-text strong {
    color: #003d4c;
}
.empty-state-draft-actions {
    display: flex;
    gap: 8px;
}
.empty-state.has-draft .empty-state-actions .empty-state-btn-primary {
    background: #ffffff;
    border-color: #c6d6da;
    color: #003D4C;
}
.empty-state.has-draft .empty-state-actions .empty-state-btn-primary:hover {
    background: #f0f6f7;
}

/* Insertion line shown while dragging (core.js showDropIndicator). Lives in
   <body>, positioned over the canvas, so it never shifts the layout. */
.drop-indicator {
    position: fixed;
    z-index: 1000;
    height: 4px;
    border-radius: 2px;
    background: var(--nord-secondary, #165c7d);
    pointer-events: none;
    display: none;
}

/* Element Controls */
.element-controls {
    position: absolute;
    top: -36px;
    right: 0;
    display: none;
    gap: var(--spacing-xs);
    background: var(--nord-white);
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--nord-border);
    /* Slight delay before appearing to prevent flicker when moving between elements */
    animation: controlsFadeIn 0.1s ease;
}

@keyframes controlsFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Show controls only on the innermost hovered element.
   :hover matches ancestors too, so we suppress when a child is hovered.
   Combined with the :has() rules below, only ONE set of controls shows. */
.canvas-element:hover > .element-controls {
    display: flex;
}

.control-btn {
    width: 50px;
    height: 35px;
    border: none;
    background: var(--nord-background);
    color: var(--nord-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
}

.control-btn:hover {
    background: var(--nord-primary);
    color: var(--nord-white);
}

/* ============================================================================
   Phase 6 bridge (2026-04-12): fix overlap + overflow for .element-controls
   on canvas-elements that live inside .container-zone (the "Layouter"
   palette category).

   Issue 1 — overlap: when a nested canvas-element is hovered, the outer
     container's :hover state ALSO fires (events bubble), so both control
     bars become visible simultaneously and stack on top of each other.
     Solution: use :has(.canvas-element:hover) on the outer container to
     suppress its own controls AND its own hover styling whenever any
     nested child is being hovered. Safari 15.4+ supports :has().

   Issue 2 — narrow column overflow: the control bar is 300–350px wide
     (6–7 buttons × 50px) which overflows the ~180px width of a 1/4
     column. Solution: compact button size (32×28) + flex-wrap: wrap +
     anchor to bottom: 100% so the bar grows UPWARD when it wraps onto
     a second row, instead of crashing into the zone below.
   ============================================================================ */

/* Issue 1: suppress outer container's controls and hover styling when a
   nested child is being hovered */
.canvas-element:has(.canvas-element:hover) > .element-controls {
    display: none;
}
.canvas-element:has(.canvas-element:hover) {
    border-color: transparent;
    background: transparent;
}

/* Child controls INSIDE the block's top-right corner (2026-10-16). They used
   to hang below the block, over the next one: the next block was painted on
   top and took the click meant for "Edit", and on the way to the bar the
   pointer crossed the next block, which hid the bar (worst under a short
   heading, where the bar lay on the next block's first line). Inside its own
   block the bar is reached without leaving the block, never covers a
   neighbour, and can't collide with the section's bar, which sits above the
   section. The active block is still lifted above its siblings, for blocks
   shorter than the bar. */
.container-zone .canvas-element:hover,
.container-zone .canvas-element:focus-within {
    z-index: 4;
}
/* The selected block sits highest, so its bar stays clickable even when the
   pointer comes from (and hovers) the block below. */
.container-zone .canvas-element.is-selected {
    z-index: 6;
}
.container-zone .canvas-element > .element-controls {
    top: 4px;
    bottom: auto;
    right: 4px;
    margin-top: 0;
    margin-bottom: 0;
    z-index: 10;
    max-width: calc(100% - 8px);
    flex-wrap: wrap;
    padding: 3px;
    gap: 3px;
    justify-content: flex-end;
}

/* Suppress preceding child's controls when a later sibling is hovered (prevents
   overlap), except on the selected block: its bar must not vanish while the
   pointer is over another block. */
.container-zone .canvas-element:not(.is-selected):has(~ .canvas-element:hover) > .element-controls {
    display: none;
}

/* Issue 2b: compact button size inside zones so more fit per row */
.container-zone .canvas-element > .element-controls .control-btn {
    width: 32px;
    height: 28px;
    font-size: 0.75rem;
}

/* Container shell: suppress hover highlight, promote z-index so top controls
   render above the preceding sibling's bottom edge. */
.canvas-element[data-is-container="true"]:hover {
    border-color: transparent;
    background: transparent;
    z-index: 5;
}

/* Container controls at TOP — move arrows feel natural (up=up).
   Child controls are now BELOW children, so no overlap is possible. */
.canvas-element[data-is-container="true"] > .element-controls {
    top: -44px;
    bottom: auto;
    right: 0;
    left: auto;
}

/* ============================================================================
   Layout switcher popover — opened by clicking the fa-table-columns button
   on a container element's control bar (canvasOpsMixin.openLayoutSwitcher).
   Shows a grid of 9 layout thumbnails; picking one calls
   switchContainerLayout and rewrites the grid-template-columns while
   preserving content by positional zone mapping.
   ============================================================================ */
.layout-switcher-popover {
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    max-width: 340px;
    z-index: 9999;
}

.layout-switcher-title {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5c6878;
    margin-bottom: 10px;
}

.layout-switcher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.layout-switcher-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 2px solid #e0e7e8;
    background: #f7fafa;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
    text-align: center;
}

.layout-switcher-option:hover {
    border-color: #94B7BB;
    background: #edf4f5;
}

.layout-switcher-option.active {
    border-color: #003D4C;
    background: rgba(22, 92, 125, 0.08);
}

.layout-switcher-icon {
    font-size: 1.5em;
    color: #165C7D;
    line-height: 1;
}

.layout-switcher-option.active .layout-switcher-icon {
    color: #003D4C;
}

.layout-switcher-name {
    font-size: 0.7em;
    color: #4a5568;
    line-height: 1.25;
}

/* Grid Container */
.grid-container {
    display: grid;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    border: 2px dashed var(--nord-accent);
    border-radius: var(--radius-md);
    min-height: 150px;
    background: rgba(148, 183, 187, 0.05);
}

.grid-container.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-container.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-container.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-column {
    min-height: 100px;
    padding: var(--spacing-md);
    border: 1px dashed var(--nord-border);
    border-radius: var(--radius-sm);
    background: var(--nord-white);
    position: relative;
}

.grid-column.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nord-text-light);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.grid-column.empty:hover {
    background: var(--nord-background);
    border-color: var(--nord-accent);
}

.grid-column-controls {
    position: absolute;
    top: -30px;
    right: 0;
    display: none;
    gap: var(--spacing-xs);
    background: var(--nord-white);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--nord-border);
}

.grid-column:hover .grid-column-controls {
    display: flex;
}

.add-to-column-btn {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    border: 1px dashed var(--nord-accent);
    background: var(--nord-white);
    color: var(--nord-accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 1.2rem;
}

.add-to-column-btn:hover {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-style: solid;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--nord-white);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--nord-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--nord-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--nord-text-light);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--nord-background);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--nord-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--nord-text);
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--nord-accent);
    box-shadow: 0 0 0 3px rgba(148, 183, 187, 0.2);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.form-help {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--nord-text-light);
}

/* ========================================================================== */
/* ACCORDION BUILDER MODAL STYLING - ENHANCED & CONSOLIDATED */
/* ========================================================================== */

/* Modal enhancements */
#accordion-builder-modal .modal-content {
    max-width: 950px;
    max-height: 90vh;
}

#accordion-builder-modal .modal-body {
    max-height: 75vh;
    overflow-y: auto;
    padding: 30px;
}

#accordion-builder-modal .modal-body::-webkit-scrollbar {
    width: 8px;
}

#accordion-builder-modal .modal-body::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

#accordion-builder-modal .modal-body::-webkit-scrollbar-thumb {
    background: var(--nord-accent, #94B7BB);
    border-radius: 4px;
}

#accordion-builder-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--nord-secondary, #165C7D);
}

/* Main container for accordion inputs */
.trekkspill-input-beholder {
    background: #f8fafa;
    padding: 25px;
    border-radius: 12px;
    border: 2px solid #e1ecee;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* Individual input groups */
.trekkspill-input-gruppe {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
    padding: 22px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e5edef;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

.trekkspill-input-gruppe:hover {
    border-color: var(--nord-accent, #94B7BB);
    box-shadow: 0 3px 12px rgba(148, 183, 187, 0.15);
    transform: translateY(-1px);
}

/* Title inputs */
.trekkspill-input-gruppe .trekkspill-tittel-input,
.trekkspill-input-gruppe .trekkspill-tittel-inndata {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5edef;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: #fafbfc;
    transition: all 0.3s ease;
    box-sizing: border-box;
    margin: 0;
}

/* Content textareas */
.trekkspill-input-gruppe .trekkspill-innhold-input,
.trekkspill-input-gruppe .trekkspill-innhold-inndata {
    width: 100%;
    min-height: 120px;
    max-height: 300px;
    padding: 14px 16px;
    border: 2px solid #e5edef;
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    line-height: 1.6;
    background: #fafbfc;
    resize: vertical;
    transition: all 0.3s ease;
    box-sizing: border-box;
    margin: 0;
}

/* Enhanced focus states */
.trekkspill-input-gruppe .trekkspill-tittel-input:focus,
.trekkspill-input-gruppe .trekkspill-tittel-inndata:focus,
.trekkspill-input-gruppe .trekkspill-innhold-input:focus,
.trekkspill-input-gruppe .trekkspill-innhold-inndata:focus {
    outline: none;
    border-color: var(--nord-accent, #94B7BB);
    background: white;
    box-shadow: 0 0 0 3px rgba(148, 183, 187, 0.12);
    transform: translateY(-1px);
}

/* Remove section buttons */
.trekkspill-input-gruppe .fjern-seksjon-knapp,
.trekkspill-input-gruppe .fjern-fane-knapp {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.3s ease;
    z-index: 10;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}

.trekkspill-input-gruppe .fjern-seksjon-knapp:hover,
.trekkspill-input-gruppe .fjern-fane-knapp:hover {
    background: #ff5252;
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.4);
}

/* Add section button */
.legg-til-seksjon-knapp,
.legg-til-fane-knapp {
    background: linear-gradient(135deg, var(--nord-accent, #94B7BB) 0%, #85a8ad 100%);
    color: white;
    border: none;
    padding: 16px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    box-shadow: 0 4px 12px rgba(148, 183, 187, 0.25);
    text-transform: none;
    letter-spacing: 0.3px;
}

.legg-til-seksjon-knapp:hover,
.legg-til-fane-knapp:hover {
    background: linear-gradient(135deg, #7a9fa4 0%, #6d8a8e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(148, 183, 187, 0.35);
}

.legg-til-seksjon-knapp:active,
.legg-til-fane-knapp:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(148, 183, 187, 0.3);
}

/* Icon is added explicitly via <i class="fa-solid fa-plus"> in the button markup. */

/* Media modal tab buttons */
.media-tab-btn.active {
    color: #003d4c !important;
    border-bottom-color: #00B0B9 !important;
}

/* Style selector */
.stil-velger {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stil-alternativ {
    padding: 20px 18px;
    border: 2px solid #e5edef;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-weight: 600;
    background: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.stil-alternativ::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(148, 183, 187, 0.08), transparent);
    transition: left 0.6s ease;
}

.stil-alternativ:hover::before {
    left: 100%;
}

.stil-alternativ:hover {
    border-color: var(--nord-accent, #94B7BB);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(148, 183, 187, 0.15);
}

.stil-alternativ.valgt {
    border-color: var(--nord-primary, #003d4c);
    background: linear-gradient(135deg, rgba(0, 61, 76, 0.06), rgba(148, 183, 187, 0.04));
    color: var(--nord-primary, #003d4c);
    box-shadow: 0 4px 16px rgba(0, 61, 76, 0.12);
    transform: translateY(-2px);
}

.stil-alternativ strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1.05em;
}

.stil-alternativ small {
    color: #5c6878;
    font-size: 0.85em;
}

.stil-alternativ.valgt small {
    color: var(--nord-secondary, #165C7D);
}

/* Builder section styling */
.bygger-seksjon {
    margin-bottom: 35px;
}

.bygger-etikett {
    font-weight: 700;
    color: var(--nord-primary, #003d4c);
    margin-bottom: 15px;
    display: block;
    font-size: 1.15em;
    letter-spacing: 0.3px;
}

/* Preview area */
.forhandsvisning-omrade {
    margin-top: 35px;
    padding: 30px;
    background: linear-gradient(135deg, #fdfdfe, #f8fafa);
    border-radius: 12px;
    border: 2px solid #e1ecee;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.forhandsvisning-tittel {
    color: var(--nord-primary, #003d4c);
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.3em;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--nord-accent, #94B7BB);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* NOTE: emoji ::before removed — all markup now provides its own
   <i class="fa-solid fa-eye"></i> explicitly. Leaving the pseudo here
   caused a double-icon (emoji + FA) in builder previews. */

/* Preview container */
#trekkspill-forhandsvisning-beholder {
    max-height: 450px;
    overflow-y: auto;
    border: 1px solid #e5edef;
    border-radius: 10px;
    padding: 20px;
    background: white;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}

#trekkspill-forhandsvisning-beholder::-webkit-scrollbar {
    width: 8px;
}

#trekkspill-forhandsvisning-beholder::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

#trekkspill-forhandsvisning-beholder::-webkit-scrollbar-thumb {
    background: var(--nord-accent, #94B7BB);
    border-radius: 4px;
}

#trekkspill-forhandsvisning-beholder::-webkit-scrollbar-thumb:hover {
    background: var(--nord-secondary, #165C7D);
}

/* Loading state */
.trekkspill-forhandsvisning-beholder.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.trekkspill-forhandsvisning-beholder.loading::after {
    content: 'Oppdaterer forhåndsvisning...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9em;
    color: var(--nord-primary, #003d4c);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e5edef;
}

/* Edit button enhancements */
.control-btn[onclick*="editAccordion"] {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    box-shadow: 0 2px 4px rgba(23, 162, 184, 0.3);
}

.control-btn[onclick*="editAccordion"]:hover {
    background: linear-gradient(135deg, #138496, #0f6b7a);
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(23, 162, 184, 0.4);
}

/* Focus state for accessibility */
.trekkspill-input-gruppe:focus-within {
    border-color: var(--nord-accent, #94B7BB);
    box-shadow: 0 0 0 3px rgba(148, 183, 187, 0.15);
}

/* Smooth transitions */
.trekkspill-input-beholder *,
.stil-velger *,
.forhandsvisning-omrade * {
    transition: all 0.2s ease;
}

/* Font family consistency */
.trekkspill-input-gruppe input,
.trekkspill-input-gruppe textarea,
.trekkspill-input-gruppe button {
    font-family: inherit;
}

/* ========================================================================== */
/* RESPONSIVE DESIGN */
/* ========================================================================== */

@media (max-width: 768px) {
    #accordion-builder-modal .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    #accordion-builder-modal .modal-body {
        padding: 20px;
        max-height: 80vh;
    }
    
    .trekkspill-input-beholder {
        padding: 20px;
    }
    
    .trekkspill-input-gruppe {
        padding: 18px;
        gap: 12px;
    }
    
    .trekkspill-input-gruppe .trekkspill-innhold-input,
    .trekkspill-input-gruppe .trekkspill-innhold-inndata {
        min-height: 100px;
    }
    
    .stil-velger {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stil-alternativ {
        padding: 16px 14px;
    }
    
    .fjern-seksjon-knapp,
    .fjern-fane-knapp {
        position: static;
        margin-top: 12px;
        align-self: flex-start;
        padding: 6px 12px;
    }
    
    .legg-til-seksjon-knapp,
    .legg-til-fane-knapp {
        padding: 14px 24px;
        font-size: 0.95em;
    }
    
    .forhandsvisning-omrade {
        padding: 20px;
        margin-top: 25px;
    }
    
    #trekkspill-forhandsvisning-beholder {
        max-height: 350px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .trekkspill-input-gruppe {
        padding: 15px;
    }
    
    .trekkspill-input-gruppe .trekkspill-tittel-input,
    .trekkspill-input-gruppe .trekkspill-tittel-inndata,
    .trekkspill-input-gruppe .trekkspill-innhold-input,
    .trekkspill-input-gruppe .trekkspill-innhold-inndata {
        padding: 12px 14px;
        font-size: 0.9em;
    }
    
    .forhandsvisning-tittel {
        font-size: 1.15em;
    }
    
    .bygger-etikett {
        font-size: 1.05em;
    }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .trekkspill-input-gruppe,
    .stil-alternativ,
    .legg-til-seksjon-knapp,
    .legg-til-fane-knapp,
    .fjern-seksjon-knapp,
    .fjern-fane-knapp {
        transition: none;
    }
    
    .stil-alternativ::before {
        display: none;
    }
}
/* Edit Preview */
.edit-preview {
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-md);
    background: var(--nord-white);
    min-height: 200px;
}

/* Code Area */
.code-area {
    width: 100%;
    height: 400px;
    padding: var(--spacing-md);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-sm);
    background: #f7f7f7;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    resize: none;
}

/* Buttons */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--nord-primary);
    color: var(--nord-white);
}

.btn-primary:hover {
    background: var(--nord-secondary);
}

.btn-secondary {
    background: var(--nord-white);
    color: var(--nord-primary);
    border: 1px solid var(--nord-border);
}

.btn-secondary:hover {
    background: var(--nord-background);
}

/* Toast (core.js showToast): bottom centre of the canvas area, one dark
   style, the icon tells the type. White on #003D4C is 12:1. The left edge
   is set from the canvas area in JS; 50% is the fallback. */
.toast {
    position: fixed;
    left: 50%;
    bottom: 64px;
    z-index: 10100;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: max-content;
    max-width: min(480px, calc(100vw - 32px));
    padding: 11px 16px;
    background: #003D4C;
    color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 30, 40, 0.28);
    font-size: 0.92rem;
    line-height: 1.45;
    cursor: default;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-icon {
    flex: none;
    margin-top: 0.2em;
    color: #7fdbe0;
}
.toast.info .toast-icon { color: #b9dff0; }
.toast.warning .toast-icon { color: #ffc94d; }
.toast.error .toast-icon { color: #ff9e94; }

/* Redesign 0.5.5: the Undo button on a delete or Clear page toast */
.toast-action {
    flex: none;
    margin: -4px -6px -4px 6px;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.toast-action:hover { background: rgba(255, 255, 255, 0.14); }
.toast-action:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .toast, .toast.show { transition: none; }
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--nord-border);
    }
    
    .main-categories {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .canvas-wrapper {
        padding: var(--spacing-md);
    }
}


/* Additional CSS for Page-Specific Elements Section */

/* Page-specific elements section */
.page-specific-elements {
    padding: var(--spacing-md);
    background: var(--nord-background);
    border-bottom: 2px solid var(--nord-accent);
    margin-bottom: var(--spacing-md);
}

.page-specific-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--nord-primary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.page-specific-items {
    display: grid;
    gap: var(--spacing-sm);
}

/* Enhanced grid column styling */
.grid-column {
    min-height: 100px;
    padding: var(--spacing-md);
    border: 1px dashed var(--nord-border);
    border-radius: var(--radius-sm);
    background: var(--nord-white);
    position: relative;
    transition: all var(--transition-fast);
}

.grid-column.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nord-text-light);
    font-size: 0.875rem;
    cursor: pointer;
}

.grid-column.empty:hover {
    background: var(--nord-background);
    border-color: var(--nord-accent);
    border-style: solid;
}

.grid-column:not(.empty) {
    padding: var(--spacing-sm);
}

/* Grid column controls */
.grid-column-controls {
    position: absolute;
    top: -30px;
    right: 0;
    display: none;
    gap: var(--spacing-xs);
    background: var(--nord-white);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--nord-border);
}

.grid-column:hover .grid-column-controls {
    display: flex;
}

.add-to-column-btn {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    border: 1px dashed var(--nord-accent);
    background: var(--nord-white);
    color: var(--nord-accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 1.2rem;
}

.add-to-column-btn:hover {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-style: solid;
}

/* Enhanced grid container */
.grid-container {
    display: grid;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    border: 2px dashed var(--nord-accent);
    border-radius: var(--radius-md);
    min-height: 150px;
    background: rgba(148, 183, 187, 0.05);
    position: relative;
}

.grid-container::before {
    content: "Rutenett - " attr(data-columns) " kolonner";
    position: absolute;
    top: -10px;
    left: 15px;
    background: var(--nord-white);
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--nord-primary);
    font-weight: 500;
}

/* Form improvements for image modal */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Enhanced element item hover effects */
.element-item {
    position: relative;
    overflow: hidden;
}

.element-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(148, 183, 187, 0.2), transparent);
    transition: left 0.5s ease;
}

.element-item:hover::before {
    left: 100%;
}

/* Enhanced canvas element styling */
.canvas-element {
    position: relative;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    border: 2px dashed transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    background: transparent;
}

.canvas-element:hover {
    border-color: var(--nord-accent);
    background: rgba(148, 183, 187, 0.05);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Enhanced button styling */
.toolbar-btn.active {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-color: var(--nord-accent);
    box-shadow: var(--shadow-sm);
}

/* Responsive improvements */
@media (max-width: 768px) {
    .page-specific-elements {
        padding: var(--spacing-sm);
    }
    
    .grid-container {
        padding: var(--spacing-md);
        gap: var(--spacing-md);
    }
    
    .grid-options {
        flex-wrap: wrap;
    }
    
    .element-item {
        padding: var(--spacing-md);
    }
}

/* Enhanced Grid Editing Styles - Add to your existing CSS */

/* Grid editing mode styling */
.grid-wrapper.editing-mode {
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
    animation: editing-pulse 2s infinite;
}

@keyframes editing-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(255, 193, 7, 0.2);
    }
}

/* Enhanced grid header for editing mode */
.grid-header.editing {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7) !important;
    border-color: #ffc107 !important;
    position: relative;
}

.grid-header.editing::before {
    content: "✏️ REDIGERER";
    position: absolute;
    top: -8px;
    left: 15px;
    background: #ffc107;
    color: #000;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Enhanced interactive grid styling for edit mode */
.interactive-grid.editing {
    background: linear-gradient(135deg, #fffbf0, #fff8e1) !important;
    border-color: #ffc107 !important;
}

/* Cancel button styling */
.control-btn.cancel-edit {
    background: #dc3545 !important;
    color: white !important;
    animation: cancel-highlight 1s ease-in-out;
}

@keyframes cancel-highlight {
    0%, 100% { 
        background: #dc3545 !important;
    }
    50% { 
        background: #c82333 !important;
        transform: scale(1.1);
    }
}

/* Enhanced column selection for edit mode */
.grid-column.editing-active {
    border: 2px solid #ffc107 !important;
    background: #fffbf0 !important;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

/* Enhanced column hover effects in edit mode */
.interactive-grid.editing .grid-column:hover {
    border-color: #ffc107 !important;
    background: #fff8e1 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.2);
}

/* Column element controls enhancement */
.column-element-controls {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(4px);
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.column-element-controls button {
    transition: all 0.2s ease;
}

.column-element-controls button:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Active indicator enhancement */
.active-indicator {
    animation: active-pulse 2s infinite;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes active-pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Enhanced column tabs for editing */
.column-tab.editing-mode {
    position: relative;
}

.column-tab.editing-mode::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #ffc107;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.column-tab.editing-mode.active::after {
    opacity: 1;
}

/* Grid status indicator */
.grid-status-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.6em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grid-status-indicator.editing {
    background: #ffc107;
    color: #000;
}

.grid-status-indicator.editing::before {
    content: "✏️ ";
}

/* Enhanced empty state for edit mode */
.column-empty-state.editing {
    border: 2px dashed #ffc107;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 8px;
    padding: 20px;
}

/* Toolbar button enhancements for grid editing */
.toolbar-btn.grid-editing {
    background: linear-gradient(135deg, #ffc107, #ffca2c);
    color: #000;
    border-color: #ffc107;
    font-weight: bold;
}

.toolbar-btn.grid-editing:hover {
    background: linear-gradient(135deg, #e0a800, #ffc107);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

/* Grid content area enhancements */
.element-content .finalized-grid {
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.element-content .finalized-grid::before {
    content: "📊 Grid Layout";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(148, 183, 187, 0.1);
    padding: 8px 12px;
    font-size: 0.8em;
    font-weight: bold;
    color: #003d4c;
    border-bottom: 1px solid #e0e0e0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.element-content .finalized-grid:hover::before {
    opacity: 1;
}

/* Enhanced element hover effects in grid */
.column-element {
    transition: all 0.2s ease;
}

.column-element:hover {
    background: #f8f9fa !important;
    border-color: #94B7BB !important;
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(148, 183, 187, 0.2);
}

/* Grid column content area */
.grid-column {
    position: relative;
    overflow: visible;
}

.grid-column::before {
    content: attr(data-column-index);
    position: absolute;
    top: -15px;
    left: 10px;
    background: #94B7BB;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.grid-column:hover::before {
    opacity: 1;
}

/* Responsive enhancements */
@media (max-width: 768px) {
    .grid-header.editing::before {
        font-size: 0.6em;
        padding: 1px 6px;
    }
    
    .column-element-controls {
        position: static !important;
        display: flex !important;
        justify-content: center;
        margin-top: 10px;
        background: #f8f9fa !important;
        padding: 5px;
        border-radius: 4px;
    }
    
    .active-indicator {
        position: static !important;
        display: inline-block;
        margin: 5px auto;
    }
}

/* Animation for grid transitions */
.grid-transition {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.grid-fade-in {
    animation: gridFadeIn 0.5s ease-out;
}

@keyframes gridFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* SEARCH CONTAINER */
.search-container {
    padding: 15px;
    border-bottom: 1px solid var(--nord-border);
    background: var(--nord-background);
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid var(--nord-border);
    border-radius: 8px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--nord-accent);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 1.1em;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #5c6878;
    cursor: pointer;
    font-size: 1.2em;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    background: #f0f0f0;
}

/* UPDATED MAIN CATEGORIES - 3x2 GRID */
.main-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--nord-border);
    background: var(--nord-background);
}

/* UPDATE CATEGORY BUTTONS */
.category-btn .icon {
    font-size: 1.3em;
}

.category-btn .label {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.category-btn .count {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* SUB-CATEGORIES */
.sub-categories {
    padding: 10px 15px;
    background: #f0f4f7;
    border-bottom: 1px solid var(--nord-border);
}

.sub-category-tabs {
    display: flex;
    gap: 4px;
}

.sub-tab {
    flex: 1;
    padding: 6px 8px;
    background: var(--nord-white);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    text-align: center;
    transition: all var(--transition-fast);
    color: #666;
}

.sub-tab:hover {
    background: #e9ecef;
}

.sub-tab.active {
    background: var(--nord-primary);
    color: var(--nord-white);
    border-color: var(--nord-primary);
}

/* SIDEBAR ELEMENTS - CLEANED AND RESPONSIVE */

/* Sub Elements - Single consolidated definition */
.sub-elements {
    flex: 1;
    padding: var(--spacing-md);
    padding-bottom: 120px; /* Extra padding at bottom to ensure last element is fully visible */
    overflow-y: auto;
    /* Responsive height that uses available space */
    min-height: 200px;
    max-height: calc(100vh - 420px); /* Adjust for header + tool-nav + search + categories */
}

/* Custom scrollbar styling */
.sub-elements::-webkit-scrollbar {
    width: 6px;
}

.sub-elements::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.sub-elements::-webkit-scrollbar-thumb {
    background: var(--nord-accent);
    border-radius: 3px;
}

/* Search Results - Matching responsive behavior */
.search-results {
    flex: 1;
    padding: var(--spacing-md);
    padding-bottom: 120px; /* Extra padding at bottom to ensure last element is fully visible */
    overflow-y: auto;
    /* Same responsive height as sub-elements */
    min-height: 200px;
    max-height: calc(100vh - 420px);
}

/* Search results content styling */
.search-results .section-title {
    font-size: 0.8em;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 15px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--nord-border);
}

.search-results .section-title:first-child {
    margin-top: 5px;
}

.no-results {
    text-align: center;
    color: #5c6878;
    font-style: italic;
    padding: 20px;
}

/* Element Items - Consolidated styling */
.element-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    background: var(--nord-background);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.element-item:hover {
    background: var(--nord-white);
    border-color: var(--nord-accent);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

/* Enhanced hover effect */
.element-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(148, 183, 187, 0.2), transparent);
    transition: left 0.5s ease;
}

.element-item:hover::before {
    left: 100%;
}

.element-item .icon {
    font-size: 1.25rem;
    color: var(--nord-secondary);
}

.element-item .name {
    flex: 1;
    font-weight: 500;
}

/* Element badges */
.element-item .badge {
    background: var(--nord-accent);
    color: var(--nord-white);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: bold;
    margin-left: auto;
}

.element-item .badge.new {
    background: #4caf50;
}

.element-item .badge.page-template {
    background: #ff9800;
    color: #333;
}

.element-item .badge.coming {
    background: #9e9e9e;
}

/* Phase 3: EKSTRA badge — muted gray-teal, marks elements that are only
   visible when the user has enabled the "Ekstra design" toggle. Lower visual
   weight than the bright NY badge since "ekstra" means "extra options for
   power users" rather than "new feature". */
.element-item .badge.ekstra {
    background: #94B7BB;
    color: #ffffff;
}

/* Web-only marker — shown on elements whose Canvas output depends on jQuery
   UI enhancement (tabs-builder, sortable-quiz). Those work in Canvas web but
   degrade to plain HTML in the Canvas mobile app. Visually understated so
   it doesn't compete with NY/MAL/KOMMER. */
.element-item .badge.web-only {
    background: transparent;
    color: #5c6878;
    padding: 2px 4px;
    font-size: 0.85em;
    font-weight: normal;
    cursor: help;
}

/* SEARCH CONTAINER */
.search-container {
    padding: 15px;
    border-bottom: 1px solid var(--nord-border);
    background: var(--nord-background);
    flex-shrink: 0; /* Prevent search from shrinking */
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid var(--nord-border);
    border-radius: 8px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--nord-accent);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 1.1em;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #5c6878;
    cursor: pointer;
    font-size: 1.2em;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    background: #f0f0f0;
}

/* MAIN CATEGORIES */
.main-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--nord-border);
    background: var(--nord-background);
    flex-shrink: 0; /* Prevent categories from shrinking */
}

/* SUB-CATEGORIES */
.sub-categories {
    padding: 10px 15px;
    background: #f0f4f7;
    border-bottom: 1px solid var(--nord-border);
    flex-shrink: 0; /* Prevent sub-categories from shrinking */
}

.sub-category-tabs {
    display: flex;
    gap: 4px;
}

.sub-tab {
    flex: 1;
    padding: 6px 8px;
    background: var(--nord-white);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    text-align: center;
    transition: all var(--transition-fast);
    color: #666;
}

.sub-tab:hover {
    background: #e9ecef;
}

.sub-tab.active {
    background: var(--nord-primary);
    color: var(--nord-white);
    border-color: var(--nord-primary);
}

/* RESPONSIVE BEHAVIOR */
@media (max-width: 1200px) {
    /* Reduce height calculation for smaller screens */
    .sub-elements,
    .search-results {
        max-height: calc(100vh - 390px);
    }
}

@media (max-width: 768px) {
    /* Mobile specific adjustments */
    .main-categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 10px;
    }
    
    .search-container {
        padding: 10px;
    }
    
    .element-item {
        padding: var(--spacing-md);
    }
    
    /* Fixed height on mobile for better UX */
    .sub-elements,
    .search-results {
        max-height: 300px;
        min-height: 200px;
    }
}

/* HIGH RESOLUTION DISPLAYS */
@media (min-height: 900px) {
    /* On tall screens, allow more space for elements */
    .sub-elements,
    .search-results {
        max-height: calc(100vh - 370px);
        min-height: 300px;
    }
}

@media (min-height: 1200px) {
    /* On very tall screens, use even more space */
    .sub-elements,
    .search-results {
        max-height: calc(100vh - 350px);
        min-height: 400px;
    }
}


/* Remove reference button styling */
.remove-reference {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    color: #5c6878;
    cursor: pointer;
    font-size: 1.2em;
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.remove-reference:hover {
    background: #f0f0f0;
    color: #dc3545;
}

/* Show remove button on hover */
.reference-item:hover .remove-reference {
    display: block;
}

/* Add reference button styling */
.add-reference-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #e9ecef;
    border: 2px dashed var(--nord-accent);
    border-radius: 6px;
    color: var(--nord-primary);
    cursor: pointer;
    font-size: 0.9em;
    transition: all var(--transition-normal);
    margin-top: 15px;
    font-family: inherit;
}

.add-reference-btn:hover {
    background: var(--nord-accent);
    color: var(--nord-white);
    border-color: var(--nord-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Editor-only elements that will be removed during export */
.editor-only {
    /* No specific styling needed, just used for targeting during export cleanup */
}

        .demo-seksjon {
            background: white;
            margin: 30px 0;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
        
        .demo-tittel {
            color: var(--nord-sekund1);
            font-size: 1.5em;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--nord-sekund6);
        }
        
        /* === GRUNNLEGGENDE FANE-STILER === */
        .faner-beholder {
            margin: 25px 0;
            font-family: system-ui, -apple-system, sans-serif;
        }

        .faneliste {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .fane {
            display: inline-block;
            text-decoration: none !important;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 500;
            font-size: 0.95em;
            border: none;
            outline: none;
        }

        .fane:focus {
            outline: 2px solid var(--nord-sekund6);
            outline-offset: 2px;
        }

        .fanepanel {
            background: white;
            border-radius: 8px;
        }

        .fanepanel h2,
        .fanepanel h3,
        .fanepanel h4 {
            color: var(--nord-sekund1);
            margin-top: 0;
            margin-bottom: 15px;
        }

        .fanepanel p {
            margin-bottom: 15px;
            line-height: 1.6;
        }

        .fanepanel ul,
        .fanepanel ol {
            margin-bottom: 15px;
            padding-left: 20px;
        }

        .fanepanel li {
            margin-bottom: 6px;
        }

        /* === HORISONTALE RENE FANER === */
        .horisontale-rene .faneliste {
            display: flex;
            gap: 4px;
            padding: 4px;
            background: #f8f9fa;
            border-radius: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
            border: none;
        }

        .horisontale-rene .fane {
            padding: 12px 20px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--nord-sekund2);
            transition: all 0.3s ease;
        }

        .horisontale-rene .fane:hover {
            background: rgba(148, 183, 187, 0.2);
            transform: translateY(-1px);
            color: var(--nord-sekund1);
        }

        .horisontale-rene .fane.aktiv {
            background: var(--nord-sekund1);
            color: white;
            box-shadow: 0 2px 8px rgba(0, 61, 76, 0.3);
        }

        .horisontale-rene .fanepanel {
            padding: 25px;
            background: white;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        /* === VERTIKALE RENE FANER === */
        .vertikale-rene {
            display: grid;
            grid-template-columns: 220px 1fr;
            gap: 25px;
            background: white;
            border-radius: 12px;
            overflow: hidden;
            border: 1px solid #e9ecef;
            min-height: 350px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        }

        .vertikale-rene .faneliste {
            display: flex;
            flex-direction: column;
            padding: 20px;
            background: #f8f9fa;
            margin: 0;
            border: none;
            gap: 6px;
        }

        .vertikale-rene .fane {
            padding: 14px 18px;
            background: transparent;
            border: none;
            border-radius: 8px;
            color: var(--nord-sekund2);
            text-align: left;
            transition: all 0.3s ease;
            position: relative;
            display: block;
        }

        .vertikale-rene .fane:hover {
            background: rgba(148, 183, 187, 0.15);
            padding-left: 22px;
            color: var(--nord-sekund1);
        }

        .vertikale-rene .fane.aktiv {
            background: var(--nord-sekund1);
            color: white;
            font-weight: 600;
            position: relative;
        }

        .vertikale-rene .fane.aktiv::after {
            content: '';
            position: absolute;
            right: -20px;
            top: 50%;
            transform: translateY(-50%);
            width: 0;
            height: 0;
            border-left: 8px solid var(--nord-sekund1);
            border-top: 6px solid transparent;
            border-bottom: 6px solid transparent;
        }

        .vertikale-rene .fane-innhold {
            padding: 30px;
        }

        .vertikale-rene .fanepanel {
            padding: 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }
        
        /* === FANE-BYGGER STILER === */
        .fane-bygger {
            background: #f8f9fa;
            padding: 30px;
            border-radius: 12px;
            border: 2px dashed var(--nord-sekund6);
            margin: 20px 0;
        }

        .bygger-seksjon {
            margin-bottom: 25px;
        }

        .bygger-etikett {
            font-weight: 600;
            color: var(--nord-sekund1);
            margin-bottom: 12px;
            display: block;
            font-size: 1.1em;
        }

        .stil-velger {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 12px;
            margin-bottom: 20px;
        }

        .stil-alternativ {
            padding: 16px;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            cursor: pointer;
            text-align: center;
            transition: all 0.3s ease;
            font-size: 0.95em;
            font-weight: 500;
            background: white;
        }

        .stil-alternativ:hover {
            border-color: var(--nord-sekund6);
            transform: translateY(-1px);
        }

        .stil-alternativ.valgt {
            border-color: var(--nord-sekund1);
            background: rgba(0, 61, 76, 0.05);
            color: var(--nord-sekund1);
        }

        .faner-beholder-input {
            background: white;
            padding: 20px;
            border-radius: 8px;
            border: 1px solid #e9ecef;
        }

        .fane-input-gruppe {
            display: flex;
            gap: 10px;
            margin-bottom: 12px;
            align-items: center;
        }

        .fane-input {
            flex: 1;
            padding: 10px 14px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 0.95em;
            transition: border-color 0.3s ease;
            font-family: inherit;
        }

        .fane-input:focus {
            outline: none;
            border-color: var(--nord-sekund6);
            box-shadow: 0 0 0 3px rgba(148, 183, 187, 0.1);
        }

        .fjern-fane-knapp {
            background: #dc3545;
            color: white;
            border: none;
            padding: 6px 10px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.85em;
            transition: background-color 0.3s ease;
            font-family: inherit;
        }

        .fjern-fane-knapp:hover {
            background: #c82333;
        }

        .legg-til-fane-knapp {
            background: var(--nord-sekund6);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.95em;
            font-weight: 500;
            transition: all 0.3s ease;
            font-family: inherit;
        }

        .legg-til-fane-knapp:hover {
            background: #7a9fa4;
            transform: translateY(-1px);
        }

        .forhandsvisning-omrade {
            margin-top: 30px;
            padding: 25px;
            background: white;
            border-radius: 8px;
            border: 1px solid #e9ecef;
        }

        .forhandsvisning-tittel {
            color: var(--nord-sekund1);
            margin-top: 0;
            margin-bottom: 20px;
            font-size: 1.2em;
            padding-bottom: 8px;
            border-bottom: 1px solid #e9ecef;
        }

        .generer-kode-knapp {
            background: var(--nord-sekund1);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: 600;
            margin-top: 20px;
            transition: all 0.3s ease;
            font-family: inherit;
        }

        .generer-kode-knapp:hover {
            background: var(--nord-sekund2);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 61, 76, 0.3);
        }

        .kode-utdata {
            background: #2d3748;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 8px;
            font-family: 'Courier New', Monaco, Consolas, monospace;
            font-size: 0.85em;
            overflow-x: auto;
            margin-top: 20px;
            max-height: 300px;
            overflow-y: auto;
            display: none;
            white-space: pre-wrap;
            line-height: 1.4;
        }

        .kode-utdata.vis {
            display: block;
        }
        
        /* === RESPONSIV DESIGN === */
        @media (max-width: 768px) {
            .vertikale-rene {
                grid-template-columns: 1fr;
            }
            
            .vertikale-rene .faneliste {
                flex-direction: row;
                overflow-x: auto;
                padding: 15px;
                gap: 8px;
            }
            
            .vertikale-rene .fane {
                white-space: nowrap;
                min-width: 120px;
                text-align: center;
            }
            
            .vertikale-rene .fane.aktiv::after {
                display: none;
            }
            
            .horisontale-rene .faneliste {
                flex-direction: column;
                gap: 6px;
            }
            
            .horisontale-rene .fane {
                text-align: center;
            }
            
            .stil-velger {
                grid-template-columns: 1fr;
            }
        }
        #tab-builder-modal .stil-velger {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* Faner D in the designer (sections 3f): drawn as Canvas draws it on the
   web, from canvas-lms's own tab styles. The first tab is open (white,
   joined to its panel), the other panels are hidden; the builder shows
   them all. In Canvas, jQuery UI does this and lets students switch. */
.tab-preview-scope .cd-tabs > ul > li,
#canvas .canvas-element .cd-tabs > ul > li {
    position: relative;
    top: 1px;
    border-bottom: 0 !important;
}
.tab-preview-scope .cd-tabs > ul > li:first-child,
#canvas .canvas-element .cd-tabs > ul > li:first-child {
    padding-bottom: 1px !important;
    background: #ffffff;
}
.tab-preview-scope .cd-tabs > ul > li:first-child a,
#canvas .canvas-element .cd-tabs > ul > li:first-child a {
    color: #333333 !important;
}
.tab-preview-scope .cd-tabs > .cd-tab-panel ~ .cd-tab-panel,
#canvas .canvas-element .cd-tabs > .cd-tab-panel ~ .cd-tab-panel {
    display: none;
}

/* Tab builder — turn the tabs into a FAQ block or sections */
#tab-builder-modal .tab-convert .form-help {
    margin: 0 0 10px 0;
}
#tab-builder-modal .tab-convert-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Tab builder — per-tab row with inline rich-text editor */
#tab-builder-modal #tab-inputs {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 12px;
}
#tab-builder-modal .fane-input-gruppe {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f8fafa;
    border: 1px solid #e1ecee;
    border-radius: 10px;
}
#tab-builder-modal .fane-input-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
#tab-builder-modal .fane-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #003d4c;
    color: #ffffff;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
#tab-builder-modal .fane-input-header .fane-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    color: #003d4c;
    background: #ffffff;
}
#tab-builder-modal .tab-content-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    background: #e8eef0;
    border: 1px solid #d4e3e6;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}
#tab-builder-modal .tab-rt-btn {
    width: 32px;
    height: 28px;
    border: none;
    background: transparent;
    color: #003d4c;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#tab-builder-modal .tab-rt-btn:hover {
    background: #d4e3e6;
}
#tab-builder-modal .tab-rt-btn.active {
    background: #00B0B9;
    color: #ffffff;
}
#tab-builder-modal .tab-rt-sep {
    width: 1px;
    margin: 4px 4px;
    background: #cbd8dc;
}
#tab-builder-modal .tab-content-editor {
    min-height: 80px;
    max-height: 240px;
    overflow-y: auto;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 0 0 6px 6px;
    font-size: 0.95em;
    color: #1e293b;
    line-height: 1.6;
    outline: none;
}
#tab-builder-modal .tab-content-editor:focus {
    border-color: #00B0B9;
}
#tab-builder-modal .tab-content-editor:empty::before {
    content: attr(data-placeholder);
    color: #5c6878;
    font-style: italic;
    pointer-events: none;
}
#tab-builder-modal .tab-content-editor h2,
#tab-builder-modal .tab-content-editor h3,
#tab-builder-modal .tab-content-editor h4 {
    margin: 8px 0 6px;
    color: #003d4c;
}
#tab-builder-modal .tab-content-editor p {
    margin: 0 0 8px;
}
#tab-builder-modal .fane-remove-btn {
    flex-shrink: 0;
}

/* ==========================================================================
   Canvas connection indicator + status badges
   ========================================================================== */
.canvas-conn-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.canvas-conn-indicator::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    border: 1.5px solid #ffffff;
}
.canvas-conn-indicator.connected::after {
    background: #007041;
}

/* Connection modal status messages.
   Hidden by default; a kind-specific modifier class (cc-status-testing /
   saved / success / error) turns it on AND applies the colour palette.
   We use a single-selector rule to keep specificity low so the inline
   element style doesn't need to fight it. */
.cc-status {
    display: none;
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}
.cc-status.cc-status-testing,
.cc-status.cc-status-saved,
.cc-status.cc-status-success,
.cc-status.cc-status-error {
    display: block;
}
.cc-status.cc-status-testing { background: #eef4f5; color: #165C7D; border-left: 4px solid #165C7D; }
.cc-status.cc-status-saved { background: #eef4f5; color: #003D4C; border-left: 4px solid #94B7BB; }
.cc-status.cc-status-success { background: #edf8f4; color: #007041; border-left: 4px solid #007041; }
.cc-status.cc-status-error { background: #fff5f2; color: #9f1239; border-left: 4px solid #EC5742; }

/* Publish modal status messages (same pattern) */
.cp-status {
    display: none;
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}
.cp-status.cp-status-working,
.cp-status.cp-status-success,
.cp-status.cp-status-warning,
.cp-status.cp-status-error,
.cp-status.cp-status-saved {
    display: block;
}
.cp-status.cp-status-working { background: #eef4f5; color: #165C7D; border-left: 4px solid #165C7D; }
.cp-status.cp-status-success { background: #edf8f4; color: #007041; border-left: 4px solid #007041; }
.cp-status.cp-status-warning { background: #fff7ed; color: #92400e; border-left: 4px solid #f59e0b; }
.cp-status.cp-status-error { background: #fff5f2; color: #9f1239; border-left: 4px solid #EC5742; }
.cp-status.cp-status-saved { background: #f7fafa; color: #4a5568; border-left: 4px solid #94B7BB; font-size: 0.85em; }
.cp-status.cp-status-success a { color: #007041; text-decoration: underline; font-weight: 700; }
.cp-status.cp-status-warning a { color: #92400e; text-decoration: underline; font-weight: 700; }

/* Unfinished images in the Export and Publish dialogs (placeholderImages.js):
   the warning pattern above, with one button per block */
.image-warning {
    margin: 0 0 14px;
    padding: 10px 14px;
    border-radius: 6px;
    background: #fff7ed;
    color: #92400e;
    border-left: 4px solid #f59e0b;
    font-size: 0.9em;
    line-height: 1.5;
}
.image-warning[hidden] { display: none; }
.image-warning p { margin: 0; }
.image-warning ul { margin: 6px 0; padding-left: 20px; }
.image-warning button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}
.image-warning button:focus-visible { outline: 2px solid #003d4c; outline-offset: 2px; }

/* ==========================================================================
   Preview mode (2026-04-15) — hide the editor chrome on the canvas so the
   teacher can see the page as it will appear in Canvas, without dashed
   drop zones / hover controls / container placeholders getting in the
   way. Pure visual toggle: interactions are preserved so the teacher can
   still click anywhere to exit via the floating "Exit preview" pill (or
   press Esc, or re-click the toolbar button). Nothing about the canvas
   state changes while preview mode is on.
   ========================================================================== */

/* The canvas itself loses padding/border affordances. */
body.preview-mode #canvas {
    background: #ffffff;
}

/* Every .canvas-element loses its hover border, padding, and background. */
body.preview-mode .canvas-element {
    border: none !important;
    background: none !important;
    padding: 0 !important;
    margin-bottom: 0;
}
body.preview-mode .canvas-element:hover {
    border: none !important;
    background: none !important;
}

/* Hover controls (move up/down, edit, delete, clone, etc.) are the
   single biggest source of visual noise during preview — kill them
   unconditionally, including the :has() escalation rules that normally
   force the innermost hovered element to show its controls. */
body.preview-mode .element-controls,
body.preview-mode .canvas-element:hover > .element-controls,
body.preview-mode .canvas-element:has(.canvas-element:hover) > .element-controls {
    display: none !important;
}

/* Container zones: drop borders off, empty-state hints off, active/hover
   highlights off. Teachers can still technically interact with these
   while previewing, but they look like plain content flow. */
body.preview-mode .container-zone {
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    min-height: 0;
}
body.preview-mode .container-zone:not(:has(> :not(.editor-only)))::after,
body.preview-mode .container-zone[data-zone]:not(:has(> :not(.editor-only)))::after {
    content: none !important;
    display: none !important;
}
body.preview-mode .container-zone.active-zone,
body.preview-mode .container-zone.drop-zone-hover {
    border: none !important;
    background: none !important;
    box-shadow: none !important;
}

/* Container breadcrumb navigation is a pure-editor affordance. Hide it
   so preview mode looks like a real Canvas page. */
body.preview-mode .container-breadcrumb-wrapper {
    display: none !important;
}

/* Empty-state helper text on a blank canvas — nothing to preview, but
   we don't want the welcome text leaking into the preview illusion. */
body.preview-mode #canvas .empty-state {
    display: none !important;
}

/* The "Exit preview" pill: floats top-right over the canvas wrapper,
   hidden except when preview mode is active. Using transform here is
   fine because this element never goes through Canvas's HTML sanitizer
   — it only exists in the designer UI. */
.preview-exit-pill {
    display: none;
    position: fixed;
    top: 96px;
    right: 24px;
    z-index: 9999;
    padding: 10px 18px;
    background: #165C7D;
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 999px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(22, 92, 125, 0.35);
    gap: 8px;
    align-items: center;
    transition: background 0.15s ease, transform 0.15s ease;
}
.preview-exit-pill i {
    margin-right: 6px;
}
.preview-exit-pill:hover {
    background: #0e4460;
    transform: translateY(-1px);
}
body.preview-mode .preview-exit-pill {
    display: inline-flex;
}

/* Toolbar "Forhåndsvis" button active-state — matches the existing
   `.toolbar-btn.active` convention used by viewport-toggle. */
#preview-toggle.active {
    background: #165C7D;
    color: #ffffff;
}
#preview-toggle.active .icon {
    color: #ffffff;
}

/* ==========================================================================
   Canvas Bootstrap grid simulation — designer preview only
   ==========================================================================
   Canvas's WYSIWYG editor preserves <details>/<summary> inside Canvas's own
   Bootstrap grid classes (grid-row + col-md-* + col-xs-*), but strips them
   when wrapped in inline `display: grid`. So our generated HTML uses the
   Bootstrap classes.
   The Canvas Designer app itself, however, does NOT load Bootstrap, so
   those classes have no visible effect in our preview — everything would
   stack vertically. These rules simulate the Bootstrap grid layout so the
   designer preview matches what teachers will see in Canvas. Scoped to
   `#canvas`, the flashcard preview, and the template browser preview so
   they don't interfere with the designer chrome.
   ========================================================================== */
#canvas .grid-row,
#fc-preview .grid-row,
#template-browser .grid-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -6px;
}
#canvas .grid-row [class*="col-md-"],
#fc-preview .grid-row [class*="col-md-"],
#template-browser .grid-row [class*="col-md-"] {
    box-sizing: border-box;
}
#canvas .grid-row .col-md-12, #fc-preview .grid-row .col-md-12, #template-browser .grid-row .col-md-12 { flex: 0 0 100%;    max-width: 100%; }
#canvas .grid-row .col-md-6,  #fc-preview .grid-row .col-md-6,  #template-browser .grid-row .col-md-6  { flex: 0 0 50%;     max-width: 50%; }
#canvas .grid-row .col-md-4,  #fc-preview .grid-row .col-md-4,  #template-browser .grid-row .col-md-4  { flex: 0 0 33.333%; max-width: 33.333%; }
#canvas .grid-row .col-md-3,  #fc-preview .grid-row .col-md-3,  #template-browser .grid-row .col-md-3  { flex: 0 0 25%;     max-width: 25%; }
#canvas .grid-row .col-md-2,  #fc-preview .grid-row .col-md-2,  #template-browser .grid-row .col-md-2  { flex: 0 0 16.666%; max-width: 16.666%; }
/* Mobile stacking — Bootstrap 3 md breakpoint is 992px, but in the
   constrained designer preview viewport we want stacking below ~640px to
   match typical reading widths. Below 640px, col-xs-12 takes over. */
@media (max-width: 640px) {
    #canvas .grid-row [class*="col-xs-12"],
    #fc-preview .grid-row [class*="col-xs-12"],
    #template-browser .grid-row [class*="col-xs-12"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   Shared row patterns for self-check builders.
   The Flashcard, Worked-example, Concept-check, and Worksheet builders
   all use the same per-item row layout (sections 3e: their style and
   colour row uses the box editor's controls, lookRow.js). Keeping
   one rule-set saves duplication.
   ========================================================================== */

/* Flashcard builder — per-card row */
#flashcard-builder-modal #fc-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}
#flashcard-builder-modal .fc-card-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f8fafa;
    border: 1px solid #e1ecee;
    border-radius: 10px;
}
#flashcard-builder-modal .fc-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
#flashcard-builder-modal .fc-card-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #003d4c;
    color: #ffffff;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
#flashcard-builder-modal .fc-question {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-weight: 600;
    color: #003d4c;
    background: #ffffff;
}
#flashcard-builder-modal .fc-answer {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    color: #1e293b;
    background: #ffffff;
    resize: vertical;
}
#flashcard-builder-modal .fc-question:focus,
#flashcard-builder-modal .fc-answer:focus {
    outline: none;
    border-color: #00B0B9;
}
#flashcard-builder-modal .fc-row-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Worked example builder */
#worked-example-builder-modal #we-stages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}
#worked-example-builder-modal .we-stage-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f8fafa;
    border: 1px solid #e1ecee;
    border-radius: 10px;
}
#worked-example-builder-modal .we-stage-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
#worked-example-builder-modal .we-stage-type-chip {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.72em;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
}
#worked-example-builder-modal .we-stage-type-chip.we-type-hint { background: #9a6a00; }
#worked-example-builder-modal .we-stage-type-chip.we-type-start { background: #165C7D; }
#worked-example-builder-modal .we-stage-type-chip.we-type-solution { background: #007041; }
#worked-example-builder-modal .we-stage-label {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
}
#worked-example-builder-modal .we-stage-content {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
    resize: vertical;
    font-family: inherit;
}
#worked-example-builder-modal .we-row-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Concept-check builder */
#concept-check-builder-modal #cc-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}
#concept-check-builder-modal .cc-option-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f8fafa;
    border: 2px solid #e1ecee;
    border-radius: 10px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
#concept-check-builder-modal .cc-option-row.is-correct {
    background: #edf8f4;
    border-color: #a5dcbc;
}
#concept-check-builder-modal .cc-option-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
#concept-check-builder-modal .cc-option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #003d4c;
    color: #ffffff;
    font-weight: 700;
    flex-shrink: 0;
}
#concept-check-builder-modal .cc-correct-btn {
    padding: 6px 14px;
    border: 2px solid #e5edef;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    color: #5c6878;
    font-size: 0.82em;
    font-weight: 600;
}
#concept-check-builder-modal .cc-correct-btn:hover {
    border-color: #94B7BB;
}
#concept-check-builder-modal .cc-correct-btn.selected {
    background: #edf8f4;
    border-color: #007041;
    color: #007041;
}
#concept-check-builder-modal .cc-option-text,
#concept-check-builder-modal .cc-option-feedback {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
    resize: vertical;
}
#concept-check-builder-modal .cc-row-controls {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Worksheet builder */
#worksheet-builder-modal #ws-prompts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}
#worksheet-builder-modal .ws-prompt-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f8fafa;
    border: 1px solid #e1ecee;
    border-radius: 10px;
}
#worksheet-builder-modal .ws-prompt-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
#worksheet-builder-modal .ws-prompt-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #003d4c;
    color: #ffffff;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
#worksheet-builder-modal .ws-row-controls {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
#worksheet-builder-modal .ws-prompt-text,
#worksheet-builder-modal .ws-prompt-answer {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
    resize: vertical;
}

/* Sortable quiz — per-card reasoning toggle layout tweak */
#sortable-quiz-builder-modal .sq-card-row.with-reasoning {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
}
#sortable-quiz-builder-modal .sq-card-row .sq-card-main-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
#sortable-quiz-builder-modal .sq-card-reasoning {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
    resize: vertical;
    font-size: 0.9em;
}

/* Per-statement row */
#true-false-builder-modal #tf-statements {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 12px;
}
#true-false-builder-modal .tf-statement-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: #f8fafa;
    border: 1px solid #e1ecee;
    border-radius: 10px;
}
#true-false-builder-modal .tf-statement-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
#true-false-builder-modal .tf-statement-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #003d4c;
    color: #ffffff;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
#true-false-builder-modal .tf-correct-group {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}
#true-false-builder-modal .tf-correct-btn {
    flex: 1;
    padding: 8px 14px;
    border: 2px solid #e5edef;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    color: #5c6878;
    font-weight: 700;
    font-size: 0.8em;
    letter-spacing: 0.04em;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
#true-false-builder-modal .tf-correct-btn:hover {
    border-color: #94B7BB;
}
#true-false-builder-modal .tf-correct-btn.selected[data-value="true"] {
    background: #edf8f4;
    border-color: #007041;
    color: #007041;
}
#true-false-builder-modal .tf-correct-btn.selected[data-value="false"] {
    background: #fff5f2;
    border-color: #9f1239;
    color: #9f1239;
}
#true-false-builder-modal .tf-row-controls {
    display: flex;
    gap: 4px;
}
#true-false-builder-modal .tf-statement-text,
#true-false-builder-modal .tf-explanation-text {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.92em;
    color: #1e293b;
    resize: vertical;
    background: #ffffff;
}
#true-false-builder-modal .tf-statement-text:focus,
#true-false-builder-modal .tf-explanation-text:focus {
    outline: none;
    border-color: #00B0B9;
}

/* Custom HTML modal — sanitiser explainer <code> styling */
#html-modal .html-sanitize-explainer code {
    background: #ffffff;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.92em;
    color: #003D4C;
    font-family: 'Courier New', Courier, monospace;
}

/* Source mode: textarea hidden by default, contenteditable visible. When the
   row has .source-mode the visibility swaps so the user can paste raw HTML. */
#tab-builder-modal .tab-content-source {
    display: none;
    width: 100%;
    min-height: 120px;
    max-height: 280px;
    padding: 12px 14px;
    margin: 0;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 0 0 6px 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    line-height: 1.55;
    resize: vertical;
    outline: none;
    tab-size: 2;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
#tab-builder-modal .tab-content-source:focus {
    border-color: #00B0B9;
    box-shadow: 0 0 0 2px rgba(0, 176, 185, 0.25);
}
#tab-builder-modal .fane-input-gruppe.source-mode .tab-content-editor {
    display: none;
}
#tab-builder-modal .fane-input-gruppe.source-mode .tab-content-source {
    display: block;
}
/* Highlight the source toggle button when active */
#tab-builder-modal .tab-rt-btn.tab-source-btn.active {
    background: #0f172a;
    color: #00B0B9;
}

/* Sortable quiz builder — content type picker */
#sortable-quiz-builder-modal .sq-content-type-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
#sortable-quiz-builder-modal .sq-content-type-btn {
    padding: 10px 18px;
    border: 2px solid #e5edef;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    color: #003d4c;
    font-weight: 600;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#sortable-quiz-builder-modal .sq-content-type-btn.selected {
    border-color: #003d4c;
    box-shadow: 0 4px 14px rgba(0, 61, 76, 0.18);
}
#sortable-quiz-builder-modal .sq-content-type-btn:hover {
    border-color: #94B7BB;
}
#sortable-quiz-builder-modal #sq-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
#sortable-quiz-builder-modal .sq-card-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}
#sortable-quiz-builder-modal .sq-card-row .sq-card-index {
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #003d4c;
    color: #fff;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
#sortable-quiz-builder-modal .sq-card-row input.sq-card-label {
    flex: 1;
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
}
#sortable-quiz-builder-modal .sq-card-row .control-btn {
    flex-shrink: 0;
}




/* Enhanced Accordion Styles *//* Enhanced Accordion Styles */
/*
.nord-accordion {
    transition: all 0.3s ease;
}

.nord-accordion:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.nord-accordion[open] .accordion-icon {
    transform: rotate(180deg);
    background: #003d4c !important;
}

.nord-accordion[open] .accordion-header {
    background: linear-gradient(135deg, #e8f2f5, #f0f7ff) !important;
    border-bottom-color: #d0dae0 !important;
}
*/
/* FAQ Accordion Specific Styles */
/*
.faq-item:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.faq-item[open] .faq-toggle {
    transform: rotate(45deg);
    color: #003d4c !important;
}

.faq-item[open] .accordion-header {
    background: linear-gradient(135deg, #e8f2f5, #ffffff) !important;
}
*/
/* Learning Section Accordion */
/*.learning-section:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.learning-section[open] .expand-icon {
    transform: rotate(45deg);
}

.learning-section[open] .section-icon {
    transform: scale(1.1);
}
*/
/* Resource Accordion */
/*.resource-item:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.resource-item[open] .toggle-indicator {
    transform: rotate(90deg);
}

.resource-item .accordion-content a:hover {
    background: #e9ecef !important;
    transform: translateX(5px);
}*/

/* General Accordion Animation */
/*
.accordion-content {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
*/
/* Accordion Builder Specific Styles */
/*
.accordion-content-input {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: inherit;
    line-height: 1.4;
    resize: vertical;
    margin-top: 8px;
    transition: border-color 0.3s ease;
}

.accordion-content-input:focus {
    outline: none;
    border-color: var(--nord-accent);
    box-shadow: 0 0 0 3px rgba(148, 183, 187, 0.1);
}

.fane-input-gruppe {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    position: relative;
}

.fane-input-gruppe .fjern-fane-knapp {
    position: absolute;
    top: 10px;
    right: 10px;
}
*/
/* Responsive Accordion Adjustments */
/*
@media (max-width: 768px) {
    .accordion-header {
        padding: 15px 18px !important;
        font-size: 1.1rem !important;
    }
    
    .accordion-content {
        padding: 20px 22px !important;
    }
    
    .learning-section .section-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2em !important;
    }
    
    .faq-number {
        width: 20px !important;
        height: 20px !important;
        font-size: 0.7em !important;
    }
    
    .resource-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 1em !important;
    }
    
    .fane-input-gruppe {
        padding: 12px;
    }
    
    .accordion-content-input {
        min-height: 60px;
    }
}
        */


/*==========================================================================
   NEW ACCORDION STYLES (for Builder Preview & Canvas Output)
   Using Pseudo-elements for Icons
   ========================================================================== */

/* === GRUNNLEGGENDE TREKKSPILL-STILER (Copied from Canvas Custom CSS v2) === */
.trekkspill-beholder {
    margin: 25px 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

.trekkspill-element {
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    border: 1px solid #e0e5e7;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.trekkspill-hode {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border: none;
    color: #003d4c;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 20px 25px;
    width: 100%;
    text-align: left;
    font-weight: 600;
    list-style: none; 
    display: flex;
    align-items: center;
    gap: 15px; 
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
    border-bottom: 1px solid transparent;
    box-sizing: border-box;
}

.trekkspill-hode::-webkit-details-marker,
.trekkspill-hode::marker {
    display: none;
}

.trekkspill-hode::before,
.trekkspill-hode::after {
    transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trekkspill-tittel {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.trekkspill-innhold {
    background-color: #fff;
    padding: 25px 30px;
    border-top: 1px solid #f0f2f3;
    animation: gliNed 0.3s ease-out;
    text-align: left;
}
.trekkspill-innhold p {
    margin-top: 0;
    color: #444; 
    line-height: 1.6;
}
.trekkspill-innhold p:last-child {
    margin-bottom: 0;
}
.trekkspill-innhold p + p { 
    color: #666;
    font-size: 0.95em;
}

.seksjons-header {
    text-align: center;
    margin-bottom: 25px;
}
.seksjons-header h3 {
    color: #003d4c;
    font-size: 1.6em;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.seksjons-header p {
    color: #666;
    margin: 0;
    font-size: 1.1em;
}
.seksjons-header .header-ikon {
    font-size: 1.2em;
}

.nord-trekkspill:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.nord-trekkspill .trekkspill-hode::before {
    content: '▼';
    background: #94b7bb;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.8em; 
    order: -1; 
    margin-right: 15px;
}
.nord-trekkspill .trekkspill-hode {
    gap: 0; 
}
.nord-trekkspill .trekkspill-hode::before {
     margin-right: 15px; 
}
.nord-trekkspill[open] .trekkspill-hode::before {
    transform: rotate(180deg);
    background: #003d4c !important;
}
.nord-trekkspill[open] .trekkspill-hode {
    background: linear-gradient(135deg, #e8f2f5, #f0f7ff) !important;
    border-bottom-color: #d0dae0 !important;
}

.sporsmal-element:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.sporsmal-element .trekkspill-hode {
    background: #f8f9fa;
    font-size: 1.1rem;
    padding: 18px 22px;
    font-weight: 500;
    gap: 12px;
}
.sporsmal-nummer {
    background: #165c7d;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
    flex-shrink: 0;
}
.sporsmal-element .trekkspill-hode::after {
    content: '+';
    color: #5c6878;
    font-size: 1.5rem; 
    font-weight: 300; 
    display: inline-block;
    margin-left: auto; 
    padding-left: 10px; 
}
.sporsmal-element[open] .trekkspill-hode::after {
    transform: rotate(45deg);
    color: #003d4c !important;
}
.sporsmal-element[open] .trekkspill-hode {
    background: linear-gradient(135deg, #e8f2f5, #ffffff) !important;
}
.sporsmal-element .trekkspill-innhold {
    padding: 20px 25px 20px 58px; 
    color: #555;
    line-height: 1.6;
}

.laerings-seksjon:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.laerings-seksjon .trekkspill-hode {
    gap: 15px;
    border-left: 4px solid;
}
.seksjon-ikon { 
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em; 
    color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}
.laerings-tittel-beholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}
.laerings-hovedtittel {
    font-size: 1em; 
    margin-bottom: 2px;
    display: block;
    font-weight: 600;
}
.laerings-undertittel {
    font-size: 0.75em; 
    font-weight: 400;
    display: block;
}
.laerings-seksjon .trekkspill-hode::after {
    content: '⊕';
    font-size: 1.6rem; 
    font-weight: normal; 
    display: inline-block;
    margin-left: auto; 
    padding-left: 10px; 
}
.laerings-seksjon[open] .trekkspill-hode::after {
    transform: rotate(45deg);
}
.laerings-seksjon[open] .seksjon-ikon {
    transform: scale(1.1);
}
.laerings-seksjon .trekkspill-innhold .innhold-boks {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}
.laerings-seksjon .trekkspill-innhold .innhold-boks h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.laerings-seksjon .trekkspill-innhold .innhold-boks ul {
    margin: 0;
    padding-left: 20px;
    color: #555;
}
.laerings-seksjon .trekkspill-innhold .innhold-boks li {
    margin-bottom: 5px;
}

.laerings-seksjon .trekkspill-hode { 
    background: linear-gradient(135deg, #f0f0f0, #e8e8e8);
    border-left-color: #777;
    color: #333;
}
.laerings-seksjon .seksjon-ikon { 
    background: #777;
}
.laerings-seksjon .laerings-undertittel {
    color: #555; 
}
.laerings-seksjon .trekkspill-hode::after { 
    color: #5c6878;
}
.laerings-seksjon .trekkspill-innhold {
    border-top: 1px solid #e0e0e0;
}
.laerings-seksjon .trekkspill-innhold h4 {
    color: #333;
}
.laerings-seksjon .trekkspill-innhold .innhold-boks {
    background: #f5f5f5;
}

.laerings-seksjoner > .laerings-seksjon:nth-child(1) .trekkspill-hode {
    background: linear-gradient(135deg, #e8f5e8, #f8f9fa);
    border-left-color: #4caf50;
    color: #2e7d32;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .seksjon-ikon {
    background: #4caf50;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.2);
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .laerings-undertittel {
    color: #4caf50;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .trekkspill-hode::after {
    color: #4caf50;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .trekkspill-innhold {
     border-top: 1px solid #e8f5e8;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .trekkspill-innhold h4 {
    color: #2e7d32;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(1) .trekkspill-innhold .innhold-boks {
    background: #f0f8f0;
}

.laerings-seksjoner > .laerings-seksjon:nth-child(2) .trekkspill-hode {
    background: linear-gradient(135deg, #e3f2fd, #f8f9fa);
    border-left-color: #2196f3;
    color: #1565c0;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .seksjon-ikon {
    background: #2196f3;
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.2);
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .laerings-undertittel {
    color: #2196f3;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .trekkspill-hode::after {
    color: #2196f3;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .trekkspill-innhold {
     border-top: 1px solid #e3f2fd;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .trekkspill-innhold h4 {
    color: #1565c0;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(2) .trekkspill-innhold .innhold-boks {
    background: #f0f7ff;
}

.laerings-seksjoner > .laerings-seksjon:nth-child(3) .trekkspill-hode {
    background: linear-gradient(135deg, #fff3e0, #f8f9fa);
    border-left-color: #ff9800;
    color: #e65100;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .seksjon-ikon {
    background: #ff9800;
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.2);
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .laerings-undertittel {
    color: #ff9800;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .trekkspill-hode::after {
    color: #ff9800;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .trekkspill-innhold {
     border-top: 1px solid #fff3e0;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .trekkspill-innhold h4 {
    color: #e65100;
}
.laerings-seksjoner > .laerings-seksjon:nth-child(3) .trekkspill-innhold .innhold-boks {
    background: #fffbf0;
}

.ressurs-element:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.ressurs-element .trekkspill-hode {
    font-size: 1.1rem;
    padding: 16px 20px;
    font-weight: 600;
    gap: 12px;
}
.ressurs-ikon { 
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em; 
    color: white;
    flex-shrink: 0;
}
.ressurs-element .trekkspill-hode::after { 
    content: '⊞'; 
    font-size: 1.2em; 
    display: inline-block;
    margin-left: auto;
    padding-left: 10px;
    transition: transform 0.3s ease, color 0.3s ease;
}
.ressurs-element[open] .trekkspill-hode::after {
    transform: rotate(90deg);
}
.ressurs-element .trekkspill-innhold .ressurs-lenkeliste {
    display: grid;
    gap: 10px;
}
.ressurs-element .trekkspill-innhold a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
    color: #333; 
}
.ressurs-element .trekkspill-innhold a:hover {
    background: #e9ecef !important;
    transform: translateX(5px);
}
.ressurs-element .trekkspill-innhold .lenke-ikon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.ressurs-element .trekkspill-hode {
    background: linear-gradient(135deg, #f5f5f5, #e9e9e9);
    color: #333;
}
.ressurs-element .ressurs-ikon {
    background: #888;
}
.ressurs-element .trekkspill-hode::after {
    color: #5c6878;
}
.ressurs-element .trekkspill-innhold {
    border-top-color: #f5f5f5;
}
.ressurs-element .trekkspill-innhold a {
    color: #333;
}

.ressurs-trekkspill > .ressurs-element:nth-child(1) .trekkspill-hode { 
    background: linear-gradient(135deg, #f0f8f0, #ffffff);
    color: #2e7d32;
}
.ressurs-trekkspill > .ressurs-element:nth-child(1) .ressurs-ikon {
    background: #4caf50;
}
.ressurs-trekkspill > .ressurs-element:nth-child(1) .trekkspill-hode::after {
    color: #4caf50;
}
.ressurs-trekkspill > .ressurs-element:nth-child(1) .trekkspill-innhold {
    border-top-color: #f0f8f0;
}
.ressurs-trekkspill > .ressurs-element:nth-child(1) .trekkspill-innhold a {
    color: #2e7d32;
}

.ressurs-trekkspill > .ressurs-element:nth-child(2) .trekkspill-hode { 
    background: linear-gradient(135deg, #f0f7ff, #ffffff);
    color: #1565c0;
}
.ressurs-trekkspill > .ressurs-element:nth-child(2) .ressurs-ikon {
    background: #2196f3;
}
.ressurs-trekkspill > .ressurs-element:nth-child(2) .trekkspill-hode::after {
    color: #2196f3;
}
.ressurs-trekkspill > .ressurs-element:nth-child(2) .trekkspill-innhold {
    border-top-color: #f0f7ff;
}
.ressurs-trekkspill > .ressurs-element:nth-child(2) .trekkspill-innhold a {
    color: #1565c0;
}

.ressurs-trekkspill > .ressurs-element:nth-child(3) .trekkspill-hode { 
    background: linear-gradient(135deg, #fffbf0, #ffffff);
    color: #e65100;
}
.ressurs-trekkspill > .ressurs-element:nth-child(3) .ressurs-ikon {
    background: #ff9800;
}
.ressurs-trekkspill > .ressurs-element:nth-child(3) .trekkspill-hode::after {
    color: #ff9800;
}
.ressurs-trekkspill > .ressurs-element:nth-child(3) .trekkspill-innhold {
    border-top-color: #fffbf0;
}
.ressurs-trekkspill > .ressurs-element:nth-child(3) .trekkspill-innhold a {
    color: #e65100;
}

@keyframes gliNed {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .trekkspill-hode { padding: 15px 18px !important; font-size: 1.1rem !important; }
    .trekkspill-hode::before, .trekkspill-hode::after { font-size: 1.3rem; }
    .nord-trekkspill .trekkspill-hode::before { width: 28px; height: 28px; font-size: 0.7em; }
    .seksjon-ikon { width: 36px !important; height: 36px !important; font-size: 1.2em !important; }
    .sporsmal-nummer { width: 20px !important; height: 20px !important; font-size: 0.7em !important; }
    .ressurs-ikon { width: 28px !important; height: 28px !important; font-size: 1em !important; }
    .trekkspill-innhold { padding: 20px 22px !important; }
    .trekkspill-beholder { margin: 15px 0; }
}

.trekkspill-element:focus-within {
    outline: 2px solid var(--nord-sekund6, #94B7BB); 
    outline-offset: 2px;
}
@media (prefers-contrast: high) {
    .trekkspill-element { border: 2px solid currentColor; }
    .trekkspill-hode { border-bottom: 1px solid currentColor; }
}
@media (prefers-reduced-motion: reduce) {
    .trekkspill-element, .trekkspill-hode::before, .trekkspill-hode::after,
    .seksjon-ikon, .ressurs-ikon { transition: none; }
    .nord-trekkspill:hover, .sporsmal-element:hover, .laerings-seksjon:hover,
    .ressurs-element:hover { transform: none; }
    .trekkspill-innhold { animation: none; }
}
/* ============================================
   LAPTOP OPTIMIZATION (13" screens)
   Maximize vertical space for element list
   ============================================ */

/* 1. COMPACT ELEMENT ITEMS - More elements visible at once */
.element-item {
    padding: 6px 12px !important; /* Reduced from 8px 16px */
    margin-bottom: 4px !important; /* Reduced from 8px */
    gap: 8px !important;
}

.element-item .icon {
    font-size: 1.1rem !important; /* Reduced from 1.25rem */
}

.element-item .name {
    font-size: 0.875rem; /* Slightly smaller text */
    line-height: 1.3;
}

.element-item .badge {
    font-size: 0.65em !important;
    padding: 1px 5px !important;
}

/* 2. OPTIMIZED SIDEBAR HEIGHT - More space for elements */
.sub-elements {
    max-height: calc(100vh - 280px) !important; /* Increased from 420px */
    padding-bottom: 80px !important; /* Reduced from 120px */
}

.search-results {
    max-height: calc(100vh - 280px) !important; /* Increased from 420px */
    padding-bottom: 80px !important; /* Reduced from 120px */
}

/* 3. COMPACT SEARCH BAR */
.search-container {
    padding: 10px 12px !important; /* Reduced from 15px */
}

.search-input {
    padding: 8px 35px 8px 12px !important; /* Reduced from 10px 40px 10px 15px */
    font-size: 0.85em !important;
}

/* 4. COMPACT CATEGORY GRID */
.main-categories {
    padding: 10px !important; /* Reduced from 16px */
    gap: 6px !important; /* Reduced from 8px */
}

.category-btn {
    padding: 8px 6px !important; /* Reduced from 16px 8px */
}

.category-btn .icon {
    font-size: 1.3rem !important; /* Reduced from 1.5rem */
}

.category-btn .label {
    font-size: 0.7rem !important; /* Reduced from 0.75rem */
}

.category-btn .count {
    font-size: 0.65rem !important; /* Reduced from 0.7rem */
}

/* 5. COLLAPSIBLE CATEGORIES */
.categories-collapse-btn {
    background: var(--nord-background);
    border: 1px solid var(--nord-border);
    border-top: none;
    width: 100%;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--nord-text-light);
    transition: all var(--transition-fast);
}

.categories-collapse-btn:hover {
    background: var(--nord-white);
    color: var(--nord-secondary);
}

.categories-collapse-btn .arrow {
    transition: transform var(--transition-fast);
}

.main-categories.collapsed {
    display: none;
}

.main-categories.collapsed + .categories-collapse-btn .arrow {
    transform: rotate(180deg);
}

/* When categories are collapsed, give even more space to elements */
.main-categories.collapsed ~ * .sub-elements,
.main-categories.collapsed ~ * .search-results {
    max-height: calc(100vh - 180px) !important; /* Extra 100px when collapsed */
}

/* 6. COMPACT SUB-CATEGORY TABS */
.sub-categories {
    padding: 8px 12px !important; /* Reduced from 10px 15px */
}

.sub-tab {
    flex: 0 1 auto !important;   /* Size to content instead of equal-width */
    padding: 5px 6px !important;
    font-size: 0.75em !important;
    white-space: nowrap;
}

.sub-category-tabs {
    flex-wrap: wrap;              /* Wrap to second row if tabs still overflow */
}

/* 7. COMPACT HEADER */
.app-header {
    padding: 6px var(--spacing-xl) 6px var(--spacing-lg) !important;
}

.header-left h1 {
    font-size: 1.3rem !important; /* Reduced from 1.5rem */
    margin-bottom: 2px !important;
}

.header-left p {
    font-size: 0.8rem !important; /* Reduced from 0.875rem */
}

.compatibility-filter {
    padding: 8px 12px !important; /* Reduced from 12px 18px */
}

.compatibility-filter label {
    font-size: 0.85em !important; /* Reduced from 0.95em */
}

/* Icon mode segmented control */
.icon-mode-btn.active {
    background: #ffffff !important;
    color: var(--nord-primary) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* Language pill toggle — mirrors icon-mode-btn */
.lang-btn.active {
    background: #ffffff !important;
    color: var(--nord-primary) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* 8. COMPACT TOOLBAR */
.preview-toolbar {
    padding: 6px 24px 6px 16px !important;
    min-height: 44px !important;
    height: auto !important;
}

/* Not in the redesign B bar: designer-ui.css sizes .app-bar buttons and
   closes them up step by step (1.5, appBar.js fit) */
.toolbar-btn:not(.app-bar *) {
    padding: 6px 10px !important; /* Reduced from 8px 16px */
    font-size: 0.8rem !important; /* Reduced from 0.875rem */
}

.toolbar-btn .icon {
    font-size: 0.9em;
}

/* Adjust canvas wrapper height to account for compact toolbar */
.canvas-wrapper {
    height: calc(100vh - 110px) !important; /* Adjusted for smaller header + toolbar */
}

/* ============================================
   END LAPTOP OPTIMIZATION
   ============================================ */

/* ============================================
   GRID LAYOUT SELECTOR SPACING FIX
   Give more breathing room when grid is active
   ============================================ */

/* When grid options are visible, give toolbar more height */
#grid-options {
    padding: 4px 8px;
    margin-left: 8px;
}

.grid-layout-selector {
    padding: 6px 10px !important;
    gap: 10px !important;
}

.grid-selector-label {
    font-size: 0.8rem !important;
    margin-right: 4px;
}

.grid-layout-primary {
    gap: 8px !important;
}

.grid-layout-option {
    padding: 8px 10px !important;
    min-width: 55px !important;
}

.layout-preview {
    width: 45px !important;
    height: 22px !important;
}

.layout-label {
    font-size: 0.7rem !important;
    margin-top: 2px;
}

.grid-layout-more-btn {
    padding: 8px 12px !important;
    font-size: 0.75rem !important;
}

/* Give toolbar more height when grid is active */
.preview-toolbar:has(#grid-options[style*="display: flex"]),
.preview-toolbar:has(#grid-options:not([style*="display: none"])) {
    height: 58px !important;
    padding: 8px 12px !important;
}

/* Ensure grid end button has good spacing */
#grid-end {
    margin-right: 12px;
}

/* ============================================
   END GRID SPACING FIX
   ============================================ */

/* ============================================
   TOOLBAR REDESIGN (2026-04-17)
   Grouped layout with dividers, Canvas dropdown
   menu, top-right corner with flag-icon language
   toggle and avatar/account menu.
   ============================================ */

/* Visual divider between toolbar groups. */
.toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--nord-border);
    margin: 0 4px;
    flex-shrink: 0;
    align-self: center;
}

/* Canvas LMS actions dropdown (Connect / Import / Publish / HTML / Clear). */
.canvas-menu-wrapper {
    position: relative;
}

.canvas-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--nord-white);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    padding: 4px;
    z-index: 50;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.canvas-menu-dropdown.show {
    display: block;
}

.canvas-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.82em;
    color: var(--nord-primary);
    transition: background 0.12s;
    font-family: inherit;
}

.canvas-menu-item:hover {
    background: var(--nord-background);
}

.canvas-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.canvas-menu-item:disabled:hover {
    background: transparent;
}

.canvas-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--nord-secondary);
}

.canvas-menu-item-danger {
    color: #c53030;
}

.canvas-menu-item-danger i {
    color: #c53030;
}

.canvas-menu-item-danger:hover {
    background: #fff5f5;
}

.canvas-menu-divider {
    height: 1px;
    background: var(--nord-border);
    margin: 4px 0;
}

/* Header right region — make compatibility-filter and the top-right
   corner sit side-by-side. */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-right-corner {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Compact globe + NB/EN language toggle — mirrors the html-course
   header design (subtle pill with text codes). */
.lang-toggle-compact {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #e8eef0;
    border-radius: 6px;
    padding: 2px 4px;
}

.lang-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nord-text-light);
    font-size: 0.85em;
    padding: 0 4px 0 2px;
    line-height: 1;
}

.lang-code-btn {
    border: none;
    background: transparent;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78em;
    font-weight: 600;
    color: #4a5568;
    line-height: 1.2;
    font-family: inherit;
    transition: background 0.12s, color 0.12s;
}

.lang-code-btn:hover {
    background: rgba(255, 255, 255, 0.55);
}

/* .lang-btn.active styling already exists earlier; both selectors apply. */

/* Icon-only toolbar button (e.g. Clear/trash) — square, no label.
   Not in the redesign B bar, which sizes its own (designer-ui.css). */
.toolbar-btn-icon:not(.app-bar *) {
    padding: 6px 8px !important;
}

.toolbar-btn-icon .icon {
    margin: 0;
}

/* Account widget — login button when logged out, avatar circle + menu
   when logged in. The mixin toggles which is visible. */
.account-wrapper {
    position: relative;
}

.account-login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--nord-secondary);
    background: var(--nord-secondary);
    color: #ffffff;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.12s, border-color 0.12s;
}

.account-login-btn:hover {
    background: var(--nord-primary);
    border-color: var(--nord-primary);
}

.account-avatar-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--nord-secondary);
    color: #ffffff;
    border: 2px solid var(--nord-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.95em;
    text-transform: uppercase;
    font-family: inherit;
    padding: 0;
    transition: transform 0.12s;
}

.account-avatar-btn:hover {
    transform: scale(1.05);
}

.account-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--nord-white);
    border: 1px solid var(--nord-border);
    border-radius: var(--radius-md);
    padding: 4px;
    z-index: 100;
    min-width: 240px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.account-menu-dropdown.show {
    display: block;
}

.account-menu-header {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--nord-border);
    margin-bottom: 4px;
    font-size: 0.75em;
    color: var(--nord-text-light);
    word-break: break-word;
    line-height: 1.3;
}

.account-menu-header strong {
    color: var(--nord-primary);
    display: block;
    font-size: 1.05em;
    margin-top: 2px;
}

.account-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.82em;
    color: var(--nord-primary);
    transition: background 0.12s;
    font-family: inherit;
}

.account-menu-item:hover {
    background: var(--nord-background);
}

.account-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--nord-secondary);
}

.account-menu-item-danger {
    color: #c53030;
}

.account-menu-item-danger i {
    color: #c53030;
}

.account-menu-item-danger:hover {
    background: #fff5f5;
}

.account-menu-divider {
    height: 1px;
    background: var(--nord-border);
    margin: 4px 0;
}

/* Connection indicator dot for the canvas-menu-toggle button. Inherits
   the existing .canvas-conn-indicator.connected pulse from earlier in
   this stylesheet. */

/* ============================================
   END TOOLBAR REDESIGN
   ============================================ */

/* ============================================
   TEMPLATE SYSTEM STYLES
   ============================================ */

/* Template cards: their look is in designer-ui.css ("Template browser") */

/* Template category buttons */
.template-category-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Template panel scrolling */
#templates-panel {
    overflow-y: auto;
}

/* Empty state for templates */
.templates-empty {
    text-align: center;
    padding: 60px 20px;
    color: #5c6878;
}

.templates-empty p {
    margin: 10px 0 0 0;
    font-size: 0.95em;
}

/* ============================================
   END TEMPLATE SYSTEM STYLES
   ============================================ */

/* Clear canvas button in templates panel */
#templates-panel button[onclick*="clearCanvas"]:hover {
    background: #d4442f !important;
    box-shadow: 0 4px 12px rgba(236, 87, 66, 0.3);
    transform: translateY(-1px);
}

#templates-panel button[onclick*="clearCanvas"]:active {
    transform: translateY(0);
}

/* ============================================
   CONTAINER SYSTEM STYLES
   ============================================ */

/* Container wrapper element */
.container-wrapper {
    position: relative;
}

.container-wrapper .element-content {
    position: relative;
}

/* Active container highlight */
.container-wrapper.container-active {
    outline: 2px dashed var(--secondary);
    outline-offset: 4px;
}

/* Container zones - base styles */
.container-zone {
    min-height: 48px;
    border: 2px dashed transparent;
    transition: all 0.2s ease;
    position: relative;
}

/* Empty zone state — compact placeholder (Norwegian default).
   A zone is empty when it has no element children other than editor-only
   controls. Whitespace text nodes don't count (unlike :empty), so this needs
   no JS bookkeeping and stays correct after undo/redo, drafts and cloud loads
   (sections 1.3 — replaced the per-zone MutationObservers). */
.container-zone:not(:has(> :not(.editor-only)))::after {
    content: 'Klikk for å plassere elementer';
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #5c6878;
    padding: 16px 20px;
    font-size: 0.85em;
    min-height: 48px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    background: rgba(148, 183, 187, 0.05);
    margin: 6px;
}

/* English override */
html:lang(en) .container-zone:not(:has(> :not(.editor-only)))::after {
    content: 'Click to place elements here';
}

/* Active zone highlight */
.container-zone.active-zone {
    border-color: var(--secondary);
    background: rgba(22, 92, 125, 0.03);
    box-shadow: inset 0 0 0 2px rgba(22, 92, 125, 0.1);
}

.container-zone.active-zone::after {
    content: none;
}

/* Drop zone hover state */
.container-zone.drop-zone-hover {
    border-color: var(--primary) !important;
    background: rgba(22, 92, 125, 0.08) !important;
    box-shadow: 0 0 12px rgba(22, 92, 125, 0.2);
}

/* Zone labels for empty containers — Norwegian default */
.container-zone[data-zone="header"]:not(:has(> :not(.editor-only)))::after {
    content: 'Header — klikk for å plassere elementer';
}
.container-zone[data-zone="content"]:not(:has(> :not(.editor-only)))::after {
    content: 'Innhold — klikk for å plassere elementer';
}
.container-zone[data-zone="left"]:not(:has(> :not(.editor-only)))::after {
    content: 'Venstre kolonne — klikk for å plassere elementer';
}
.container-zone[data-zone="right"]:not(:has(> :not(.editor-only)))::after {
    content: 'Høyre kolonne — klikk for å plassere elementer';
}
.container-zone[data-zone="center"]:not(:has(> :not(.editor-only)))::after {
    content: 'Midtkolonne — klikk for å plassere elementer';
}
.container-zone[data-zone="main"]:not(:has(> :not(.editor-only)))::after {
    content: 'Hovedinnhold — klikk for å plassere elementer';
}
.container-zone[data-zone="sidebar"]:not(:has(> :not(.editor-only)))::after {
    content: 'Sidepanel — klikk for å plassere elementer';
}

/* English overrides */
html:lang(en) .container-zone[data-zone="header"]:not(:has(> :not(.editor-only)))::after {
    content: 'Header — click to place elements';
}
html:lang(en) .container-zone[data-zone="content"]:not(:has(> :not(.editor-only)))::after {
    content: 'Content — click to place elements';
}
html:lang(en) .container-zone[data-zone="left"]:not(:has(> :not(.editor-only)))::after {
    content: 'Left column — click to place elements';
}
html:lang(en) .container-zone[data-zone="right"]:not(:has(> :not(.editor-only)))::after {
    content: 'Right column — click to place elements';
}
html:lang(en) .container-zone[data-zone="center"]:not(:has(> :not(.editor-only)))::after {
    content: 'Center column — click to place elements';
}
html:lang(en) .container-zone[data-zone="main"]:not(:has(> :not(.editor-only)))::after {
    content: 'Main content — click to place elements';
}
html:lang(en) .container-zone[data-zone="sidebar"]:not(:has(> :not(.editor-only)))::after {
    content: 'Sidebar — click to place elements';
}

/* ============================================================================
   Quick-add inline element picker (Notion/Gutenberg-style "+" between elements)
   ============================================================================ */

/* Floating "+" trigger button — positioned dynamically by JS */
.quick-add-trigger {
    position: fixed;
    z-index: 100;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #d4e3e6;
    background: #ffffff;
    color: #5c6878;
    font-size: 0.85em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.quick-add-trigger:hover {
    border-color: #00B0B9;
    color: #00B0B9;
    background: #f0fbfc;
    transform: scale(1.15);
}

/* Popover panel */
.quick-add-popover {
    position: fixed;
    z-index: 10000;
    width: 300px;
    max-height: 400px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search input */
.quick-add-search {
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.85em;
    outline: none;
    background: #f8f9fa;
}

.quick-add-search:focus {
    background: #ffffff;
}

/* Category tab strip */
.quick-add-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.quick-add-tab {
    flex: 1;
    padding: 6px 4px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    text-align: center;
    transition: background 0.15s;
}

.quick-add-tab:hover {
    background: #e9ecef;
}

.quick-add-tab.active {
    background: #003D4C;
    color: #ffffff;
}

.quick-add-tab.active i {
    color: #ffffff;
}

/* Sub-category tabs */
.quick-add-subtabs {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.quick-add-subtab {
    padding: 3px 10px;
    border: 1px solid #d4e3e6;
    background: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.75em;
    color: #4a5568;
    transition: all 0.15s;
}

.quick-add-subtab:hover {
    border-color: #94B7BB;
    background: #f7fafa;
}

.quick-add-subtab.active {
    background: #003D4C;
    color: #ffffff;
    border-color: #003D4C;
}

/* Scrollable element list */
.quick-add-elements {
    overflow-y: auto;
    flex: 1;
    padding: 4px;
    max-height: 260px;
}

/* Individual element items */
.quick-add-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}

.quick-add-item:hover {
    background: #f0f8fa;
}

/* Keyboard-highlighted option (ArrowUp/ArrowDown; Enter inserts it) */
.quick-add-item.is-active {
    background: #e6f2f4;
    box-shadow: inset 3px 0 0 #165c7d;
}

.quick-add-trigger:focus-visible,
.quick-add-tab:focus-visible,
.quick-add-subtab:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}

.quick-add-item-icon {
    width: 24px;
    text-align: center;
    font-size: 0.9em;
    flex-shrink: 0;
}

.quick-add-item-name {
    font-size: 0.82em;
    color: #2d3b45;
}

/* Group heading inside a quick-add list (section-divider markers) */
.quick-add-divider {
    padding: 8px 10px 4px;
    font-size: 0.72rem;
    color: #5c6878;
}

.quick-add-empty {
    padding: 20px;
    text-align: center;
    color: #5c6878;
    font-size: 0.85em;
}

/* ============================================================================
   Help guide modal — tabbed panel with getting started, accessibility, etc.
   ============================================================================ */

.help-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e9ecef;
    background: #f8f9fa;
    padding: 0 16px;
}

.help-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.82em;
    color: #5c6878;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.help-tab:hover {
    color: #003D4C;
    background: rgba(0, 61, 76, 0.04);
}

.help-tab.active {
    color: #003D4C;
    border-bottom-color: #003D4C;
    background: #ffffff;
}

.help-panel {
    display: none;
    max-height: 55vh;
    overflow-y: auto;
}

.help-panel.active {
    display: block;
}

.help-step {
    margin-bottom: 16px;
    padding-left: 0;
}

.help-step h4 {
    margin: 0 0 4px 0;
    color: #003D4C;
    font-size: 0.95em;
}

.help-step p {
    margin: 0;
    color: #4a5568;
    font-size: 0.9em;
    line-height: 1.6;
}

kbd {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.85em;
    font-family: monospace;
    color: #003D4C;
    background: #f0f4f5;
    border: 1px solid #d4e3e6;
    border-radius: 4px;
}

/* Sidebar zone context indicator — shown when user is inside a container zone */
.sidebar-zone-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(22, 92, 125, 0.08), rgba(0, 176, 185, 0.06));
    border-bottom: 2px solid var(--secondary, #165c7d);
    color: var(--secondary, #165c7d);
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.sidebar-zone-indicator i {
    font-size: 0.9em;
    opacity: 0.7;
}

/* Breadcrumb navigation */
.container-breadcrumb-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}

.breadcrumb-label {
    color: #666;
    font-size: 0.85em;
}

.container-breadcrumb-wrapper.at-root {
    display: none;
}

#container-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.breadcrumb-item.clickable {
    cursor: pointer;
    color: var(--secondary);
}

.breadcrumb-item.clickable:hover {
    background: rgba(22, 92, 125, 0.1);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #ccc;
    font-weight: bold;
}

/* Exit container button */
.exit-container-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exit-container-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Nested elements styling inside containers */
.container-zone > .canvas-element {
    margin: 8px 0;
}

.container-zone > .canvas-element:first-child {
    margin-top: 0;
}

.container-zone > .canvas-element:last-child {
    margin-bottom: 0;
}

/* Container element icon in sidebar */
.element-item[data-is-container="true"] .element-icon::after {
    content: '+';
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--secondary);
    color: white;
    font-size: 10px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ============================================
   END CONTAINER SYSTEM STYLES
   ============================================ */

/* ============================================
   CLOUD SAVE — MY DESIGNS MODAL (Phase 1)
   Sidebar + tag filter + card list. These
   classes live under the cloud-my-designs-modal
   scope, so they don't leak out into the canvas
   or the public preview.
   ============================================ */

/* The inline new-space modal is reachable from BOTH the Save modal and
   the My Designs sidebar, so it must stack above either of them.
   Same trick for any other "modal-opens-over-modal" flow we add later. */
#cloud-new-space-modal,
#cloud-edit-design-modal {
    z-index: 1050;
}

.cloud-my-designs-content {
    max-width: 860px;
    width: 100%;
}

.cloud-my-designs-body {
    display: flex;
    padding: 0;
    min-height: 480px;
    max-height: 70vh;
}

.cloud-my-designs-sidebar {
    flex: 0 0 220px;
    border-right: 1px solid #edf2f7;
    background: #fafbfc;
    overflow-y: auto;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cloud-sidebar-heading {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5c6878;
    padding: 14px 10px 6px 10px;
}

.cloud-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #2d3748;
    font-size: 0.92em;
    text-align: left;
    cursor: pointer;
    width: 100%;
    transition: background 0.12s ease;
}

.cloud-sidebar-item:hover {
    background: #edf2f7;
}

.cloud-sidebar-item.active {
    background: #e6f7f5;
    color: #003d4c;
    font-weight: 600;
}

.cloud-sidebar-item .cloud-sidebar-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-sidebar-item > i {
    width: 16px;
    color: #5c6878;
    text-align: center;
}

.cloud-sidebar-item.active > i {
    color: #00B0B9;
}

.cloud-sidebar-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cloud-sidebar-count {
    font-size: 0.78em;
    color: #5c6878;
    background: #edf2f7;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}

.cloud-sidebar-new {
    margin-top: 4px;
    color: #00B0B9;
    font-weight: 600;
}

.cloud-sidebar-new:hover {
    background: #e6f7f5;
}

.cloud-my-designs-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.cloud-my-designs-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid #edf2f7;
}

.cloud-my-designs-search {
    width: 100%;
}

.cloud-my-designs-tagbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    align-items: center;
    border-bottom: 1px solid #edf2f7;
    background: #fafbfc;
}

.cloud-filter-label {
    font-size: 0.8em;
    color: #5c6878;
    margin-right: 4px;
}

.cloud-filter-tag {
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.82em;
    cursor: pointer;
    color: #4a5568;
    transition: all 0.12s ease;
}

.cloud-filter-tag:hover {
    border-color: #00B0B9;
    color: #003d4c;
}

.cloud-filter-tag.active {
    background: #00B0B9;
    color: #ffffff;
    border-color: #00B0B9;
}

.cloud-filter-clear {
    background: transparent;
    border: none;
    color: #5c6878;
    font-size: 0.82em;
    cursor: pointer;
    text-decoration: underline;
}

.cloud-my-designs-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.cloud-my-designs-empty {
    padding: 40px 24px;
    text-align: center;
    color: #5c6878;
}

.cloud-design-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #edf2f7;
}

.cloud-design-row:last-child {
    border-bottom: none;
}

.cloud-card-body {
    flex: 1;
    min-width: 0;
}

.cloud-card-title {
    font-weight: 600;
    color: #1a202c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-card-meta {
    font-size: 0.82em;
    color: #5c6878;
    margin-top: 2px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cloud-card-space {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #165c7d;
}

.cloud-card-shared {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #165c7d;
}

/* The share dialog. .btn sets display, which would override [hidden]. */
#cloud-share-modal [hidden] {
    display: none;
}

.cloud-share-name {
    margin: 0 0 12px 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cloud-share-link-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.cloud-share-link-row .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.cloud-share-link-row .btn {
    flex-shrink: 0;
}

.cloud-share-note {
    margin: 12px 0 0 0;
    font-size: 0.9em;
    color: #4a5568;
}

.cloud-card-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.cloud-card-tag {
    background: #f0f4f8;
    color: #4a5568;
    font-size: 0.76em;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
}

.cloud-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

/* Icon-only button used for the pencil on each design card. The base
   .btn-sm spacing is tuned for text; icon-only buttons need equal
   padding on all sides so they don't look chopped next to the text
   buttons. */
.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: #5c6878;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #003d4c;
    background: #edf2f7;
    border-color: #e2e8f0;
}

/* ============================================
   CLOUD SAVE — TAG CHIP INPUT
   Shared by the Save modal's tags field and any
   future use (element library save, etc.).
   ============================================ */

.cloud-tag-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cloud-tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 4px;
}

.cloud-tag-chips:empty {
    display: none;
}

.cloud-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #00B0B9;
    color: #ffffff;
    font-size: 0.84em;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
}

.cloud-tag-chip button {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.05em;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 999px;
}

.cloud-tag-chip button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive: on narrow screens, stack sidebar above list */
@media (max-width: 680px) {
    .cloud-my-designs-body {
        flex-direction: column;
        max-height: none;
    }
    .cloud-my-designs-sidebar {
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 1px solid #edf2f7;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
    }
    .cloud-sidebar-heading {
        display: none;
    }
    .cloud-sidebar-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* ============================================================
   Styles migrated from the inline <style> block in
   index.html (2026-04-17). These are regular app
   styles that had accumulated in the HTML head over time; they
   are not critical-path / above-the-fold, and no rule here was
   load-order-sensitive in a way that required being inline.
   Appended at the END of this file so that source-order
   specificity matches what they had before.
   ============================================================ */

        /* Fixed license footer styling */
        #canvas-designer-attribution {
            font-family: system-ui, -apple-system, sans-serif;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        #canvas-designer-attribution:hover {
            opacity: 1 !important;
            transform: translateY(-2px);
        }

        #canvas-designer-attribution a:hover {
            color: #a8dbc4 !important;
        }

        /* Fixed grid active indicator positioning */
        .active-indicator {
            position: absolute;
            top: 5px;
            left: 10px; /* Moved to left to avoid overlap with controls */
            background: #003d4c;
            color: white;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 0.7em;
            font-weight: bold;
            z-index: 5; /* Lower than controls */
            animation: pulse 2s infinite;
        }

        /* Enhanced grid column controls positioning */
        .column-element-controls {
            position: absolute;
            top: -8px;
            right: -8px;
            display: none;
            gap: 2px;
            z-index: 15; /* Higher than active indicator */
            background: rgba(255, 255, 255, 0.95);
            padding: 4px;
            border-radius: 6px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            border: 1px solid #e0e0e0;
        }

        /* Improved mobile responsiveness for grid elements */
        @media (max-width: 768px) {
            .active-indicator {
                position: static;
                display: inline-block;
                margin: 2px 0;
                font-size: 0.6em;
            }
            
            .column-element-controls {
                position: static !important;
                display: flex !important;
                justify-content: center;
                margin-top: 8px;
                background: #f8f9fa !important;
                padding: 6px;
                border-radius: 4px;
                box-shadow: none;
            }
        }

        /* page-layout-* styles removed 2026-04-09 — superseded by Sideramme feature */

        /* Multi-reference container */
        .references-container {
            border-top: 2px solid #e9ecef;
            margin-top: 40px;
            padding-top: 30px;
            background: #f8f9fa;
            border-radius: 8px;
            padding: 30px;
        }

        .references-title {
            font-size: 1.3em;
            font-weight: 600;
            color: #003d4c;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .reference-item {
            margin-bottom: 15px;
            padding: 15px;
            background: #fff;
            border-left: 4px solid #94B7BB;
            border-radius: 0 6px 6px 0;
            font-size: 0.9em;
        }

        .reference-item:last-child {
            margin-bottom: 0;
        }

        .reference-author {
            font-weight: 600;
            color: #003d4c;
        }

        .reference-details {
            color: #666;
            margin-top: 4px;
        }

        /* Tool Navigation Styles */
        .tool-nav-btn {
            flex: 1;
            padding: 18px 24px;
            background: transparent;
            border: none;
            border-bottom: 4px solid transparent;
            cursor: pointer;
            font-size: 1.05em;
            font-weight: 500;
            color: #666;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }

        .tool-nav-btn:hover {
            background: rgba(0,176,185,0.08) !important;
            color: #003d4c !important;
        }

        .tool-nav-btn.active {
            background: white !important;
            border-bottom-color: #00B0B9 !important;
            color: #003d4c !important;
            font-weight: 600 !important;
        }

        /* Tool Panel Containers */
        .tool-panel {
            display: none;
        }

        .tool-panel.active {
            display: block;
        }

        /* Shape Designer specific styles (kept for Nord variants) */
        #shape-designer-panel {
            height: 100%;
        }

        /* HugeRTE Editor Custom Styling */
        .tox .tox-toolbar {
            background: #f8f9fa !important;
            flex-wrap: wrap !important;  /* Allow toolbar to wrap to multiple lines */
        }

        .tox .tox-toolbar__primary {
            flex-wrap: wrap !important;  /* Ensure primary toolbar wraps */
        }

        .tox .tox-toolbar__group {
            padding: 2px 4px !important;  /* Reduce padding for better wrapping */
        }

        .tox .tox-edit-area__iframe {
            background: white !important;
        }

        /* Hide any promotional messages */
        .tox-promotion,
        .tox-statusbar__branding {
            display: none !important;
        }

        /* Box Builder Specific Styles */
        .box-control-section {
            margin-bottom: 25px;
            padding-bottom: 20px;
            border-bottom: 1px solid #e0e0e0;
        }

        .box-control-section:last-child {
            border-bottom: none;
        }

        .box-control-section h4 {
            margin: 0 0 15px 0;
            color: #003d4c;
            font-size: 1.05em;
            font-weight: 600;
        }

        .box-control-group {
            margin-bottom: 15px;
        }

        .box-control-group label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.9em;
            color: #666;
            font-weight: 500;
        }

        .box-control-group input[type="range"] {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: #ddd;
            outline: none;
            -webkit-appearance: none;
            appearance: none;
        }

        .box-control-group input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #00B0B9;
            cursor: pointer;
        }

        .box-control-group input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #00B0B9;
            cursor: pointer;
            border: none;
        }

        .box-control-group input[type="color"] {
            width: 100%;
            height: 40px;
            border: 1px solid #ddd;
            border-radius: 6px;
            cursor: pointer;
        }

        .box-control-group select {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 0.9em;
        }

        .box-range-value {
            display: inline-block;
            background: #00B0B9;
            color: white;
            padding: 3px 8px;
            border-radius: 3px;
            font-size: 0.85em;
            font-weight: 600;
            margin-left: 8px;
        }

        .box-checkbox-group {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
        }

        .box-checkbox-group input[type="checkbox"] {
            width: 16px;
            height: 16px;
            cursor: pointer;
        }

        .box-color-presets {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
            margin-top: 8px;
        }

        .box-color-preset {
            aspect-ratio: 1;
            border-radius: 4px;
            border: 2px solid #ddd;
            cursor: pointer;
            transition: all 0.2s;
        }

        .box-color-preset:hover {
            transform: scale(1.05);
        }

        .box-color-preset.selected {
            border-color: #003D4C;
            box-shadow: 0 0 0 2px rgba(0,61,76,0.2);
        }

        .box-insert-button {
            width: 100%;
            padding: 12px;
            background: #00B0B9;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1em;
            font-weight: 600;
            cursor: pointer;
            margin-top: 20px;
            transition: background 0.2s;
        }

        .box-insert-button:hover {
            background: #008c94;
        }

        #box-preview-container {
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
            margin-top: 15px;
        }

        /* Shape Designer Specific Styles */
        .control-section {
            margin-bottom: 25px;
            padding-bottom: 20px;
            border-bottom: 1px solid #e0e0e0;
        }

        .control-section:last-child {
            border-bottom: none;
        }

        .control-section h4 {
            margin: 0 0 15px 0;
            color: #003d4c;
            font-size: 1.05em;
            font-weight: 600;
        }

        .control-section label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.9em;
            color: #666;
            font-weight: 500;
        }

        .control-section input[type="range"] {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: #ddd;
            outline: none;
            -webkit-appearance: none;
            appearance: none;
        }

        .control-section input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #165C7D;
            cursor: pointer;
        }

        .control-section input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #165C7D;
            cursor: pointer;
            border: none;
        }

        .range-value {
            display: inline-block;
            background: #165C7D;
            color: white;
            padding: 3px 8px;
            border-radius: 3px;
            font-size: 0.85em;
            font-weight: 600;
            margin-left: 8px;
        }

        .control-btn {
            padding: 6px 8px;
            background: #e0e0e0;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s;
            font-family: inherit;
            width: 65px;
            height: 55px;
            font-size: 0.85em;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
        }

        .control-btn > div:first-child {
            font-size: 1.2em;
            line-height: 1;
        }

        .control-btn > div:last-child {
            font-size: 0.75em;
            line-height: 1;
        }

        .control-btn:hover {
            background: #d0d0d0;
        }

        .control-btn.active {
            background: #00B0B9;
            color: white;
        }

        .control-btn.active:hover {
            background: #008c94;
        }

        .shape-presets {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }

        .shape-preset {
            border: 2px solid #ddd;
            border-radius: 8px;
            padding: 12px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
            background: white;
        }

        .shape-preset:hover {
            border-color: #165C7D;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transform: translateY(-1px);
        }

        .shape-preset.selected {
            border-color: #003D4C;
            background: #E9F7F9;
            box-shadow: 0 0 0 3px rgba(0,61,76,0.1);
        }

        .shape-preset-icon {
            font-size: 1.8em;
            margin-bottom: 6px;
        }

        .shape-preset-name {
            font-weight: 600;
            color: #003D4C;
            font-size: 0.85em;
        }

        .color-presets {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 8px;
            margin-top: 10px;
        }

        .shape-color-preset {
            aspect-ratio: 1;
            border-radius: 6px;
            border: 2px solid #ddd;
            cursor: pointer;
            transition: all 0.2s;
        }

        .shape-color-preset:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        }

        .shape-color-preset.selected {
            border-color: #003D4C;
            box-shadow: 0 0 0 3px rgba(0,61,76,0.2);
        }

/* ============================================================
   AI Phase 1 — sparkle button, gear button, inline draft panel,
   and the AI-settings modal's test-result area. Teal accent
   distinguishes AI affordances from Canvas/brand actions.
   ============================================================ */

.ai-sparkle-btn,
.ai-gear-btn {
    border: 2px solid #94B7BB;
    border-radius: 6px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
}
.ai-sparkle-btn {
    background: linear-gradient(135deg, #00B0B9, #165C7D);
    color: #ffffff;
    border-color: transparent;
    min-width: 44px;
}
.ai-sparkle-btn:hover {
    background: linear-gradient(135deg, #008891, #0f4a66);
}
.ai-sparkle-btn.active {
    background: #003D4C;
}
.ai-gear-btn {
    background: #ffffff;
    color: #4a5568;
    min-width: 40px;
}
.ai-gear-btn:hover {
    background: #f7fafa;
    border-color: #00B0B9;
    color: #003D4C;
}

.ai-draft-panel {
    margin: 12px 0 18px;
    padding: 14px 16px;
    background: #f7fafa;
    border: 1px solid #d4e3e6;
    border-left: 4px solid #00B0B9;
    border-radius: 0 8px 8px 0;
}
.ai-draft-panel-setup {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.ai-draft-panel-message {
    margin: 0;
    flex: 1;
    min-width: 200px;
    color: #165C7D;
    font-size: 0.92em;
    line-height: 1.5;
}
.ai-draft-panel-form .bygger-etikett {
    margin-bottom: 4px;
    font-size: 0.85em;
}
.ai-draft-panel-status {
    display: none;
    margin: 12px 0 0;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}
.ai-draft-panel-status.pending,
.ai-draft-panel-status.ok,
.ai-draft-panel-status.err {
    display: block;
}
.ai-draft-panel-status.pending { background: #eef4f5; color: #165C7D; border-left: 4px solid #165C7D; }
.ai-draft-panel-status.ok      { background: #edf8f4; color: #007041; border-left: 4px solid #007041; }
.ai-draft-panel-status.err     { background: #fff5f2; color: #9f1239; border-left: 4px solid #EC5742; }
/* Redesign 0.5.4: Replace / Add / Cancel before a draft overwrites the form */
.ai-draft-ask {
    margin: 12px 0 0;
    padding: 10px 14px;
    border: 1px solid #8c8174;
    border-radius: 6px;
    background: #ffffff;
}
.ai-draft-ask-text { margin: 0 0 8px; font-size: 0.92em; line-height: 1.5; color: #1e1b18; }
.ai-draft-ask-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Phase 1.5 — Canvas context picker ---- */
.ai-context-picker {
    margin: 0 0 12px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 6px;
}
.ai-context-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: #165C7D;
    font-size: 0.9em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.ai-context-toggle:hover {
    background: #f7fafa;
}
.ai-context-toggle .ai-context-chevron {
    font-size: 0.75em;
    transition: transform 0.2s;
}
.ai-context-toggle.open .ai-context-chevron {
    transform: rotate(180deg);
}
.ai-context-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e8eef0;
    display: grid;
    gap: 10px;
}
.ai-context-body .bygger-etikett {
    margin-bottom: 4px;
    font-size: 0.85em;
}
.ai-context-course {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.9em;
}
.ai-context-pages {
    max-height: 180px;
    overflow-y: auto;
    padding: 6px 10px;
    background: #f7fafa;
    border: 1px solid #e0e6e8;
    border-radius: 6px;
    font-size: 0.88em;
}
.ai-context-pages label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 0;
    cursor: pointer;
    line-height: 1.35;
}
.ai-context-pages label.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ai-context-pages input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
}
.ai-context-pages input[type="checkbox"]:disabled {
    cursor: not-allowed;
}
.ai-context-empty {
    padding: 4px 0;
    color: #5c6878;
    font-size: 0.88em;
    font-style: italic;
}
.ai-context-status {
    font-size: 0.85em;
    min-height: 1em;
    color: #165C7D;
}
.ai-context-status.err      { color: #9f1239; }
.ai-context-status.pending  { color: #165C7D; }
.ai-context-status.ok       { color: #007041; }
.ai-context-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.ai-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    background: #eef4f5;
    border: 1px solid #c5dde1;
    border-radius: 999px;
    font-size: 0.82em;
    color: #165C7D;
}
.ai-context-chip button {
    border: none;
    background: transparent;
    color: #165C7D;
    cursor: pointer;
    padding: 0 6px;
    font-size: 0.9em;
    line-height: 1;
    border-radius: 999px;
}
.ai-context-chip button:hover {
    color: #9f1239;
    background: #ffe5e0;
}
.ai-context-summary {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.82em;
    color: #4a5568;
}
.ai-context-summary.truncated {
    color: #9f1239;
}

/* ---- External-prompt export (Phase 1.5) ---- */
.ai-external-prompt {
    margin: 0 0 12px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 6px;
}
.ai-external-prompt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: #165C7D;
    font-size: 0.9em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.ai-external-prompt-toggle:hover {
    background: #f7fafa;
}
.ai-external-prompt-toggle .ai-external-prompt-chevron {
    font-size: 0.75em;
    transition: transform 0.2s;
}
.ai-external-prompt-toggle.open .ai-external-prompt-chevron {
    transform: rotate(180deg);
}
.ai-external-prompt-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e8eef0;
}
.ai-external-prompt-text {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #f7fafa;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    line-height: 1.45;
    resize: vertical;
    color: #2d3748;
}
.ai-external-prompt-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.ai-external-prompt-status {
    font-size: 0.85em;
    color: #4a5568;
}
.ai-external-prompt-status.ok  { color: #007041; }
.ai-external-prompt-status.err { color: #9f1239; }
.ai-external-prompt-hint {
    margin: 8px 0 0;
    color: #4a5568;
    font-size: 0.82em;
    line-height: 1.45;
}

/* The AI settings modal is usually opened FROM inside a builder modal
   (flashcard / concept-check / true-false). The builder is already at
   z-index 1000, so without this override the nested AI modal would
   stack behind it. Bump to 1100 so it always renders on top. */
#ai-settings-modal {
    z-index: 1100;
}

/* Settings-modal test-result area (same pattern as .cc-status). */
.ai-test-result {
    display: none;
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}
.ai-test-result.pending,
.ai-test-result.ok,
.ai-test-result.err {
    display: block;
}
.ai-test-result.pending { background: #eef4f5; color: #165C7D; border-left: 4px solid #165C7D; }
.ai-test-result.ok      { background: #edf8f4; color: #007041; border-left: 4px solid #007041; }
.ai-test-result.err     { background: #fff5f2; color: #9f1239; border-left: 4px solid #EC5742; }

/* -------------------------------------------------------------
 * "Mine elementer" palette (Phase 2 of My designs)
 * -----------------------------------------------------------*/
.my-elements-empty {
    padding: 24px 16px;
    text-align: center;
    color: #4a5568;
    font-size: 0.9em;
}
.my-element-item {
    position: relative;
    padding-right: 32px;  /* room for the delete button */
}
.my-element-item .my-element-tags {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    flex-wrap: wrap;
}
.my-element-item .my-element-tag {
    font-size: 0.68em;
    padding: 1px 6px;
    border-radius: 10px;
    background: #eef4f5;
    color: #165C7D;
}
.my-element-item .my-element-delete {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #5c6878;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.my-element-item:hover .my-element-delete { opacity: 1; }
.my-element-item .my-element-delete:hover { color: #9f1239; background: #fff5f2; }

/* Type-bucket tab row — only rendered when library has ≥ 8 elements
 * AND spans ≥ 2 buckets. Visually echoes the built-in palette's .sub-tab
 * so it feels native. */
.my-elements-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px 8px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 6px;
}
.my-elements-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #4a5568;
    font-size: 0.82em;
    cursor: pointer;
    line-height: 1.2;
}
.my-elements-tab:hover { background: #eef4f5; color: #003D4C; }
.my-elements-tab.active {
    background: #003D4C;
    color: #ffffff;
    border-color: #003D4C;
}
.my-elements-tab-count {
    display: inline-block;
    padding: 0 6px;
    min-width: 18px;
    border-radius: 9px;
    background: rgba(148, 183, 187, 0.2);
    color: inherit;
    font-size: 0.85em;
    text-align: center;
}
.my-elements-tab.active .my-elements-tab-count {
    background: rgba(255, 255, 255, 0.2);
}
.my-elements-list { display: block; }

/* Tag-filter chip row — shown when library has ≥ 2 distinct tags.
 * Visually secondary to type tabs: smaller, lighter, flatter. */
.my-elements-tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px 8px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 6px;
}
.my-elements-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid #d4e3e6;
    border-radius: 999px;
    background: #f7fafa;
    color: #165C7D;
    font-size: 0.78em;
    cursor: pointer;
    line-height: 1.2;
}
.my-elements-tag-chip:hover {
    background: #eef4f5;
    border-color: #94B7BB;
}
.my-elements-tag-chip.active {
    background: #00B0B9;
    color: #ffffff;
    border-color: #00B0B9;
}
.my-elements-tag-count {
    display: inline-block;
    padding: 0 5px;
    min-width: 16px;
    border-radius: 8px;
    background: rgba(148, 183, 187, 0.2);
    font-size: 0.9em;
    text-align: center;
}
.my-elements-tag-chip.active .my-elements-tag-count {
    background: rgba(255, 255, 255, 0.25);
}


/* ============================================================================
   Sections (Stage 2) — "+ Section" lines and the in-flow section chooser
   (sectionPicker.js). Editor-only; hidden in preview mode.
   ============================================================================ */
.section-gap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 24px;
    margin: -4px 0 4px;
}
.section-gap::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 12px;
    border-top: 1px dashed #b7cbd0;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.section-gap-btn {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 1px;
    padding: 2px 12px;
    border-radius: 999px;
    border: 1px solid #b7cbd0;
    background: #ffffff;
    color: #165c7d;
    font-size: 0.78rem;
    line-height: 1.6;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.canvas:hover .section-gap::before,
.canvas:hover .section-gap-btn,
.section-gap.is-open::before,
.section-gap.is-open .section-gap-btn,
.section-gap-btn:focus-visible {
    opacity: 1;
}
.section-gap-btn:hover,
.section-gap.is-open .section-gap-btn {
    background: #e6f2f4;
}
.section-gap-btn:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}
body.preview-mode .section-gap {
    display: none;
}

.section-chooser {
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0 12px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #c6d6da;
    border-radius: 12px;
    text-align: left;
}
.empty-state .section-chooser {
    margin-top: 16px;
}
.section-chooser-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.section-chooser-title {
    font-size: 0.85rem;
    color: #003D4C;
}
.section-chooser-close {
    border: none;
    background: none;
    color: #5c6878;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.section-chooser-close:hover { background: #f0f6f7; }
.section-layout-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}
.section-layout-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 96px;
    padding: 8px 6px;
    border: 1px solid #d4e3e6;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}
.section-layout-option[hidden] { display: none; }
.section-layout-option:hover,
.section-layout-option:focus-visible {
    border-color: #165c7d;
    background: #f0f6f7;
}
.section-layout-option:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}
.section-layout-thumb {
    display: flex;
    gap: 3px;
    width: 76px;
    height: 34px;
}
.section-layout-thumb > span {
    display: block;
    border-radius: 3px;
    background: #94B7BB;
}
.section-layout-name {
    font-size: 0.75rem;
    color: #2d3b45;
    text-align: center;
    line-height: 1.25;
}
.section-chooser-more {
    align-self: center;
    border: 1px dashed #b7cbd0;
    background: none;
    color: #165c7d;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}
.section-chooser-foot {
    margin-top: 10px;
}
.section-chooser-link {
    border: none;
    background: none;
    padding: 4px 0;
    color: #165c7d;
    text-decoration: underline;
    font-size: 0.8rem;
    cursor: pointer;
}
.section-chooser-more:focus-visible,
.section-chooser-link:focus-visible,
.section-chooser-close:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}

/* Column "+" (sectionPicker.js syncColumnAdds): always the last child of a
   layout column. Small and quiet under content; in an empty column it is
   the empty state itself (replaces the old "click to place" hint). */
.container-zone > .column-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    margin: 6px 0 0;
    padding: 4px 8px;
    border: 1px dashed #c6d6da;
    border-radius: 6px;
    background: transparent;
    color: #5c6878;
    font-size: 0.78rem;
    cursor: pointer;
}
.container-zone > .column-add:hover {
    border-color: #165c7d;
    color: #165c7d;
    background: #f0f6f7;
}
.container-zone > .column-add:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}
.column-add .column-add-label {
    display: none;
}
.container-zone:not(:has(> :not(.editor-only))) > .column-add {
    min-height: 64px;
    margin: 0;
    background: rgba(148, 183, 187, 0.06);
}
.container-zone:not(:has(> :not(.editor-only))) > .column-add .column-add-label {
    display: inline;
}
/* The column "+" replaces the text hint */
.container-zone:has(> .column-add)::after {
    content: none !important;
    display: none !important;
}
body.preview-mode .container-zone > .column-add {
    display: none;
}

.quick-add-all {
    margin: 4px 8px 8px;
    padding: 8px 10px;
    border: 1px dashed #b7cbd0;
    border-radius: 6px;
    background: none;
    color: #165c7d;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
}
.quick-add-all:hover { background: #f0f6f7; }
.quick-add-all:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}

/* ============================================================================
   Section and block toolbars (sections 2.4)
   ============================================================================ */

/* Sections: their old control bar is replaced by the section toolbar */
.canvas-element[data-is-container="true"] > .element-controls {
    display: none !important;
}

/* "Section N" tab on the top-left edge of every layout container */
.section-tab {
    position: absolute;
    top: -11px;
    left: 12px;
    z-index: 6;
    padding: 1px 10px;
    border: 1px solid #b7cbd0;
    border-radius: 999px;
    background: #ffffff;
    color: #165c7d;
    font-size: 0.72rem;
    line-height: 1.5;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.canvas-element[data-is-container="true"]:hover > .section-tab,
.canvas-element.is-selected > .section-tab,
.section-tab:focus-visible {
    opacity: 1;
}
.canvas-element.is-selected > .section-tab,
.section-tab[aria-pressed="true"] {
    background: #165c7d;
    border-color: #165c7d;
    color: #ffffff;
}
.section-tab:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}

/* Section toolbar: inside the selected section, above its top edge */
.section-toolbar {
    position: absolute;
    top: -50px;
    left: 0;
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 6px;
    background: #ffffff;
    border: 1px solid #c6d6da;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}
.st-group {
    display: flex;
    align-items: center;
    gap: 2px;
}
.st-group + .st-group {
    padding-left: 6px;
    border-left: 1px solid #e2e8f0;
}
.st-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: #2d3b45;
    cursor: pointer;
}
.st-btn:hover { background: #f0f6f7; }
.st-btn[aria-pressed="true"] {
    border-color: #165c7d;
    background: #e6f2f4;
}
.st-btn:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 1px;
}
.st-thumb {
    width: 26px;
    height: 14px;
    gap: 2px;
}
.st-thumb > span { border-radius: 2px; }

body.preview-mode .section-tab,
body.preview-mode .section-toolbar {
    display: none !important;
}

/* Block toolbar: handle · Edit · Copy HTML · Delete · ⋯ (menu holds every other action) */
.element-controls[data-toolbar="v2"] {
    align-items: center;
    gap: 2px;
    padding: 3px;
}
.element-controls[data-toolbar="v2"] > .control-btn {
    width: 32px;
    height: 30px;
}
/* Delete on the bar (sections 3f): red on hover, so it is not hit by mistake */
.element-controls[data-toolbar="v2"] > .control-btn.ctl-delete:hover,
.element-controls[data-toolbar="v2"] > .control-btn.ctl-delete:focus-visible {
    color: #b42318;
}
.ctl-handle {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    color: #5c6878;
    cursor: grab;
}
.element-controls .ctl-label {
    display: none;
}
.ctl-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 60;
    flex-direction: column;
    min-width: 210px;
    padding: 4px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.ctl-menu.opens-up {
    top: auto;
    bottom: calc(100% + 4px);
}
.element-controls.is-open {
    display: flex !important;
}
.element-controls.is-open > .ctl-menu {
    display: flex;
}
/* [data-toolbar] outranks the compact in-column rule (.container-zone …) and
   the generic .control-btn tiles */
.element-controls[data-toolbar="v2"] .ctl-menu .control-btn {
    width: 100%;
    height: 32px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    background: none;
    color: #2d3b45;
    font-size: 0.82rem;
    text-align: left;
    white-space: nowrap;
}
.element-controls[data-toolbar="v2"] .ctl-menu .control-btn:hover,
.element-controls[data-toolbar="v2"] .ctl-menu .control-btn:focus-visible {
    background: #e6f2f4;
    color: #003D4C;
}
.element-controls[data-toolbar="v2"] .ctl-menu .control-btn i {
    width: 16px;
    text-align: center;
}
.element-controls .ctl-menu .ctl-label {
    display: inline;
}

/* Box variant button and menu (sections 3.1) */
.element-controls[data-toolbar="v2"] > .control-btn.ctl-variant {
    width: auto;
    gap: 6px;
    padding: 0 8px;
    flex-direction: row;
    font-size: 0.78rem;
    color: #2d3b45;
    white-space: nowrap;
}
.ctl-variant .fa-chevron-down {
    font-size: 0.65rem;
    color: #5c6878;
}
.ctl-variant-dot,
.variant-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.variant-menu {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    max-width: 260px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 4px;
    background: #ffffff;
    border: 1px solid #d4e3e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.variant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #2d3b45;
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}
.variant-item:hover,
.variant-item:focus-visible {
    background: #e6f2f4;
    color: #003D4C;
    outline: none;
}
.variant-item[aria-checked="true"] {
    background: #eef4f5;
}
.variant-item[aria-checked="true"]::after {
    content: "\2713";
    margin-left: auto;
    color: #007A82;
}
.variant-heading {
    padding: 8px 10px 4px;
    font-size: 0.72rem;
    color: #5c6878;
}
.variant-heading:first-child {
    padding-top: 4px;
}
.variant-swatches,
.variant-bgs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 6px 4px;
}
.variant-item.variant-swatch {
    width: 26px;
    height: 26px;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
}
.variant-swatch span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.variant-item.variant-swatch[aria-checked="true"] {
    border-color: #003D4C;
    background: none;
}
.variant-item.variant-swatch[aria-checked="true"]::after,
.variant-item.variant-bg[aria-checked="true"]::after {
    content: none;
}
.variant-item.variant-bg {
    height: 28px;
    padding: 0 10px;
    border: 1px solid #d4e3e6;
    border-radius: 999px;
    font-size: 0.78rem;
}
.variant-item.variant-bg[aria-checked="true"] {
    background: #003D4C;
    border-color: #003D4C;
    color: #ffffff;
}
.variant-reset {
    margin-top: 4px;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 6px 6px;
}
/* Activities (sections 3, activities): 17 types in two columns, so the menu
   stays short */
.variant-menu[data-family="activity"] { max-width: 340px; }
.variant-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 2px;
}
.variant-grid .variant-item { min-width: 0; }
.variant-grid .variant-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* An old box (sections 3.2e): "Update to the new design" first in the menu */
.variant-upgrade {
    margin-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
    color: #003D4C;
    font-weight: 600;
}

/* Box editor (sections 3.2, upload/boxEditor.js) */
/* Wide: form on the left, preview on the right (stays in view); narrow: stacked */
.box-editor .modal-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 24px; align-items: start; }
.be-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.be-side { grid-column: 2; grid-row: 1; position: sticky; top: 0; }
.be-label { display: block; margin-bottom: 6px; font-size: 0.82rem; font-weight: 600; color: #2d3b45; }
.be-preview { padding: 4px 16px; border: 1px dashed #d4e3e6; border-radius: 8px; background: #ffffff; max-height: 70vh; overflow-y: auto; }
@media (max-width: 820px) {
    .box-editor .modal-body { grid-template-columns: minmax(0, 1fr); }
    .be-side { grid-column: 1; position: static; }
    .be-preview { max-height: 260px; }
}
.be-inline { display: flex; flex-wrap: wrap; gap: 16px 28px; }
.be-types, .be-swatches, .be-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.be-chip, .be-seg button {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
    border: 1px solid #d4e3e6; border-radius: 999px; background: #ffffff; color: #2d3b45;
    font: inherit; font-size: 0.82rem; cursor: pointer;
}
.be-seg { display: inline-flex; gap: 4px; }
/* An editor's Font Awesome choice while Font Awesome is off in Settings */
.be-seg button[hidden] { display: none; }
.be-chip[aria-checked="true"], .be-seg button[aria-checked="true"], .be-chip[aria-pressed="true"] {
    background: #003D4C; border-color: #003D4C; color: #ffffff;
}
.be-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.be-swatch { width: 32px; height: 32px; padding: 3px; border-radius: 50%; border: 2px solid transparent; background: #ffffff; cursor: pointer; }
.be-swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.be-swatch[aria-checked="true"] { border-color: #003D4C; }
.be-icons { max-height: 132px; overflow-y: auto; padding: 2px; }
.be-icon {
    width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #d4e3e6; border-radius: 8px; background: #ffffff; color: #003D4C; font-size: 1.05rem; cursor: pointer;
}
.be-icon[aria-checked="true"] { border: 2px solid #003D4C; background: #e6f2f4; }
.be-letter { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: #5c6878; }
.be-icon-tabs { margin-bottom: 8px; flex-wrap: wrap; }
.be-icon-fa-other, .be-icon-letter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.be-icon-fa-other input { flex: 1 1 180px; height: 32px; }
.be-icon-fa-other a { font-size: 0.82rem; }
.be-icon-letter-row input { width: 64px; height: 32px; text-align: center; }
.be-icons[hidden], .be-icon-fa-other[hidden], .be-icon-letter-row[hidden], .be-fa-warning[hidden] { display: none; }
.be-legacy { margin: 0; padding: 10px 12px; border-radius: 6px; background: #eef6f7; border: 1px solid #c8e3e6; color: #003D4C; font-size: 0.85rem; line-height: 1.5; }
.be-legacy[hidden] { display: none; }
.be-fa-warning { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 6px; background: #fffbf5; border: 1px solid #fde8cd; color: #7c4a12; font-size: 0.82rem; line-height: 1.5; }
.be-fa-warning i { margin-top: 2px; color: #b45309; }
.be-icon-help:empty { display: none; }
.be-rt { display: flex; gap: 2px; padding: 4px; background: #e8eef0; border: 1px solid #d4e3e6; border-bottom: none; border-radius: 6px 6px 0 0; }
.be-rt button { width: 30px; height: 28px; border: none; background: transparent; color: #003D4C; border-radius: 4px; cursor: pointer; }
.be-rt button:hover { background: #ffffff; }
.be-rt .be-full-editor { width: auto; margin-left: auto; padding: 0 10px; font-size: 0.78rem; color: #003D4C; text-decoration: underline; }
.be-rt .be-full-editor[hidden] { display: none; }
.be-body hr { border: none; border-top: 1px solid #c3ced4; margin: 12px 0; }
.be-body { min-height: 110px; padding: 10px 12px; border: 1px solid #d4e3e6; border-radius: 0 0 6px 6px; background: #ffffff; line-height: 1.6; }
.be-body:focus { outline: 2px solid #00B0B9; outline-offset: 1px; }
.be-complex { margin-top: 8px; padding: 10px 12px; border-radius: 6px; background: #fffbf5; border: 1px solid #fde8cd; font-size: 0.85rem; color: #7c4a12; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.be-complex[hidden], .be-rt[hidden] { display: none; }
.box-editor [role="radio"]:focus-visible { outline: 2px solid #00B0B9; outline-offset: 2px; }
.be-advanced { border: 1px solid #d4e3e6; border-radius: 8px; padding: 0 12px; }
.be-advanced[open] { padding-bottom: 12px; }
.be-advanced > summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 0.85rem; color: #003D4C; }
.be-advanced .be-row { margin-top: 12px; }
.be-advanced .be-seg { flex-wrap: wrap; }
.be-contrast { margin: 0 0 4px; font-size: 0.82rem; color: #1b6e3c; }
.be-contrast.bad { color: #b42318; }
.be-custom, .be-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.be-custom input[type="color"] { width: 40px; height: 32px; padding: 0; border: 1px solid #d4e3e6; border-radius: 6px; background: #ffffff; }
.be-custom input[type="text"] { width: 110px; }
.be-link input { flex: 1 1 180px; }
.be-link-hint { display: block; margin-top: 6px; color: #1b6e3c; }
/* Table editor grid (sections 3e): one text field per cell */
.tx-grid-wrap { overflow-x: auto; }
.tx-grid { border-collapse: separate; border-spacing: 4px; margin-left: -4px; }
.tx-grid th, .tx-grid td { padding: 0; vertical-align: top; }
.tx-grid tbody th { font-weight: normal; color: #5c6878; font-size: 0.8rem; padding: 8px 4px 0 0; text-align: right; }
.tx-grid textarea { min-width: 120px; min-height: 0; resize: vertical; font-family: inherit; font-size: 0.85rem; line-height: 1.4; padding: 6px 8px; }
.tx-grid thead textarea, .tx-grid.tx-rubric tbody td:first-of-type textarea { font-weight: 600; background: #f3f8f9; }
.tx-grid .lp-icon-btn { margin-top: 4px; }
.tx-grid-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.be-link-hint.bad { color: #b42318; }
/* Activity editor (sections 3, activities): the box editor's layout */
.activity-editor .be-side .be-contrast { margin-top: 8px; }
.activity-editor .ae-custom { margin-top: 8px; }
.activity-editor .ae-duration { max-width: 220px; }
.activity-editor .ae-link-as { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.lp-link-as { flex: 0 0 auto; width: auto; }
/* Activities list: what a new activity gets (the last style and layout) */
.activity-defaults-hint { margin: 2px 4px 10px; font-size: 0.78rem; line-height: 1.4; color: #5c6878; }
/* Learning path builder (sections 3, activities) */
.learning-path-builder .be-side .be-contrast { margin-top: 8px; }
.lp-intro { margin: 0; }
.lp-icons-numbers { margin: 6px 0 0 0; }
.lp-icons-numbers[hidden] { display: none; }
.lp-icons-row .be-fa-warning { margin-top: 8px; }
.lp-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.lp-total { width: 100%; margin: 0; }
.lp-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lp-step { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid #d4e3e6; border-radius: 8px; background: #fbfcfd; }
.lp-step-head { display: flex; align-items: center; gap: 6px; }
.lp-step-title { flex: 1; font-size: 0.85rem; font-weight: 600; color: #003D4C; }
.lp-icon-btn { width: 32px; height: 32px; border: 1px solid #d4e3e6; border-radius: 6px; background: #ffffff; color: #2d3b45; cursor: pointer; }
.lp-icon-btn:hover:not(:disabled) { background: #e6f2f4; }
.lp-icon-btn:disabled { color: #a0aab4; cursor: default; }
.lp-icon-btn:focus-visible { outline: 2px solid #007A82; outline-offset: 1px; }
.lp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; }
/* The path builder's type, label and time (2026-11-04) */
.lp-grid.lp-grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 130px; }
/* The contact card editor: name and role, link and link text */
.lp-grid.kc-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.kc-photo-hint { display: block; margin-top: 6px; }
.kc-photo-hint.bad { color: #b42318; }
.lp-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: #2d3b45; }
.lp-field > span { font-weight: 600; }
.lp-field textarea { font: inherit; line-height: 1.5; resize: vertical; }
.lp-add { align-self: flex-start; }
/* Quote editor (sections 3, quotes) */
.quote-editor .be-side .be-contrast { margin-top: 8px; }
.qe-bubble[hidden] { display: none; }
.qe-lang-row select { max-width: 260px; }
.qe-lang-row input { max-width: 160px; }
.qe-source { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: none; }
.qe-source legend { padding: 0; }
.qe-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.be-swatches .be-colour-default { margin-right: 4px; }
.be-sides-row[hidden] { display: none; }
.be-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #2d3b45; cursor: pointer; }
.be-check input { width: 16px; height: 16px; }
.be-check input:disabled + span { color: #8a96a3; }
.be-title-line-help:empty { display: none; }

/* Section background choices in the section toolbar (2.5) */
.st-bg-swatch {
    display: block;
    width: 18px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #b7cbd0;
}
.st-bg-none {
    background: linear-gradient(135deg, transparent 45%, #b42318 46%, #b42318 54%, transparent 55%), #ffffff;
}
.st-bg-soft { background: rgba(0, 176, 185, 0.12); }
.st-bg-strong { background: #c9dbdd; border-color: #47737A; }

/* Category rail tip (paletteMixin.setupCategoryRailLabels, sections 2.8) */
.category-rail-tip {
    position: fixed;
    z-index: 10050;
    transform: translateY(-50%);
    padding: 4px 10px;
    border-radius: 6px;
    background: #003D4C;
    color: #ffffff;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
}
.category-rail-tip[hidden] { display: none; }

/* Palette items can be dragged onto the page (2.8) */
.element-item[draggable="true"] { cursor: grab; }
.element-item[draggable="true"]:active { cursor: grabbing; }

/* Ready-made sections in the chooser (2.9) */
.section-chooser-head-ready {
    margin-top: 14px;
}
.section-ready-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 96px;
    padding: 8px 6px;
    border: 1px solid #d4e3e6;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}
.section-ready-option:hover,
.section-ready-option:focus-visible {
    border-color: #165c7d;
    background: #f0f6f7;
}
.section-ready-option:focus-visible {
    outline: 2px solid #165c7d;
    outline-offset: 2px;
}
.section-ready-thumb {
    position: relative;
}
.section-ready-thumb > span:not(.section-ready-icon) {
    background: #c6d6da;
}
.section-ready-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #003D4C;
    font-size: 0.95rem;
    background: none !important;
}

/* Hero editor (sections, page types): fact and button rows of two fields
   and a remove button; the intro in the page's font */
.hero-editor textarea.form-control { font: inherit; line-height: 1.5; }
.hero-editor .hr-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: end; margin: 0 0 8px; }
.hero-editor .hr-row .hr-link-hint { grid-column: 1 / -1; margin-top: -4px; }
.hero-editor .hr-row .hr-remove { margin-bottom: 2px; }
.hero-editor .hr-row.hr-part { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.2fr) auto; }
.hero-editor .hr-part-current { margin-bottom: 8px; white-space: nowrap; }
.hero-editor .hr-link-hint.bad, .hero-editor .hr-image-hint.bad { color: #b42318; }
.hero-editor fieldset.be-row [data-hr-add] { margin-top: 4px; }

/* Ready-made sections grouped by page type (sections 3): tabs */
.section-ready-groups { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.section-ready-group { border: 1px solid #d4dde2; background: #fff; color: #1d2b33; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.82em; cursor: pointer; }
.section-ready-group[aria-pressed="true"] { background: #003D4C; border-color: #003D4C; color: #fff; }
.section-ready-group:focus-visible { outline: 2px solid #007A82; outline-offset: 2px; }
.section-ready-option[hidden] { display: none; }


/* Call to action and Resource editors (sections 3c) */
.cta-editor .be-side .be-contrast, .resource-editor .be-side .be-contrast { margin-top: 8px; }
.resource-editor .be-seg[data-group="type"] { flex-wrap: wrap; }
.resource-editor textarea.form-control { font: inherit; line-height: 1.5; }
.resource-editor .re-refs-body { min-height: 140px; }
.resource-editor .re-refs-body p { margin: 0 0 8px 0; padding-left: 2em; text-indent: -2em; }
.resource-editor .be-rt [data-re-sort] { width: auto; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.resource-editor .re-items .lp-step .lp-field + .lp-field { margin-top: 0; }
.resource-editor .be-link-hint.bad, .cta-editor .be-link-hint.bad { color: #b42318; }
.steps-editor .sx-image-more .be-check { margin-top: 8px; }

/* Code editor (sections 3f): the code in a fixed-width font, as shown */
.code-editor .ce-code {
    font-family: Menlo, Consolas, 'Courier New', monospace;
    font-size: 0.88em;
    line-height: 1.55;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
}
