/* Eulumdat Editor Styles */

/* ============================================
   LIGHT THEME (default)
   ============================================ */
:root,
.theme-light {
    /* Base colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;

    /* Background and surface */
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --border: #e2e8f0;

    /* Text colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Tab colors */
    --tab-active: #2563eb;
    --tab-inactive: #94a3b8;

    /* Diagram colors - consistent across all visualizations */
    --diagram-bg: #ffffff;
    --diagram-surface: #fafafa;
    --diagram-legend-bg: rgba(255, 255, 255, 0.95);
    --diagram-grid: #e0e0e0;
    --diagram-grid-minor: #f0f0f0;
    --diagram-axis: #c0c0c0;
    --diagram-text: #333333;
    --diagram-text-secondary: #666666;
    --diagram-text-muted: #999999;

    /* C-plane line colors */
    --diagram-c0: #ef4444;    /* Red - C0/C180 */
    --diagram-c90: #3b82f6;   /* Blue - C90/C270 */
    --diagram-c45: #22c55e;   /* Green - C45/C225 */
    --diagram-c135: #f97316;  /* Orange - C135/C315 */

    /* C-plane fill colors (semi-transparent) */
    --diagram-c0-fill: rgba(239, 68, 68, 0.15);
    --diagram-c90-fill: rgba(59, 130, 246, 0.2);
    --diagram-c45-fill: rgba(34, 197, 94, 0.15);
    --diagram-c135-fill: rgba(249, 115, 22, 0.15);

    /* Zone colors (BUG/LCS) */
    --diagram-forward: #22c55e;  /* Green */
    --diagram-back: #3b82f6;     /* Blue */
    --diagram-uplight: #ef4444;  /* Red */

    /* Rating colors */
    --rating-good: #22c55e;
    --rating-ok: #eab308;
    --rating-warn: #f97316;
    --rating-bad: #ef4444;

    /* Rating background colors */
    --rating-bg-good: #dcfce7;
    --rating-bg-ok: #fef9c3;
    --rating-bg-warn: #ffedd5;
    --rating-bg-bad: #fee2e2;

    /* Zone fill colors */
    --zone-fill-good: #ecfdf5;
    --zone-fill-warn: #fef3c7;
    --zone-fill-danger: #fee2e2;
}

/* ============================================
   DARK THEME
   ============================================ */
.theme-dark {
    /* Base colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --error-color: #f87171;

    /* Background and surface */
    --background: #0f172a;
    --surface: #1e293b;
    --surface-elevated: #334155;
    --border: #334155;

    /* Text colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    /* Tab colors */
    --tab-active: #3b82f6;
    --tab-inactive: #64748b;

    /* Diagram colors - consistent across all visualizations */
    --diagram-bg: #1a1a2e;
    --diagram-surface: #16213e;
    --diagram-legend-bg: rgba(22, 33, 62, 0.95);
    --diagram-grid: #404060;
    --diagram-grid-minor: #2a2a4a;
    --diagram-axis: #606080;
    --diagram-text: #e0e0e0;
    --diagram-text-secondary: #bebebe;
    --diagram-text-muted: #808080;

    /* C-plane line colors (brighter for dark mode) */
    --diagram-c0: #f87171;    /* Red - C0/C180 */
    --diagram-c90: #60a5fa;   /* Blue - C90/C270 */
    --diagram-c45: #4ade80;   /* Green - C45/C225 */
    --diagram-c135: #fb923c;  /* Orange - C135/C315 */

    /* C-plane fill colors (semi-transparent, brighter for dark mode) */
    --diagram-c0-fill: rgba(248, 113, 113, 0.2);
    --diagram-c90-fill: rgba(96, 165, 250, 0.25);
    --diagram-c45-fill: rgba(74, 222, 128, 0.2);
    --diagram-c135-fill: rgba(251, 146, 60, 0.2);

    /* Zone colors (BUG/LCS - matching reference SVG) */
    --diagram-forward: #62c58a;  /* Green */
    --diagram-back: #42b4ff;     /* Blue */
    --diagram-uplight: #f87171;  /* Red */

    /* Rating colors */
    --rating-good: #4ade80;
    --rating-ok: #facc15;
    --rating-warn: #fb923c;
    --rating-bad: #f87171;

    /* Rating background colors (darker versions for dark mode) */
    --rating-bg-good: #166534;
    --rating-bg-ok: #854d0e;
    --rating-bg-warn: #9a3412;
    --rating-bg-bad: #991b1b;

    /* Zone fill colors (darker versions for dark mode) */
    --zone-fill-good: #14532d;
    --zone-fill-warn: #78350f;
    --zone-fill-danger: #7f1d1d;
}

/* Theme toggle button */
.theme-toggle {
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
    min-width: auto;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Global input styling for theme support */
input, select, textarea {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

.app {
    min-height: 100vh;
    background: var(--background);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app > * {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.app > header {
    padding-top: 1rem;
}

/* Mobile app container */
@media (max-width: 768px) {
    .app > * {
        padding: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .app > * {
        padding: 0 0.25rem;
    }
}

/* Header */
.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    white-space: nowrap;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* File Menu Dropdown */
.file-menu {
    position: relative;
}

.file-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-arrow {
    font-size: 0.7em;
    opacity: 0.7;
}

.file-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}

.file-menu:hover .file-menu-dropdown,
.file-menu:focus-within .file-menu-dropdown {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

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

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Submenu for templates */
.menu-submenu {
    position: relative;
}

.menu-submenu-toggle {
    cursor: default;
}

.submenu-arrow {
    font-size: 0.7em;
    opacity: 0.7;
}

.menu-submenu-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem 0;
    margin-left: 0.25rem;
}

.menu-submenu:hover .menu-submenu-content {
    display: block;
}

/* Templates dropdown - needs scrolling for many items */
.templates-dropdown {
    max-height: 400px;
    overflow-y: auto;
}

/* Mobile: Full-width dropdown */
@media (max-width: 768px) {
    .file-menu-dropdown {
        position: fixed;
        top: auto;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        min-width: auto;
    }

    .menu-submenu-content {
        position: static;
        border: none;
        box-shadow: none;
        margin-left: 1rem;
        padding-left: 0.5rem;
        border-left: 2px solid var(--border);
        max-height: 200px;
    }

    .menu-submenu:hover .menu-submenu-content,
    .menu-submenu .menu-submenu-content {
        display: block;
    }

    .submenu-arrow {
        transform: rotate(90deg);
    }
}

/* Tablet: Start compressing */
@media (max-width: 1100px) {
    .header-actions {
        gap: 0.4rem;
    }

    .header-actions > button,
    .header-actions > select {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
}

/* Mobile: Stack header */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .header h1 {
        text-align: center;
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.4rem;
    }

    .header-actions > button {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .language-selector-compact {
        min-width: 90px;
        font-size: 0.8rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem;
        border-radius: 6px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header-actions {
        gap: 0.3rem;
    }

    .header-actions > button {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    .language-selector-compact {
        min-width: 80px;
        font-size: 0.75rem;
    }
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

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

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

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

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

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

/* Main Layout - single column, full width */
.main-content {
    display: block;
    max-width: 100%;
}

/* Panels */
.panel {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.panel-body {
    padding: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tab {
    padding: 0.75rem 1.25rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--tab-inactive);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--tab-active);
    border-bottom-color: var(--tab-active);
    font-weight: 500;
}

/* Main tabs (primary navigation) */
.main-tabs {
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.main-tabs .tab {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.main-tabs .tab.active {
    border-bottom-color: var(--primary-color);
    border-bottom-width: 3px;
}

/* Sub-tabs (secondary navigation) */
.sub-tabs {
    background: var(--background);
    border-bottom: 1px solid var(--border);
    padding-left: 0.5rem;
}

.sub-tabs .tab {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 400;
    border-bottom-width: 2px;
}

.sub-tabs .tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    padding: 1rem;
}

/* Tablet: Smaller tabs */
@media (max-width: 1024px) {
    .tab {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
    }

    .main-tabs .tab {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .sub-tabs .tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
}

/* Mobile: Even smaller tabs, scrollable */
@media (max-width: 768px) {
    .tabs {
        flex-wrap: nowrap;
        gap: 0;
    }

    .tab {
        padding: 0.5rem 0.7rem;
        font-size: 0.75rem;
    }

    .main-tabs .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .sub-tabs {
        padding-left: 0.25rem;
    }

    .sub-tabs .tab {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .tab-content {
        padding: 0.75rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .main-tabs .tab {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .sub-tabs .tab {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .tab {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .tab-content {
        padding: 0.5rem;
    }
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    background: var(--surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input:read-only {
    background: var(--background);
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

/* Info Display */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

/* Mobile: Stack info grid */
@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}

.info-item {
    padding: 0.5rem;
    background: var(--background);
    border-radius: 4px;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.info-value {
    font-weight: 500;
}

/* Data Table */
.data-table-wrapper {
    display: flex;
    flex-direction: column;
}

.data-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.data-table-container {
    overflow: auto;
    max-height: 500px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.data-table {
    width: max-content;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.data-table th,
.data-table td {
    padding: 0.2rem 0.3rem;
    border: 1px solid var(--border);
    text-align: right;
}

.data-table th {
    background: var(--background);
    font-weight: 500;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table .angle-header {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 40px;
}

.data-table .c-angle-header {
    min-width: 45px;
    font-family: 'SF Mono', Monaco, monospace;
}

.data-table .g-angle-header {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--background);
    font-family: 'SF Mono', Monaco, monospace;
    min-width: 40px;
}

.data-table td {
    padding: 0;
}

.data-table .intensity-input {
    width: 45px;
    text-align: right;
    border: none;
    background: transparent;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
    color: var(--text-primary);
}

.data-table .intensity-input:focus {
    background: var(--surface-elevated);
    outline: none;
}

.data-table tr:hover td {
    background: var(--background);
}

.data-table tr:hover .intensity-input {
    background: var(--background);
}

/* Diagram Toggle */
.diagram-toggle {
    display: flex;
    gap: 2px;
    background: var(--background);
    padding: 2px;
    border-radius: 6px;
}

.btn-toggle {
    padding: 0.25rem 0.75rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-toggle:hover {
    color: var(--text-primary);
}

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

/* Responsive diagram toggle */
@media (max-width: 480px) {
    .diagram-toggle {
        gap: 1px;
        padding: 1px;
    }

    .btn-toggle {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Polar Diagram */
.polar-diagram {
    width: 100%;
    aspect-ratio: 1;
    background: var(--surface);
    border-radius: 8px;
}

.polar-diagram svg {
    width: 100%;
    height: 100%;
}

/* Cartesian Diagram */
.cartesian-diagram {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
}

.cartesian-diagram svg {
    width: 100%;
    height: auto;
}

/* Validation Messages */
.validation-panel {
    max-height: 200px;
    overflow-y: auto;
}

.validation-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.validation-item.warning {
    background: var(--rating-bg-ok);
    color: var(--text-primary);
}

.validation-item.error {
    background: var(--rating-bg-bad);
    color: var(--text-primary);
}

.validation-item.success {
    background: var(--rating-bg-good);
    color: var(--text-primary);
}

.validation-code {
    font-weight: 600;
    font-family: monospace;
}

/* Schema Validation Styles */
.schema-validation-section,
.ldt-validation-section {
    margin-bottom: 0.75rem;
}

.validation-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.validation-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.75rem 0;
}

.schema-badge {
    font-family: monospace;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    min-width: 55px;
    text-align: center;
}

.error-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.tm33-errors {
    margin-top: 0.5rem;
    margin-left: 0.5rem;
}

.tm33-errors summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tm33-errors summary:hover {
    color: var(--text-secondary);
}

.error-details {
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
}

.validation-item.small {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
}

.validation-item.small .validation-code {
    font-size: 0.65rem;
}

/* Lamp Sets */
.lamp-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.lamp-set-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.lamp-set-tab {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
    font-size: 0.8rem;
}

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

.btn-add-lamp {
    padding: 0.5rem 1rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Direct Ratios */
.ratios-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.ratio-item {
    text-align: center;
}

.ratio-item label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.ratio-item input {
    width: 100%;
    text-align: center;
    padding: 0.25rem;
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.drop-zone.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Tablet: Smaller dropzone */
@media (max-width: 768px) {
    .drop-zone {
        padding: 0.75rem;
    }

    .drop-zone p {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
}

/* Mobile: Hide dropzone (drag & drop not useful on touch devices) */
@media (max-width: 600px) {
    .drop-zone {
        display: none;
    }
}

/* File Info */
.file-info {
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.file-info strong {
    color: var(--primary-color);
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.hidden {
    display: none;
}

/* Intensity Tab Layout */
.intensity-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.intensity-diagram-section {
    background: var(--background);
    border-radius: 8px;
    padding: 0.75rem;
}

.diagram-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.diagram-title {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Responsive diagram header */
@media (max-width: 600px) {
    .diagram-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .diagram-title {
        font-size: 0.85rem;
    }

    .diagram-controls,
    .text-muted {
        font-size: 0.7rem;
    }
}

.diagram-container {
    display: flex;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

.intensity-table-section {
    background: var(--background);
    border-radius: 8px;
    padding: 0.75rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.table-info {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 2D Diagram Tab */
.diagram-2d-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.diagram-container-large {
    display: flex;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

/* Full-width diagram container */
.diagram-fullwidth {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.diagram-fullwidth .polar-diagram,
.diagram-fullwidth .cartesian-diagram {
    width: 100%;
    max-width: 700px;
}

.diagram-fullwidth .polar-diagram svg,
.diagram-fullwidth .cartesian-diagram svg {
    width: 100%;
    height: auto;
}

/* Responsive diagram container */
@media (max-width: 768px) {
    .diagram-fullwidth {
        min-height: 400px;
        padding: 0.5rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .diagram-fullwidth {
        min-height: 300px;
        padding: 0.25rem;
    }

    .diagram-fullwidth .polar-diagram,
    .diagram-fullwidth .cartesian-diagram {
        max-width: 100%;
    }
}

/* ============================================
   RESPONSIVE SVG DETAIL LEVELS

   These rules work with DetailLevel classes embedded
   in SVGs generated by to_svg_responsive().

   The SVGs contain embedded media queries too, but
   these container-based rules provide additional
   control for the web app.
   ============================================ */

/* Auto-sizing SVG container */
.svg-responsive {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.svg-responsive svg {
    width: 100%;
    height: auto;
    max-height: 100%;
}

/* Container query for auto-adjusting detail levels */
/* Note: Container queries require modern browsers */
@container (max-width: 400px) {
    .svg-responsive svg .detail-full {
        display: none;
    }
}

@container (max-width: 300px) {
    .svg-responsive svg .detail-compact,
    .svg-responsive svg .detail-full {
        display: none;
    }
}

/* Fallback media queries for browsers without container query support */
@media (max-width: 400px) {
    .diagram-fullwidth svg .detail-full,
    .polar-diagram svg .detail-full,
    .cartesian-diagram svg .detail-full {
        display: none;
    }
}

@media (max-width: 300px) {
    .diagram-fullwidth svg .detail-compact,
    .diagram-fullwidth svg .detail-full,
    .polar-diagram svg .detail-compact,
    .polar-diagram svg .detail-full,
    .cartesian-diagram svg .detail-compact,
    .cartesian-diagram svg .detail-full {
        display: none;
    }
}

/* Zoomable diagram with overlay controls */
.diagram-zoomable {
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.diagram-zoomable:active {
    cursor: grabbing;
}

.diagram-zoomable .polar-diagram,
.diagram-zoomable .cartesian-diagram {
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

/* Diagram controls header */
.diagram-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.zoom-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive zoom hint */
@media (max-width: 600px) {
    .zoom-hint {
        font-size: 0.65rem;
    }
}

/* Diagram Zoom Component */
.diagram-zoom-container {
    position: relative;
    width: 100%;
    min-height: 550px;
    overflow: hidden;
    background: var(--background);
    border-radius: 8px;
    cursor: grab;
}

.diagram-zoom-container:active {
    cursor: grabbing;
}

/* Responsive diagram zoom container */
@media (max-width: 768px) {
    .diagram-zoom-container {
        min-height: 450px;
    }
}

@media (max-width: 480px) {
    .diagram-zoom-container {
        min-height: 350px;
        border-radius: 6px;
    }
}

.diagram-zoom-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
    transition: none;
}

.diagram-zoom-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: var(--text-secondary);
}

.zoom-level {
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.zoom-reset-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-primary);
    transition: background 0.15s;
}

.zoom-reset-btn:hover {
    background: var(--background);
}

/* Heatmap Tab */
.heatmap-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Spectral Tab */
.spectral-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spectral-diagram-container {
    width: 100%;
}

.spectral-diagram {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.spectral-diagram svg {
    width: 100%;
    height: auto;
}

.spectral-no-data {
    text-align: center;
    padding: 1rem;
}

.spectral-no-data .sample {
    margin-top: 1rem;
}

.spectral-info {
    text-align: center;
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #22c55e;
    color: white;
}

.badge-info {
    background: #3b82f6;
    color: white;
}

.badge-warning {
    background: #f59e0b;
    color: white;
}

.badge-secondary {
    background: #6b7280;
    color: white;
}

.badge-danger {
    background: #ef4444;
    color: white;
    animation: pulse 2s infinite;
}

.badge-ir {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    color: white;
}

.badge-uv {
    background: linear-gradient(135deg, #7c3aed, #4c1d95);
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.spectral-diagrams-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.diagram-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.diagram-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.diagram-section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.spectral-diagram,
.greenhouse-diagram {
    width: 100%;
    display: flex;
    justify-content: center;
}

.spectral-diagram svg,
.greenhouse-diagram svg {
    max-width: 100%;
    height: auto;
}

.hint-text {
    text-align: center;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Spectral Sub-tabs */
.spectral-tab-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spectral-sub-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface);
    border-radius: 8px;
    flex-wrap: wrap;
}

.sub-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sub-tab:hover {
    background: var(--background);
    color: var(--text-primary);
}

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

.sub-tab-badges {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.spectral-sub-content {
    background: var(--surface);
    border-radius: 8px;
    padding: 1rem;
}

/* SPD Diagram Container */
.spd-diagram-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.diagram-svg {
    width: 100%;
    display: flex;
    justify-content: center;
}

.diagram-svg svg {
    max-width: 100%;
    height: auto;
}

/* TM-30 Summary (inline metrics on SPD tab) */
.tm30-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.tm30-metric-inline {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.tm30-metric-inline .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tm30-metric-inline .value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* TM-30 CVG Container */
.tm30-cvg-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.tm30-cvg-diagram {
    display: flex;
    justify-content: center;
}

.tm30-cvg-legend {
    text-align: center;
    max-width: 500px;
}

.tm30-cvg-legend p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
}

/* TM-30 Hue Container */
.tm30-hue-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tm30-hue-diagram {
    display: flex;
    justify-content: center;
}

.tm30-hue-details {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
}

.tm30-hue-table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tm30-hue-table th,
.tm30-hue-table td {
    padding: 0.35rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.tm30-hue-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
}

.tm30-hue-table tbody tr:hover {
    background: var(--background);
}

.tm30-legend {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tm30-legend p {
    margin: 0.25rem 0;
}

/* TM-30 Report (legacy, can be removed) */
.tm30-report {
    margin-top: 1.5rem;
}

.tm30-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    justify-content: center;
}

.tm30-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.tm30-metric .metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tm30-metric .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.tm30-diagrams {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: flex-start;
}

.tm30-cvg,
.tm30-hue-chart {
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tm30-cvg svg,
.tm30-hue-chart svg {
    max-width: 100%;
    height: auto;
}

@media (max-width: 900px) {
    .tm30-diagrams {
        flex-direction: column;
        align-items: center;
    }
}

/* ============================================
   SPECTRAL METRICS DISPLAY
   ============================================ */
.spectral-metrics-container {
    padding: 1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.metric-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.metric-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.metric-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Energy Distribution Bars */
.energy-bars,
.par-bars,
.hort-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.energy-row,
.par-row,
.hort-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.energy-label,
.par-label,
.hort-label {
    width: 60px;
    font-size: 0.8rem;
    font-weight: 500;
}

.energy-bar,
.par-bar {
    height: 16px;
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.3s ease;
}

.energy-value,
.par-value,
.hort-value {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

/* Energy bar colors */
.uv-bar {
    background: linear-gradient(90deg, #7c3aed, #4c1d95);
}

.visible-bar {
    background: linear-gradient(90deg, #7c3aed, #3b82f6, #22c55e, #eab308, #ef4444);
}

.ir-bar {
    background: linear-gradient(90deg, #b91c1c, #7f1d1d);
}

/* PAR bar colors */
.par-label.blue { color: #3b82f6; }
.par-label.green { color: #22c55e; }
.par-label.red { color: #ef4444; }

.blue-bar { background: #3b82f6; }
.green-bar { background: #22c55e; }
.red-bar { background: #ef4444; }

/* Warning card */
.warning-card {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fecaca;
}

.theme-dark .warning-card {
    background: linear-gradient(135deg, #450a0a, #7f1d1d);
    border-color: #991b1b;
}

.warning-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.warning-item.thermal {
    background: rgba(239, 68, 68, 0.1);
}

.warning-item.uv {
    background: rgba(124, 58, 237, 0.1);
}

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

.intensity-heatmap {
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.intensity-heatmap svg {
    width: 100%;
    height: auto;
    display: block;
}

.intensity-heatmap .no-data {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* BUG Rating Tab */
.bug-rating-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bug-rating-container {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.bug-rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.bug-rating-header h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.bug-rating-edit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rating-inputs {
    display: flex;
    gap: 0.5rem;
}

.rating-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rating-input-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.rating-input-group input {
    width: 45px;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.2s;
    background: var(--surface);
    color: var(--text-primary);
}

.rating-input-group input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.rating-input-group input::-webkit-inner-spin-button,
.rating-input-group input::-webkit-outer-spin-button {
    opacity: 1;
}

.bug-rating-value {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 2px solid;
}

.bug-rating-svg-container {
    width: 100%;
    overflow-x: auto;
    background: var(--diagram-bg);
    border-radius: 8px;
    padding: 0.5rem;
}

.bug-rating-svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* LCS View Layout - diagram on left, tables on right in single SVG */
.bug-rating-content.lcs-layout {
    width: 100%;
}

.bug-rating-content.lcs-layout .lcs-svg {
    width: 100%;
    max-width: 510px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* BUG Rating content layout */
.bug-rating-content {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.bug-rating-diagram {
    flex: 1 1 300px;
    min-width: 280px;
}

.bug-rating-diagram svg {
    width: 100%;
    height: auto;
}

.bug-rating-tables {
    flex: 1 1 250px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bug-rating-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Cone Diagram Tab */
.cone-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cone-diagram {
    width: 100%;
    aspect-ratio: 5/4;
    background: var(--surface);
    border-radius: 8px;
}

.cone-diagram svg {
    width: 100%;
    height: 100%;
}

.mounting-height-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 6px;
    font-size: 0.85rem;
}

.mounting-height-control label {
    color: var(--text-secondary);
    white-space: nowrap;
}

.mounting-height-control input[type="range"] {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

.mounting-height-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.mounting-height-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.mounting-height-control .value-display {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

@media (max-width: 600px) {
    .mounting-height-control {
        flex-wrap: wrap;
        justify-content: center;
    }

    .mounting-height-control input[type="range"] {
        width: 100%;
        order: 3;
    }
}

/* 3D Diagram Tab */
.diagram-3d-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.diagram-3d-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background: var(--background);
    border: 2px dashed var(--border);
    border-radius: 8px;
}

.diagram-3d-placeholder .placeholder-content {
    text-align: center;
    color: var(--text-secondary);
}

.diagram-3d-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.diagram-3d-placeholder h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.diagram-3d-placeholder p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.diagram-3d-placeholder .hint {
    font-size: 0.8rem;
    font-style: italic;
}

/* Validation Tab */
.validation-tab {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

.validation-section,
.summary-section {
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.validation-section h3,
.summary-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.info-grid-wide {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .info-grid-wide {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Butterfly Diagram */
.butterfly-diagram {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.butterfly-diagram svg {
    width: 100%;
    height: auto;
    display: block;
}

/* 3D Canvas Container */
.butterfly-3d-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.butterfly-3d-canvas {
    width: 100%;
    height: 600px;
    display: block;
    cursor: grab;
}

.butterfly-3d-canvas:active {
    cursor: grabbing;
}

.butterfly-3d-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

.butterfly-3d-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.butterfly-3d-controls button {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 12px;
}

.butterfly-3d-controls button:hover {
    background: var(--background);
}

/* Responsive 3D canvas */
@media (max-width: 768px) {
    .butterfly-3d-canvas {
        height: 450px;
    }

    .butterfly-3d-overlay {
        font-size: 10px;
    }

    .butterfly-3d-controls button {
        padding: 4px 8px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .butterfly-3d-canvas {
        height: 350px;
    }

    .butterfly-3d-controls {
        bottom: 5px;
        right: 5px;
        gap: 3px;
    }

    .butterfly-3d-controls button {
        padding: 3px 6px;
        font-size: 9px;
    }
}

/* Scene container responsive */
.scene-container {
    width: 100%;
    min-height: 400px;
}

@media (max-width: 768px) {
    .scene-container {
        min-height: 350px;
    }

    .scene-controls {
        font-size: 0.7rem;
    }

    .scene-controls p {
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .scene-container {
        min-height: 280px;
    }
}

/* ============================================
   CALCULATED PHOTOMETRIC SUMMARY
   ============================================ */
.calculated-summary {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    background: linear-gradient(to bottom, var(--background), transparent);
    padding: 1.5rem;
    border-radius: 8px;
}

.calculated-summary .summary-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculated-summary .summary-header::before {
    content: "⚡";
    font-size: 0.875rem;
}

.calculated-summary .text-small {
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.calculated-summary .subsection-header {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--border);
}

.calculated-summary .info-grid-wide {
    background: var(--surface);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.calculated-summary .info-item {
    background: transparent;
}

.calculated-summary .info-value.mono {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    letter-spacing: 0.05em;
}

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */
.language-selector {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 120px;
}

.language-selector:hover {
    border-color: var(--primary-color);
}

.language-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Compact language selector (dropdown style) */
.language-selector-compact {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 100px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1em;
    padding-right: 1.8rem;
}

.language-selector-compact:hover {
    border-color: var(--primary-color);
}

.language-selector-compact:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Header language selector - styles moved to main header section */

/* ============================================
   ABOUT MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modal-appear 0.2s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.about-modal h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.75rem;
    color: var(--text-primary);
    font-weight: 700;
}

.about-subtitle {
    margin: 0 0 1.25rem 0;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 500;
}

.about-description {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.about-description p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

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

.about-highlight {
    color: var(--text-primary) !important;
    font-weight: 600;
    margin-top: 0.75rem !important;
}

.about-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.about-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.about-links a:hover {
    text-decoration: underline;
}

.about-version {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: monospace;
}

.about-modal .btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}
