/* macOS-style GLDF Viewer */

/* CSS Variables for macOS Dark Mode */
:root {
    --bg-window: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-content: #1e1e1e;
    --bg-card: #2d2d2d;
    --bg-card-hover: #363636;
    --bg-input: #3c3c3c;
    --bg-table-header: #252526;

    --border-color: #3d3d3d;
    --border-subtle: #2d2d2d;

    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;

    --accent-blue: #0a84ff;
    --accent-blue-hover: #409cff;
    --accent-orange: #ff9f0a;
    --accent-yellow: #ffd60a;
    --accent-green: #30d158;
    --accent-purple: #bf5af2;
    --accent-red: #ff453a;
    --accent-cyan: #64d2ff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;

    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Mono", Menlo, Monaco, Consolas, monospace;

    --sidebar-width: 220px;
}

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

html, body {
    font-family: var(--font-family);
    background: var(--bg-window);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    max-width: 100vw;
}

/* App Container - Split View Layout */
/* Note: Final #wrapper styles are at bottom of file for specificity */

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h1 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header h1 .icon {
    color: var(--accent-orange);
}

.sidebar-section {
    padding: 12px 0;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 16px 8px;
}

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

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 6px;
    margin: 0 8px;
    font-size: 13px;
    position: relative;
    z-index: 1;
}

.sidebar-nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: var(--accent-blue);
    color: white;
}

.sidebar-nav-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-nav-item .badge {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-tertiary);
}

.sidebar-nav-item.active .badge {
    color: rgba(255,255,255,0.7);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    min-height: 0; /* Important for flex children with overflow */
}

/* Content Header/Toolbar */
.content-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-content);
    display: flex;
    align-items: center;
    gap: 16px;
}

.content-title {
    font-size: 20px;
    font-weight: 600;
}

.toolbar-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

/* Content Body */
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Welcome View (No file loaded) */
.welcome-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    text-align: center;
    padding: 48px;
}

.welcome-icon {
    font-size: 80px;
    color: var(--text-tertiary);
    margin-bottom: 24px;
    transition: color 0.3s ease;
}

.welcome-view.dragging .welcome-icon {
    color: var(--accent-blue);
}

.welcome-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.welcome-divider {
    width: 200px;
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.welcome-instructions {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 8px;
}

.welcome-or {
    color: var(--text-tertiary);
    font-size: 13px;
    margin: 12px 0;
}

.welcome-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
}

.drop-zone:hover,
.drop-zone.dragging {
    border-color: var(--accent-blue);
    background: rgba(10, 132, 255, 0.05);
}

.drop-zone .icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.drop-zone:hover .icon,
.drop-zone.dragging .icon {
    color: var(--accent-blue);
}

.drop-zone p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    font-family: var(--font-family);
}

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

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

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

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

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

.btn-outline:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

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

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px 8px;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header .icon {
    font-size: 18px;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}

.card-header .badge {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-body {
    padding: 20px;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.stat-card .icon {
    font-size: 28px;
    margin-bottom: 12px;
}

.stat-card .icon.blue { color: var(--accent-blue); }
.stat-card .icon.yellow { color: var(--accent-yellow); }
.stat-card .icon.purple { color: var(--accent-purple); }
.stat-card .icon.orange { color: var(--accent-orange); }
.stat-card .icon.green { color: var(--accent-green); }

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Product Info Card */
.product-info-card {
    margin-bottom: 24px;
}

.product-info-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 16px;
}

.product-info-header .icon {
    font-size: 40px;
    color: var(--accent-orange);
}

.product-info-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.product-info-header .format-version {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-row .label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.info-row .value {
    font-size: 14px;
}

/* Content Columns Layout */
.content-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.content-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Collapsible Sections */
.collapsible {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.collapsible-header:hover {
    background: var(--bg-card-hover);
}

.collapsible-header .icon {
    font-size: 16px;
}

.collapsible-header .icon.blue { color: var(--accent-blue); }
.collapsible-header .icon.yellow { color: var(--accent-yellow); }
.collapsible-header .icon.purple { color: var(--accent-purple); }
.collapsible-header .icon.orange { color: var(--accent-orange); }
.collapsible-header .icon.green { color: var(--accent-green); }

.collapsible-header h4 {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.collapsible-header .count {
    font-size: 13px;
    color: var(--text-secondary);
}

.collapsible-header .chevron {
    color: var(--text-tertiary);
    font-size: 12px;
    transition: transform 0.2s ease;
}

.collapsible.open .chevron {
    transform: rotate(90deg);
}

.collapsible-content {
    padding: 0 16px 16px;
}

/* File List Items */
.file-category {
    margin-bottom: 12px;
}

.file-category-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.file-item .icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.file-item .name {
    font-family: var(--font-mono);
    font-size: 13px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .type {
    font-size: 11px;
    color: var(--text-tertiary);
}

.more-items {
    font-size: 12px;
    color: var(--text-tertiary);
    padding-left: 30px;
    margin-top: 4px;
}

/* Light Source Items */
.light-source-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
}

.light-source-item .icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    margin-top: 2px;
}

.light-source-item .info {
    flex: 1;
}

.light-source-item .name {
    font-size: 13px;
    font-weight: 500;
}

.light-source-item .id {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* Variant Items */
.variant-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.variant-item:last-child {
    border-bottom: none;
}

.variant-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.variant-item .icon {
    font-size: 14px;
    color: var(--accent-purple);
}

.variant-item .name {
    font-size: 13px;
    font-weight: 500;
}

.variant-item .description {
    font-size: 12px;
    color: var(--text-secondary);
    padding-left: 24px;
    margin-top: 4px;
}

.variant-item .id {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    padding-left: 24px;
    margin-top: 2px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle);
}

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

/* Filter Tabs / Segmented Control */
.segmented-control {
    display: inline-flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.segmented-control button {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-family: var(--font-family);
}

.segmented-control button:hover {
    color: var(--text-primary);
}

.segmented-control button.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Form Elements */
input, select, textarea {
    font-family: var(--font-family);
    font-size: 13px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    width: 100%;
    transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: var(--font-mono);
}

label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-help {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    margin-bottom: 0;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
}

/* Tags Container */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-input);
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-primary);
}

.application-tag {
    background: var(--accent-blue);
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
    color: white;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-remove:hover {
    opacity: 1;
}

/* Input with Button */
.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.btn-add {
    padding: 8px 16px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.btn-add:hover:not(:disabled) {
    background: var(--accent-blue-hover);
}

.btn-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Section Description */
.section-description {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

/* Empty Message */
.empty-message {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
    padding: 8px 0;
}

/* Applications List */
.applications-list {
    margin-bottom: 20px;
}

.applications-list h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Add Custom Form */
.add-custom-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* Electrical Editor */
.electrical-editor select,
.applications-editor select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.electrical-editor select:focus,
.applications-editor select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Photometry Editor */
.photometry-editor {
    max-width: 900px;
}

.photometry-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.photometry-info {
    display: flex;
    gap: 16px;
    padding: 8px 12px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.photometry-id {
    color: var(--accent-blue);
    font-weight: 500;
}

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

.photometry-fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg-card);
}

.photometry-fieldset legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 8px;
}

.photometry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* Photometry Field */
.photometry-field {
    position: relative;
}

.photometry-field .field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.photometry-field label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.photometry-field .field-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.photometry-field .photometry-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    min-width: 0;
}

.photometry-field .photometry-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.photometry-field .field-unit {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.photometry-field .field-help {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Value Source Badges */
.value-source-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* GLDF source - blue */
.value-source-gldf .value-source-badge,
.legend-badge.value-source-gldf {
    background: var(--accent-blue);
    color: white;
}

/* Calculated source - orange/yellow */
.value-source-calculated .value-source-badge,
.legend-badge.value-source-calculated {
    background: var(--accent-orange);
    color: #000;
}

/* Empty source - subtle */
.value-source-empty .value-source-badge {
    display: none;
}

.value-source-empty .photometry-input {
    border-style: dashed;
    color: var(--text-tertiary);
}

/* Field highlighting based on source */
.value-source-gldf .photometry-input {
    border-left: 3px solid var(--accent-blue);
}

.value-source-calculated .photometry-input {
    border-left: 3px solid var(--accent-orange);
}

/* Value source legend */
.value-source-legend {
    display: flex;
    gap: 24px;
    padding: 8px 12px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

/* =========================== */
/* Dual-value Photometry Field */
/* =========================== */

.photometry-grid-dual {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.photometry-field-dual {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.photometry-field-dual .field-header {
    margin-bottom: 8px;
}

.photometry-field-dual .field-header label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.field-values-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field-value-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
}

.field-value-box.value-source-gldf {
    border-left: 3px solid var(--accent-blue);
}

.field-value-box.value-source-calculated {
    border-left: 3px solid var(--accent-orange);
    background: rgba(255, 159, 10, 0.05);
}

.field-value-box.value-source-empty {
    border-style: dashed;
    opacity: 0.7;
}

.field-value-box .value-source-badge {
    align-self: flex-start;
}

.field-value-box .field-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-value-box .photometry-input {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-content);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    min-width: 0;
}

.field-value-box .photometry-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
}

.field-value-box .photometry-input::placeholder {
    color: var(--text-tertiary);
    font-style: italic;
}

.field-display-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: transparent;
    border-radius: 4px;
    min-height: 32px;
}

.calculated-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-orange);
    font-family: var(--font-mono);
}

.field-value-box .field-unit {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.photometry-field-dual .field-help {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* Responsive: stack on narrow screens */
@media (max-width: 600px) {
    .field-values-row {
        grid-template-columns: 1fr;
    }
}

/* Photometry card for read-only view */
.photometry-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.photometry-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 8px;
}

.photometry-card .file-ref {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* JSON/Code Display */
.code-block {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 13px;
}

/* Privacy Note */
.privacy-note {
    font-size: 12px;
    color: var(--accent-green);
    font-style: italic;
}

/* LDT Viewer Container */
.ldt-viewer-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
}

.ldt-viewer {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.ldt-viewer-controls {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
}

.ldt-diagram {
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
    border-radius: var(--radius-sm);
    min-height: 300px;
    overflow: hidden;
}

.ldt-diagram svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

/* LDT Viewer Tabs */
.ldt-viewer-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
    flex-wrap: wrap;
}

.ldt-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ldt-tab:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.ldt-tab.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.ldt-tab .tab-icon {
    font-size: 14px;
}

.ldt-tab .tab-label {
    white-space: nowrap;
}

/* Compact mode - icons only */
.ldt-viewer.compact .ldt-tab {
    padding: 8px 10px;
}

.ldt-viewer.compact .ldt-tab .tab-label {
    display: none;
}

/* LDT Diagram clickable hint */
.ldt-diagram.clickable {
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ldt-diagram.clickable:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(10, 132, 255, 0.3);
}

.ldt-diagram.clickable::after {
    content: "🔍";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.15s ease;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
}

.ldt-diagram.clickable:hover::after {
    opacity: 1;
}

/* LDT Zoom Modal Overlay */
.ldt-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

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

.ldt-zoom-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ldt-zoom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
}

.ldt-zoom-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ldt-zoom-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin-left: 16px;
}

.ldt-zoom-close:hover {
    background: var(--accent-red);
    color: white;
}

.ldt-zoom-content {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    min-width: 600px;
    min-height: 500px;
}

.ldt-zoom-content svg {
    max-width: 100%;
    max-height: 100%;
}

/* L3D Viewer Container */
.l3d-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    width: 100%;
    min-height: 400px;
    margin-bottom: 16px;
}

.l3d-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
}

.l3d-header .icon {
    color: var(--accent-green);
}

.l3d-header .name {
    font-size: 13px;
    font-weight: 500;
}

.l3d-canvas-container {
    position: relative;
    background: #1a1a1a;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.l3d-canvas-container canvas {
    display: block;
}

/* L3D Viewer component styling */
.l3d-viewer {
    background: #1a1a1a;
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.l3d-viewer canvas {
    border-radius: var(--radius-sm);
    background: #2a2a2a;
}

.l3d-viewer p {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* File Preview */
.preview-tile {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-header .icon {
    font-size: 20px;
    color: var(--accent-blue);
}

.preview-name {
    font-size: 15px;
    font-weight: 600;
}

.preview-type {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

.preview-media {
    padding: 20px;
}

.preview-media img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}

.preview-media video {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}

.preview-media textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    resize: vertical;
}

/* Embedded Files Section */
#buf_file {
    padding: 12px;
    margin: 8px 0;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

#buf_file p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

#buf_file img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-sm);
}

/* URL Files Section */
.url-files {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.url-file-entry {
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin: 6px 0;
}

.url-file-entry p {
    font-size: 12px;
    margin-bottom: 4px;
}

.url-file-entry a {
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: none;
}

.url-file-entry a:hover {
    text-decoration: underline;
}

/* Editor Tabs */
.editor-tabs-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.editor-nav {
    display: flex;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.nav-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    font-family: var(--font-family);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.nav-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: var(--bg-card);
}

.editor-content {
    padding: 24px;
}

.editor-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 8px;
}

.section-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Mode Toggle & Export Buttons */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
}

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

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

.export-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    background: var(--accent-green);
    color: white;
    font-family: var(--font-family);
}

.export-btn:hover {
    opacity: 0.9;
}

/* Files Table */
.files-table {
    width: 100%;
    border-collapse: collapse;
}

.files-table th,
.files-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.files-table th {
    background: var(--bg-table-header);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.files-table td {
    font-size: 13px;
}

.files-table .filename {
    font-family: var(--font-mono);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clickable files table */
.files-table-clickable tr.clickable:hover td {
    background: var(--bg-card-hover);
}

.files-table-clickable tr.selected td {
    background: rgba(10, 132, 255, 0.15);
}

.files-table-clickable .file-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-cyan);
}

.files-table-clickable .file-name {
    font-family: var(--font-mono);
    font-size: 13px;
}

.files-table-clickable .file-type {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Content Type Badges */
.content-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.content-type-ldc {
    background: rgba(255, 159, 10, 0.2);
    color: var(--accent-orange);
}

.content-type-geo {
    background: rgba(48, 209, 88, 0.2);
    color: var(--accent-green);
}

.content-type-image {
    background: rgba(10, 132, 255, 0.2);
    color: var(--accent-blue);
}

.content-type-sensor {
    background: rgba(191, 90, 242, 0.2);
    color: var(--accent-purple);
}

.content-type-doc {
    background: rgba(255, 214, 10, 0.2);
    color: var(--accent-yellow);
}

.content-type-other {
    background: rgba(142, 142, 147, 0.2);
    color: var(--text-secondary);
}

.files-table .actions {
    white-space: nowrap;
}

/* Button Variants */
.btn-edit, .btn-remove, .btn-save, .btn-cancel, .btn-add {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
    font-family: var(--font-family);
}

.btn-edit {
    background: var(--accent-blue);
    color: white;
}

.btn-remove {
    background: var(--accent-red);
    color: white;
}

.btn-save {
    background: var(--accent-green);
    color: white;
}

.btn-cancel {
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-add {
    background: var(--accent-blue);
    color: white;
}

.btn-edit:disabled,
.btn-add:disabled {
    background: var(--bg-input);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

/* Light Source & Variant Cards */
.light-source-cards,
.variant-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.light-source-card,
.variant-card {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Expandable Variant Cards */
.variant-card .card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background 0.15s;
}

.variant-card .card-header:hover {
    background: rgba(0,0,0,0.3);
}

.variant-card .card-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.variant-card .expand-icon {
    font-size: 10px;
    color: var(--text-tertiary);
}

.variant-card.expanded {
    grid-column: 1 / -1;
}

.variant-card .card-body {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
}

.variant-card .variant-info {
    margin-bottom: 16px;
}

.variant-card .variant-info .detail {
    display: flex;
    font-size: 13px;
    margin-bottom: 6px;
}

.variant-card .variant-info .detail.wide {
    flex-direction: column;
    gap: 4px;
}

.variant-card .variant-info .detail .label {
    color: var(--text-tertiary);
    margin-right: 8px;
    min-width: 120px;
}

.variant-card .variant-info .detail .value.code {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
}

/* Mountings Details */
.mountings-details {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
}

.mountings-details h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mountings-details.empty {
    opacity: 0.6;
}

.mountings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.mounting-detail {
    background: var(--bg-sidebar);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border-left: 3px solid var(--accent-blue);
}

.mounting-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-blue);
    display: block;
    margin-bottom: 6px;
}

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

.mounting-subtypes li {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 0;
}

.mounting-subtypes li::before {
    content: "•";
    color: var(--text-tertiary);
    margin-right: 6px;
}

/* Geometry & Emitter sections in variants */
.geometry-info,
.emitter-refs {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.geometry-info h5,
.emitter-refs h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emitter-refs ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.emitter-refs li {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-orange);
    background: rgba(255, 159, 10, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0,0,0,0.2);
}

.card-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-cyan);
}

.card-type {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--accent-blue);
    color: white;
    border-radius: 4px;
}

.card-type.changeable {
    background: var(--accent-orange);
}

.card-content {
    padding: 14px;
}

.card-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.card-content .description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.card-content .detail {
    display: flex;
    font-size: 12px;
    margin-bottom: 4px;
}

.card-content .detail .label {
    color: var(--text-tertiary);
    margin-right: 6px;
}

/* Properties Grid for Light Sources */
.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.property {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.property-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.card-actions-row {
    padding: 10px 14px;
    border-top: 1px solid var(--border-subtle);
    text-align: right;
}

/* Fieldset */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0;
}

fieldset legend {
    color: var(--text-secondary);
    font-size: 12px;
    padding: 0 8px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    font-family: var(--font-family);
}

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

.tab.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* Tags */
.tag {
    display: inline-block;
    font-size: 11px;
    padding: 3px 8px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 4px;
    margin: 2px;
}

/* Links */
a {
    color: var(--accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Footer */
.app-footer {
    margin-top: 24px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.app-footer p {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0;
}

/* Hidden file input */
input#file-upload {
    visibility: hidden;
    position: absolute;
    width: 0;
    height: 0;
}

/* =========================== */
/* Responsive Adjustments */
/* =========================== */

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

    .content-columns {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .ldt-zoom-content {
        min-width: auto;
        min-height: auto;
    }
}

/* Mobile - Landscape & larger phones */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    #wrapper {
        flex-direction: column;
        height: auto !important;
        min-height: 100vh;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: auto;
    }

    /* Compact sidebar on mobile - single row nav */
    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        min-height: auto;
        max-height: 60px;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 0 8px;
    }

    .sidebar-header {
        display: none !important;
    }

    .sidebar-section {
        display: contents;
    }

    .sidebar-section-title {
        display: none !important;
    }

    .main-content {
        flex: 1 1 auto;
        height: auto !important;
        min-height: 80vh;
        overflow: visible !important;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        display: block;
    }

    .content-body {
        display: block;
        height: auto;
        min-height: 70vh;
        overflow: visible;
        padding: 16px;
    }

    .welcome-view {
        display: flex;
        min-height: 60vh;
        height: auto;
    }

    /* Horizontal scrolling nav on mobile */
    .sidebar-nav {
        display: contents;
    }

    .sidebar-nav-item {
        padding: 6px 10px;
        margin: 4px 2px;
        font-size: 11px;
        border-radius: 12px;
        background: var(--bg-card);
        flex-shrink: 0;
        white-space: nowrap;
    }

    .sidebar-nav-item .icon {
        display: none;
    }

    .sidebar-nav-item .badge {
        display: none;
    }

    .content-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    .content-title {
        font-size: 18px;
        width: 100%;
    }

    .toolbar-actions {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .toolbar-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card .icon {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .stat-card .value {
        font-size: 20px;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    /* Editor tabs */
    .editor-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .editor-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        padding: 12px 16px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .editor-content {
        padding: 16px;
    }

    /* Buttons - larger touch targets */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px; /* iOS minimum touch target */
    }

    .btn-sm {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Welcome view */
    .welcome-view {
        padding: 24px 16px;
        min-height: auto;
        justify-content: flex-start;
        padding-top: 40px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .welcome-icon {
        font-size: 60px;
        margin-bottom: 16px;
    }

    .welcome-title {
        font-size: 22px;
    }

    .welcome-subtitle {
        font-size: 13px;
    }

    .welcome-buttons {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .welcome-buttons .btn {
        width: 100%;
    }

    /* Drop zone */
    .drop-zone,
    #drop-container {
        padding: 24px 16px;
    }

    .drop-zone .icon,
    #drop-container i {
        font-size: 36px;
    }

    /* Cards */
    .card-header {
        padding: 12px 16px;
    }

    .card-body {
        padding: 16px;
    }

    /* Light source cards */
    .light-source-cards,
    .variant-cards {
        grid-template-columns: 1fr;
    }

    /* Tables - horizontal scroll */
    .data-table,
    .files-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td,
    .files-table th,
    .files-table td {
        padding: 12px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* LDT viewer */
    .ldt-viewer-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding: 6px 8px;
    }

    .ldt-tab {
        padding: 10px 14px;
        font-size: 11px;
    }

    .ldt-diagram {
        min-height: 250px;
        padding: 12px;
    }

    /* LDT Zoom modal */
    .ldt-zoom-modal {
        max-width: 95vw;
        max-height: 95vh;
    }

    .ldt-zoom-content {
        min-width: auto;
        min-height: 300px;
        padding: 16px;
    }

    .ldt-zoom-header {
        padding: 10px 12px;
    }

    .ldt-zoom-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    /* L3D viewer */
    .l3d-container {
        min-height: 300px;
    }

    .l3d-canvas-container {
        min-height: 300px;
    }

    /* Bevy viewer */
    .viewer-container.bevy-viewer {
        min-height: 400px;
    }

    /* App actions */
    .app-actions {
        top: 8px;
        right: 8px;
        gap: 6px;
    }

    .app-action-btn {
        padding: 10px 12px;
        font-size: 11px;
    }

    .app-action-btn .label {
        display: none;
    }

    /* Help modal */
    .help-modal {
        width: 95%;
        max-height: 90vh;
    }

    .help-content {
        padding: 16px;
    }

    /* Photometry editor */
    .photometry-grid {
        grid-template-columns: 1fr;
    }

    .field-values-row {
        grid-template-columns: 1fr;
    }

    /* Collapsible sections */
    .collapsible-header {
        padding: 12px 14px;
    }

    .collapsible-content {
        padding: 0 14px 14px;
    }

    /* Mode toggle */
    .mode-toggle {
        padding: 12px 0;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .toggle-btn,
    .export-btn {
        padding: 12px 16px;
        font-size: 13px;
        width: 100%;
    }

    /* Info grid */
    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .product-info-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .product-info-header h2 {
        font-size: 18px;
    }

    /* Segmented control */
    .segmented-control {
        width: 100%;
        justify-content: center;
    }

    .segmented-control button {
        flex: 1;
        padding: 10px 12px;
    }

    /* Tags */
    .tags-container {
        gap: 6px;
    }

    .tag {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Input with button */
    .input-with-button {
        flex-direction: column;
    }

    .input-with-button input {
        width: 100%;
    }

    .input-with-button .btn-add {
        width: 100%;
    }
}

/* Mobile - Portrait / Small phones */
@media (max-width: 480px) {
    html, body {
        font-size: 13px;
    }

    .sidebar-nav {
        padding: 6px;
        gap: 4px;
    }

    .sidebar-nav-item {
        padding: 8px 12px;
        font-size: 11px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .value {
        font-size: 18px;
    }

    .stat-card .label {
        font-size: 11px;
    }

    .welcome-icon {
        font-size: 48px;
    }

    .welcome-title {
        font-size: 18px;
    }

    .content-body {
        padding: 12px;
    }

    .editor-content {
        padding: 12px;
    }

    .card-body {
        padding: 12px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Hide less important UI on very small screens */
    .privacy-note {
        font-size: 11px;
    }

    .app-footer p {
        font-size: 11px;
    }

    /* Photometry fieldset */
    .photometry-fieldset {
        padding: 12px;
    }

    .photometry-field .photometry-input {
        font-size: 14px;
    }

    /* Value source legend stacked */
    .value-source-legend {
        flex-direction: column;
        gap: 8px;
    }

    /* Mounting details */
    .mountings-grid {
        grid-template-columns: 1fr;
    }

    /* Properties grid */
    .properties-grid {
        grid-template-columns: 1fr;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .sidebar-nav-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .btn,
    .toggle-btn,
    .export-btn,
    .nav-tab,
    .ldt-tab,
    .tab {
        min-height: 44px;
    }

    /* Remove hover effects that don't work on touch */
    .sidebar-nav-item:hover {
        background: transparent;
    }

    .sidebar-nav-item.active {
        background: var(--accent-blue);
    }

    .btn:hover,
    .toggle-btn:hover {
        transform: none;
    }

    /* Disable hover zoom on diagrams */
    .ldt-diagram.clickable:hover {
        transform: none;
        box-shadow: none;
    }

    /* Better tap feedback */
    .btn:active,
    .toggle-btn:active,
    .sidebar-nav-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }

    /* Scrollbar hiding for cleaner mobile look */
    .sidebar-nav::-webkit-scrollbar,
    .editor-nav::-webkit-scrollbar,
    .ldt-viewer-tabs::-webkit-scrollbar {
        display: none;
    }

    .sidebar-nav,
    .editor-nav,
    .ldt-viewer-tabs {
        scrollbar-width: none;
    }
}

/* ============================================ */
/* Legacy compatibility for existing HTML */
/* ============================================ */

/* App Header - redesign for centered welcome when no file */
.app-header {
    display: none; /* Hide old header, we'll use sidebar */
}

/* Info Section - integrate into welcome view */
.info-section {
    display: none; /* Moved to welcome view */
}

/* Upload Section - now part of welcome/main content */
.upload-section {
    margin-bottom: 0;
}

#drop-container {
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
}

#drop-container:hover {
    background: rgba(10, 132, 255, 0.05);
    border-color: var(--accent-blue);
}

#drop-container i {
    font-size: 40px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

#drop-container:hover i {
    color: var(--accent-blue);
}

#drop-container p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
}

/* Preview Area */
#preview-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#content-area {
    padding: 0;
}

/* Override wrapper for new layout */
/* Base wrapper - desktop */
#wrapper {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    height: 100vh;
}

/* Mobile wrapper override - must come after base */
@media (max-width: 768px) {
    #wrapper {
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto !important;
    }

    .sidebar {
        width: 100% !important;
        max-height: 50px !important;
        min-height: 50px;
        flex-shrink: 0 !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        padding: 0 8px;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header,
    .sidebar-section-title {
        display: none !important;
    }

    .sidebar-section {
        display: contents !important;
    }

    .sidebar-nav {
        display: contents !important;
    }

    .sidebar-nav-item {
        padding: 6px 10px !important;
        margin: 0 2px !important;
        font-size: 11px !important;
        border-radius: 12px;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .sidebar-nav-item .icon,
    .sidebar-nav-item .badge {
        display: none !important;
    }

    .main-content {
        flex: 1 1 auto !important;
        height: auto !important;
        min-height: calc(100vh - 50px);
        overflow: visible !important;
    }
}

/* Bevy 3D Scene Viewer */
.bevy-scene-container {
    background: #0d0d0d;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bevy-scene-container canvas {
    display: block;
}

.bevy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    cursor: pointer;
}

.bevy-overlay.error {
    cursor: default;
}

.bevy-overlay-content {
    text-align: center;
    padding: 40px;
}

.bevy-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.bevy-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.bevy-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.bevy-error {
    font-size: 12px;
    color: var(--accent-red);
    margin-bottom: 20px;
    max-width: 400px;
    word-break: break-word;
}

.bevy-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: bevy-spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.bevy-controls-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.viewer-container.bevy-viewer {
    min-height: 600px;
}

/* =========================== */
/* App Action Buttons (Clear/Help) */
/* =========================== */

.app-actions {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 100;
    display: flex;
    gap: 8px;
}

.app-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(10px);
}

.app-action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.app-action-btn.clear:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.app-action-btn.help:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.app-action-btn .icon {
    font-size: 14px;
}

.app-action-btn .label {
    font-size: 12px;
}

/* =========================== */
/* Help Overlay */
/* =========================== */

.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.help-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.2s ease;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
}

.help-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.help-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.help-close:hover {
    background: var(--accent-red);
    color: white;
}

.help-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.help-list {
    display: grid;
    gap: 8px;
}

.help-list dt {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.help-list dd {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 0;
    padding-left: 12px;
    border-left: 2px solid var(--border-subtle);
    margin-bottom: 8px;
}

.help-formats,
.help-tips {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-formats li,
.help-tips li {
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.help-formats li strong {
    color: var(--accent-orange);
    font-family: var(--font-mono);
}

.help-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
}

.help-version {
    font-size: 11px;
    color: var(--text-tertiary);
}

.help-link {
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: none;
}

.help-link:hover {
    text-decoration: underline;
}
