:root {
    --bg-primary: #08081a;
    --bg-secondary: #0e0e28;
    --bg-surface: #161638;
    --bg-elevated: #1e1e44;
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-tertiary: #555570;
    --text-muted: #555570;
    --accent: #00d4aa;
    --accent-dim: #00a888;
    --accent-blue: #00a8ff;
    --accent-glow: rgba(0, 212, 170, 0.15);
    --accent-gradient: linear-gradient(135deg, #00d4aa, #00a8ff);
    --error: #ff5566;
    --danger: #ff4455;
    --warning: #ddaa44;
    --border: #2a2a4a;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --glass-bg: rgba(22, 22, 56, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-blur: blur(16px);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;
    --status-offline-bg: #332233;
    --status-offline-fg: #886688;
    --status-idle-bg: #1a3322;
    --status-idle-fg: #44cc66;
    --status-printing-bg: #1a2833;
    --status-printing-fg: #44aaff;
    --status-paused-bg: #332a1a;
    --status-paused-fg: #ddaa44;
    --status-error-bg: #331a1a;
    --status-error-fg: #ff5566;
    --status-completed-bg: #1a3322;
    --status-completed-fg: #44cc66;
    --badge-upload-fg: #44aaff;
    --badge-upload-bg: rgba(68, 170, 255, 0.15);
    --badge-import-fg: #cc88ff;
    --badge-import-bg: rgba(204, 136, 255, 0.15);
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 64px;
}

[x-cloak] { display: none !important; }

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; gap: 8px; }
.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent);
}
.header-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

/* Buttons */
.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    transition: all 0.15s var(--ease-out);
}
.btn-icon:hover, .btn-icon.active {
    background: var(--bg-elevated);
    color: var(--accent);
    border-color: var(--accent);
}
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
}
.btn-sm:hover { background: var(--accent-dim); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-sm.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-sm.btn-danger {
    background: var(--danger);
}
.btn-sm.btn-danger:hover {
    background: #cc3344;
}
.btn-sm.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-sm.btn-danger-outline:hover {
    border-color: var(--danger);
    color: var(--danger);
}
.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    padding: 4px 0;
}
.btn-text:hover { color: var(--accent); }
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: var(--bg-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* View System */
.view-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
.view-container {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}
.view-container::-webkit-scrollbar { width: 6px; }
.view-container::-webkit-scrollbar-track { background: transparent; }
.view-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--glass-border);
    z-index: 20;
}
.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    min-width: 64px;
    min-height: 44px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s var(--ease-out);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.nav-tab svg {
    transition: transform 0.2s var(--ease-out);
}
.nav-tab.active {
    color: var(--accent);
}
.nav-tab.active svg {
    filter: drop-shadow(0 0 6px var(--accent-glow));
}
.nav-tab:active svg {
    transform: scale(0.9);
}

/* Dashboard View */
.dashboard-view {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Printer Farm Grid */
.printer-farm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.farm-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-muted);
}
.farm-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
    position: relative;
    overflow: hidden;
}
.farm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.farm-card:active {
    transform: scale(0.98);
}
.farm-status-idle { border-color: rgba(68, 204, 102, 0.2); }
.farm-status-printing { border-color: rgba(68, 170, 255, 0.2); }
.farm-status-error { border-color: rgba(255, 85, 102, 0.2); }
.farm-status-offline { border-color: var(--glass-border); }
.farm-status-idle::after,
.farm-status-printing::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    pointer-events: none;
}
.farm-status-idle::after {
    box-shadow: inset 0 0 30px rgba(68, 204, 102, 0.05);
}
.farm-status-printing::after {
    box-shadow: inset 0 0 30px rgba(68, 170, 255, 0.05);
}

.farm-card-illustration {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    margin-bottom: 12px;
}
.printer-svg {
    width: 120px;
    height: 100px;
}
.progress-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.progress-ring-fill {
    transition: stroke-dashoffset 0.5s var(--ease-out);
}
.nozzle-glow {
    filter: drop-shadow(0 0 4px var(--accent));
}
.bed-glow {
    transition: fill 0.3s var(--ease-out);
}

.farm-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.farm-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.farm-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-idle { background: var(--status-idle-fg); box-shadow: 0 0 6px var(--status-idle-fg); }
.dot-printing { background: var(--status-printing-fg); box-shadow: 0 0 6px var(--status-printing-fg); animation: pulse-dot 2s ease-in-out infinite; }
.dot-paused { background: var(--status-paused-fg); }
.dot-error { background: var(--status-error-fg); }
.dot-offline { background: var(--status-offline-fg); }
.dot-completed { background: var(--status-completed-fg); }
.dot-failed { background: var(--status-error-fg); }
.dot-cancelled { background: var(--status-paused-fg); }
.dot-sent { background: var(--status-printing-fg); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.farm-card-temps {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* Activity Feed */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s var(--ease-out);
}
.activity-item:hover { background: var(--bg-elevated); }
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.activity-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Dashboard Quick Actions */
.dashboard-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s var(--ease-out);
}
.action-card:hover {
    background: var(--bg-elevated);
    color: var(--accent);
    border-color: rgba(0, 212, 170, 0.2);
}
.action-card:active {
    transform: scale(0.97);
}

/* Library View */
.library-view {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}
.library-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}
.library-search {
    flex: 1;
}
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    flex: 1;
}
.library-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
}
.library-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.library-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.library-card:active {
    transform: scale(0.98);
}
.library-card-thumb {
    height: 140px;
    background: var(--bg-surface);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.library-card-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}
.library-card-info {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.library-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.library-card-size {
    font-size: 11px;
    color: var(--text-muted);
}
.library-card-actions {
    padding: 0 12px 10px;
    display: flex;
    gap: 6px;
    align-items: center;
}
.library-sort {
    width: auto;
    min-width: 100px;
}
.library-count {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Model Detail Bottom Sheet */
.model-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.model-detail-sheet {
    width: 100%;
    max-width: 500px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 12px 20px 28px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.sheet-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.sheet-header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.sheet-thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sheet-info {
    flex: 1;
    min-width: 0;
}
.sheet-model-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sheet-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.sheet-meta-dot { opacity: 0.5; }
.sheet-close {
    flex-shrink: 0;
    align-self: flex-start;
}
.sheet-actions {
    display: flex;
    gap: 10px;
}
.sheet-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    text-decoration: none;
    text-align: center;
}
.sheet-action-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
}
.sheet-action-btn:active {
    transform: scale(0.97);
}
.sheet-action-primary {
    color: var(--accent);
    border-color: var(--accent-dim);
    background: var(--accent-glow);
}
.sheet-action-primary:hover {
    background: var(--accent-glow);
    filter: brightness(1.3);
}
.sheet-action-danger:hover {
    color: var(--danger);
    border-color: var(--status-error-fg);
}

/* Printers View */
.printers-view {
    padding: 16px;
}
.printers-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Interactive Printer Detail Cards */
.printer-detail-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.printer-detail-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.printer-detail-card:active { transform: scale(0.99); }
.printer-detail-card.expanded {
    cursor: default;
    border-color: rgba(0, 212, 170, 0.15);
}
.detail-status-idle { border-color: rgba(68, 204, 102, 0.15); }
.detail-status-printing { border-color: rgba(68, 170, 255, 0.15); }
.detail-status-error { border-color: rgba(255, 85, 102, 0.15); }

.detail-card-top {
    display: flex;
    gap: 16px;
    padding: 16px;
    align-items: center;
}
.detail-illustration {
    position: relative;
    width: 100px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.detail-illustration .printer-svg { width: 90px; height: 70px; }
.detail-illustration .progress-ring { width: 100px; height: 100px; top: -10px; left: 0; }
.detail-card-summary {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.detail-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.detail-card-type {
    font-size: 12px;
    color: var(--text-muted);
}
.detail-card-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.detail-card-ip {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-tertiary);
}
.detail-progress-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.detail-temps-compact {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-top: 2px;
}

/* Expanded Detail Sections */
.detail-expanded {
    border-top: 1px solid var(--glass-border);
    padding: 0 16px 16px;
}
.detail-section {
    padding-top: 16px;
}
.detail-section + .detail-section {
    border-top: 1px solid var(--border-subtle);
    margin-top: 16px;
}
.detail-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Temperature Controls */
.temp-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.temp-gauge {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.temp-gauge-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.temp-gauge-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    margin-bottom: 8px;
}
.temp-current {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-primary);
}
.temp-unit {
    font-size: 14px;
    color: var(--text-muted);
}
.temp-target {
    font-size: 12px;
    color: var(--accent);
    margin-left: 4px;
}
.temp-buttons {
    display: flex;
    gap: 4px;
    justify-content: center;
}
.temp-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    min-width: 36px;
    min-height: 32px;
    transition: all 0.15s var(--ease-out);
}
.temp-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.temp-btn:active { transform: scale(0.95); }
.temp-btn-off:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Temperature Presets */
.temp-presets {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}
.temp-presets-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 4px;
}
.preset-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    min-height: 32px;
    transition: all 0.15s var(--ease-out);
}
.preset-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
    color: var(--accent);
}
.preset-btn:active { transform: scale(0.95); }

/* Job Info */
.detail-job-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.detail-job-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.detail-job-row span:first-child {
    color: var(--text-muted);
}
.detail-job-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* Queue within detail card */
.queue-add-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.queue-add-row .queue-select { flex: 1; }

/* Detail Actions */
.detail-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 16px;
    flex-wrap: wrap;
}

/* History View */
.history-view {
    padding: 16px;
}
.history-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.history-filters::-webkit-scrollbar { display: none; }
.filter-chip {
    padding: 10px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    min-height: 44px;
}
.filter-chip:hover {
    border-color: var(--accent-dim);
    color: var(--text-primary);
}
.filter-chip.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.history-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: border-color 0.15s var(--ease-out);
}
.history-item:hover {
    border-color: var(--border);
}
.history-item.history-completed {
    border-left: 3px solid var(--status-completed-fg);
}
.history-item.history-printing {
    border-left: 3px solid var(--status-printing-fg);
}
.history-item.history-failed {
    border-left: 3px solid var(--status-error-fg);
}
.history-item.history-cancelled {
    border-left: 3px solid var(--status-paused-fg);
}
.history-status-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.history-completed .history-status-icon {
    background: var(--status-completed-bg);
}
.history-printing .history-status-icon {
    background: var(--status-printing-bg);
}
.history-failed .history-status-icon {
    background: var(--status-error-bg);
}
.history-cancelled .history-status-icon {
    background: var(--status-paused-bg);
}
.history-item-content {
    flex: 1;
    min-width: 0;
}
.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.history-item-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Layout */
.layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
}
.chat-panel.full-width { border-right: none; }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Welcome */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 40px 20px;
    gap: 16px;
    animation: fadeIn 0.3s var(--ease-out);
}
.welcome-icon {
    color: var(--accent);
    opacity: 0.6;
    position: relative;
}
.welcome-icon::after {
    content: "";
    position: absolute;
    inset: -24px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    z-index: -1;
    border-radius: 50%;
}
.welcome h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.welcome p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 400px;
}
.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    max-width: 500px;
}
.example-chip {
    padding: 8px 16px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
}
.example-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}
.custom-chip {
    border-style: dashed;
    color: var(--accent);
}

/* Template Gallery */
.template-gallery {
    margin-top: 20px;
    width: 100%;
    max-width: 600px;
}
.template-gallery-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.template-gallery-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}
.template-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.template-scroll::-webkit-scrollbar { height: 4px; }
.template-scroll::-webkit-scrollbar-track { background: transparent; }
.template-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.template-card {
    flex: 0 0 130px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px 12px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    text-align: center;
    font-family: var(--font);
    color: var(--text-primary);
}
.template-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.1);
}
.template-card:active {
    transform: scale(0.97);
}
.template-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
}
.template-card-icon svg { flex-shrink: 0; }
.template-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}
.template-card-desc {
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Messages */
.message { display: flex; animation: slideUp 0.2s var(--ease-out); }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
}
.message.user .message-content {
    background: var(--accent);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
    background: var(--bg-surface);
    border-bottom-left-radius: 4px;
}

/* Loading */
.loading-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}
.loading-msg span::after {
    content: "";
    display: inline-block;
    animation: loadingDots 1.4s steps(4) infinite;
}
@keyframes loadingDots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Error */
.error-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 85, 102, 0.08);
    border: 1px solid rgba(255, 85, 102, 0.2);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13px;
    line-height: 1.5;
}
.error-msg::before {
    content: "\26A0";
    flex-shrink: 0;
    font-size: 14px;
}

/* Model Card */
.model-msg { display: flex; flex-direction: column; gap: 10px; }
.model-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}
.model-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.1);
    transform: translateY(-1px);
}
.model-preview {
    height: 200px;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
}
.model-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}
.model-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Code block */
.code-block {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
}

/* Slice result */
.slice-msg { display: flex; flex-direction: column; gap: 8px; }
.slice-result {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 14px;
}
.slice-meta {
    font-size: 12px;
    color: var(--text-secondary);
}
.text-muted { color: var(--text-muted); font-size: 12px; }

/* Input Area */
.input-area {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.15s;
}
.input-row:focus-within { border-color: var(--accent); }
.refine-badge {
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-clear-chat {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-clear-chat:hover {
    color: var(--error);
    background: rgba(255, 85, 102, 0.1);
}
textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
}
textarea::placeholder { color: var(--text-muted); }
.btn-send {
    background: var(--accent);
    border: none;
    color: var(--bg-primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}
.btn-send:hover { background: var(--accent-dim); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* 3D Viewer Panel */
.viewer-panel {
    width: 50%;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-width: 300px;
}
.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.viewer-container {
    flex: 1;
    min-height: 0;
}
.viewer-model-name {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}
.viewer-controls {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

/* Slice Panel */
.slice-panel {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.slice-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.slice-advanced {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.slice-advanced label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}
.slice-advanced .unit {
    font-size: 11px;
    color: var(--text-muted);
}
.checkbox-label {
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
}

/* Form inputs */
.select-sm {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
}
.select-sm:focus { border-color: var(--accent); }
.select-sm option { background: var(--bg-surface); }

.input-sm {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font);
    width: 60px;
    outline: none;
}
.input-sm:focus { border-color: var(--accent); }
.input-sm::placeholder { color: var(--text-muted); }
.full-width { width: 100%; }

/* Library */
.library-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: flex-end;
    animation: fadeIn 0.2s var(--ease-out);
}
.library-panel {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    animation: slideInRight 0.25s var(--ease-out);
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.library-header h3 { font-size: 16px; font-weight: 600; }
.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.library-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
}
.library-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
}
.library-item:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 212, 170, 0.08);
}
.library-item-info { display: flex; flex-direction: column; gap: 2px; }
.model-id { font-family: var(--mono); font-size: 12px; }
.model-size { font-size: 11px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
.badge-sliced {
    font-size: 10px;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Printer Panel */
.printer-panel-wide { width: 380px; }

.printer-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.printer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.printer-name {
    font-size: 13px;
    font-weight: 600;
}
.printer-type {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}
.printer-status {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-offline { background: var(--status-offline-bg); color: var(--status-offline-fg); }
.status-idle { background: var(--status-idle-bg); color: var(--status-idle-fg); }
.status-printing { background: var(--status-printing-bg); color: var(--status-printing-fg); }
.status-paused { background: var(--status-paused-bg); color: var(--status-paused-fg); }
.status-completed { background: var(--status-idle-bg); color: var(--accent); }
.status-error { background: var(--status-error-bg); color: var(--error); }

.printer-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.printer-ip {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}
.printer-temps {
    font-size: 12px;
    color: var(--text-secondary);
}
.printer-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    min-width: 35px;
    text-align: right;
}
.printer-card-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
}

/* Add Printer Form */
.add-printer-form {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.add-printer-form h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.add-printer-form > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Drop Overlay */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 212, 170, 0.08);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px;
    border: 3px dashed var(--accent);
    border-radius: 24px;
    color: var(--accent);
    font-size: 18px;
    font-weight: 600;
}

/* Upload welcome button */
.btn-upload-welcome {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--font);
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 4px;
}
.btn-upload-welcome:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Model name */
.model-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
}
.model-name-sm {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

/* Upload badge */
.badge-upload {
    font-size: 10px;
    color: var(--badge-upload-fg);
    background: var(--badge-upload-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Library item actions */
.library-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

/* Small icon button for delete */
.btn-icon-xs {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    transition: all 0.15s var(--ease-out);
}
.btn-icon-xs:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(255, 68, 85, 0.1);
}

/* Import Bar */
.import-bar {
    display: flex;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.import-input {
    flex: 1;
    width: auto;
}

/* Welcome buttons */
.welcome-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* Import badge */
.badge-import {
    font-size: 10px;
    color: var(--badge-import-fg);
    background: var(--badge-import-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Scale slider */
.scale-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.scale-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
}
.scale-slider {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
    cursor: pointer;
}
.scale-value {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    min-width: 40px;
    text-align: right;
}

/* Library Thumbnails */
.library-thumb {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    background: var(--bg-elevated);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.library-item {
    gap: 10px;
}

/* Import row in welcome */
.import-row {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 500px;
}
.import-row .import-input {
    flex: 1;
}

/* Printer Queue */
.printer-queue {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
}
.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.queue-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.queue-count {
    font-size: 10px;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
}
.queue-add {
    display: flex;
    gap: 4px;
    align-items: center;
}
.queue-select {
    max-width: 160px;
    font-size: 11px;
}
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}
.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    font-size: 12px;
}
.queue-pos {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 16px;
    text-align: center;
}
.queue-model-name {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Job History */
.job-printer {
    font-size: 13px;
    font-weight: 500;
}
.job-model {
    font-size: 12px;
    color: var(--text-secondary);
}
.job-time {
    font-size: 11px;
    color: var(--text-muted);
}
.job-error {
    margin-top: 4px;
    font-size: 11px;
    color: var(--error);
}
.status-started { background: var(--status-printing-bg); color: var(--status-printing-fg); }
.status-failed { background: var(--status-error-bg); color: var(--error); }
.status-queued { background: var(--status-paused-bg); color: var(--status-paused-fg); }

/* Camera Overlay */
.camera-overlay {
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Camera Panel */
.camera-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 720px;
    width: 90vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.camera-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.camera-body {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}
.camera-img {
    width: 100%;
    display: block;
}
.camera-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}
.camera-footer {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: center;
}

.notification-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    font-weight: 500;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border-radius: 10px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: var(--bg-primary);
}

/* Settings Panel */
.settings-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.settings-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.settings-label {
    font-size: 13px;
    color: var(--text-secondary);
}
.settings-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* More Menu Dropdown */
.more-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 180px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    font-family: var(--font);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}
.more-item:hover {
    background: var(--bg-elevated);
    color: var(--accent);
}
.more-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.more-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Camera Picker */
.camera-picker {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 160px;
    z-index: 50;
}
.camera-picker-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}
.camera-picker-item:hover {
    background: var(--bg-elevated);
    color: var(--accent);
}

/* SCAD Code Viewer */
.scad-viewer-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 720px;
    width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.scad-viewer-code {
    flex: 1;
    overflow: auto;
    padding: 16px;
    margin: 0;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-primary);
    -webkit-overflow-scrolling: touch;
}

/* Back button hidden on desktop, close button visible */
.btn-back {
    display: none;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 13px;
    font-family: var(--font);
    font-weight: 500;
    padding: 6px 12px 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    min-height: 36px;
}
.btn-back:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* Search Section */
.search-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 16px;
    width: 100%;
    max-width: 500px;
}
.search-divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}
.search-divider-text {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.search-section {
    width: 100%;
    max-width: 500px;
}
.search-bar {
    display: flex;
    gap: 8px;
}
.search-input {
    flex: 1;
}
.btn-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    padding: 0;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    max-height: 320px;
    overflow-y: auto;
}
.search-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
}
.search-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.search-card-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-elevated);
    flex-shrink: 0;
}
.search-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.search-source-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    line-height: 1.4;
}
.search-source-badge.thingiverse {
    background: rgba(36, 138, 255, 0.85);
    color: #fff;
}
.search-source-badge.thangs {
    background: rgba(255, 107, 53, 0.85);
    color: #fff;
}
.search-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.search-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}
.search-card-dot { opacity: 0.5; }
.search-card-action {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.search-action-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    padding: 4px 10px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    transition: all 0.15s var(--ease-out);
}
.search-card:hover .search-action-label {
    background: var(--accent);
    color: var(--bg-primary);
}
.search-empty {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Printing badge pulse */
.status-printing {
    animation: printPulse 2s ease-in-out infinite;
}
@keyframes printPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Printer select message */
.printer-select-msg {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.printer-select-msg p {
    font-size: 14px;
    color: var(--text-secondary);
}
.printer-select-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.toast {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    animation: toastIn 0.25s var(--ease-out);
}
.toast-info {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.toast-success {
    background: var(--status-idle-bg);
    color: var(--status-idle-fg);
    border: 1px solid rgba(68, 204, 102, 0.3);
}
.toast-error {
    background: var(--status-error-bg);
    color: var(--error);
    border: 1px solid rgba(255, 85, 102, 0.3);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Section titles weight hierarchy */
.library-header h3 { font-weight: 700; }
.settings-section-title {
    font-weight: 600;
}
.printer-name { font-weight: 600; }

/* Mobile */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .chat-panel { border-right: none; }
    .viewer-panel {
        width: 100%;
        height: 50vh;
        min-width: unset;
        border-top: 1px solid var(--border);
    }
    .welcome h2 { font-size: 18px; }
    .examples { max-width: 100%; }
    .message-content { max-width: 90%; }
    .library-panel { width: 280px; }
    .printer-panel-wide { width: 300px; }
    .slice-advanced { flex-direction: column; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .dashboard-actions { grid-template-columns: repeat(3, 1fr); }
    .library-grid { grid-template-columns: repeat(2, 1fr); }
    .printer-farm-grid { grid-template-columns: 1fr; }

    .layout.has-viewer .chat-panel { display: none; }
    .layout.has-viewer .viewer-panel {
        height: 100%;
        border-top: none;
        overflow-y: auto;
    }
    .layout.has-viewer .viewer-container {
        min-height: 250px;
        flex: 0 0 50vh;
    }
    .btn-back { display: flex; }
    .btn-close-viewer { display: none; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-stats { grid-template-columns: repeat(4, 1fr); }
    .printer-farm-grid { grid-template-columns: repeat(2, 1fr); }
    .library-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Desktop */
@media (min-width: 1025px) {
    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 72px;
        height: auto;
        flex-direction: column;
        justify-content: flex-start;
        padding: calc(env(safe-area-inset-top) + 80px) 0 20px 0;
        border-top: none;
        border-right: 1px solid var(--glass-border);
    }
    .nav-tab {
        width: 100%;
        padding: 12px 8px;
    }
    .view-content {
        padding-bottom: 0;
        padding-left: 72px;
    }
    .header {
        padding-left: 92px;
    }
    .dashboard-stats { grid-template-columns: repeat(4, 1fr); }
    .printer-farm-grid { grid-template-columns: repeat(3, 1fr); }
    .library-grid { grid-template-columns: repeat(4, 1fr); }
}
