* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--mg-font-body, 'Barlow', system-ui, sans-serif);
    background: #fafaf8;
    color: #14161c;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-footer {
    margin-top: 0;
    flex-shrink: 0;
    flex-grow: 0;
}

.page-header {
    text-align: center;
    padding: 48px 24px 8px;
}

.page-header h1 {
    font-family: var(--mg-font-display, 'Rajdhani', system-ui, sans-serif);
    font-size: 2rem;
    color: #0a1a0d;
    margin: 0 0 8px;
}

.page-header p {
    font-size: 1.05rem;
    color: #555;
    margin: 0;
}

.page-header code {
    font-family: var(--mg-font-mono, 'JetBrains Mono', monospace);
    font-size: 0.85em;
    background: #f0ede6;
    padding: 2px 6px;
    border-radius: 3px;
}

.page-header__breadcrumb {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.page-header__breadcrumb a {
    color: #2a5a3a;
    text-decoration: none;
}

.page-header__breadcrumb a:hover {
    color: #4cdf7a;
}

/* Sections */
.demo-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 0;
    overflow: hidden;
}

.demo-section:last-of-type {
    padding-bottom: 48px;
    flex-grow: 1;
}

.demo-section__title {
    font-family: var(--mg-font-display, 'Rajdhani', system-ui, sans-serif);
    font-size: 1.4rem;
    color: #1a3322;
    margin: 0 0 6px;
    padding-top: 20px;
    border-top: 1px solid #e6e3d8;
}

.demo-section:first-of-type .demo-section__title {
    border-top: none;
    padding-top: 0;
}

.demo-section__desc {
    font-size: 0.95rem;
    color: #555;
    margin: 0 0 20px;
    line-height: 1.5;
}

.demo-section__desc code {
    font-family: var(--mg-font-mono, 'JetBrains Mono', monospace);
    font-size: 0.85em;
    background: #f0ede6;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Gallery grid */
.demo-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Panels */
.demo-panel {
    background: #fff;
    border: 1px solid #e6e3d8;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.demo-panel--wide {
    flex: 1;
    min-width: 0;
}

.demo-panel__header {
    padding: 10px 14px;
    background: #f5f4ef;
    border-bottom: 1px solid #e6e3d8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.demo-panel__header--bottom {
    border-bottom: none;
    border-top: 1px solid #e6e3d8;
}

.demo-panel__header h3 {
    margin: 0;
    font-family: var(--mg-font-display, 'Rajdhani', system-ui, sans-serif);
    font-size: 14px;
    font-weight: 600;
    color: #1a3322;
}

.demo-panel__canvas {
    width: 100%;
    height: 320px;
    position: relative;
    background: #1a2e1f;
}

.demo-panel__canvas--short {
    height: 240px;
}

.demo-panel__canvas--gallery {
    height: 200px;
}

.demo-panel__caption {
    padding: 8px 14px;
    margin: 0;
    font-size: 0.8rem;
    color: #777;
    background: #f9f8f5;
    border-top: 1px solid #e6e3d8;
    line-height: 1.4;
}

.demo-panel__caption code {
    font-family: var(--mg-font-mono, 'JetBrains Mono', monospace);
    font-size: 0.85em;
    background: #f0ede6;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Gallery panel style selector */
.demo-panel__style-bar {
    padding: 6px 10px;
    background: #f9f8f5;
    border-top: 1px solid #e6e3d8;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.demo-style-btn {
    padding: 2px 8px;
    font-size: 10px;
    font-family: var(--mg-font-body, 'Barlow', system-ui, sans-serif);
    border: 1px solid #e6e3d8;
    border-radius: 3px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.12s;
}

.demo-style-btn:hover {
    border-color: #4cdf7a;
    color: #1a3322;
}

.demo-style-btn.active {
    background: #4cdf7a;
    border-color: #4cdf7a;
    color: #0a1a0d;
    font-weight: 600;
}

/* Controls */
.demo-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.demo-btn {
    padding: 5px 12px;
    font-family: var(--mg-font-body, 'Barlow', system-ui, sans-serif);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #e6e3d8;
    border-radius: 4px;
    background: #fff;
    color: #1a3322;
    cursor: pointer;
    transition: all 0.15s;
}

.demo-btn:hover {
    background: #4cdf7a;
    color: #0a1a0d;
    border-color: #4cdf7a;
}

.demo-btn:active {
    background: #3ab868;
    border-color: #3ab868;
}

.demo-btn--accent {
    background: #1a3322;
    color: #4cdf7a;
    border-color: #1a3322;
}

.demo-btn--accent:hover {
    background: #4cdf7a;
    color: #0a1a0d;
}

.demo-btn--active {
    background: #4cdf7a;
    color: #0a1a0d;
    border-color: #4cdf7a;
}

.demo-input {
    padding: 5px 10px;
    font-family: var(--mg-font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    border: 1px solid #e6e3d8;
    border-radius: 4px;
    background: #fff;
    color: #14161c;
    width: 140px;
}

.demo-input:focus {
    outline: none;
    border-color: #4cdf7a;
    box-shadow: 0 0 0 2px rgba(76, 223, 122, 0.15);
}

/* Split layout (map + sidebar) */
.demo-split {
    display: flex;
    gap: 16px;
}

.demo-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.demo-info-panel {
    background: #fff;
    border: 1px solid #e6e3d8;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.demo-info-panel h4 {
    margin: 0;
    padding: 8px 12px;
    font-family: var(--mg-font-display, 'Rajdhani', system-ui, sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: #1a3322;
    background: #f5f4ef;
    border-bottom: 1px solid #e6e3d8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.demo-info-content {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.5;
}

.demo-info-content strong {
    color: #1a3322;
}

.demo-log {
    padding: 8px 12px;
    font-family: var(--mg-font-mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    line-height: 1.5;
    color: #4cdf7a;
    background: #0a1a0d;
    height: 120px;
    overflow-y: auto;
}

/* Grids */
.demo-grid--three {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.demo-grid--four {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Code snippets */
.demo-code {
    margin-top: 16px;
    border-radius: 8px;
    overflow: hidden;
}

.demo-code--above {
    margin-top: 0;
    margin-bottom: 16px;
}

.demo-code summary {
    font-family: var(--mg-font-body, 'Barlow', system-ui, sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: #2a5a3a;
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
}

.demo-code summary::-webkit-details-marker {
    display: none;
}

.demo-code summary::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 6px;
    font-size: 9px;
    transition: transform 0.15s;
}

.demo-code[open] summary::before {
    transform: rotate(90deg);
}

.demo-code pre[class*="language-"] {
    margin: 0;
    border-radius: 0 0 8px 8px;
    font-size: 12px;
}

.demo-code[open] pre[class*="language-"] {
    border-radius: 8px;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 1024px) {
    .demo-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    .demo-split {
        flex-direction: column;
    }

    .demo-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .demo-info-panel {
        flex: 1;
        min-width: 200px;
    }
}

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

    .demo-grid--three,
    .demo-grid--four {
        grid-template-columns: 1fr;
    }

    .demo-section {
        padding: 32px 16px 0;
    }

    .page-header {
        padding: 32px 16px 8px;
    }

    .page-header h1 {
        font-size: 1.6rem;
    }

    .demo-sidebar {
        flex-direction: column;
    }

    .demo-info-panel {
        min-width: auto;
    }
}
