/*
 * SimplyPages Framework CSS (Core Defaults)
 *
 * This file defines the baseline visual system for framework-generated HTML.
 * Most users should NOT fork this file. Instead, keep this as the stable base
 * and layer project-specific styles with `ShellBuilder.withCustomCss(...)`.
 *
 * Override strategy (recommended):
 * 1) Override `:root` tokens first (colors, spacing, type scale).
 * 2) Add app selectors in your own stylesheet for page/module-specific behavior.
 * 3) Use inline styles in Java only for one-off runtime values.
 *
 * Load order in ShellBuilder:
 * - /css/framework.css
 * - your custom CSS from withCustomCss(...)
 *
 * Matching Java concepts:
 * - ShellBuilder layout: `.main-container`, `.main-sidebar`, `.content-wrapper`
 * - Layout package: `.container`, `.row`, `.col-*`, `.grid-*`
 * - BannerBuilder: `.banner*` family
 * - ContentModule / Rich content wrappers: `.content-module`, `.module-content`
 * - Editing package: styles in "Editing System Styles" section
 */

/* ===== Theme Tokens =====
 * Beginner note:
 * CSS variables are read with var(--token-name). Change values here to retheme
 * large parts of the framework without rewriting component selectors.
 */
:root {
    /* Legacy color tokens (kept for compatibility) */
    --sp-color-bg: #ccd7ec;
    --sp-color-surface: #e3ebfb;
    --sp-color-text-primary: #17233f;
    --sp-color-text-secondary: #33486d;
    --sp-color-heading: #0f1b35;
    --sp-color-border: #90a6cf;
    --sp-color-border-soft: #adc0e0;
    --sp-color-primary: #3f63da;
    --sp-color-primary-hover: #2f54ca;
    --sp-color-secondary: #4f63a7;
    --sp-color-secondary-hover: #40508a;
    --sp-color-success: #16a34a;
    --sp-color-success-hover: #15803d;
    --sp-color-danger: #dc2626;
    --sp-color-danger-hover: #b91c1c;
    --sp-color-warning: #d97706;
    --sp-color-warning-hover: #b45309;
    --sp-color-info: #0284c7;
    --sp-color-info-hover: #0369a1;

    /* Palette primitives (preferred retheme surface) */
    --sp-palette-iris-700: #334bb1;
    --sp-palette-iris-600: #3f63da;
    --sp-palette-violet-600: #4f63a7;
    --sp-palette-violet-500: #5f74bc;
    --sp-palette-sky-300: #6fa6ff;
    --sp-palette-sky-100: #dbeafe;
    --sp-palette-slate-950: #10152a;
    --sp-palette-slate-800: #232c48;
    --sp-palette-slate-700: #333f60;
    --sp-palette-slate-600: #4c5a7e;
    --sp-palette-slate-500: #68789f;
    --sp-palette-slate-400: #94a3c5;
    --sp-palette-slate-300: #b6c3dd;
    --sp-palette-slate-200: #ced9ec;
    --sp-palette-slate-100: #e3ebf8;
    --sp-palette-slate-50: #eff4fd;
    --sp-palette-white: #ffffff;

    /* Semantic theme tokens (preferred customization surface) */
    --sp-theme-bg-canvas: var(--sp-color-bg);
    --sp-theme-surface-base: var(--sp-color-surface);
    --sp-theme-surface-raised: #f4f7fe;
    --sp-theme-surface-muted: #dfe8f7;
    --sp-theme-surface-alt: #ccd9ef;
    --sp-theme-surface-contrast: #101b36;
    --sp-theme-surface-overlay: rgba(15, 23, 42, 0.76);

    --sp-theme-text-strong: var(--sp-color-heading);
    --sp-theme-text-default: var(--sp-color-text-primary);
    --sp-theme-text-muted: var(--sp-color-text-secondary);
    --sp-theme-text-subtle: #4f638c;
    --sp-theme-text-soft: #6c82ac;
    --sp-theme-text-inverse: #f8fafc;

    --sp-theme-border-default: var(--sp-color-border);
    --sp-theme-border-soft: var(--sp-color-border-soft);
    --sp-theme-border-strong: #869cc6;
    --sp-theme-border-emphasis: #6f87b7;
    --sp-theme-border-accent: #7f98ea;
    --sp-theme-border-focus: #8ea8ff;

    --sp-theme-accent: var(--sp-color-primary);
    --sp-theme-accent-hover: var(--sp-color-primary-hover);
    --sp-theme-accent-strong: #233f9f;
    --sp-theme-accent-soft: #d9e4ff;
    --sp-theme-accent-soft-strong: #c4d4ff;

    --sp-theme-success: var(--sp-color-success);
    --sp-theme-success-hover: var(--sp-color-success-hover);
    --sp-theme-success-soft: #dcfce7;
    --sp-theme-success-ink: #14532d;

    --sp-theme-warning: var(--sp-color-warning);
    --sp-theme-warning-hover: var(--sp-color-warning-hover);
    --sp-theme-warning-soft: #ffedd5;
    --sp-theme-warning-ink: #9a3412;

    --sp-theme-danger: var(--sp-color-danger);
    --sp-theme-danger-hover: var(--sp-color-danger-hover);
    --sp-theme-danger-soft: #fee2e2;
    --sp-theme-danger-ink: #991b1b;

    --sp-theme-info: var(--sp-color-info);
    --sp-theme-info-hover: var(--sp-color-info-hover);
    --sp-theme-info-soft: #dbeafe;
    --sp-theme-info-soft-strong: #bfdbfe;
    --sp-theme-info-ink: #0c4a6e;

    --sp-theme-code-bg: #1f2b3d;
    --sp-theme-code-header: #172235;
    --sp-theme-code-border: #3b4f68;
    --sp-theme-code-text: #f8f8f2;
    --sp-theme-code-muted: #94a3b8;
    --sp-theme-overlay-backdrop: rgba(15, 23, 42, 0.52);

    /* Gradient tokens */
    --sp-gradient-surface-panel: linear-gradient(180deg, #eff4fe 0%, #e2eafb 100%);
    --sp-gradient-surface-panel-muted: linear-gradient(180deg, #e7effd 0%, #d9e4f8 100%);
    --sp-gradient-surface-card: linear-gradient(165deg, #f6f9ff 0%, #e5eefc 100%);
    --sp-gradient-accent-pill: linear-gradient(180deg, #dce7ff 0%, #c7d8fb 100%);
    --sp-gradient-info-pill: linear-gradient(180deg, #d9eeff 0%, #c3defd 100%);
    --sp-gradient-shell-bg: radial-gradient(circle at 9% 4%, rgba(67, 98, 196, 0.22) 0%, rgba(67, 98, 196, 0) 44%),
                            radial-gradient(circle at 92% 8%, rgba(31, 124, 199, 0.16) 0%, rgba(31, 124, 199, 0) 46%),
                            linear-gradient(165deg, #d4def0 0%, #c6d3ea 52%, #bccbe5 100%);
    --sp-gradient-nav-shell: linear-gradient(120deg, rgba(222, 230, 247, 0.96) 0%, rgba(204, 217, 241, 0.94) 56%, rgba(191, 207, 236, 0.92) 100%);
    --sp-gradient-nav-shell-muted: linear-gradient(120deg, rgba(213, 223, 244, 0.96) 0%, rgba(196, 210, 238, 0.94) 58%, rgba(182, 199, 232, 0.92) 100%);
    --sp-gradient-top-nav: var(--sp-gradient-nav-shell);
    --sp-gradient-side-nav: linear-gradient(180deg, #d5e0f3 0%, #c5d4ec 58%, #b7c9e6 100%);
    --sp-gradient-banner: linear-gradient(136deg, #2f57d4 0%, #2f4dbf 46%, #3553b4 100%);

    /* Header/nav/banner component tokens */
    --sp-banner-border-color: rgba(43, 71, 170, 0.72);
    --sp-banner-shadow: 0 16px 32px rgba(20, 39, 92, 0.32);
    --sp-banner-pattern-primary: radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.18) 0%, transparent 52%);
    --sp-banner-pattern-secondary: radial-gradient(circle at 84% 10%, rgba(132, 181, 255, 0.26) 0%, transparent 50%);
    --sp-banner-sheen-pattern: linear-gradient(
        120deg,
        transparent 0%,
        transparent 48%,
        rgba(255, 255, 255, 0.08) 50%,
        transparent 52%,
        transparent 100%
    );
    --sp-banner-title-color: var(--sp-theme-text-inverse);
    --sp-banner-subtitle-color: rgba(248, 250, 252, 0.9);
    --sp-banner-padding-y: var(--sp-space-md);
    --sp-banner-padding-x: var(--sp-space-lg);
    --sp-banner-bottom-clearance: 48px;
    --sp-top-nav-overlap: 38px;
    --sp-top-nav-max-width: 1680px;
    --sp-top-nav-width: 92%;
    --sp-top-nav-max-span: 96%;
    --sp-top-nav-padding-y: 5px;
    --sp-top-nav-padding-x: 8px;
    --sp-top-nav-item-padding-y: 4px;
    --sp-top-nav-item-padding-x: 9px;
    --sp-radius-surface-xl: 14px;
    --sp-radius-surface-lg: 12px;
    --sp-radius-surface-md: 10px;
    --sp-radius-surface-sm: 8px;
    --sp-radius-hero: 14px;
    --sp-top-nav-item-radius: var(--sp-radius-surface-sm);
    --sp-top-nav-bg: linear-gradient(120deg, rgba(34, 67, 165, 0.58) 0%, rgba(40, 79, 174, 0.54) 58%, rgba(36, 90, 166, 0.5) 100%);
    --sp-top-nav-border-color: rgba(199, 219, 255, 0.5);
    --sp-top-nav-shadow: 0 5px 12px rgba(18, 34, 72, 0.22);
    --sp-top-nav-item-text: #edf2ff;
    --sp-top-nav-item-hover-bg: rgba(234, 242, 255, 0.2);
    --sp-top-nav-item-active-bg: rgba(230, 239, 255, 0.3);
    --sp-top-nav-item-active-text: #ffffff;
    --sp-top-nav-item-border: rgba(214, 229, 255, 0.38);
    --sp-top-nav-blur: blur(10px);

    /* Side navigation tokens */
    --sp-side-nav-item-text: var(--sp-palette-slate-800);
    --sp-side-nav-section-text: var(--sp-palette-slate-600);
    --sp-side-nav-item-hover-bg: rgba(137, 160, 214, 0.3);
    --sp-side-nav-item-active-bg: transparent;

    /* Form + button tokens */
    --sp-form-control-bg: linear-gradient(180deg, rgba(244, 248, 255, 0.94) 0%, rgba(233, 240, 252, 0.92) 100%);
    --sp-form-control-bg-focus: linear-gradient(180deg, rgba(248, 251, 255, 0.98) 0%, rgba(238, 245, 255, 0.96) 100%);
    --sp-form-control-placeholder: #50638d;
    --sp-form-control-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54);
    --sp-button-primary-bg: linear-gradient(180deg, #476be2 0%, #3157d1 100%);
    --sp-button-primary-bg-hover: linear-gradient(180deg, #3d62da 0%, #284ec4 100%);
    --sp-button-secondary-bg: linear-gradient(180deg, #5b72ba 0%, #4a5ea3 100%);
    --sp-button-secondary-bg-hover: linear-gradient(180deg, #546ab2 0%, #425394 100%);

    /* Home landing accents */
    --sp-home-shell-bg: linear-gradient(150deg, rgba(220, 229, 247, 0.92) 0%, rgba(205, 218, 241, 0.9) 52%, rgba(192, 206, 234, 0.88) 100%);
    --sp-home-card-bg: linear-gradient(160deg, rgba(241, 247, 255, 0.97) 0%, rgba(221, 233, 252, 0.94) 100%);
    --sp-home-card-bg-hover: linear-gradient(160deg, rgba(247, 251, 255, 0.98) 0%, rgba(229, 239, 255, 0.96) 100%);
    --sp-home-shell-border: rgba(109, 132, 184, 0.58);
    --sp-home-card-border: rgba(95, 123, 182, 0.56);

    /* Hero module tokens */
    --sp-gradient-hero: linear-gradient(136deg, #2852c7 0%, #2f53bf 44%, #2e5fa8 100%);
    --sp-hero-text-color: var(--sp-theme-text-inverse);
    --sp-hero-subtitle-color: rgba(255, 255, 255, 0.95);
    --sp-hero-description-color: rgba(255, 255, 255, 0.9);
    --sp-hero-button-primary-bg: linear-gradient(160deg, #3f63da 0%, #3152c4 52%, #2f5aa8 100%);
    --sp-hero-button-primary-text: #eef3ff;
    --sp-hero-button-primary-hover-bg: linear-gradient(160deg, #4a6fe6 0%, #3a5fcd 52%, #3567b4 100%);
    --sp-hero-button-secondary-border: rgba(216, 227, 255, 0.9);
    --sp-hero-button-secondary-hover-bg: rgba(96, 145, 255, 0.24);

    /* Typography */
    --sp-font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --sp-font-size-base: 1rem;
    --sp-line-height-base: 1.6;
    --sp-line-height-heading: 1.2;
    --sp-heading-weight: 600;
    --sp-h1-size: 2.5rem;
    --sp-h2-size: 2rem;
    --sp-h3-size: 1.75rem;
    --sp-h4-size: 1.5rem;
    --sp-h5-size: 1.25rem;
    --sp-h6-size: 1rem;

    /* Spacing scale */
    --sp-space-1: 0.25rem;
    --sp-space-2: 0.5rem;
    --sp-space-3: 0.75rem;
    --sp-space-4: 1rem;
    --sp-space-5: 1.25rem;
    --sp-space-6: 1.5rem;
    --sp-space-7: 1.875rem;
    --sp-space-8: 2rem;
    --sp-space-xs: 10px;
    --sp-space-sm: 15px;
    --sp-space-md: 20px;
    --sp-space-lg: 30px;

    /* Radius and shadow */
    --sp-radius-sm: 3px;
    --sp-radius-md: 4px;
    --sp-radius-lg: 8px;
    --sp-shadow-sm: 0 2px 8px rgba(25, 39, 68, 0.12);
    --sp-shadow-md: 0 8px 22px rgba(25, 39, 68, 0.16);
    --sp-shadow-lg: 0 16px 34px rgba(20, 33, 58, 0.22);
    --sp-shadow-focus: 0 0 0 3px rgba(63, 99, 218, 0.2);
    --sp-shadow-overlay: 0 20px 40px rgba(24, 40, 62, 0.24);

    /* Layout and motion */
    --sp-sidebar-width: 250px;
    --sp-sidebar-collapsed-width: 60px;
    --sp-content-max-width: 1400px;
    --sp-transition-fast: 0.2s;
    --sp-transition-base: 0.3s;
    --sp-ease-standard: ease;
}

/* ===== Reset & Base Styles ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sp-font-family-base);
    font-size: var(--sp-font-size-base);
    margin: 0;
    background: var(--sp-gradient-shell-bg);
    color: var(--sp-color-text-primary);
    line-height: var(--sp-line-height-base);
}

/* ===== Layout System ===== */
.main-container {
    display: grid;
    grid-template-areas: "content";
    grid-template-columns: 1fr;
    min-height: calc(100vh - 60px);
}

.main-container.has-sidebar {
    grid-template-areas: "sidebar content";
    grid-template-columns: var(--sp-sidebar-width) 1fr;
}

.main-header {
    background: transparent;
    padding: 0;
    margin: var(--sp-space-4) var(--sp-space-4) 0;
    border-bottom: none;
    box-shadow: none;
    backdrop-filter: none;
}

.main-header.has-top-nav {
    margin-bottom: 0;
}

.header-top-nav-wrap {
    width: min(var(--sp-top-nav-width), var(--sp-top-nav-max-span));
    width: fit-content;
    min-width: min(var(--sp-top-nav-width), var(--sp-top-nav-max-span));
    max-width: min(var(--sp-top-nav-max-span), var(--sp-top-nav-max-width));
    margin: calc(-1 * var(--sp-top-nav-overlap)) auto 0;
    padding-inline: 0;
    position: relative;
    z-index: 6;
}

.main-header:not(.has-top-banner) .header-top-nav-wrap {
    margin-top: 0;
}

.main-sidebar {
    grid-area: sidebar;
    background: var(--sp-gradient-side-nav);
    margin: 0;
    padding: calc(var(--sp-space-md) + 8px) 0 var(--sp-space-md);
    overflow-y: auto;
    border: 1px solid var(--sp-theme-border-emphasis);
    border-radius: var(--sp-radius-surface-lg);
    box-shadow: 0 8px 18px rgba(39, 59, 96, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.content-wrapper {
    grid-area: content;
    padding: 0;
    overflow-y: auto;
}

.main-container {
    padding: var(--sp-space-4) var(--sp-space-4) var(--sp-space-4);
    gap: var(--sp-space-4);
    margin-top: 0;
}

#content-area {
    background: var(--sp-gradient-surface-card);
    padding: var(--sp-space-lg);
    border-radius: var(--sp-radius-surface-lg);
    border: 1px solid var(--sp-theme-border-emphasis);
    box-shadow: 0 12px 24px rgba(28, 45, 76, 0.14);
    min-height: 400px;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--sp-space-sm);
}

.container-sm { max-width: 720px; }
.container-md { max-width: 960px; }
.container-lg { max-width: 1140px; }
.container-xl { max-width: 1320px; }
.container-fluid { max-width: 100%; }

/* ===== Grid System ===== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--sp-space-2));
    margin-bottom: var(--sp-space-xs);
}

.col {
    flex: 1;
    min-width: 0;
    padding: 0 var(--sp-space-2);
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-fill { flex: 1 1 0; }

/* Grid Layout */
.grid {
    display: grid;
    gap: var(--sp-space-md);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Gap utilities */
.gap-sm { gap: var(--sp-space-xs); }
.gap-medium { gap: var(--sp-space-md); }
.gap-lg { gap: var(--sp-space-lg); }

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--sp-color-heading);
    font-weight: var(--sp-heading-weight);
    margin-top: var(--sp-space-2);
    margin-bottom: var(--sp-space-3);
    line-height: var(--sp-line-height-heading);
}

h1 { font-size: var(--sp-h1-size); }
h2 { font-size: var(--sp-h2-size); }
h3 { font-size: var(--sp-h3-size); }
h4 { font-size: var(--sp-h4-size); }
h5 { font-size: var(--sp-h5-size); }
h6 { font-size: var(--sp-h6-size); }

p { margin-bottom: 1rem; }

#content-area > .page-content > h1:first-child {
    margin-top: var(--sp-space-4);
}

/* ===== Forms ===== */
.form {
    width: 100%;
}

.form-field {
    margin-bottom: var(--sp-space-md);
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--sp-color-text-secondary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--sp-space-xs) var(--sp-space-sm);
    border: 1px solid var(--sp-theme-border-strong);
    border-radius: var(--sp-radius-md);
    font-size: 1rem;
    color: var(--sp-theme-text-default);
    background: var(--sp-form-control-bg);
    box-shadow: var(--sp-form-control-shadow);
    transition: border-color var(--sp-transition-fast), box-shadow var(--sp-transition-fast);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--sp-form-control-placeholder);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--sp-color-primary);
    background: var(--sp-form-control-bg-focus);
    box-shadow: var(--sp-shadow-focus);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Checkbox & Radio */
.form-checkbox,
.form-radio-group {
    margin-bottom: 15px;
}

.checkbox-input,
.radio-input {
    margin-right: 8px;
}

.checkbox-label,
.radio-label {
    cursor: pointer;
    user-select: none;
}

.radio-option {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.radio-inline .radio-option {
    display: inline-flex;
    margin-right: 20px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: var(--sp-space-xs) var(--sp-space-md);
    border: none;
    border-radius: var(--sp-radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--sp-transition-fast);
    text-decoration: none;
    text-align: center;
}

.btn:where([hidden]:not([hidden="until-found" i])) {
    display: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--sp-shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--sp-button-primary-bg);
    color: white;
    border: 1px solid rgba(72, 80, 186, 0.44);
}

.btn-primary:hover { background: var(--sp-button-primary-bg-hover); }

.btn-secondary {
    background: var(--sp-button-secondary-bg);
    color: white;
    border: 1px solid rgba(83, 68, 164, 0.42);
}

.btn-secondary:hover { background: var(--sp-button-secondary-bg-hover); }

.btn-success { background-color: var(--sp-color-success); color: white; }
.btn-success:hover { background-color: var(--sp-color-success-hover); }

.btn-danger { background-color: var(--sp-color-danger); color: white; }
.btn-danger:hover { background-color: var(--sp-color-danger-hover); }

.btn-warning { background-color: var(--sp-color-warning); color: white; }
.btn-warning:hover { background-color: var(--sp-color-warning-hover); }

.btn-info { background-color: var(--sp-color-info); color: white; }
.btn-info:hover { background-color: var(--sp-color-info-hover); }

.btn-link { background: none; color: var(--sp-color-primary); text-decoration: underline; }

.btn-sm { padding: 6px 12px; font-size: 0.875rem; }
.btn-lg { padding: 14px 28px; font-size: 1.125rem; }
.btn-full-width { width: 100%; }

/* ===== Tables ===== */
/* Tables are used by:
 * - `.table` utility class in hand-authored markup
 * - markdown-rendered `<table>` inside ContentModule/Rich content wrappers
 * We style both through a shared selector set so markdown tables inherit the
 * same baseline visuals as explicit `.table` usage.
 */
:is(.table, .content-module table, .module-content table) {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--sp-space-md);
}

:is(.table, .content-module table, .module-content table) th,
:is(.table, .content-module table, .module-content table) td {
    padding: 12px var(--sp-space-sm);
    text-align: left;
}

/* Markdown tables were historically always bordered.
 * Keep that behavior for render compatibility while `.table` stays lighter.
 */
:is(.content-module table, .module-content table) th,
:is(.content-module table, .module-content table) td {
    border: 1px solid var(--sp-color-border);
}

:is(.table, .content-module table, .module-content table) thead th {
    background: var(--sp-gradient-surface-panel-muted);
    font-weight: 600;
    color: var(--sp-theme-text-default);
    border-bottom: 2px solid var(--sp-color-border);
}

:is(.table, .content-module table, .module-content table) tbody tr {
    border-bottom: 1px solid var(--sp-color-border);
}

.table-striped tbody tr:nth-child(odd) {
    background-color: var(--sp-theme-surface-raised);
}

.table-bordered {
    border: 1px solid var(--sp-color-border);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--sp-color-border);
}

.table-hover tbody tr:hover {
    background-color: var(--sp-theme-surface-muted);
}

/* Keep historical markdown striping parity (even rows). */
:is(.content-module table, .module-content table) tbody tr:nth-child(even) {
    background-color: var(--sp-theme-surface-raised);
}

/* ===== Markdown Content Styling ===== */
/* This section applies only inside framework rich text wrappers.
 * Most rules are scoped so generic page typography is not unexpectedly changed.
 */
:is(.content-module, .module-content) {
    --sp-markdown-link: var(--sp-theme-accent-hover);
    --sp-markdown-link-hover: var(--sp-theme-accent-strong);
}

/* Blockquotes */
:is(.content-module, .module-content) blockquote {
    margin: 1.5em 0;
    padding: 0.75em 1.25em;
    border-left: 4px solid var(--sp-color-primary);
    background-color: var(--sp-theme-accent-soft);
    color: var(--sp-theme-accent-strong);
    font-style: italic;
}

:is(.content-module, .module-content) blockquote p {
    margin: 0.5em 0;
}

:is(.content-module, .module-content) blockquote p:first-child {
    margin-top: 0;
}

:is(.content-module, .module-content) blockquote p:last-child {
    margin-bottom: 0;
}

/* Headings in markdown content */
:is(.content-module, .module-content) h1 {
    font-size: 2em;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: var(--sp-theme-text-strong);
    border-bottom: 2px solid var(--sp-color-border);
    padding-bottom: 0.3em;
}

:is(.content-module, .module-content) h1:first-child {
    margin-top: 0;
}

:is(.content-module, .module-content) h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: var(--sp-theme-text-default);
    border-bottom: 1px solid var(--sp-color-border);
    padding-bottom: 0.3em;
}

:is(.content-module, .module-content) h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 1.25em;
    margin-bottom: 0.5em;
    color: var(--sp-theme-text-default);
}

:is(.content-module, .module-content) h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--sp-theme-text-muted);
}

:is(.content-module, .module-content) h5 {
    font-size: 1em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--sp-theme-text-muted);
}

:is(.content-module, .module-content) h6 {
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--sp-theme-text-subtle);
}

/* Paragraphs */
:is(.content-module, .module-content) p {
    margin: 1em 0;
    line-height: 1.7;
}

/* Lists */
:is(.content-module, .module-content) ul {
    margin: 1em 0;
    padding-left: 2em;
    list-style-type: disc;
}

:is(.content-module, .module-content) ol {
    margin: 1em 0;
    padding-left: 2em;
    list-style-type: decimal;
}

:is(.content-module, .module-content) li {
    margin: 0.5em 0;
    line-height: 1.6;
}

/* Nested lists */
:is(.content-module, .module-content) :is(ul ul, ol ol, ul ol, ol ul) {
    margin: 0.25em 0;
}

:is(.content-module, .module-content) ul ul {
    list-style-type: circle;
}

:is(.content-module, .module-content) ul ul ul {
    list-style-type: square;
}

/* Horizontal rules */
:is(.content-module, .module-content) hr {
    margin: 2em 0;
    border: none;
    border-top: 2px solid var(--sp-color-border);
}

/* Links */
:is(.content-module, .module-content) a {
    color: var(--sp-markdown-link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

:is(.content-module, .module-content) a:hover {
    color: var(--sp-markdown-link-hover);
    border-bottom-color: var(--sp-markdown-link-hover);
}

/* Images */
:is(.content-module, .module-content) img {
    max-width: 100%;
    height: auto;
    margin: 1em 0;
    border-radius: 4px;
}

/* Strong and emphasis */
:is(.content-module, .module-content) strong {
    font-weight: 600;
    color: var(--sp-theme-text-default);
}

:is(.content-module, .module-content) em {
    font-style: italic;
}

/* Inline code */
:is(.content-module, .module-content) code {
    background-color: var(--sp-theme-surface-raised);
    color: var(--sp-theme-danger);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

/* Code blocks override inline code styling */
:is(.content-module, .module-content) pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* Pre-formatted text / code blocks */
:is(.content-module, .module-content) pre {
    background-color: var(--sp-theme-text-default);
    color: var(--sp-theme-border-default);
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5em 0;
    line-height: 1.5;
}

/* Definition lists */
:is(.content-module, .module-content) dl {
    margin: 1em 0;
}

:is(.content-module, .module-content) dt {
    font-weight: 600;
    margin-top: 1em;
}

:is(.content-module, .module-content) dd {
    margin-left: 2em;
    margin-bottom: 0.5em;
}

/* ===== Code Blocks ===== */
code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    background-color: var(--sp-theme-surface-raised);
    color: var(--sp-theme-danger);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--sp-theme-border-default);
}

pre {
    background-color: var(--sp-theme-text-default);
    color: var(--sp-theme-border-default);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--sp-theme-text-muted);
    line-height: 1.5;
}

pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border: none;
    font-size: 0.875rem;
}

/* Scrollbar styling for code blocks */
pre::-webkit-scrollbar {
    height: 8px;
}

pre::-webkit-scrollbar-track {
    background: var(--sp-theme-surface-contrast);
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
    background: var(--sp-theme-text-muted);
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
    background: var(--sp-theme-text-subtle);
}

/* ===== Cards ===== */
.card {
    background: var(--sp-gradient-surface-card);
    border: 1px solid var(--sp-theme-border-emphasis);
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(31, 49, 84, 0.12);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    background: var(--sp-gradient-surface-panel-muted);
    border-bottom: 1px solid var(--sp-theme-border-emphasis);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    background: var(--sp-gradient-surface-panel-muted);
    border-top: 1px solid var(--sp-theme-border-emphasis);
}

.card-img-top {
    width: 100%;
    height: auto;
}

.card-grid {
    display: grid;
    gap: 20px;
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 14px;
    border: 1px solid transparent;
    border-left: 6px solid;
    box-shadow: 0 4px 10px rgba(25, 38, 64, 0.08);
    font-weight: 600;
}

.alert-info {
    background: linear-gradient(180deg, #e0f2fe 0%, #c9e8ff 100%);
    border-color: var(--sp-theme-info);
    color: var(--sp-theme-info-ink);
}

.alert-success {
    background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
    border-color: var(--sp-theme-success);
    color: var(--sp-theme-success-ink);
}

.alert-warning {
    background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
    border-color: var(--sp-theme-warning);
    color: var(--sp-theme-warning-ink);
}

.alert-danger {
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
    border-color: var(--sp-theme-danger);
    color: #7f1d1d;
}

.alert[hidden] {
    display: none !important;
}

.alert-dismissible {
    position: relative;
    min-height: 54px;
    padding-right: 64px;
    overflow-wrap: anywhere;
}

.alert-dismissible > .alert-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: #fff;
    color: inherit;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.alert-dismissible > .alert-close:hover {
    background: #f1f5f9;
}

.alert-dismissible > .alert-close:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

/* ===== Badges & Tags ===== */
.badge {
    display: inline-block;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 1px 4px rgba(25, 40, 72, 0.18);
}

.badge-primary { background: linear-gradient(180deg, var(--sp-theme-accent), var(--sp-theme-accent-hover)); color: white; }
.badge-secondary { background: linear-gradient(180deg, var(--sp-theme-text-subtle), var(--sp-theme-text-muted)); color: white; }
.badge-success { background: linear-gradient(180deg, var(--sp-theme-success), var(--sp-theme-success-hover)); color: white; }
.badge-danger { background: linear-gradient(180deg, var(--sp-theme-danger), var(--sp-theme-danger-hover)); color: white; }
.badge-warning { background: linear-gradient(180deg, var(--sp-theme-warning), var(--sp-theme-warning-hover)); color: white; }
.badge-info { background: linear-gradient(180deg, var(--sp-theme-info), var(--sp-theme-info-hover)); color: white; }
.badge-pill { border-radius: 50px; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin: 2px 4px 2px 0;
    background: linear-gradient(180deg, #eef3fc 0%, #dfe8f8 100%);
    color: var(--sp-theme-text-default);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.tag-primary {
    background: linear-gradient(180deg, #dbe6ff 0%, #c6d7ff 100%);
    border-color: var(--sp-theme-border-accent);
    color: var(--sp-theme-accent-strong);
}

.tag-secondary {
    background: linear-gradient(180deg, #e6edf9 0%, #d5dfef 100%);
    border-color: var(--sp-theme-border-default);
    color: var(--sp-theme-text-default);
}

.tag-success {
    background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
    border-color: #4ade80;
    color: #14532d;
}

.tag-info {
    background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
    border-color: #38bdf8;
    color: #0c4a6e;
}

.tag-warning {
    background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    color: #7c2d12;
}

.tag-danger {
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    color: #7f1d1d;
}

.tag-removable {
    padding-right: 14px;
}

.label {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--sp-theme-text-default);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.label-required::after {
    content: " *";
    color: var(--sp-theme-danger);
    font-weight: 700;
}

/* ===== Navigation ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: var(--sp-top-nav-padding-y) var(--sp-top-nav-padding-x);
    border: 1px solid var(--sp-top-nav-border-color);
    border-radius: var(--sp-radius-surface-lg);
    background: var(--sp-gradient-top-nav);
    box-shadow: var(--sp-shadow-sm);
}

.navbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--sp-theme-accent-strong);
    letter-spacing: -0.02em;
}

.navbar-items {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.navbar-utility {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-left: auto;
    flex-wrap: wrap;
}

.navbar-item {
    padding: var(--sp-top-nav-item-padding-y) var(--sp-top-nav-item-padding-x);
    color: var(--sp-top-nav-item-text);
    text-decoration: none;
    border-radius: var(--sp-top-nav-item-radius);
    border: 1px solid transparent;
    background: transparent;
    font-weight: 650;
    letter-spacing: 0.01em;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
    white-space: nowrap;
}

.navbar-item:hover {
    background: var(--sp-top-nav-item-hover-bg);
    border-color: var(--sp-top-nav-item-border);
    color: var(--sp-top-nav-item-active-text);
}

.navbar-item.active {
    background: var(--sp-top-nav-item-active-bg);
    border-color: var(--sp-top-nav-item-border);
    color: var(--sp-top-nav-item-active-text);
    box-shadow: inset 0 -2px 0 rgba(83, 102, 168, 0.18);
}

.navbar-horizontal {
    flex-direction: row;
}

.navbar-vertical {
    flex-direction: column;
    align-items: stretch;
}

.navbar-vertical .navbar-items {
    flex-direction: column;
}

.top-nav {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--sp-top-nav-border-color);
    background: var(--sp-top-nav-bg);
    box-shadow: var(--sp-top-nav-shadow);
    backdrop-filter: var(--sp-top-nav-blur);
    -webkit-backdrop-filter: var(--sp-top-nav-blur);
    flex-wrap: wrap;
    row-gap: 6px;
}

.top-nav .navbar-items {
    flex: 1 1 auto;
}

.top-nav .navbar-utility {
    flex: 0 1 auto;
    min-width: max-content;
}

.top-nav .account-widget,
.top-nav .account-widget-guest {
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-nav .account-widget-link {
    white-space: nowrap;
}

.navbar-dropdown .dropdown-trigger {
    border: 1px solid transparent;
    border-radius: var(--sp-top-nav-item-radius);
    color: var(--sp-top-nav-item-text);
    font-weight: 600;
    padding: var(--sp-top-nav-item-padding-y) var(--sp-top-nav-item-padding-x);
}

.navbar-dropdown .dropdown-trigger:hover {
    background: var(--sp-top-nav-item-hover-bg);
    border-color: var(--sp-top-nav-item-border);
}

.navbar-dropdown .dropdown-menu {
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-top-nav-item-border);
    border-radius: var(--sp-radius-surface-md);
    box-shadow: var(--sp-shadow-md);
}

/* Side Navigation */
.sidenav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 10px;
}

.sidenav-item {
    padding: 10px 12px;
    color: var(--sp-side-nav-item-text);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--sp-radius-surface-md);
    border: 1px solid transparent;
    background: transparent;
}

.sidenav-item:hover {
    background: var(--sp-side-nav-item-hover-bg);
    border-color: var(--sp-top-nav-item-border);
    color: var(--sp-theme-text-strong);
}

.sidenav-item.active {
    background: transparent;
    border-color: transparent;
    color: var(--sp-side-nav-item-text);
    box-shadow: none;
}

.sidenav-section {
    padding: 12px 12px 4px;
    color: var(--sp-side-nav-section-text);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 6px;
}

.sidenav-icon {
    font-size: 1.25rem;
}

/* Breadcrumb */
.breadcrumb {
    padding: 10px 0;
    margin-bottom: 20px;
}

.breadcrumb-list {
    display: flex;
    list-style: none;
    gap: 5px;
    padding-left: 0 !important; /* Override module content padding */
}

/* Override module content list styling for breadcrumbs */
.content-module .breadcrumb-list,
.module-content .breadcrumb-list {
    list-style: none !important;
    list-style-type: none !important;
    padding-left: 0;
    margin: 0;
}

.breadcrumb-item {
    color: var(--sp-theme-text-subtle);
}

.breadcrumb-item::after {
    content: "/";
    margin-left: 10px;
    color: var(--sp-theme-border-strong);
}

.breadcrumb-item:last-child::after {
    content: "";
}

.breadcrumb-item.active {
    color: var(--sp-theme-text-default);
    font-weight: 500;
}

.breadcrumb-item a {
    color: var(--sp-theme-accent);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* ===== Modules ===== */
.module {
    margin-bottom: 12px;
}

/* Prevent nested module wrappers from creating doubled vertical gaps. */
.module > .module {
    margin-bottom: 0;
}

/* Apply module surface treatment only to plain module types.
   Structured/specialized modules keep their own dedicated styling. */
:is(
    .content-module,
    .form-module,
    .data-module,
    .gallery-module,
    .simple-list-module,
    .card-module,
    .list-module,
    .table-module,
    .rich-content-module
) {
    padding: var(--sp-space-sm) var(--sp-space-md);
    border: 1px solid var(--sp-theme-border-emphasis);
    border-radius: var(--sp-radius-surface-lg);
    background: linear-gradient(180deg, rgba(248, 252, 255, 0.95) 0%, rgba(236, 245, 255, 0.92) 100%);
    box-shadow: 0 6px 14px rgba(30, 49, 82, 0.09);
}

.module-title {
    margin-bottom: 12px;
    padding-bottom: 10px;
    padding-right: 70px; /* Space for edit/delete buttons */
    border-bottom: 1px solid var(--sp-theme-border-emphasis);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.module-content {
    padding: 10px 0 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.module-description {
    color: var(--sp-theme-text-muted);
    margin-bottom: 12px;
}

/* ===== Gallery ===== */
.gallery {
    display: grid;
    gap: 15px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-item:hover .gallery-img {
    transform: scale(1.05);
}

.gallery-caption {
    padding: 10px;
    background-color: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.875rem;
}

/* ===== Forum Components ===== */
/* Legacy forum primitives retained for backwards compatibility */
.forum-post,
.comment {
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.post-header,
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--sp-theme-border-default);
}

.post-author,
.comment-author {
    font-weight: 600;
    color: var(--sp-theme-text-default);
}

.post-timestamp,
.comment-timestamp {
    font-size: 0.875rem;
    color: var(--sp-theme-text-subtle);
}

.post-title {
    margin-bottom: 15px;
}

.post-content,
.comment-content {
    color: var(--sp-theme-text-muted);
    line-height: 1.7;
}

.post-footer {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--sp-theme-border-default);
    font-size: 0.875rem;
    color: var(--sp-theme-text-subtle);
}

/* Renderer-based forum defaults */
.forum-categories-view,
.forum-topics-view,
.forum-comments-view {
    display: grid;
    gap: var(--sp-space-sm);
}

.forum-demo-main {
    display: grid;
    gap: var(--sp-space-md);
}

.forum-demo-panel {
    display: grid;
    gap: var(--sp-space-2);
    padding: var(--sp-space-md);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 12px;
    background: var(--sp-gradient-surface-panel);
    box-shadow: 0 6px 16px rgba(34, 55, 81, 0.08);
}

.forum-demo-panel-title {
    margin: 0;
    color: var(--sp-theme-text-default);
}

.forum-demo-panel-subtitle {
    margin: 0;
    color: var(--sp-theme-text-subtle);
    font-size: 0.9rem;
}

.forum-composer {
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 12px;
    background: var(--sp-gradient-surface-panel);
    box-shadow: 0 6px 16px rgba(34, 55, 81, 0.08);
}

.forum-composer-summary {
    cursor: pointer;
    padding: var(--sp-space-sm) var(--sp-space-md);
    color: var(--sp-theme-text-default);
    font-weight: 600;
    list-style: none;
    border-bottom: 1px solid transparent;
}

.forum-composer-summary::-webkit-details-marker {
    display: none;
}

.forum-composer-summary::marker {
    content: "";
}

.forum-composer-summary::before {
    content: "+ ";
    color: var(--sp-theme-text-muted);
}

.forum-composer[open] > .forum-composer-summary::before {
    content: "- ";
}

.forum-composer[open] > .forum-composer-summary {
    border-bottom-color: var(--sp-theme-border-soft);
    background: linear-gradient(180deg, rgba(243, 247, 255, 0.9) 0%, rgba(236, 243, 252, 0.9) 100%);
}

.forum-composer-content {
    display: grid;
    gap: var(--sp-space-2);
    padding: 0 var(--sp-space-md) var(--sp-space-md);
}

.forum-demo-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.forum-demo-breadcrumb-sep {
    color: var(--sp-theme-text-soft);
    font-size: 0.85rem;
}

.forum-demo-breadcrumb-current {
    color: var(--sp-theme-text-strong);
    font-weight: 600;
    font-size: 0.9rem;
}

.forum-demo-category-group {
    display: grid;
    gap: var(--sp-space-2);
}

.forum-demo-group-title {
    margin: 0;
    color: var(--sp-theme-text-default);
    font-size: 1rem;
}

.forum-demo-parent-topic {
    display: grid;
    gap: var(--sp-space-2);
    margin-top: var(--sp-space-2);
}

.forum-composer.forum-demo-parent-topic-toggle {
    margin-top: var(--sp-space-2);
    border-color: var(--sp-theme-border-strong);
}

.forum-demo-parent-topic-toggle > .forum-composer-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sp-theme-text-strong);
}

.forum-demo-parent-topic-toggle:not([open]) > .forum-composer-summary {
    background: var(--sp-gradient-surface-panel-muted);
}

.forum-demo-parent-topic-toggle:not([open]) > .forum-composer-summary::after {
    content: "Thread starter";
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sp-theme-text-default);
    border: 1px solid var(--sp-theme-border-strong);
    border-radius: 999px;
    padding: 2px 8px;
}

.forum-category,
.forum-topic,
.forum-comment {
    background: var(--sp-gradient-surface-card);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(31, 52, 80, 0.09);
}

.forum-category,
.forum-topic {
    padding: var(--sp-space-md);
}

.forum-category-title,
.forum-topic-title {
    margin: 0;
    color: var(--sp-theme-text-default);
}

.forum-category-link {
    color: var(--sp-theme-text-default);
    text-decoration: none;
}

.forum-category-link:hover {
    color: var(--sp-theme-accent);
}

.forum-category-description {
    margin-top: var(--sp-space-2);
    color: var(--sp-theme-text-muted);
}

.forum-category-topic-count {
    display: inline-flex;
    margin-top: var(--sp-space-3);
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--sp-gradient-accent-pill);
    color: var(--sp-theme-accent-strong);
    font-size: 0.78rem;
    font-weight: 600;
}

.forum-topic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-sm);
    color: var(--sp-theme-text-muted);
    font-size: 0.9rem;
}

.forum-topic-meta-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
    min-width: 0;
}

.forum-topic-author,
.forum-topic-timestamp {
    display: inline-flex;
    align-items: center;
    padding: 6px;
    line-height: 1;
    border-radius: 8px;
}

.forum-topic-author {
    padding: 6px;
    border: 1px solid var(--sp-theme-border-accent);
    background: linear-gradient(180deg, #f0f3ff 0%, #e5eaff 100%);
    color: var(--sp-theme-accent-strong);
    font-weight: 600;
}

.forum-topic-timestamp {
    border: 1px solid var(--sp-theme-border-default);
    background: linear-gradient(180deg, #f7faff 0%, #edf3fb 100%);
    color: var(--sp-theme-text-muted);
    font-size: 0.8rem;
}

.forum-topic-title {
    margin-top: var(--sp-space-3);
}

.forum-topic-title-link {
    color: inherit;
    text-decoration: none;
}

.forum-topic-title-link:hover {
    color: var(--sp-theme-accent);
    text-decoration: none;
}

.forum-topic-body-content {
    margin-top: var(--sp-space-3);
    color: var(--sp-theme-text-muted);
}

.forum-topic-body-content > p,
.forum-comment-body-content > p {
    margin: 0 0 var(--sp-space-2);
}

.forum-topic-body-content > p:last-child,
.forum-comment-body-content > p:last-child {
    margin-bottom: 0;
}

.forum-topic-body-content > p:has(+ .forum-tag:not(.forum-tag-quote)),
.forum-comment-body-content > p:has(+ .forum-tag:not(.forum-tag-quote)),
.forum-topic-body-content > .forum-tag:not(.forum-tag-quote) + p,
.forum-comment-body-content > .forum-tag:not(.forum-tag-quote) + p {
    display: inline;
    margin: 0;
}

.forum-topic-body-content > p:has(+ .forum-tag:not(.forum-tag-quote)) + .forum-tag:not(.forum-tag-quote),
.forum-comment-body-content > p:has(+ .forum-tag:not(.forum-tag-quote)) + .forum-tag:not(.forum-tag-quote) {
    margin-inline: 0.3em;
}

.forum-topic-body-content > .forum-tag:not(.forum-tag-quote) + p + p,
.forum-comment-body-content > .forum-tag:not(.forum-tag-quote) + p + p {
    display: block;
    margin-top: var(--sp-space-2);
}

.forum-topic-footer,
.forum-comment-footer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-3);
    color: var(--sp-theme-text-subtle);
    font-size: 0.85rem;
}

.forum-topic-annotations,
.forum-comment-annotations {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.forum-topic-actions,
.forum-comment-actions {
    margin-left: auto;
    justify-content: flex-end;
}

.forum-comment {
    padding: var(--sp-space-sm);
}

.forum-comment:where(.forum-comment-depth-0, .forum-comment-depth-1, .forum-comment-depth-2,
    .forum-comment-depth-3, .forum-comment-depth-4) {
    container-type: inline-size;
}

.forum-comment:where(.forum-comment-depth-0) {
    margin-inline-start: 0;
}

.forum-comment:where(.forum-comment-depth-1) {
    margin-inline-start: min(16px, 8%);
}

.forum-comment:where(.forum-comment-depth-2) {
    margin-inline-start: min(32px, 8%);
}

.forum-comment:where(.forum-comment-depth-3) {
    margin-inline-start: min(48px, 8%);
}

.forum-comment:where(.forum-comment-depth-4) {
    margin-inline-start: min(64px, 8%);
}

.forum-comment-layout {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: var(--sp-space-sm);
}

.forum-comment-identity {
    display: grid;
    gap: var(--sp-space-2);
    align-content: start;
    justify-items: start;
}

.forum-comment-author {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 6px;
    line-height: 1;
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 8px;
    background: linear-gradient(180deg, #f8faff 0%, #ecf2fc 100%);
    font-weight: 600;
    color: var(--sp-theme-text-default);
}

.forum-comment-avatar-slot {
    border-radius: 12px;
    border: 1px dashed var(--sp-theme-border-strong);
    background: linear-gradient(180deg, #f8fbff 0%, #edf3fb 100%);
    overflow: hidden;
}

.forum-comment-main {
    display: grid;
    gap: var(--sp-space-2);
    min-width: 0;
}

.forum-comment-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    min-width: 0;
}

.forum-comment-timestamp {
    display: inline-flex;
    align-items: center;
    padding: 6px;
    line-height: 1;
    border: 1px solid var(--sp-theme-accent-soft-strong);
    border-radius: 8px;
    background: var(--sp-gradient-accent-pill);
    color: var(--sp-theme-accent-strong);
    font-size: 0.78rem;
    font-weight: 600;
}

.forum-comment-body-content {
    color: var(--sp-theme-text-muted);
}

.forum-demo-form {
    display: grid;
    gap: var(--sp-space-2);
}

.forum-demo-inline-form {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.forum-demo-inline-form > .btn {
    margin-bottom: var(--sp-space-md);
}

.forum-demo-size-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    align-items: end;
}

.forum-demo-size-form .form-field {
    min-width: 180px;
}

.forum-demo-size-form > .forum-action,
.forum-demo-size-form > .btn {
    margin-bottom: var(--sp-space-md);
}

.forum-demo-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
}

.forum-action {
    border: 1px solid var(--sp-theme-border-strong);
    border-radius: 10px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #f7faff 0%, #edf3fc 100%);
    color: var(--sp-theme-text-default);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background-color var(--sp-transition-fast), border-color var(--sp-transition-fast), color var(--sp-transition-fast);
}

.forum-action:hover {
    background: linear-gradient(180deg, #ecefff 0%, #e2e8ff 100%);
    border-color: var(--sp-theme-border-accent);
    color: var(--sp-theme-accent-strong);
}

.forum-tag {
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
}

.forum-tag-mention {
    padding: 2px 8px;
    background: linear-gradient(180deg, #edfdf4 0%, #daf6e6 100%);
    color: var(--sp-theme-success-ink);
    font-weight: 600;
}

.forum-tag-link,
.forum-tag-quote-link {
    color: var(--sp-theme-accent);
}

.forum-demo-quote {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    margin: var(--sp-space-2) 0;
    max-width: fit-content;
    padding: 6px 10px;
    border-left: 3px solid var(--sp-theme-accent);
    border-radius: 8px;
    background: linear-gradient(180deg, #eef1ff 0%, #e3e8ff 100%);
    text-align: left;
}

.forum-topic-body-content > .forum-demo-quote + p,
.forum-comment-body-content > .forum-demo-quote + p {
    margin-top: var(--sp-space-2);
}

.forum-demo-quote-meta {
    color: var(--sp-theme-accent-strong);
    font-size: 0.76rem;
    font-weight: 600;
}

.forum-demo-quote-body {
    color: var(--sp-theme-text-default);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.forum-demo-quote-missing {
    border-left-color: var(--sp-theme-text-soft);
    background-color: var(--sp-theme-surface-raised);
    color: var(--sp-theme-text-muted);
}

.forum-tag-literal {
    padding: 2px 6px;
    border-radius: 6px;
    background: linear-gradient(180deg, #f3f7ff 0%, #e9eff9 100%);
    color: var(--sp-theme-text-subtle);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8rem;
}

.forum-topics-pagination,
.forum-comments-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-space-2);
    margin-top: var(--sp-space-2);
}

.forum-topics-page-button,
.forum-comments-page-button {
    border: 1px solid var(--sp-theme-border-strong);
    border-radius: 10px;
    background: linear-gradient(180deg, #f7faff 0%, #edf2fb 100%);
    color: var(--sp-theme-text-default);
    padding: 6px 12px;
    cursor: pointer;
    transition: all var(--sp-transition-fast);
}

.forum-topics-page-button:hover:not([disabled]),
.forum-comments-page-button:hover:not([disabled]) {
    border-color: var(--sp-theme-border-accent);
    background: linear-gradient(180deg, #e9eeff 0%, #dfe6ff 100%);
    color: var(--sp-theme-accent-strong);
}

.forum-topics-page-button[disabled],
.forum-comments-page-button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.forum-topics-page-status,
.forum-comments-page-status {
    color: var(--sp-theme-text-subtle);
    font-size: 0.84rem;
}

@media (max-width: 920px) {
    .forum-demo-inline-form {
        grid-template-columns: 1fr;
    }

    .forum-demo-size-form {
        align-items: stretch;
    }

    .forum-comment:where(.forum-comment-depth-1) {
        margin-inline-start: min(8px, 8%);
    }

    .forum-comment:where(.forum-comment-depth-2) {
        margin-inline-start: min(16px, 8%);
    }

    .forum-comment:where(.forum-comment-depth-3) {
        margin-inline-start: min(24px, 8%);
    }

    .forum-comment:where(.forum-comment-depth-4) {
        margin-inline-start: min(32px, 8%);
    }

    .forum-comment-layout {
        grid-template-columns: 1fr;
    }

    .forum-comment-avatar-slot {
        max-width: 150px;
    }

    .forum-topics-pagination,
    .forum-comments-pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* Keep 170px identity + 15px gap beside a usable 185px main; stack smaller cards. */
@container (max-width: 370px) {
    .forum-comment:where(.forum-comment-depth-0, .forum-comment-depth-1, .forum-comment-depth-2,
        .forum-comment-depth-3, .forum-comment-depth-4) > .forum-comment-layout {
        grid-template-columns: 1fr;
    }

    .forum-comment:where(.forum-comment-depth-0, .forum-comment-depth-1, .forum-comment-depth-2,
        .forum-comment-depth-3, .forum-comment-depth-4) > .forum-comment-layout > .forum-comment-main
        > .forum-comment-meta {
        flex-wrap: wrap;
    }
}

/* ===== InfoBox ===== */
.info-box {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--sp-gradient-surface-card);
    border-radius: 10px;
    border: 1px solid var(--sp-theme-border-emphasis);
    box-shadow: 0 8px 18px rgba(30, 49, 83, 0.12);
}

.info-box-icon {
    font-size: 2.5rem;
    color: var(--sp-theme-accent-strong);
}

.info-box-title {
    font-size: 0.875rem;
    color: var(--sp-theme-text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.info-box-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sp-theme-text-strong);
}

/* ===== Utility Classes ===== */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Legacy size aliases retained for backwards compatibility.
 * Prefer scale utilities in "Spacing Utilities" (`.p-1`..`.p-6`, `.m-1`..`.m-6`)
 * for new code.
 */
.p-sm { padding: 10px; }
.p-medium { padding: 20px; }
.p-lg { padding: 30px; }

.m-sm { margin: 10px; }
.m-medium { margin: 20px; }
.m-lg { margin: 30px; }

/* ===== Page Content ===== */
.page-content {
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* ===== Lists ===== */
.list {
    margin-bottom: 20px;
}

.list li {
    margin-bottom: 8px;
}

.list-unstyled {
    list-style: none;
}

.list-inline {
    display: flex;
    gap: 15px;
}

.list-inline li {
    display: inline-block;
}

/* ===== Demo Home Landing ===== */
.home-landing-stack {
    display: grid;
    gap: var(--sp-space-2);
    padding: var(--sp-space-3);
    border-radius: var(--sp-radius-surface-xl);
    border: 1px solid var(--sp-home-shell-border);
    background: linear-gradient(150deg, rgba(206, 218, 248, 0.7) 0%, rgba(190, 205, 241, 0.64) 56%, rgba(176, 191, 230, 0.6) 100%);
    box-shadow: 0 14px 28px rgba(42, 58, 102, 0.16);
}

.home-landing-stack .hero-module {
    margin-bottom: 0;
    border-radius: var(--sp-radius-surface-lg);
}

.home-landing-nav-shell {
    margin: var(--sp-space-lg) 0 var(--sp-space-md);
    padding: var(--sp-space-md);
    border-radius: var(--sp-radius-surface-lg);
    border: 1px solid var(--sp-home-shell-border);
    background: var(--sp-home-shell-bg);
    box-shadow: 0 12px 24px rgba(55, 70, 106, 0.12);
}

.home-landing-stack .home-landing-nav-shell {
    margin: 0;
    padding: var(--sp-space-sm);
    box-shadow: none;
    background: linear-gradient(155deg, rgba(226, 236, 255, 0.9) 0%, rgba(205, 220, 249, 0.86) 100%);
}

.home-landing-nav-title {
    margin-bottom: var(--sp-space-2);
    color: var(--sp-palette-slate-800);
}

.home-landing-nav-subtitle {
    color: var(--sp-palette-slate-600);
    margin-bottom: var(--sp-space-md);
}

.home-landing-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-space-md);
}

.home-landing-stack .home-landing-nav-grid {
    gap: var(--sp-space-sm);
}

@media (max-width: 1120px) {
    .home-landing-nav-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .home-landing-nav-grid {
        grid-template-columns: 1fr;
    }
}

.home-landing-nav-card {
    display: grid;
    gap: var(--sp-space-2);
    min-height: 180px;
    padding: var(--sp-space-md);
    border: 1px solid var(--sp-home-card-border);
    border-radius: var(--sp-radius-surface-lg);
    background: var(--sp-home-card-bg);
    box-shadow: 0 10px 20px rgba(55, 70, 105, 0.14);
    color: inherit;
    text-decoration: none;
    transition:
        transform var(--sp-transition-fast) var(--sp-ease-standard),
        border-color var(--sp-transition-fast) var(--sp-ease-standard),
        box-shadow var(--sp-transition-fast) var(--sp-ease-standard),
        background var(--sp-transition-fast) var(--sp-ease-standard);
}

.home-landing-nav-card:hover {
    transform: translateY(-4px);
    border-color: var(--sp-top-nav-item-border);
    background: var(--sp-home-card-bg-hover);
    box-shadow: 0 14px 26px rgba(35, 44, 62, 0.2);
}

.home-landing-nav-card-badge {
    display: inline-flex;
    justify-self: start;
    padding: 3px 10px;
    border: 1px solid var(--sp-top-nav-item-border);
    border-radius: 999px;
    background: var(--sp-gradient-nav-shell-muted);
    color: var(--sp-palette-slate-600);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.home-landing-nav-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sp-palette-slate-800);
}

.home-landing-nav-card-body {
    color: var(--sp-palette-slate-600);
    line-height: 1.5;
}

.home-landing-nav-card-cta {
    margin-top: auto;
    color: var(--sp-theme-accent-strong);
    font-weight: 600;
}

/* ===== Demos Overview ===== */
.demo-overview-shell {
    display: grid;
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
    border: 1px solid #b9c9e6;
    background: linear-gradient(160deg, rgba(246, 250, 255, 0.96) 0%, rgba(229, 238, 254, 0.92) 100%);
    box-shadow: 0 14px 28px rgba(44, 60, 96, 0.12);
}

.demo-overview-header-box {
    border: 1px solid #c4d2ea;
    border-radius: 12px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 250, 255, 0.96) 100%);
    box-shadow: 0 8px 18px rgba(36, 53, 87, 0.11);
    display: grid;
    gap: 8px;
}

.demo-overview-title {
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #c7d5ec;
}

.demo-overview-intro {
    margin: 0;
    color: #3a4f78;
    line-height: 1.45;
}

.demo-overview-shell-tags {
    margin-top: 2px;
}

.demo-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.demo-overview-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #c0d0ea;
    border-radius: 12px;
    background: linear-gradient(170deg, rgba(255, 255, 255, 0.99) 0%, rgba(243, 248, 255, 0.96) 100%);
    box-shadow: 0 10px 20px rgba(34, 48, 79, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    color: inherit;
    text-decoration: none;
    transition:
        transform var(--sp-transition-fast) var(--sp-ease-standard),
        border-color var(--sp-transition-fast) var(--sp-ease-standard),
        box-shadow var(--sp-transition-fast) var(--sp-ease-standard);
}

.demo-overview-card:hover {
    transform: translateY(-2px);
    border-color: #97add6;
    box-shadow: 0 14px 24px rgba(33, 45, 74, 0.13);
}

.demo-overview-card-header {
    border: 1px solid #bed0ea;
    border-radius: 9px;
    padding: 6px 8px;
    background: #ffffff;
}

.demo-overview-card-title {
    margin: 0;
    font-size: 1.33rem;
    line-height: 1.2;
    color: var(--sp-theme-accent-strong);
    border-bottom: 1px solid #c7d5ec;
    padding-bottom: 6px;
}

.demo-overview-card-tags {
    margin: 0 1px;
}

.demo-overview-card-main {
    border: 1px solid #c3d2eb;
    border-radius: 9px;
    padding: 8px 10px;
    background: #ffffff;
}

.demo-overview-card-body {
    margin: 0;
    color: #425983;
    line-height: 1.42;
}

.demo-overview-card-footer {
    border-top: 1px dashed #c9d7ee;
    padding: 4px 2px 0;
}

.demo-overview-card-cta {
    color: var(--sp-theme-accent-strong);
    font-weight: 600;
    font-size: 0.9rem;
}

@media (max-width: 980px) {
    .demo-overview-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Banner (New Flexible System) ===== */
/* BannerBuilder maps directly to `.banner*` selectors in this section.
 * Legacy `.top-banner*` selectors are retained as compatibility aliases.
 */
.banner,
.top-banner {
    background: var(--sp-gradient-banner);
    padding: var(--sp-banner-padding-y) var(--sp-banner-padding-x) var(--sp-banner-bottom-clearance);
    border: 1px solid var(--sp-banner-border-color);
    border-radius: var(--sp-radius-surface-xl);
    box-shadow: var(--sp-banner-shadow);
    position: relative;
    overflow: hidden;
}

.banner::before,
.top-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--sp-banner-pattern-primary), var(--sp-banner-pattern-secondary);
    pointer-events: none;
}

.banner::after,
.top-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--sp-banner-sheen-pattern);
    pointer-events: none;
    opacity: 0.75;
}

/* Full-width banner variant */
.banner-full-width .banner-content,
.banner-full-width .top-banner-content {
    max-width: none;
    text-align: center;
}

.banner-full-width .banner-title,
.banner-full-width .top-banner-title {
    font-size: 2rem;
    margin-bottom: 8px;
}

.banner-full-width .banner-subtitle,
.banner-full-width .top-banner-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.banner-content,
.top-banner-content {
    max-width: var(--sp-content-max-width);
    margin: 0 auto;
    padding-inline: var(--sp-space-2);
    position: relative;
    z-index: 1;
}

/* Horizontal layout (image + text side by side) */
.banner-horizontal .banner-content,
.banner-horizontal .top-banner-content {
    display: flex;
    align-items: center;
    gap: var(--sp-space-md);
}

.banner-horizontal .banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)),
.banner-horizontal .top-banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)) {
    justify-content: center;
    text-align: center;
}

.banner-horizontal .banner-image,
.banner-horizontal .top-banner-image {
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

.banner-horizontal .banner-text,
.banner-horizontal .top-banner-text {
    flex: 1;
}

.banner-horizontal .banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)) .banner-text,
.banner-horizontal .top-banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)) .top-banner-text {
    flex: 0 1 920px;
    width: 100%;
    margin: 0 auto;
}

/* Fallback for browsers where :has() is unavailable: text-only banner content is the only child. */
.banner-horizontal .banner-content > .banner-text:only-child,
.banner-horizontal .top-banner-content > .top-banner-text:only-child {
    flex: 0 1 920px;
    width: 100%;
    margin: 0 auto;
}

/* Centered layout */
.banner-centered .banner-content {
    text-align: center;
}

/* Left-aligned layout */
.banner-left .banner-content {
    text-align: left;
}

/* Right-aligned layout */
.banner-right .banner-content {
    text-align: right;
}

/* Image overlay layout */
.banner-image-overlay {
    background-size: cover;
    background-position: center;
    position: relative;
    min-height: 200px;
}

.banner-image-overlay .banner-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    min-height: 200px;
    padding: 40px 20px;
}

.banner-image-overlay .banner-content.align-left {
    justify-content: flex-start;
}

.banner-image-overlay .banner-content.align-center {
    justify-content: center;
    text-align: center;
}

.banner-image-overlay .banner-content.align-right {
    justify-content: flex-end;
    text-align: right;
}

.banner-image-overlay .banner-text {
    background-color: rgba(255, 255, 255, 0.92);
    padding: var(--sp-space-md) var(--sp-space-lg);
    border-radius: var(--sp-radius-lg);
    box-shadow: var(--sp-shadow-md);
}

/* Banner typography */
.banner-title,
.top-banner-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sp-banner-title-color);
    letter-spacing: -0.02em;
}

.banner-subtitle,
.top-banner-subtitle {
    margin: 8px 0 0 0;
    font-size: 0.92rem;
    color: var(--sp-banner-subtitle-color);
    max-width: 72ch;
}

.banner-text,
.top-banner-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-space-1);
}

.banner-horizontal .banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)) .banner-text,
.banner-horizontal .top-banner-content:not(:has(.banner-image)):not(:has(.top-banner-image)) .top-banner-text,
.banner-centered .banner-text,
.banner-centered .top-banner-text {
    align-items: center;
}

/* ===== Account Bar ===== */
.account-bar {
    background: var(--sp-top-nav-bg);
    padding: 10px 14px;
    border: 1px solid var(--sp-top-nav-border-color);
    border-radius: var(--sp-radius-surface-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-space-3);
    margin: 0;
    box-shadow: var(--sp-top-nav-shadow);
    position: relative;
    z-index: 5;
    backdrop-filter: var(--sp-top-nav-blur);
    -webkit-backdrop-filter: var(--sp-top-nav-blur);
}

.account-bar-left,
.account-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.account-bar-left {
    justify-content: flex-start;
}

.account-bar-right {
    justify-content: flex-end;
}

.account-bar a {
    color: var(--sp-top-nav-item-text);
    text-decoration: none;
    padding: var(--sp-top-nav-item-padding-y) var(--sp-top-nav-item-padding-x);
    border-radius: var(--sp-top-nav-item-radius);
    border: 1px solid transparent;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
    font-size: 0.875rem;
}

.account-bar a:hover {
    background-color: var(--sp-top-nav-item-hover-bg);
    border-color: var(--sp-top-nav-item-border);
    color: var(--sp-top-nav-item-active-text);
}

/* ===== Generic Dropdown ===== */
.dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.dropdown-trigger {
    border: 0;
    background: transparent;
    font-family: inherit;
    color: var(--sp-theme-text-default);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
}

.dropdown-trigger:hover {
    background-color: var(--sp-theme-surface-muted);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    margin-top: 2px;
    padding-top: 3px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 4px;
    box-shadow: var(--sp-shadow-md);
    min-width: 150px;
    z-index: 1000;
}

.dropdown-menu.dropdown-align-left {
    left: 0;
}

.dropdown-menu.dropdown-align-right {
    right: 0;
}

.dropdown-menu.dropdown-align-center {
    left: 50%;
    transform: translateX(-50%);
}

.dropdown-menu:not([hidden]) {
    display: flex;
    flex-direction: column;
}

.dropdown-link {
    padding: 10px 15px;
    color: var(--sp-theme-text-muted);
    text-decoration: none;
    display: block;
    transition: background-color 0.2s;
}

.dropdown-link:first-child {
    padding-top: 13px;
}

.dropdown-link:hover {
    background-color: var(--sp-theme-surface-raised);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--sp-theme-border-default);
    margin: 5px 0;
}

/* ===== Account Widget ===== */
.account-widget {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Guest state */
.account-widget-guest {
    display: flex;
    gap: 10px;
    align-items: center;
}

.account-widget-link {
    color: var(--sp-theme-text-muted);
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.account-widget-login {
    background-color: transparent;
    border: 1px solid var(--sp-theme-border-strong);
}

.account-widget-login:hover {
    background-color: var(--sp-theme-surface-muted);
    border-color: var(--sp-theme-border-emphasis);
}

.account-widget-signup {
    background: linear-gradient(180deg, var(--sp-theme-accent), var(--sp-theme-accent-hover));
    color: #fff;
    border: 1px solid var(--sp-theme-accent-hover);
}

.account-widget-signup:hover {
    background: linear-gradient(180deg, var(--sp-theme-accent-hover), var(--sp-theme-accent-strong));
    border-color: var(--sp-theme-accent-strong);
}

/* Authenticated state */
.account-widget-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-widget-greeting {
    border: 0;
    background: transparent;
    font-family: inherit;
    color: var(--sp-theme-text-default);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.account-widget-greeting:hover {
    background-color: var(--sp-theme-surface-muted);
}

.account-widget-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    padding-top: 3px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 4px;
    box-shadow: var(--sp-shadow-md);
    min-width: 150px;
    z-index: 1000;
}

.account-widget-dropdown:not([hidden]) {
    display: flex;
    flex-direction: column;
}

.account-widget-dropdown .account-widget-link {
    padding: 10px 15px;
    border-radius: 0;
    display: block;
    border: none;
    color: var(--sp-theme-text-muted);
}

.account-widget-dropdown .account-widget-link:first-child {
    padding-top: 13px;
}

.account-widget-dropdown .account-widget-link:hover {
    background-color: var(--sp-theme-surface-raised);
}

/* ===== Independent Scrolling Page ===== */
.page-content.scrollable-page {
    height: calc(100vh - 60px - 100px); /* Adjust based on header/banner heights */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 40px; /* Add space to inset scrollbar from content area edge */
}

/* Scrollbar styling for scrollable page */
.page-content.scrollable-page::-webkit-scrollbar {
    width: 10px;
}

.page-content.scrollable-page::-webkit-scrollbar-track {
    background: var(--sp-theme-surface-muted);
    border-radius: 5px;
}

.page-content.scrollable-page::-webkit-scrollbar-thumb {
    background: var(--sp-theme-border-strong);
    border-radius: 5px;
}

.page-content.scrollable-page::-webkit-scrollbar-thumb:hover {
    background: var(--sp-theme-border-emphasis);
}

.content-wrapper.scrollable-wrapper {
    height: calc(100vh - 60px); /* Full viewport height minus header */
    overflow-y: auto;
    overflow-x: hidden;
}

.content-wrapper.scrollable-wrapper #content-area {
    min-height: auto;
}

/* ===== Sticky Sidebar Layout ===== */
.page-content.with-sticky-sidebar {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.sticky-sidebar-main {
    flex: 1;
    min-width: 0; /* Prevent flex item overflow */
}

.sticky-sidebar-aside {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: var(--sp-gradient-surface-panel);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--sp-theme-border-default);
    box-shadow: var(--sp-shadow-md);
}

.sticky-sidebar-mobile-collapse {
    display: block;
}

.sticky-sidebar-mobile-summary {
    display: block;
    cursor: pointer;
    font-weight: 600;
    color: var(--sp-color-heading);
    background-color: var(--sp-theme-surface-raised);
    border: 1px solid var(--sp-color-border);
    border-radius: var(--sp-radius-md);
    padding: var(--sp-space-sm);
}

.sticky-sidebar-mobile-collapse > .sticky-sidebar-content {
    display: none;
}

.sticky-sidebar-mobile-collapse[open] > .sticky-sidebar-content {
    display: block;
}

.sticky-sidebar-mobile-summary:focus-visible {
    outline: 2px solid var(--sp-theme-border-emphasis);
    outline-offset: 2px;
}

/* Scrollbar styling for sticky sidebar */
.sticky-sidebar-aside::-webkit-scrollbar {
    width: 8px;
}

.sticky-sidebar-aside::-webkit-scrollbar-track {
    background: var(--sp-theme-surface-muted);
    border-radius: 4px;
}

.sticky-sidebar-aside::-webkit-scrollbar-thumb {
    background: var(--sp-theme-border-strong);
    border-radius: 4px;
}

.sticky-sidebar-aside::-webkit-scrollbar-thumb:hover {
    background: var(--sp-theme-border-emphasis);
}

/* ===== Static Content Helper ===== */
.sp-content-index-shell,
.sp-content-detail-shell {
    background: linear-gradient(160deg, rgba(247, 250, 255, 0.96) 0%, rgba(235, 242, 255, 0.92) 100%);
    border: 1px solid #b9c9e6;
    box-shadow: 0 14px 28px rgba(44, 60, 96, 0.12);
    border-radius: 22px;
    padding: var(--sp-space-lg);
}

.sp-content-index-title {
    margin-bottom: var(--sp-space-md);
    font-size: clamp(2rem, 3.2vw, 2.8rem);
    letter-spacing: -0.01em;
}

.sp-content-detail-title {
    margin-bottom: var(--sp-space-sm);
}

.sp-content-index-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-sm);
}

.sp-content-list-item {
    position: relative;
    border: 1px solid #c3d2eb;
    border-radius: 16px;
    background: linear-gradient(170deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 248, 255, 0.95) 100%);
    box-shadow: 0 10px 22px rgba(34, 48, 79, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.68);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform var(--sp-transition-fast) var(--sp-ease-standard),
        box-shadow var(--sp-transition-fast) var(--sp-ease-standard),
        border-color var(--sp-transition-fast) var(--sp-ease-standard);
}

.sp-content-list-item:hover {
    transform: translateY(-2px);
    border-color: #97add6;
    box-shadow: 0 12px 24px rgba(33, 45, 74, 0.13);
}

.sp-content-list-main-box {
    border: 1px solid #bccde8;
    border-radius: 10px;
    padding: 10px 12px;
    background: #ffffff;
    box-shadow: 0 6px 14px rgba(39, 56, 91, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.sp-content-list-item .sp-content-list-title {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #c7d5ec;
    padding-bottom: 8px;
    font-size: 1.5rem;
    line-height: 1.25;
}

.sp-content-list-link {
    text-decoration: none;
    color: var(--sp-theme-text-strong);
}

.sp-content-list-link:hover {
    color: var(--sp-theme-accent-strong);
    text-decoration: underline;
}

.sp-content-list-item .sp-content-list-summary {
    margin: 10px 0 0;
    color: var(--sp-theme-text-subtle);
    line-height: 1.5;
}

.sp-content-list-tags,
.sp-content-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sp-content-list-tags-top {
    margin: 0;
    padding: 0;
}

.sp-content-list-top-meta {
    margin: 0 2px 2px;
}

.sp-content-detail-tags-top {
    margin-top: 0;
    margin-bottom: 0;
}

.sp-content-list-footer {
    margin: 0 2px;
    padding: 0;
    border: none;
}

.sp-content-list-byline {
    color: #4e6189;
    font-size: 0.86rem;
    line-height: 1.35;
}

.sp-content-list-tags .tag,
.sp-content-detail-tags .tag {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 14px 0 8px;
    margin: 0;
    border: 1px solid #6f89b8;
    border-radius: 2px;
    background: #dbe8fb;
    color: #2a4370;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    line-height: 1;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.sp-content-list-tags .tag::before,
.sp-content-detail-tags .tag::before {
    content: none;
}

.sp-content-list-tags .tag::after,
.sp-content-detail-tags .tag::after {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 9px;
    height: calc(100% + 2px);
    background: #bdd1f2;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.sp-content-detail-header .sp-content-detail-byline {
    margin: 0;
    color: #4e6189;
    font-size: 0.86rem;
    line-height: 1.35;
    white-space: nowrap;
}

.sp-content-detail-header .sp-content-detail-tags {
    flex-wrap: nowrap;
}

.sp-content-pagination {
    margin-top: var(--sp-space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-2);
    padding-top: var(--sp-space-2);
    border-top: 1px solid var(--sp-theme-border-soft);
}

.sp-content-page-link {
    border: none;
    background: transparent;
    padding: 0;
    min-width: 0;
    color: var(--sp-theme-accent-strong);
    text-decoration: none;
    font-weight: 600;
}

.sp-content-page-link:hover {
    text-decoration: underline;
}

.sp-content-page-link.disabled {
    opacity: 0.55;
    pointer-events: none;
    color: var(--sp-theme-text-muted);
}

.sp-content-page-status {
    color: var(--sp-theme-text-subtle);
    font-size: 0.9rem;
    font-weight: 500;
}

.sp-content-detail-summary {
    margin-top: 0;
    color: var(--sp-theme-text-subtle);
    line-height: 1.55;
}

.sp-content-detail-header {
    margin: 0 0 6px;
    padding: 6px 10px;
    border: 1px solid #c8d6eb;
    border-radius: 10px;
    background: #f7faff;
    box-shadow: 0 2px 8px rgba(37, 52, 86, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.78);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.sp-content-markdown-body {
    margin-top: 0;
    padding: 10px;
    border: 1px solid #aec2e4;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.995) 0%, rgba(241, 247, 255, 0.98) 100%);
    box-shadow: 0 16px 34px rgba(30, 44, 73, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-content-detail-content {
    border: 1px solid #bdd0ea;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 10px 14px var(--sp-space-md);
    box-shadow: 0 8px 20px rgba(33, 49, 82, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.sp-content-detail-content h1:first-child {
    margin-top: 0;
}

.sp-content-detail-footer {
    margin-top: var(--sp-space-sm);
    padding-top: var(--sp-space-2);
    border-top: 1px dashed #c9d7ee;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-space-2);
    flex-wrap: wrap;
}

.sp-content-detail-back-link {
    color: var(--sp-theme-accent-strong);
    font-weight: 600;
    text-decoration: none;
}

.sp-content-detail-back-link:hover {
    text-decoration: underline;
}

.sp-content-detail-page .sticky-sidebar-aside {
    padding: 12px;
}

.sp-content-toc {
    width: 100%;
    max-width: 100%;
    gap: 4px;
}

.sp-content-toc-empty {
    color: var(--sp-theme-text-subtle);
    font-size: 0.9rem;
    padding: 6px 10px;
}

.sp-content-toc-item {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sp-content-toc-item.level-3 {
    padding-left: 22px;
    font-size: 0.92rem;
}

.sp-content-toc-item.level-4 {
    padding-left: 34px;
    font-size: 0.85rem;
}

/* ===== Collapsible Sidebar ===== */
.main-sidebar.collapsible {
    position: relative;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(180deg, rgba(224, 234, 255, 0.92) 0%, rgba(205, 219, 250, 0.92) 100%);
    color: #24358a;
    border: 1px solid rgba(105, 126, 182, 0.44);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.sidebar-toggle:hover {
    background: linear-gradient(180deg, rgba(216, 227, 255, 0.96) 0%, rgba(196, 210, 245, 0.96) 100%);
    border-color: rgba(102, 123, 183, 0.56);
    color: #1c2f82;
}

.main-sidebar.collapsible.collapsed {
    width: var(--sp-sidebar-collapsed-width);
}

.main-sidebar.collapsible.collapsed .sidenav-item {
    padding: 12px 10px;
    justify-content: center;
}

.main-sidebar.collapsible.collapsed .sidenav-item span:not(.sidenav-icon) {
    display: none;
}

.main-sidebar.collapsible.collapsed .sidenav-section {
    display: none;
}

.main-container.sidebar-collapsed {
    grid-template-columns: var(--sp-sidebar-collapsed-width) 1fr;
}

/* ===== Responsive Design ===== */

/* Tablet and below */
@media (max-width: 768px) {
    .main-header {
        margin: var(--sp-space-3) var(--sp-space-3) 0;
    }

    .main-header.has-top-nav {
        margin-bottom: var(--sp-space-4);
    }

    .header-top-nav-wrap {
        margin-top: calc(-1 * var(--sp-top-nav-overlap) + var(--sp-space-3));
        padding-inline: 0;
        width: min(100%, var(--sp-top-nav-max-width));
        min-width: 100%;
        max-width: 100%;
    }

    .main-container,
    .main-container.has-sidebar {
        grid-template-columns: 1fr;
        grid-template-areas:
            "content";
        padding: var(--sp-space-3) var(--sp-space-3) var(--sp-space-3);
        margin-top: 0;
    }

    .main-sidebar,
    .main-sidebar.collapsible {
        position: fixed;
        left: calc(-1 * var(--sp-sidebar-width));
        top: 0;
        bottom: 0;
        width: var(--sp-sidebar-width);
        margin: 0;
        border-radius: 0;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .main-sidebar:not(.mobile-open) {
        visibility: hidden;
    }

    .main-sidebar.mobile-open {
        left: 0;
        box-shadow: 2px 0 10px rgba(15, 23, 42, 0.2);
    }

    /* Desktop collapse state is retained, but never narrows/hides the mobile drawer. */
    .main-container.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .main-sidebar.collapsible.collapsed {
        width: var(--sp-sidebar-width);
    }

    .main-sidebar.collapsible.collapsed .sidenav-item {
        padding: 12px 15px;
        justify-content: flex-start;
    }

    .main-sidebar.collapsible.collapsed .sidenav-item span:not(.sidenav-icon),
    .main-sidebar.collapsible.collapsed .sidenav-section {
        display: block;
    }

    .main-sidebar .sidebar-toggle {
        display: none;
    }

    .banner-content,
    .top-banner-content {
        flex-direction: column;
        text-align: center;
    }

    /* Keep text-only horizontal banners compact on mobile; only image banners should stack. */
    .banner-horizontal .banner-content,
    .banner-horizontal .top-banner-content {
        flex-direction: row;
    }

    .banner-horizontal .banner-content:has(.banner-image),
    .banner-horizontal .banner-content:has(.top-banner-image),
    .banner-horizontal .top-banner-content:has(.banner-image),
    .banner-horizontal .top-banner-content:has(.top-banner-image) {
        flex-direction: column;
    }

    .banner-horizontal .banner-text,
    .banner-horizontal .top-banner-text {
        flex: 0 1 auto;
    }

    .account-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
        margin: 0;
        border-radius: var(--sp-radius-surface-md);
    }

    .top-nav {
        padding: 10px 12px;
    }

    .top-nav .navbar-items,
    .top-nav .navbar-utility,
    .account-bar-left,
    .account-bar-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .top-nav .navbar-utility {
        margin-left: 0;
        padding-top: 4px;
        border-top: 1px solid var(--sp-top-nav-border-color);
    }

    .content-wrapper {
        padding: 15px;
    }

    #content-area {
        padding: 20px;
    }

    .row > .col,
    .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        min-width: 0;
    }

    .row > .col + .col,
    .row > [class*="col-"] + [class*="col-"] {
        margin-top: var(--sp-space-md);
    }

    .col {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .page-content.with-sticky-sidebar {
        flex-direction: column;
    }

    .sticky-sidebar-main {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .sticky-sidebar-aside {
        position: relative;
        top: 0;
        max-height: none;
        width: 100%;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .sticky-sidebar-mobile-collapse > .sticky-sidebar-content {
        margin-top: var(--sp-space-sm);
    }

    /* Mobile sidebar toggle button (show in header) */
    .mobile-sidebar-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background-color: var(--sp-theme-text-strong);
        color: white;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 4px;
        font-size: 1.5rem;
        cursor: pointer;
    }
}

/* Desktop */
@media (min-width: 769px) {
    .mobile-sidebar-toggle {
        display: none;
    }

    /* A closed disclosure stays recoverable without JS; focused summaries retain native keys. */
    .sticky-sidebar-mobile-collapse[open] > .sticky-sidebar-mobile-summary:not(:focus) {
        display: none;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .home-landing-stack {
        padding: var(--sp-space-2);
        gap: var(--sp-space-2);
    }

    .home-landing-stack .home-landing-nav-shell {
        padding: var(--sp-space-2);
    }

    .banner,
    .top-banner {
        padding: var(--sp-space-sm) var(--sp-space-md) calc(var(--sp-space-lg) + 12px);
        border-radius: var(--sp-radius-surface-md);
    }

    .main-header {
        margin: var(--sp-space-2) var(--sp-space-2) 0;
    }

    .banner-title,
    .top-banner-title {
        font-size: 1.5rem;
    }

    .account-bar {
        padding: var(--sp-space-sm);
        margin: 0;
        border-radius: var(--sp-radius-surface-sm);
    }

    /* Stack account widget vertically on mobile */
    .account-widget-guest {
        flex-direction: column;
        gap: 8px;
    }

    .account-widget-link {
        width: 100%;
        text-align: center;
    }

    /* Banner horizontal layout stacks on mobile */
    .banner-horizontal .banner-content {
        flex-direction: row;
        text-align: center;
    }

    .banner-horizontal .banner-content:has(.banner-image),
    .banner-horizontal .banner-content:has(.top-banner-image) {
        flex-direction: column;
    }

    .banner-horizontal .banner-text,
    .banner-horizontal .top-banner-text {
        flex: 0 1 auto;
    }

    .banner-image-overlay .banner-content {
        padding: 20px 15px;
    }

    .row {
        margin: 0 -6px;
    }

    .col {
        padding: 0 6px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .info-box {
        gap: 10px;
        align-items: flex-start;
        padding: 14px;
    }

    .info-box-icon {
        font-size: 2rem;
        line-height: 1;
    }

    .info-box-title {
        font-size: 0.75rem;
    }

    .info-box-value {
        font-size: 1.25rem;
    }
}

/* ===== Alignment Utilities ===== */
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }
.align-justify { text-align: justify; }

/* Flexbox alignment */
.flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

/* ===== Spacing Utilities ===== */

/* Margin utilities */
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }
.m-5 { margin: 1.5rem; }
.m-6 { margin: 2rem; }
.m-auto { margin: auto; }

/* Margin top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; }

/* Margin right */
.mr-0 { margin-right: 0; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.mr-4 { margin-right: 1rem; }
.mr-5 { margin-right: 1.5rem; }
.mr-6 { margin-right: 2rem; }
.mr-auto { margin-right: auto; }

/* Margin bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }

/* Margin left */
.ml-0 { margin-left: 0; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.ml-4 { margin-left: 1rem; }
.ml-5 { margin-left: 1.5rem; }
.ml-6 { margin-left: 2rem; }
.ml-auto { margin-left: auto; }

/* Margin X (horizontal) */
.mx-0 { margin-left: 0; margin-right: 0; }
.mx-1 { margin-left: 0.25rem; margin-right: 0.25rem; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; }
.mx-4 { margin-left: 1rem; margin-right: 1rem; }
.mx-5 { margin-left: 1.5rem; margin-right: 1.5rem; }
.mx-6 { margin-left: 2rem; margin-right: 2rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Margin Y (vertical) */
.my-0 { margin-top: 0; margin-bottom: 0; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-3 { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.my-5 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.my-6 { margin-top: 2rem; margin-bottom: 2rem; }

/* Padding utilities */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.5rem; }
.p-6 { padding: 2rem; }

/* Padding top */
.pt-0 { padding-top: 0; }
.pt-1 { padding-top: 0.25rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-3 { padding-top: 0.75rem; }
.pt-4 { padding-top: 1rem; }
.pt-5 { padding-top: 1.5rem; }
.pt-6 { padding-top: 2rem; }

/* Padding right */
.pr-0 { padding-right: 0; }
.pr-1 { padding-right: 0.25rem; }
.pr-2 { padding-right: 0.5rem; }
.pr-3 { padding-right: 0.75rem; }
.pr-4 { padding-right: 1rem; }
.pr-5 { padding-right: 1.5rem; }
.pr-6 { padding-right: 2rem; }

/* Padding bottom */
.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pb-4 { padding-bottom: 1rem; }
.pb-5 { padding-bottom: 1.5rem; }
.pb-6 { padding-bottom: 2rem; }

/* Padding left */
.pl-0 { padding-left: 0; }
.pl-1 { padding-left: 0.25rem; }
.pl-2 { padding-left: 0.5rem; }
.pl-3 { padding-left: 0.75rem; }
.pl-4 { padding-left: 1rem; }
.pl-5 { padding-left: 1.5rem; }
.pl-6 { padding-left: 2rem; }

/* Padding X (horizontal) */
.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-6 { padding-left: 2rem; padding-right: 2rem; }

/* Padding Y (vertical) */
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-6 { padding-top: 2rem; padding-bottom: 2rem; }

/* ===== Width & Height Utilities ===== */
.w-25 { width: 25%; }
.w-50 { width: 50%; }
.w-75 { width: 75%; }
.w-100 { width: 100%; }
.w-auto { width: auto; }

.h-25 { height: 25%; }
.h-50 { height: 50%; }
.h-75 { height: 75%; }
.h-100 { height: 100%; }
.h-auto { height: auto; }

/* ===== Display Utilities ===== */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Responsive display utilities */
@media (max-width: 768px) {
    .d-md-none { display: none; }
    .d-md-block { display: block; }
}

@media (min-width: 769px) {
    .d-md-inline { display: inline; }
    .d-md-flex { display: flex; }
}

/* ===== Editing System Styles ===== */

/* Edit toolbar - minimal, unobtrusive edit icon */
.edit-toolbar {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    z-index: 10;
}

.edit-toolbar .btn-sm {
    font-size: 0.9rem;
    padding: 2px 6px;
    line-height: 1;
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.edit-toolbar .btn-sm:hover {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--sp-shadow-sm);
    border-radius: 3px;
}

.editable-module-wrapper {
    position: relative;
    margin-bottom: 24px;
}

/* Edit/Delete buttons for editable modules */
.module-edit-btn {
    position: absolute;
    top: 2px;
    right: 30px;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--sp-theme-text-subtle);
    padding: 2px 4px;
    z-index: 10;
    cursor: pointer;
    background: none;
    border: none;
}

.module-edit-btn:hover {
    color: var(--sp-theme-text-muted);
}

.module-delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--sp-theme-danger);
    padding: 2px 4px;
    z-index: 10;
    cursor: pointer;
    background: none;
    border: none;
}

.module-delete-btn:hover {
    color: var(--sp-theme-danger-hover);
}

/* Page builder UI - module addition section */
.add-module-section {
    margin: 16px 0;
    text-align: center;
}

.add-module-section .btn {
    background-color: var(--sp-theme-border-default);
    border: 2px dashed var(--sp-theme-border-strong);
    padding: 12px 24px;
    font-weight: 500;
}

.add-module-section .btn:not(:where(.btn-secondary)) {
    color: var(--sp-theme-text-muted);
}

.add-module-section .btn:hover {
    background-color: var(--sp-theme-border-strong);
    border-color: var(--sp-theme-border-emphasis);
    transform: translateY(-1px);
}

/* Insert row section - dashed border separator */
.insert-row-section {
    margin: 24px 0;
    padding: 16px 0;
    border-top: 1px solid var(--sp-theme-border-default);
    text-align: center;
}

.insert-row-section .btn {
    color: var(--sp-theme-text-subtle);
    background: transparent;
    font-size: 0.9rem;
    border: 1px solid var(--sp-theme-border-default);
}

.insert-row-section .btn:hover {
    background-color: var(--sp-theme-surface-raised);
    border-color: var(--sp-theme-border-strong);
}

/* Editable page wrapper */
.editable-page-wrapper {
    position: relative;
}

.editable-page {
    min-height: 200px;
}

/* Editable row wrapper */
.editable-row-wrapper {
    position: relative;
    margin-bottom: 32px;
    padding: 16px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.editable-row-wrapper:hover {
    background-color: var(--sp-theme-surface-raised);
}

/* Hover states for better UX */
.edit-toolbar button:hover {
    transform: translateY(-1px);
    box-shadow: var(--sp-shadow-md);
}

/* ===== Modal System ===== */

/* Modal backdrop - full viewport overlay */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--sp-theme-overlay-backdrop);
    z-index: calc(var(--sp-modal-layer, 1100) + var(--sp-modal-stack, 0));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Navigation controls must not overlay or activate through a dialog. */
body:has(.modal-backdrop > .modal-container[role="dialog"]) .mobile-sidebar-toggle {
    visibility: hidden;
    pointer-events: none;
}

/* Modal container - centered content box */
.modal-container {
    background: var(--sp-gradient-surface-panel);
    border-radius: 8px;
    box-shadow: var(--sp-shadow-overlay);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
    z-index: 1001;
}

/* Modal slide-in animation */
@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal header */
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--sp-theme-border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modal body */
.modal-body {
    padding: 24px;
}

/* Modal footer */
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--sp-theme-border-default);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form fields in modals - better spacing */
.modal-body .form-field {
    margin-bottom: 24px;
}

.modal-body .form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--sp-theme-text-default);
}

.modal-body .form-input,
.modal-body .form-textarea,
.modal-body .form-select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--sp-theme-border-strong);
    border-radius: 4px;
    font-size: 1rem;
}

.modal-body .form-input:focus,
.modal-body .form-textarea:focus,
.modal-body .form-select:focus {
    outline: none;
    border-color: var(--sp-theme-accent);
    box-shadow: var(--sp-shadow-focus);
}

/* Mobile: Full screen modal */
@media (max-width: 768px) {
    .modal-container {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-backdrop {
        padding: 0;
    }
}

/* ===== New Components ===== */

/* ----- Spinner Component ----- */
.spinner {
    display: inline-block;
    border: 3px solid rgba(93, 116, 165, 0.25);
    border-top-color: var(--sp-theme-accent-strong);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner.spinner-md {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.spinner.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

.spinner-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.spinner-message {
    color: var(--sp-theme-text-muted);
    font-size: 0.95rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----- ProgressBar Component ----- */
.progress,
.progress-bar-container {
    width: 100%;
    background: linear-gradient(180deg, #dce6f7 0%, #cfdcf2 100%);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 999px;
    overflow: hidden;
    height: 20px;
    margin: 10px 0;
    box-shadow: inset 0 1px 2px rgba(22, 37, 64, 0.12);
}

.progress-bar {
    height: 100%;
    --sp-progress-fill: linear-gradient(180deg, #3056ca 0%, #2446b5 100%);
    background: var(--sp-progress-fill);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
}

.progress-bar.progress-primary {
    --sp-progress-fill: linear-gradient(180deg, #3056ca 0%, #2446b5 100%);
}

.progress-bar.progress-success {
    --sp-progress-fill: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    color: #111827;
}

.progress-bar.progress-warning {
    --sp-progress-fill: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    color: #111827;
}

.progress-bar.progress-error {
    --sp-progress-fill: linear-gradient(180deg, #f05252 0%, #ef4444 100%);
    color: #111827;
}

.progress-bar.progress-info {
    --sp-progress-fill: linear-gradient(180deg, #38bdf8 0%, #028ccc 100%);
    color: #111827;
}

.progress-bar.progress-bar-striped,
.progress-bar.progress-striped {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    ), var(--sp-progress-fill);
    background-size: 20px 20px, 100% 100%;
}

.progress-bar.progress-bar-animated,
.progress-bar.progress-animated {
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    0% { background-position: 20px 0, 0 0; }
    100% { background-position: 0 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar {
        transition: none;
    }
    .progress-bar.progress-bar-animated,
    .progress-bar.progress-animated {
        animation: none;
    }
}

/* ----- Blockquote Component ----- */
blockquote.blockquote {
    padding: 20px 30px;
    margin: 20px 0;
    border-left: 4px solid var(--sp-theme-accent);
    background-color: var(--sp-theme-surface-raised);
    font-style: italic;
    color: var(--sp-theme-text-muted);
}

blockquote.blockquote p {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    line-height: 1.6;
}

blockquote.blockquote p:last-child {
    margin-bottom: 0;
}

.blockquote-citation {
    display: block;
    margin-top: 15px;
    font-style: normal;
    font-weight: 600;
    color: var(--sp-theme-text-strong);
    font-size: 0.95rem;
}

.blockquote-citation::before {
    content: "— ";
}

.blockquote-source {
    display: block;
    margin-top: 5px;
    font-style: normal;
    font-weight: normal;
    color: var(--sp-theme-text-subtle);
    font-size: 0.9rem;
}

/* ----- Code Component ----- */
.code-inline {
    background-color: var(--sp-theme-surface-raised);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: var(--sp-theme-danger);
    border: 1px solid var(--sp-theme-border-default);
}

.code-block {
    background-color: var(--sp-theme-code-bg);
    color: var(--sp-theme-code-text);
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 15px 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--sp-theme-code-header);
    border-bottom: 1px solid var(--sp-theme-code-border);
    border-radius: 6px 6px 0 0;
}

.code-block-title {
    font-weight: 600;
    color: var(--sp-theme-code-text);
    font-size: 0.9rem;
}

.code-block-language {
    font-size: 0.85rem;
    color: var(--sp-theme-code-muted);
    text-transform: uppercase;
}

.code-block pre {
    margin: 0;
    white-space: pre;
    word-wrap: normal;
}

/* ----- Divider Component ----- */
.divider {
    border: none;
    margin: 20px 0;
}

.divider.divider-horizontal {
    border-top: 1px solid var(--sp-theme-border-soft);
    width: 100%;
}

.divider.divider-vertical {
    border-left: 1px solid var(--sp-theme-border-soft);
    height: 100%;
    display: inline-block;
    margin: 0 20px;
}

.divider.divider-thick {
    border-width: 2px;
}

.divider.divider-dashed {
    border-style: dashed;
}

.divider-with-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.divider-with-text::before,
.divider-with-text::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--sp-theme-border-soft);
}

.divider-with-text span {
    padding: 0 15px;
    color: var(--sp-theme-text-subtle);
    font-size: 0.9rem;
}

/* ----- Spacer Component ----- */
.spacer-vertical-small {
    height: 16px;
}

.spacer-vertical-medium {
    height: 32px;
}

.spacer-vertical-large {
    height: 48px;
}

.spacer-vertical-xl {
    height: 64px;
}

.spacer-horizontal-small {
    width: 16px;
    display: inline-block;
}

.spacer-horizontal-medium {
    width: 32px;
    display: inline-block;
}

.spacer-horizontal-large {
    width: 48px;
    display: inline-block;
}

.spacer-horizontal-xl {
    width: 64px;
    display: inline-block;
}

/* ===== New Modules ===== */

/* ----- Hero Module ----- */
.hero-module {
    position: relative;
    padding: 100px 40px;
    margin-bottom: 30px;
    background: var(--sp-gradient-hero);
    color: var(--sp-hero-text-color);
    overflow: hidden;
    text-align: center;
    border-radius: var(--sp-radius-hero);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.hero-module::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-module.hero-centered {
    text-align: center;
}

.hero-background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.2;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.hero-module.hero-centered .hero-content {
    margin: 0 auto;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 24px;
    line-height: 1.1;
    color: var(--sp-hero-text-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--sp-hero-subtitle-color);
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.hero-description {
    font-size: 1.2rem;
    margin-bottom: 40px;
    line-height: 1.8;
    color: var(--sp-hero-description-color);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.hero-module.hero-centered .hero-buttons {
    justify-content: center;
}

/* Hero-specific button styling */
.hero-module .btn {
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.hero-module .btn-primary {
    background: var(--sp-hero-button-primary-bg);
    background-color: var(--sp-hero-button-primary-bg);
    color: var(--sp-hero-button-primary-text);
    border: 1px solid rgba(188, 208, 255, 0.58);
}

.hero-module .btn-primary:visited {
    color: var(--sp-hero-button-primary-text);
}

.hero-module .btn-primary:hover {
    background: var(--sp-hero-button-primary-hover-bg);
    background-color: var(--sp-hero-button-primary-hover-bg);
    color: var(--sp-hero-button-primary-text);
    border-color: rgba(214, 226, 255, 0.72);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
}

.hero-module .btn-secondary {
    background-color: transparent;
    color: var(--sp-hero-text-color);
    border: 2px solid var(--sp-hero-button-secondary-border);
}

.hero-module .btn-secondary:hover {
    background-color: var(--sp-hero-button-secondary-hover-bg);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-module {
        padding: 60px 30px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.2rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }

    .hero-module .btn {
        width: 100%;
        max-width: 280px;
    }
}

/* ----- Stats Module ----- */
.stats-module {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    gap: 30px;
    margin-top: 20px;
}

.stats-grid.stats-cols-1 { grid-template-columns: 1fr; }
.stats-grid.stats-cols-2 { grid-template-columns: repeat(2, 1fr); }
.stats-grid.stats-cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid.stats-cols-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid.stats-cols-5 { grid-template-columns: repeat(5, 1fr); }
.stats-grid.stats-cols-6 { grid-template-columns: repeat(6, 1fr); }

.stat-item {
    text-align: center;
    padding: 25px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--sp-shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--sp-theme-accent);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--sp-theme-text-strong);
    margin-bottom: 5px;
}

.stat-description {
    font-size: 0.9rem;
    color: var(--sp-theme-text-subtle);
}

/* ----- Timeline Module ----- */
.timeline-module {
    margin-bottom: 0;
}

.timeline-vertical {
    position: relative;
    padding-left: 40px;
    margin-top: 20px;
}

.timeline-vertical::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--sp-theme-accent);
}

.timeline-event {
    position: relative;
    margin-bottom: 30px;
    padding-left: 25px;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--sp-theme-accent);
    border: 3px solid white;
    box-shadow: 0 0 0 2px var(--sp-theme-accent);
}

.timeline-date {
    font-weight: 700;
    color: var(--sp-theme-accent);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.timeline-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--sp-theme-text-strong);
    margin-bottom: 8px;
}

.timeline-description {
    color: var(--sp-theme-text-muted);
    line-height: 1.6;
}

.timeline-horizontal {
    display: flex;
    gap: 30px;
    overflow-x: auto;
    padding: 20px 0;
    margin-top: 20px;
}

.timeline-horizontal .timeline-event {
    flex: 0 0 250px;
    padding: 20px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 8px;
    border-top: 4px solid var(--sp-theme-accent);
}

.timeline-horizontal .timeline-event::before {
    display: none;
}

/* ----- Accordion Module ----- */
.accordion-module {
    margin-bottom: 0;
}

.accordion-item {
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 6px;
    margin-bottom: 10px;
}

.accordion-header {
    width: 100%;
    padding: 15px 20px;
    border-radius: 5px;
    background: var(--sp-gradient-surface-panel-muted);
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.accordion-header:hover {
    background: var(--sp-theme-surface-muted);
    color: var(--sp-theme-text-strong);
}

.accordion-header.active {
    border-radius: 5px 5px 0 0;
    background: var(--sp-theme-accent);
    color: var(--sp-theme-text-inverse);
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    overflow: visible;
}

.accordion-body {
    padding: 20px;
    background: var(--sp-gradient-surface-panel);
    line-height: 1.6;
    color: var(--sp-theme-text-muted);
    border-radius: 0 0 6px 6px;
}

@media (prefers-reduced-motion: reduce) {
    .accordion-header,
    .accordion-icon {
        transition: none;
    }
}

/* ----- Tabs Module ----- */
.tabs-module {
    margin-bottom: 0;
}

.tabs-container {
    margin-top: 20px;
}

.tab-nav {
    list-style: none;
    display: flex;
    border-bottom: 2px solid var(--sp-theme-border-soft);
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.tab-item {
    margin: 0;
}

.tab-button {
    padding: 12px 24px;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--sp-theme-text-subtle);
    transition: all 0.3s ease;
    position: relative;
    top: 2px;
}

.tab-button:hover {
    color: var(--sp-theme-accent);
    background-color: var(--sp-theme-surface-raised);
}

.tab-button.active {
    color: var(--sp-theme-accent);
    border-bottom-color: var(--sp-theme-accent);
    font-weight: 600;
}

.tab-panels {
    margin-top: 20px;
}

.tab-panel {
    display: none;
    padding: 20px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: 6px;
    animation: fadeIn 0.3s ease;
}

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

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

.tab-content {
    line-height: 1.6;
    color: var(--sp-theme-text-muted);
}

/* ----- Quote Module ----- */
.quote-module {
    margin: 0;
    padding: 20px 24px;
    background: var(--sp-gradient-surface-panel);
    border-left: 5px solid var(--sp-theme-accent);
    border-radius: 6px;
}

.quote-module.quote-centered {
    text-align: center;
    border-left: none;
    border-top: 5px solid var(--sp-theme-accent);
}

.quote-text {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--sp-theme-text-strong);
    margin-bottom: 20px;
    line-height: 1.6;
}

.quote-module.quote-large .quote-text {
    font-size: 1.75rem;
}

.quote-author {
    font-weight: 700;
    color: var(--sp-theme-accent);
    font-size: 1.1rem;
}

.quote-attribution {
    color: var(--sp-theme-text-subtle);
    font-size: 0.95rem;
    margin-top: 5px;
}

.quote-date {
    color: var(--sp-theme-text-soft);
    font-size: 0.9rem;
    margin-top: 5px;
    font-style: italic;
}

/* ----- Callout Module ----- */
.callout-module {
    margin-bottom: 0;
}

.callout {
    padding: 20px;
    border-radius: 6px;
    border-left: 5px solid;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    position: relative;
}

.callout-info {
    background-color: var(--sp-theme-info-soft);
    border-color: var(--sp-theme-info);
    color: var(--sp-theme-info-ink);
}

.callout-warning {
    background-color: var(--sp-theme-warning-soft);
    border-color: var(--sp-theme-warning);
    color: var(--sp-theme-warning-ink);
}

.callout-success {
    background-color: var(--sp-theme-success-soft);
    border-color: var(--sp-theme-success);
    color: var(--sp-theme-success-ink);
}

.callout-error {
    background-color: var(--sp-theme-danger-soft);
    border-color: var(--sp-theme-danger);
    color: var(--sp-theme-danger-ink);
}

.callout-note {
    background-color: var(--sp-theme-surface-muted);
    border-color: var(--sp-theme-text-subtle);
    color: var(--sp-theme-text-default);
}

.callout-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.callout-content {
    flex: 1;
}

.callout-title {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.callout-text {
    margin: 0;
    line-height: 1.6;
}

.callout-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.callout-close:hover {
    opacity: 1;
}

/* ----- Comparison Module ----- */
.comparison-module {
    margin-bottom: 0;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--sp-gradient-surface-panel);
    border: 1px solid var(--sp-theme-border-default);
    box-shadow: var(--sp-shadow-md);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table thead {
    background-color: var(--sp-theme-accent);
    color: white;
}

.comparison-table th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--sp-theme-accent-hover);
}

.comparison-table tbody tr {
    border-bottom: 1px solid var(--sp-theme-border-soft);
    transition: background-color 0.3s ease;
}

.comparison-table tbody tr:hover {
    background-color: var(--sp-theme-surface-raised);
}

.comparison-table tbody tr:last-child {
    border-bottom: none;
}

.comparison-table td {
    padding: 15px 20px;
    vertical-align: middle;
}

.comparison-row-label {
    font-weight: 600;
    color: var(--sp-theme-text-strong);
    background-color: var(--sp-theme-surface-raised);
}

.comparison-col-highlighted {
    background-color: var(--sp-theme-accent-soft);
    font-weight: 600;
    position: relative;
}

.comparison-table thead th.comparison-col-highlighted {
    background-color: var(--sp-theme-accent-hover);
}

.comparison-table thead th.comparison-col-highlighted::after {
    content: '★';
    margin-left: 8px;
    color: #ffd700;
}

/* ===== Chat Module ===== */
.chat-module-shell {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-4);
    padding: var(--sp-space-4);
    border: 1px solid var(--sp-theme-border-default);
    border-radius: var(--sp-radius-surface-lg);
    background: var(--sp-gradient-surface-card);
    box-shadow: var(--sp-shadow-sm);
}

.chat-module-transcript-region {
    max-height: 420px;
    overflow-y: auto;
    padding: var(--sp-space-3);
    border: 1px solid var(--sp-theme-border-soft);
    border-radius: var(--sp-radius-surface-md);
    background: rgba(255, 255, 255, 0.45);
}

.chat-transcript-view {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
}

.chat-transcript-empty {
    color: var(--sp-theme-text-muted);
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-2);
    padding: var(--sp-space-3);
    border: 1px solid var(--sp-theme-border-soft);
    border-radius: var(--sp-radius-surface-md);
    background: var(--sp-theme-surface-raised);
}

.chat-message-role-user {
    border-color: var(--sp-theme-accent-soft-strong);
    background: linear-gradient(180deg, #f3f7ff 0%, #e8efff 100%);
}

.chat-message-role-assistant {
    border-color: var(--sp-theme-border-soft);
    background: linear-gradient(180deg, #f7f9ff 0%, #eef3fd 100%);
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-space-2);
}

.chat-message-author {
    font-weight: 600;
    color: var(--sp-theme-text-strong);
}

.chat-message-timestamp {
    font-size: 0.82rem;
    color: var(--sp-theme-text-subtle);
}

.chat-message-body p {
    margin-bottom: 0;
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .stats-grid.stats-cols-3,
    .stats-grid.stats-cols-4,
    .stats-grid.stats-cols-5,
    .stats-grid.stats-cols-6 {
        grid-template-columns: 1fr;
    }

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

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .timeline-horizontal {
        flex-direction: column;
    }

    .timeline-horizontal .timeline-event {
        flex: 1 1 auto;
    }

    .tab-nav {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
        text-align: left;
    }

    .comparison-table {
        font-size: 0.9rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 10px 12px;
    }
}
