/* === Theme: GitHub Dark (Default) === */
:root,
[data-theme="github-dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --success: #3fb950;
    --danger: #f85149;
    --warning: #d29922;
    --radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

    /* Overlay Colors (Glassmorphism) */
    --bg-overlay: rgba(13, 17, 23, var(--bg-dim, 0.7));
    --glass-sidebar: rgba(22, 27, 34, 0.6);
    --glass-content: rgba(13, 17, 23, 0.4);
    --glass-modal: rgba(22, 27, 34, 0.8);
}

/* === Theme: GitHub Light === */
[data-theme="github-light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #ffffff;
    --border: #d0d7de;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-muted: #6e7781;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --success: #1a7f37;
    --danger: #cf222e;
    --warning: #9a6700;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --bg-overlay: rgba(255, 255, 255, var(--bg-dim, 0.7));
    --glass-sidebar: rgba(246, 248, 250, 0.7);
    --glass-content: rgba(255, 255, 255, 0.5);
    --glass-modal: rgba(246, 248, 250, 0.9);
}

/* === Theme: Midnight Blue === */
[data-theme="midnight-blue"] {
    --bg-primary: #0a0e1a;
    --bg-secondary: #0f1420;
    --bg-tertiary: #161d2e;
    --border: #1e2942;
    --text-primary: #d4dce8;
    --text-secondary: #8b93a6;
    --text-muted: #6e7589;
    --accent: #4a9eff;
    --accent-hover: #6db1ff;
    --success: #3fb950;
    --danger: #ff5370;
    --warning: #ffb454;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    --bg-overlay: rgba(10, 14, 26, var(--bg-dim, 0.7));
    --glass-sidebar: rgba(15, 20, 32, 0.6);
    --glass-content: rgba(10, 14, 26, 0.4);
    --glass-modal: rgba(15, 20, 32, 0.8);
}

/* === Theme: Cherry Pink === */
[data-theme="cherry-pink"] {
    --bg-primary: #fffafa;
    --bg-secondary: #fff0f5;
    --bg-tertiary: #ffe4e1;
    --border: #ffb6c1;
    --text-primary: #6a0d3f;
    --text-secondary: #880e4f;
    --text-muted: #ad1457;
    --accent: #ff69b4;
    --accent-hover: #ff1493;
    --success: #3fb950;
    --danger: #f85149;
    --warning: #d29922;
    --shadow: 0 4px 12px rgba(255, 105, 180, 0.2);
    --bg-overlay: rgba(255, 250, 250, var(--bg-dim, 0.7));
    --glass-sidebar: rgba(255, 240, 245, 0.6);
    --glass-content: rgba(255, 245, 245, 0.4);
    --glass-modal: rgba(255, 240, 245, 0.8);
}



/* === Reset === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 16px;
}

/* === Layout === */
.app {
    display: flex;
    height: 100vh;
    position: relative;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    filter: brightness(var(--bg-brightness, 1));
}

.app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay, rgba(13, 17, 23, 0.7));
    z-index: 0;
    pointer-events: none;
    display: none;
}

.app.has-bg::before {
    display: block;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.app.has-bg .sidebar {
    background: var(--glass-sidebar, rgba(22, 27, 34, 0.6));
    backdrop-filter: blur(var(--bg-blur, 10px));
    -webkit-backdrop-filter: blur(var(--bg-blur, 10px));
}

.sidebar,
.main-content {
    position: relative;
    z-index: 1;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.job-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* === Job Items === */
.job-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.job-item:hover {
    background: var(--bg-tertiary);
}

.job-item.active {
    background: var(--accent);
    color: white;
}

.job-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.job-item.running .status-dot {
    background: var(--success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.job-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.job-item:hover .job-actions {
    opacity: 1;
}

.job-btn {
    background: transparent;
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: all 0.15s;
    color: inherit;
}

.job-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app.has-bg .main-content {
    background: var(--glass-content, rgba(13, 17, 23, 0.4));
    backdrop-filter: blur(var(--bg-blur, 8px));
    -webkit-backdrop-filter: blur(var(--bg-blur, 8px));
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* === Job Editor === */
.job-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h2 {
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

/* === Tabs === */
.tabs {
    display: flex;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tab {
    padding: 14px 22px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.tab-pane h4 {
    margin: 24px 0 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tab-pane h4:first-child {
    margin-top: 0;
}

/* === Forms === */
.form-group {
    margin-bottom: 20px;
}

.form-group>label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.form-group>label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.form-group>label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    transform: scale(1.2);
}

.form-group input:not([type="checkbox"]),
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.hint,
.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.form-group code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* GPU Selection Cards */
.gpu-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 8px;
    width: 100%;
}

.gpu-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    user-select: none;
}

.gpu-card:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.gpu-card.selected {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    /* Assuming --accent-rgb is available or I can use fallback */
}

/* Fallback if accent-rgb not defined */
:root {
    --accent-rgb: 100, 108, 255;
    /* Default purple-ish if not set */
}

.gpu-card.selected {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    box-shadow: 0 0 0 1px var(--accent);
}

.gpu-card input[type="checkbox"] {
    position: absolute !important;
    top: 14px;
    right: 14px;
    margin: 0 !important;
    transform: scale(1.2);
}

.gpu-card .gpu-index {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gpu-card .gpu-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-right: 25px;
    /* Space for checkbox */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gpu-card .gpu-mem {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.gpu-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4b5563;
    /* Gray / Idle */
    transition: all 0.3s ease;
}

.gpu-card.active-training .status-dot {
    background: #10b981;
    /* Green */
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
    animation: status-pulse 2s infinite;
}

.gpu-card.active-sampling .status-dot {
    background: #3b82f6;
    /* Blue */
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
    animation: status-pulse 2s infinite;
}

.gpu-status-text {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.gpu-card.active-training .gpu-status-text {
    color: #10b981;
}

.gpu-card.active-sampling .gpu-status-text {
    color: #3b82f6;
}

@keyframes status-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}



.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-primary);
}

/* === Buttons === */
.btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    filter: brightness(1.2);
}


.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* === Console === */
.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.console-header h4 {
    margin: 0 !important;
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-family: 'SF Mono', Consolas, 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-height: 400px;
    max-height: calc(100vh - 300px);
}

/* Console theme-specific overrides for better readability */
[data-theme="github-light"] .console-output {
    background: #f6f8fa;
    color: #24292f;
    border-color: #d0d7de;
}

[data-theme="cherry-pink"] .console-output {
    background: #2d1b2e;
    color: #f0d0e8;
    border-color: #6a0d3f;
}


/* === Prompts === */
.prompts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.prompts-header h4 {
    margin: 0 !important;
}

.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-card-edit {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-card-edit.skipped {
    opacity: 0.5;
    filter: grayscale(0.5);
    border-style: dashed;
}

.prompt-card-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -8px;
}

.skip-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.skip-label input {
    margin: 0;
    cursor: pointer;
}

.prompts-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.prompts-empty.hidden,
.prompts-list.hidden {
    display: none;
}

/* === Samples === */
.samples-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.samples-header h4 {
    margin: 0 !important;
}

/* Sample Groups */
.sample-group {
    margin-bottom: 32px;
}

.group-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* Sample Cards */
.sample-card {
    position: relative;
    width: 200px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    will-change: transform;
    /* Improved font rendering during animation */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sample-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.sample-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: #000;
}

.sample-name {
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-delete-card {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(248, 81, 73, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 15;
}

.sample-card:hover .btn-delete-card {
    opacity: 1;
}

.btn-delete-card:hover {
    background: #f85149;
    transform: scale(1.1);
}

/* Selection State */
.sample-card.selected {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb, 88, 166, 255), 0.1);
    /* Fallback */
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 88, 166, 255), 0.3);
}

.group-grid.multi-select-mode .sample-card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Drag and Drop */
.sample-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.sample-card.drag-over-left {
    border-left: 4px solid var(--accent);
    border-left-color: var(--accent) !important;
}

.sample-card.drag-over-right {
    border-right: 4px solid var(--accent);
    border-right-color: var(--accent) !important;
}

.group-grid.drag-over-grid {
    background-color: rgba(var(--accent-rgb, 88, 166, 255), 0.05);
    border-radius: var(--radius);
}

/* Selection Box (Rubber Band) */
.selection-box {
    position: absolute;
    border: 1px solid var(--accent);
    background-color: rgba(var(--accent-rgb, 88, 166, 255), 0.2);
    pointer-events: none;
    z-index: 1000;
    display: none;
    /* Hidden by default */
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.lightbox-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    pointer-events: none;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2001;
}

.lightbox-metadata {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(13, 17, 23, 0.85);
    color: #e6edf3;
    padding: 16px;
    border-radius: 12px;
    font-size: 0.8rem;
    max-width: 320px;
    max-height: 80vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    line-height: 1.5;
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 2002;
    transition: opacity 0.3s ease;
}

.lightbox-metadata.hidden {
    display: none;
}

.lightbox-nav {
    position: absolute;
    bottom: 20px;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
}

.samples-empty.hidden,
.samples-grid.hidden {
    display: none;
}

/* === TensorBoard === */
.tensorboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tensorboard-header h4 {
    margin: 0 !important;
}

.tb-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.tb-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-primary);
    height: calc(100vh - 280px);
    min-height: 400px;
}

.tb-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.tb-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.tb-placeholder h3 {
    margin: 0 0 8px;
    color: var(--text-secondary);
}

.tb-placeholder p {
    margin: 4px 0;
}

/* === Image Lightbox === */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: pointer;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}

/* === Section Cards === */
.section-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.section-card h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 450px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.app.has-bg .modal-content {
    background: var(--glass-modal, rgba(22, 27, 34, 0.8));
    backdrop-filter: blur(var(--bg-blur, 16px));
    -webkit-backdrop-filter: blur(var(--bg-blur, 16px));
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-content h4 {
    margin: 24px 0 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-content h4:first-of-type {
    margin-top: 0;
}

.modal-confirm-content {
    max-width: 450px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-large {
    width: 550px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* === Danger Zone === */
.danger-zone {
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius);
    padding: 16px;
    background: rgba(248, 81, 73, 0.05);
}

/* === Utilities === */
.hidden {
    display: none !important;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* === Alert === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-warning {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--warning);
}

.alert-success {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--success);
}

/* === Editable Prompts === */
.compact-input {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compact-input label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.compact-input input {
    padding: 6px 8px;
    /* Slightly more padding */
    font-size: 0.95rem;
    /* Slightly larger font */
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 90px;
    /* Increased from 60px */
}

.compact-input input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Global Settings Bar (Prompts Tab) */
.global-settings-bar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: var(--radius);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
}

.prompts-list-editable {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 20px;
    padding-bottom: 40px;
}

.prompt-card-edit {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s;
}

.prompt-card-edit:focus-within {
    border-color: var(--accent);
}

.prompt-card-edit textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 8px;
    resize: none;
    min-height: 60px;
    font-family: inherit;
    font-size: 0.95rem;
    overflow-y: hidden;
}

.prompt-card-edit textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.prompt-card-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* === Background Drag Styles === */
.bg-drag-container {
    width: 100%;
    height: 120px;
    background: #000;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    margin: 8px 0;
    border: 1px solid var(--border);
}

.bg-drag-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.6;
    pointer-events: none;
}

.bg-drag-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    top: 50%;
    left: 50%;
}

.app.has-bg .console-output {
    background: rgba(13, 17, 23, 0.6);
}

body {
    text-shadow: 0 1px var(--text-shadow-size, 0px) rgba(0, 0, 0, 0.8);
}

input:disabled, select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === Hardware Monitor Bar === */
.hw-monitor {
    position: fixed;
    bottom: 0;
    left: 280px;
    right: 0;
    z-index: 50;
    background: transparent;
    border-top: 1px solid var(--border);
    padding: 5px 4px;
    display: flex;
    align-items: flex-start;
}

.hw-monitor::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-secondary);
    opacity: 0.55;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: -1;
}

.hw-monitor:hover::before {
    opacity: 1;
}

/* Toggle tab — right side, sits on the top border */
.hw-toggle {
    position: absolute;
    top: -20px;
    right: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--text-muted);
    font-size: 0.6rem;
    line-height: 1;
    padding: 3px 10px 4px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    z-index: 1;
}

.app.has-bg .hw-toggle {
    background: var(--glass-sidebar);
    backdrop-filter: blur(var(--bg-blur, 10px));
    -webkit-backdrop-filter: blur(var(--bg-blur, 10px));
}

.hw-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Collapsed: hide full cards, show compact bar instead */
.hw-monitor.hw-collapsed .hw-stats-container {
    display: none;
}

.hw-monitor.hw-collapsed .hw-compact-bar {
    display: flex;
}

/* Compact bar (shown when collapsed) */
.hw-compact-bar {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    padding: 4px 8px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.hw-compact-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.hw-compact-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.hw-compact-sep {
    width: 1px;
    height: 14px;
    background: var(--border);
    flex-shrink: 0;
}

.app.has-bg .hw-monitor::before {
    background: var(--glass-sidebar);
    backdrop-filter: blur(var(--bg-blur, 10px));
    -webkit-backdrop-filter: blur(var(--bg-blur, 10px));
}

.hw-stats-container {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
    gap: 0;
}

.hw-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 16px 5px 10px;
    border-right: 1px solid var(--border);
    min-width: 200px;
}

.hw-section:last-child {
    border-right: none;
}

.hw-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 1px;
}

.hw-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.hw-section-gpu .hw-section-title {
    color: var(--text-primary);
}

.hw-section-gpu.hw-active .hw-section-title {
    color: var(--accent);
}

.hw-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hw-metric-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 34px;
    white-space: nowrap;
}

.hw-bar-wrap {
    width: 72px;
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.hw-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 1.2s ease;
}

.hw-bar-ram {
    background: var(--accent);
    opacity: 0.75;
}

.hw-bar-gpu {
    background: var(--success);
}

.hw-bar-vram {
    background: var(--warning);
}

.hw-bar-power {
    background: var(--danger);
    opacity: 0.8;
}

.hw-metric-value {
    font-size: 0.71rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hw-temp {
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hw-temp-cool { color: var(--success); }
.hw-temp-warm { color: var(--warning); }
.hw-temp-hot  { color: var(--danger);  }

.hw-activity-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 3px;
    padding: 1px 5px;
    letter-spacing: 0.03em;
    background: var(--warning);
    color: #000;
    white-space: nowrap;
}

.hw-loading {
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 6px 10px;
}

/* Bottom padding adjusts dynamically via --hw-bar-height CSS variable set by JS */
.tab-content {
    padding-bottom: max(38px, var(--hw-bar-height, 38px));
}

.disabled-section {
    opacity: 0.4 !important;
    pointer-events: none !important;
    filter: grayscale(0.8);
    transition: opacity 0.2s ease;
}