:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #292e36;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #7c5cfc;
    --accent-hover: #6a4de0;
    --accent-glow: rgba(124, 92, 252, 0.15);
    --success: #3fb950;
    --error: #f85149;
    --warning: #d29922;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* Layout */
.app { display: flex; flex-direction: column; height: 100vh; }

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    -webkit-app-region: drag;
}

.header h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.header h1 span { color: var(--accent); }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-app-region: no-drag;
    position: relative;
}

.api-status {
    display: flex;
    gap: 6px;
    align-items: center;
}

.api-dot {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}
.api-dot-on {
    color: var(--success);
    background: rgba(63, 185, 80, 0.1);
}
.api-dot-off {
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.spending-tracker {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    user-select: none;
    transition: border-color 0.15s;
}

.spending-tracker:hover {
    border-color: var(--accent);
}

.spending-caret {
    font-size: 8px;
    opacity: 0.6;
}

.spending-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    overflow: hidden;
}

.spending-panel-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 10px 14px 6px;
    border-bottom: 1px solid var(--border);
}

.spending-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.spending-row:last-child {
    border-bottom: none;
}

.spending-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.spending-provider {
    font-size: 12px;
    font-weight: 700;
}

.spending-gens {
    font-size: 10px;
    color: var(--text-muted);
}

.spending-consumed,
.spending-remaining {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    margin-top: 2px;
}

.spending-consumed-label,
.spending-remaining-label {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.spending-consumed-val {
    color: var(--text-primary);
    font-weight: 600;
}

.spending-remaining-val {
    color: var(--success);
    font-weight: 600;
}

.spending-src {
    font-size: 8px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--accent-glow);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.spending-bar {
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.spending-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.spending-empty {
    padding: 16px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.nav {
    display: flex;
    gap: 2px;
    -webkit-app-region: no-drag;
}

.nav button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.nav button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav button.active { background: var(--accent); color: #fff; }

.main {
    flex: 1;
    overflow: hidden;
    display: flex;
}

/* Generate View */
.generate-view {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.gen-sidebar {
    width: 340px;
    min-width: 300px;
    max-width: 380px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.gen-sidebar::-webkit-scrollbar { width: 6px; }
.gen-sidebar::-webkit-scrollbar-track { background: transparent; }
.gen-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.gen-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.gen-section label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

select, input[type="text"], input[type="number"], textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.5;
}

.param-group {
    margin-bottom: 12px;
}

.param-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    margin-bottom: 6px;
}

.param-group label .param-val {
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
}

.param-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 4px;
    margin-top: -2px;
}

.param-desc-inline {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

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

.checkbox-group label {
    font-size: 13px;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    cursor: pointer;
}

.btn-generate {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
}

.btn-generate:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Browse more link */
.mp-browse-link {
    font-size: 10px;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    font-weight: 600;
    float: right;
    margin-top: -1px;
}
.mp-browse-link:hover { text-decoration: underline; }

/* Model pricing */
.model-pricing {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1;
}
.pricing-free {
    color: var(--success);
    font-weight: 600;
}
.pricing-cost {
    color: var(--warning, #e8a525);
}
.pricing-unknown {
    color: var(--text-muted);
}

.filter-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 4px;
}
.filter-unrestricted {
    color: var(--success);
    background: rgba(63, 185, 80, 0.12);
}
.filter-restricted {
    color: var(--warning);
    background: rgba(210, 153, 34, 0.12);
}

/* Content filter note */
.filter-note {
    font-size: 11px;
    color: var(--text-muted);
}
.filter-note summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
    user-select: none;
}
.filter-note summary:hover { color: var(--text-primary); }
.filter-note-body {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.5;
}
.filter-note-body p { margin-bottom: 4px; }
.filter-note-body ul {
    margin: 0 0 8px 16px;
    padding: 0;
}
.filter-note-body li { margin-bottom: 1px; }
.filter-note-body strong { color: var(--text-secondary); }
.filter-note-tip {
    color: var(--warning);
    font-style: italic;
    margin-bottom: 0 !important;
}

/* Model card buttons */
.model-card-buttons {
    display: flex;
    gap: 4px;
}
.btn-use-lora {
    background: var(--accent) !important;
    font-size: 11px !important;
}

/* LoRA input */
.loras-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.lora-buttons {
    display: flex;
    gap: 4px;
}
.btn-add-lora {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}
.btn-add-lora:hover { background: var(--accent-hover); }
.btn-add-lora-manual {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-add-lora-manual:hover { background: var(--bg-hover); color: var(--text-primary); }
.lora-entry {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.lora-url {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}
.lora-url:focus { outline: none; border-color: var(--accent); }
.lora-scale-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.lora-scale-wrap label {
    font-size: 10px;
    color: var(--text-muted);
}
.lora-scale {
    width: 60px;
}
.lora-scale-wrap .param-val {
    font-size: 11px;
    min-width: 28px;
    text-align: center;
}
.btn-remove-lora {
    background: none;
    border: none;
    color: var(--error);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.btn-remove-lora:hover { opacity: 0.7; }
.lora-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
}

/* ComfyUI LoRA entries */
.comfyui-lora-entry {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.comfyui-lora-select {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}
.comfyui-lora-select:focus { outline: none; border-color: var(--accent); }

/* URPM Realism Pro custom controls */
.urpm-loras-group { margin-bottom: 4px; }
.urpm-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.urpm-radio {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--text-primary) !important;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    transition: all 0.15s;
    margin: 0 !important;
}
.urpm-radio:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent) !important;
}
.urpm-radio input[type="radio"] {
    width: 12px;
    height: 12px;
    accent-color: var(--accent);
}

/* Image input */
.image-input-group { }
.image-input-controls {
    display: flex;
    gap: 6px;
}
.image-url-input {
    flex: 1;
    min-width: 0;
}
.btn-browse-file {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}
.btn-browse-file:hover { background: var(--bg-hover); }
.image-input-preview {
    margin-top: 6px;
    max-height: 120px;
    overflow: hidden;
    border-radius: var(--radius);
}
.image-input-preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: var(--radius);
    object-fit: contain;
}

/* Param textarea (negative prompt etc) */
.param-textarea {
    width: 100%;
    min-height: 48px;
    max-height: 100px;
    padding: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}
.param-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Send-to buttons */
.btn-send-to {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border) !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
}
.btn-send-to:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
}
.lightbox-send-to {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.send-to-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 2px;
}

/* Result area */
.gen-result {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

/* Center placeholder/spinner vertically, but let results flow from top */
.gen-result > .result-placeholder,
.gen-result > .spinner {
    margin: auto 0;
}

.gen-result > .result-display {
    margin: auto 0;
}

.result-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.result-placeholder .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.result-placeholder p {
    font-size: 14px;
}

.spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

.result-display {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    word-break: break-word;
}

.result-display img {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    border-radius: var(--radius-lg);
    object-fit: contain;
}

.result-display video, .result-display audio {
    max-width: 100%;
    border-radius: var(--radius-lg);
}

.result-saved {
    font-size: 11px;
    color: var(--text-muted);
}

.result-prompt-display {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 600px;
    text-align: center;
    max-height: 80px;
    overflow-y: auto;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-small {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-small:hover { background: var(--bg-hover); border-color: var(--accent); }

/* History View */
.history-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.history-filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-group-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 4px;
    white-space: nowrap;
}

.history-filter-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.filter-btn {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.history-grid {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    align-content: start;
}

.history-grid::-webkit-scrollbar { width: 6px; }
.history-grid::-webkit-scrollbar-track { background: transparent; }
.history-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.history-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.15s;
    cursor: pointer;
}

.history-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.history-card-thumb {
    width: 100%;
    height: 160px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.history-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-card-thumb .media-icon {
    font-size: 36px;
    opacity: 0.3;
}

.thumb-loading {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.history-card-info {
    padding: 12px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.history-card-info .model-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.provider-fal {
    color: #7c5cfc;
    background: rgba(124, 92, 252, 0.12);
}
.provider-replicate {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
}
.provider-civitai {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}
.provider-acestep {
    color: #ec4899;
    background: rgba(236, 72, 153, 0.12);
}
.provider-comfyui {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
}

.history-card-info .prompt-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.history-card-info .meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-card-info .timestamp {
    font-size: 11px;
    color: var(--text-muted);
}

.history-card-info .card-actions {
    display: flex;
    gap: 4px;
}

.card-btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.card-btn.remix {
    background: var(--accent-glow);
    color: var(--accent);
}
.card-btn.remix:hover { background: var(--accent); color: #fff; }

.card-btn.delete {
    background: rgba(248, 81, 73, 0.1);
    color: var(--error);
}
.card-btn.delete:hover { background: var(--error); color: #fff; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-badge.pending { background: rgba(210, 153, 34, 0.15); color: var(--warning); }
.status-badge.running { background: var(--accent-glow); color: var(--accent); }
.status-badge.completed { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.status-badge.failed { background: rgba(248, 81, 73, 0.1); color: var(--error); }

.history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.history-pagination button {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.history-pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.history-pagination span { font-size: 12px; color: var(--text-secondary); }

/* Civitai model search results */
.civitai-results {
    margin-top: 8px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
}

.civitai-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.civitai-result-item:hover { background: var(--bg-tertiary); }
.civitai-result-item.selected { background: var(--accent-glow); border-color: var(--accent); }

.civitai-result-item img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
}

.civitai-result-item .model-info {
    flex: 1;
    min-width: 0;
}

.civitai-result-item .model-info .name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.civitai-result-item .model-info .version {
    font-size: 11px;
    color: var(--text-muted);
}

/* View switching */
.view { display: none; }
.view.active { display: flex; }

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    z-index: 1000;
    animation: slideIn 0.2s ease;
}

.toast.error { background: var(--error); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Multiple images grid */
.result-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    max-width: 100%;
}

.result-images-grid img {
    width: 100%;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.15s;
}

.result-images-grid img:hover { transform: scale(1.02); }

/* Models Browser View */
.models-view {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.models-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.models-provider-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 2px;
}

.provider-tab {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.provider-tab:hover { color: var(--text-primary); }
.provider-tab.active { background: var(--accent); color: #fff; }

.models-search {
    flex: 1;
    min-width: 200px;
}

.models-search input {
    height: 34px;
}

.models-filters {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.models-filters select {
    width: auto;
    min-width: 120px;
    height: 34px;
    padding: 4px 10px;
    font-size: 12px;
}

.btn-refresh {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 16px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-refresh:hover { background: var(--bg-hover); color: var(--text-primary); }

.models-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    grid-auto-rows: min-content;
    gap: 8px;
    align-content: start;
}

.models-grid::-webkit-scrollbar { width: 6px; }
.models-grid::-webkit-scrollbar-track { background: transparent; }
.models-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.model-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: row;
    min-height: 72px;
}

.model-card:hover {
    border-color: var(--accent);
}

.model-card-thumb {
    width: 80px;
    min-height: 72px;
    align-self: stretch;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.model-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-card-thumb .no-thumb {
    font-size: 20px;
    opacity: 0.2;
}

.model-card-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 7px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--accent);
}

.model-card-info {
    padding: 6px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    justify-content: center;
    gap: 1px;
}

.model-card-info .model-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.model-card-info .model-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.model-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.model-card-stats {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
}

.model-card-stats span {
    display: flex;
    align-items: center;
    gap: 2px;
}

.model-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.model-tag {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.btn-use-model {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-use-model:hover { background: var(--accent-hover); }

.model-card-id {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Result saved indicator */
.result-saved {
    font-size: 11px;
    color: var(--success);
    margin-top: 4px;
    padding: 4px 10px;
    background: rgba(63, 185, 80, 0.1);
    border-radius: 4px;
}

.result-prompt-display {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 500px;
    text-align: center;
    line-height: 1.4;
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    max-height: 60px;
    overflow-y: auto;
}

/* AI Enhancement details */
.ai-enhance-details {
    max-width: 500px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}
.ai-enhance-details summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
}
.ai-enhance-body {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: left;
}
.ai-enhance-section {
    margin-bottom: 8px;
}
.ai-enhance-section:last-child { margin-bottom: 0; }
.ai-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.ai-prompt-text {
    font-size: 11px;
    color: var(--text-primary);
    line-height: 1.4;
    max-height: 80px;
    overflow-y: auto;
    padding: 4px 6px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-bottom: 4px;
}
.ai-enhance-settings {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.ai-enhance-settings strong {
    color: var(--accent);
}
.btn-copy {
    font-size: 10px;
    padding: 2px 8px;
}

/* History badge */
.history-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    margin-left: 4px;
    padding: 0 5px;
}

/* Lightbox overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
    backdrop-filter: blur(8px);
}

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

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 2001;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    object-fit: contain;
}

.lightbox-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 95vh;
}

.lightbox-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.lightbox-media img,
.lightbox-media video {
    max-width: 85vw;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    object-fit: contain;
}

.lightbox-details {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    max-width: 600px;
    width: 100%;
}

.lightbox-model {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}

.lightbox-prompt {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
    max-height: 80px;
    overflow-y: auto;
}

.lightbox-meta {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.lightbox-actions {
    display: flex;
    gap: 8px;
}

.lightbox-missing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
}

.lightbox-params {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.lightbox-params span {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* LoRA Browse Modal */
.lora-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
    backdrop-filter: blur(4px);
}
.lora-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lora-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.lora-modal-header h3 {
    font-size: 14px;
    font-weight: 600;
}
.lora-modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}
.lora-modal-tab {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}
.lora-modal-tab:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.lora-modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.lora-modal-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.lora-modal-search input {
    width: 100%;
    height: 32px;
}
.lora-modal-grid {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lora-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
}
.lora-modal-item:hover { background: var(--bg-hover); }
.lora-modal-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}
.lora-modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.lora-modal-info { flex: 1; min-width: 0; }
.lora-modal-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lora-modal-meta {
    font-size: 10px;
    color: var(--text-muted);
}
.lora-modal-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.lora-modal-pagination button {
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}
.lora-modal-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.lora-modal-pagination button:hover:not(:disabled) { background: var(--bg-hover); }

/* LoRA Library View */
.loras-view {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.loras-toolbar {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
}

.loras-add-group {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 250px;
}

.loras-add-group input {
    flex: 1;
    height: 36px;
}

.btn-add-lora-lib {
    padding: 0 16px;
    height: 36px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-add-lora-lib:hover { background: var(--accent-hover); }
.btn-add-lora-lib:disabled { opacity: 0.5; cursor: not-allowed; }

.loras-search-group {
    width: 220px;
    flex-shrink: 0;
}
.loras-search-group input { height: 36px; }

.loras-library-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    align-content: start;
}

.loras-library-grid::-webkit-scrollbar { width: 6px; }
.loras-library-grid::-webkit-scrollbar-track { background: transparent; }
.loras-library-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.lora-lib-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
}
.lora-lib-card:hover { border-color: var(--accent); }

.lora-lib-card-header {
    display: flex;
    gap: 10px;
    padding: 10px;
}

.lora-lib-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}
.lora-lib-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lora-lib-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lora-lib-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lora-lib-creator {
    font-size: 11px;
    color: var(--text-muted);
}

.lora-lib-base {
    font-size: 10px;
    color: var(--accent);
    font-weight: 600;
}

.lora-lib-size {
    font-size: 10px;
    color: var(--text-muted);
}

.lora-lib-desc {
    padding: 0 10px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lora-lib-samples {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    overflow-x: auto;
}
.lora-lib-samples::-webkit-scrollbar { height: 4px; }
.lora-lib-samples::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.lora-lib-sample-img {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.1s;
}
.lora-lib-sample-img:hover { transform: scale(1.05); }

.lora-lib-actions {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    align-items: center;
}

.lora-lib-actions button {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-lora-use {
    background: var(--accent);
    color: #fff;
}
.btn-lora-use:hover { background: var(--accent-hover); }

.btn-lora-detail {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border) !important;
}
.btn-lora-detail:hover { background: var(--bg-hover); }

.btn-lora-delete {
    background: none;
    color: var(--error);
    margin-left: auto;
}
.btn-lora-delete:hover { opacity: 0.7; }

.lora-lib-status {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.lora-lib-status.downloading {
    background: var(--accent-glow);
    color: var(--accent);
}
.lora-lib-status.error {
    background: rgba(248, 81, 73, 0.1);
    color: var(--error);
}

/* LoRA Detail Panel */
.lora-detail-panel {
    position: fixed;
    top: 0; right: 0;
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.lora-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.lora-detail-header h3 { font-size: 14px; }
.lora-detail-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}
.lora-detail-close:hover { color: var(--text-primary); }

.lora-detail-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lora-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lora-detail-meta-row {
    display: flex;
    gap: 8px;
    font-size: 12px;
}
.lora-detail-meta-label {
    color: var(--text-muted);
    min-width: 90px;
    flex-shrink: 0;
}
.lora-detail-meta-value {
    color: var(--text-primary);
    word-break: break-word;
}

.lora-detail-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}

.lora-detail-compat {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.lora-compat-tag {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-glow);
    color: var(--accent);
}

.lora-detail-samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
}
.lora-detail-samples-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.1s;
}
.lora-detail-samples-grid img:hover { transform: scale(1.03); }

.lora-detail-prompts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lora-detail-prompt {
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 60px;
    overflow-y: auto;
    cursor: pointer;
    transition: border-color 0.15s;
}
.lora-detail-prompt:hover {
    border-color: var(--accent);
}

.lora-detail-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: -8px;
}

/* Settings View */
.settings-view {
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
}

.settings-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 24px 20px;
}

.settings-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.settings-section {
    margin-bottom: 28px;
}

.settings-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
}

.settings-card-header {
    margin-bottom: 8px;
}

.settings-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.settings-service-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-service-status {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.settings-service-status.status-on {
    color: var(--success);
    background: rgba(63, 185, 80, 0.12);
}

.settings-service-status.status-off {
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.settings-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.settings-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-info {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-settings {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-settings-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.btn-settings-danger {
    background: transparent;
    border-color: var(--error);
    color: var(--error);
}

.btn-settings-danger:hover {
    background: rgba(248, 81, 73, 0.1);
}

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

/* Wide screen model cards */
@media (min-width: 1400px) {
    .model-card {
        flex-direction: column;
    }

    .model-card-thumb {
        width: 100%;
        height: 140px;
    }

    .model-card-info .model-desc {
        -webkit-line-clamp: 4;
    }
}

/* ---- Responsive Design ---- */

/* Short windows: allow scrolling */
@media (max-height: 600px) {
    body { overflow: auto; }
    .app { height: auto; min-height: 100vh; }
    .main { overflow: visible; }

    .gen-result {
        justify-content: flex-start;
    }

    .result-display img {
        max-height: 50vh;
    }
}

/* Medium screens: narrower sidebar */
@media (max-width: 1100px) {
    .gen-sidebar {
        width: 300px;
        min-width: 260px;
    }

    .gen-section {
        padding: 12px 14px;
    }
}

/* Small screens: stack generate view vertically */
@media (max-width: 860px) {
    .generate-view {
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .gen-sidebar {
        width: 100%;
        min-width: unset;
        max-width: none;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-y: visible;
        flex-shrink: 0;
    }

    .gen-result {
        min-height: 300px;
        flex-shrink: 0;
        padding-top: 16px;
    }

    .gen-result > .result-placeholder,
    .gen-result > .spinner,
    .gen-result > .result-display {
        margin: 0;
    }

    .result-display img {
        max-height: 55vh;
    }

    /* Header: wrap nav on small screens */
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 6px;
    }

    .header h1 { font-size: 14px; }

    .nav button {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* History */
    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        padding: 12px;
        gap: 12px;
    }

    .history-card-thumb { height: 130px; }

    .history-filter-divider { display: none; }
    .history-toolbar { gap: 6px; }

    /* Models browser */
    .models-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .models-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .models-provider-tabs {
        flex-wrap: wrap;
    }
}

/* Extra small screens */
@media (max-width: 560px) {
    .header {
        padding: 6px 8px;
    }

    .header h1 { font-size: 13px; }

    .nav {
        flex-wrap: wrap;
        gap: 2px;
    }

    .nav button {
        padding: 5px 8px;
        font-size: 11px;
    }

    .gen-section {
        padding: 10px 12px;
    }

    .gen-result {
        padding: 12px;
    }

    .history-grid {
        grid-template-columns: 1fr;
        padding: 8px;
        gap: 8px;
    }

    .history-toolbar {
        padding: 8px 12px;
    }

    .history-filter-group {
        flex-wrap: wrap;
    }

    .result-actions {
        justify-content: center;
    }

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

    .provider-badge {
        font-size: 8px;
        padding: 1px 4px;
    }
}
