/* ========================================
   AI Studio - Premium Tech Design System
   ======================================== */

/* CSS Variables */
:root {
    /* Colors */
    --bg-base: #050508;
    --bg-elevated: #0c0c12;
    --bg-card: #12121c;
    --bg-input: #1a1a28;
    --bg-hover: #22223a;

    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(168, 85, 247, 0.4);

    --gradient-primary: linear-gradient(135deg, #a855f7 0%, #06b6d4 100%);
    --gradient-glow: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(6, 182, 212, 0.15));

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.2);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --sidebar-width: 260px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app {
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Background Effects */
.bg-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-purple);
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-cyan);
    bottom: -150px;
    left: -150px;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-pink);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    opacity: 0.2;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(20px, 30px) scale(1.02);
    }
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    backdrop-filter: blur(20px);
}

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

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

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

.menu-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 12px;
}

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-align: left;
}

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.menu-icon svg {
    width: 100%;
    height: 100%;
}

.menu-glow {
    position: absolute;
    inset: 0;
    background: var(--gradient-glow);
    opacity: 0;
    transition: opacity 0.3s;
}

.menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.menu-item.active {
    background: var(--gradient-glow);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.menu-item.active .menu-glow {
    opacity: 1;
}

.menu-item.active .menu-icon {
    color: var(--accent-purple);
}

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

.settings-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.settings-trigger svg {
    width: 18px;
    height: 18px;
}

.settings-trigger:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

/* ========================================
   WORKSPACE
   ======================================== */
.workspace {
    flex: 1;
    position: relative;
    z-index: 5;
    overflow: hidden;
}

.tool-panel {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.tool-panel.active {
    display: flex;
}

/* Chat Panel */
#chat-panel {
    padding: 32px 40px;
}

.panel-header {
    margin-bottom: 24px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.title-icon {
    font-size: 32px;
}

.panel-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Panel Header Layout */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.header-left {
    flex: 1;
    min-width: 200px;
}

.header-right {
    flex-shrink: 0;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-selector label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.model-select {
    min-width: 180px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

/* Searchable Select Component */
.searchable-select {
    position: relative;
    min-width: 200px;
}

.select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.select-display:hover {
    border-color: var(--border-accent);
}

.select-display.open {
    border-color: var(--accent-purple);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.selected-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.select-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.select-display.open .select-arrow {
    transform: rotate(180deg);
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
    max-height: 300px;
    overflow: hidden;
}

.select-dropdown.open {
    display: block;
}

.select-search {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.select-search::placeholder {
    color: var(--text-muted);
}

.select-options {
    max-height: 240px;
    overflow-y: auto;
}

.select-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--text-secondary);
}

.select-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.select-option.selected {
    background: var(--gradient-glow);
    color: var(--text-primary);
}

.select-option.hidden {
    display: none;
}

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

.chat-area {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* Welcome Card */
.welcome-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.welcome-visual {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
}

.pulse-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent-purple);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.welcome-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.welcome-card h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

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

/* Chat Input */
.chat-input-wrapper {
    padding: 16px 40px 32px;
}

.image-preview-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.chat-input-box {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: var(--transition);
}

.chat-input-box:focus-within {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.input-action,
.send-action {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.input-action {
    background: transparent;
    color: var(--text-secondary);
}

.input-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.input-action svg,
.send-action svg {
    width: 20px;
    height: 20px;
}

.send-action {
    background: var(--gradient-primary);
    color: white;
}

.send-action:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    max-height: 150px;
    padding: 10px 0;
    font-family: inherit;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

/* ========================================
   IMAGE GEN PANEL
   ======================================== */
.image-gen-layout {
    display: flex;
    height: 100%;
}

.control-side {
    width: 380px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.control-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.control-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    background: var(--gradient-glow);
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    color: var(--accent-purple);
}

.control-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.control-group {
    margin-bottom: 24px;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.label-icon {
    font-size: 14px;
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.control-row {
    display: flex;
    gap: 12px;
}

.flex-1 {
    flex: 1;
}

.select-wrapper {
    position: relative;
}

.control-select,
.control-textarea,
.setting-select,
.setting-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    padding: 12px 16px;
    transition: var(--transition);
}

.control-select:focus,
.control-textarea:focus,
.setting-select:focus,
.setting-input:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.control-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Reference Upload */
.ref-upload-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

.ref-upload-zone:hover {
    border-color: var(--border-accent);
    background: rgba(168, 85, 247, 0.05);
}

.ref-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ref-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-hover);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.ref-upload-btn svg {
    width: 16px;
    height: 16px;
}

.ref-upload-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.control-footer {
    padding: 24px;
    border-top: 1px solid var(--border-subtle);
}

.generate-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.btn-content svg {
    width: 18px;
    height: 18px;
}

.btn-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(168, 85, 247, 0.4);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Preview Side */
.preview-side {
    flex: 1;
    padding: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(168, 85, 247, 0.03), transparent 70%);
}

.preview-container {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 40px;
}

.empty-visual {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    position: relative;
}

.orbit {
    position: absolute;
    inset: 0;
    border: 1px dashed var(--border-default);
    border-radius: 50%;
    animation: spin 10s linear infinite;
}

.orbit-dot {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-cyan);
}

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

.core-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

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

/* Generated Image */
.generated-result {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.generated-result img {
    max-width: 100%;
    max-height: calc(100% - 80px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.result-btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-btn.primary {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

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

.result-btn:hover {
    transform: translateY(-2px);
}

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    width: 480px;
    max-width: 90vw;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.setting-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.setting-hint a {
    color: var(--accent-cyan);
    text-decoration: none;
}

.setting-hint a:hover {
    text-decoration: underline;
}

.input-with-action {
    position: relative;
}

.input-with-action input {
    padding-right: 50px;
}

.input-action-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.input-action-btn svg {
    width: 18px;
    height: 18px;
}

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

.setting-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.setting-suffix {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
}

/* ========================================
   MESSAGES
   ======================================== */
.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
}

/* Thinking/Reasoning Block */
.thinking-block {
    margin-bottom: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(168, 85, 247, 0.05);
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(168, 85, 247, 0.1);
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.thinking-header:hover {
    background: rgba(168, 85, 247, 0.15);
}

.thinking-icon {
    font-size: 14px;
}

.thinking-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-purple);
    flex: 1;
}

.thinking-toggle {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.thinking-block.open .thinking-toggle {
    transform: rotate(180deg);
}

.thinking-content {
    display: none;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.thinking-block.open .thinking-content {
    display: block;
}

/* Loading Animation */
@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   MOBILE HEADER (hidden on desktop)
   ======================================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.menu-toggle,
.mobile-settings {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.menu-toggle:hover,
.mobile-settings:hover {
    background: var(--bg-hover);
}

.menu-toggle svg,
.mobile-settings svg {
    width: 22px;
    height: 22px;
}

.mobile-title {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ========================================
   RESPONSIVE - Tablet
   ======================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 72px;
    }

    .brand-name,
    .menu-text,
    .menu-label,
    .settings-trigger span {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 20px 12px;
    }

    .menu-item {
        justify-content: center;
        padding: 14px;
    }

    .settings-trigger {
        justify-content: center;
    }

    .control-side {
        width: 300px;
    }

    #chat-panel {
        padding: 24px;
    }

    .chat-input-wrapper {
        padding: 16px 24px 24px;
    }
}

/* ========================================
   RESPONSIVE - Mobile
   ======================================== */
@media (max-width: 768px) {

    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Sidebar becomes slide-out drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 95;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Restore sidebar content on mobile */
    .sidebar.open .brand-name,
    .sidebar.open .menu-text,
    .sidebar.open .menu-label,
    .sidebar.open .settings-trigger span {
        display: block;
    }

    .sidebar.open .sidebar-brand {
        justify-content: flex-start;
        padding: 24px 20px;
    }

    .sidebar.open .menu-item {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .sidebar.open .settings-trigger {
        justify-content: flex-start;
    }

    /* Workspace adjustments */
    .workspace {
        padding-top: 56px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chat Panel */
    #chat-panel {
        padding: 16px;
    }

    .panel-header {
        margin-bottom: 16px;
        flex-direction: column;
        gap: 12px;
    }

    .header-right {
        width: 100%;
    }

    .model-selector {
        width: 100%;
    }

    .searchable-select {
        width: 100%;
        min-width: 0;
    }

    .select-display {
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    .select-search {
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    .model-select {
        flex: 1;
        min-width: 0;
        font-size: 16px;
        /* Prevent iOS zoom */
    }

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

    .title-icon {
        font-size: 26px;
    }

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

    .chat-area {
        border-radius: var(--radius-lg);
    }

    .chat-messages {
        padding: 16px;
    }

    .welcome-visual {
        width: 100px;
        height: 100px;
    }

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

    .welcome-card h2 {
        font-size: 20px;
    }

    .chat-input-wrapper {
        padding: 12px 16px 20px;
    }

    .chat-input-box {
        padding: 6px 10px;
        border-radius: var(--radius-md);
    }

    .input-action,
    .send-action {
        width: 36px;
        height: 36px;
    }

    #messageInput {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 8px 0;
    }

    .message-content {
        max-width: 85%;
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Image Gen Layout - Stack vertically */
    .image-gen-layout {
        flex-direction: column;
        height: auto;
        min-height: 100%;
    }

    .control-side {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .control-header {
        padding: 16px;
    }

    .control-header h2 {
        font-size: 16px;
    }

    .control-body {
        padding: 16px;
    }

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

    .control-label {
        font-size: 12px;
    }

    .control-select,
    .control-textarea {
        padding: 10px 12px;
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    .control-textarea {
        min-height: 80px;
    }

    .control-footer {
        padding: 16px;
    }

    .generate-btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    .preview-side {
        padding: 16px;
        min-height: 300px;
    }

    .preview-container {
        border-radius: var(--radius-lg);
    }

    .empty-visual {
        width: 80px;
        height: 80px;
    }

    .core-icon {
        font-size: 32px;
    }

    .empty-state h3 {
        font-size: 16px;
    }

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

    .generated-result {
        padding: 16px;
    }

    .result-actions {
        flex-direction: column;
        gap: 8px;
    }

    .result-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }

    /* Modal adjustments */
    .modal-box {
        width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .setting-input,
    .setting-select {
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    /* Background effects - reduce on mobile */
    .orb {
        filter: blur(80px);
        opacity: 0.25;
    }

    .orb-1 {
        width: 300px;
        height: 300px;
    }

    .orb-2 {
        width: 250px;
        height: 250px;
    }

    .orb-3 {
        display: none;
    }
}

/* ========================================
   RESPONSIVE - Small Mobile
   ======================================== */
@media (max-width: 380px) {
    .mobile-title {
        font-size: 16px;
    }

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

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

    .control-row {
        flex-direction: column;
    }

    .ref-upload-zone {
        padding: 12px;
    }

    .ref-upload-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
}

/* ==========================================
   登录页面样式
   ========================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--border-subtle);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

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

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

.auth-form input {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
}

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

.auth-message {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    display: none;
}

.auth-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.auth-message.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* ==========================================
   管理后台样式
   ========================================== */
.admin-page {
    min-height: 100vh;
    background: var(--bg-base);
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.admin-logo img {
    width: 32px;
    height: 32px;
}

.admin-logo span {
    font-weight: 600;
    color: var(--text-primary);
}

.admin-nav {
    flex: 1;
}

.admin-nav .nav-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
}

.admin-nav .nav-item:hover {
    background: var(--bg-input);
}

.admin-nav .nav-item.active {
    background: var(--gradient-primary);
    color: white;
}

.admin-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
}

.logout-btn {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
}

.admin-main {
    flex: 1;
    padding: 32px;
    position: relative;
    overflow-y: auto;
    max-height: 100vh;
}

/* 对话模型选择栏 */
.chat-model-bar {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-model-label {
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
}

.chat-model-select {
    padding: 6px 12px;
    background: var(--bg-input, rgba(255,255,255,0.05));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
    border-radius: 8px;
    color: var(--text-primary, #f8fafc);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-model-select:hover {
    border-color: rgba(168, 85, 247, 0.4);
}

.chat-model-select:focus {
    outline: none;
    border-color: #a855f7;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-section h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

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

.admin-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.admin-table td {
    color: var(--text-primary);
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.badge.admin {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-purple);
}

.badge.vip {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--bg-input);
    color: var(--text-primary);
    margin-right: 4px;
}

.btn-sm.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.add-btn {
    padding: 10px 20px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
}

.section-toolbar {
    margin-bottom: 16px;
}

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

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

.config-input {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
}

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

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

.modal-form input,
.modal-form select {
    width: 100%;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
}

/* 用户信息样式 */
.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.user-info .logout-btn {
    padding: 4px 8px;
    font-size: 11px;
}

.level-select {
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

/* ==========================================
   角色库样式
   ========================================== */
#character-panel {
    padding: 12px 20px;
}

#character-panel .panel-header {
    margin-bottom: 12px;
}

.character-container {
    display: flex;
    height: calc(100vh - 100px);
    gap: 20px;
}

.character-sidebar {
    width: 240px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.library-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-btn {
    padding: 6px 12px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.new-btn:hover {
    transform: scale(1.05);
}

.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.library-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

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

.library-item.active {
    background: var(--gradient-glow);
    border: 1px solid var(--border-accent);
}

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

.library-item.active span {
    color: var(--text-primary);
}

.library-item .del-btn {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.library-item:hover .del-btn {
    opacity: 1;
}

.library-item .del-btn:hover {
    color: #ef4444;
}

/* 角色库主工作区 */
.character-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.create-section,
.action-section,
.result-section,
.char-list-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 20px;
}

.create-section h3,
.result-section h3,
.char-list-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* 创建表单 */
.create-form .form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.create-form .form-group {
    flex: 1;
}

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

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

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

.style-input {
    display: flex;
    gap: 8px;
}

.style-input select {
    width: 45%;
}

.style-input input {
    flex: 1;
}

/* 操作区 */
.action-section {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

.upload-area {
    flex: 1;
}

.upload-area label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-btn {
    padding: 10px 20px;
    background: var(--bg-hover);
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.upload-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.upload-preview {
    margin-top: 10px;
}

.ref-preview-item {
    position: relative;
    display: inline-block;
}

.ref-preview-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.ref-preview-item .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

/* 结果区 */
.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.result-content img {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.result-info {
    width: 100%;
    max-width: 500px;
}

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

.result-info textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
}

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

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-hover);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* 角色网格 - 单行横向滚动 */
.character-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.character-grid::-webkit-scrollbar {
    height: 6px;
}

.character-grid::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}

.character-grid::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.character-card {
    flex-shrink: 0;
    width: 150px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    transition: var(--transition);
}

.character-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.character-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
}

.char-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
}

.char-name {
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.char-info .del-btn {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.character-card:hover .del-btn {
    opacity: 1;
}

.char-info .del-btn:hover {
    color: #ef4444;
}

/* 空状态 */
.character-container .empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* 角色库响应式 - 平板 */
@media (max-width: 1024px) {
    .character-container {
        flex-direction: column;
        height: auto;
    }

    .character-sidebar {
        width: 100%;
        max-height: 200px;
    }
}

/* 角色库响应式 - 手机 */
@media (max-width: 768px) {
    .character-container {
        padding: 16px;
        gap: 16px;
    }

    .create-form .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .action-section {
        flex-direction: column;
        align-items: stretch;
    }

    .character-grid {
        gap: 12px;
    }
}

/* Toast 动画 */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* 图标按钮 */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 浅色主题 */
:root.light-theme,
body.light-theme {
    --bg-base: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --bg-hover: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.1);
}
:root.light-theme .sidebar,
body.light-theme .sidebar {
    background: #ffffff;
    border-color: #e2e8f0;
}
:root.light-theme .modal-box,
body.light-theme .modal-box {
    background: #ffffff;
}
:root.light-theme .setting-input,
body.light-theme .setting-input {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #e2e8f0;
}

/* ==========================================
   工具配置样式
   ========================================== */
.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--bg-card, #1a1a28);
    border-radius: 12px;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    overflow: hidden;
}

.tool-card-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(6, 182, 212, 0.1));
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.tool-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #f8fafc);
}

.tool-category {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-input, rgba(255,255,255,0.05));
    padding: 2px 8px;
    border-radius: 4px;
}

.tool-card-body {
    padding: 20px;
}

.config-section {
    margin-bottom: 20px;
}

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

.config-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 10px;
}

.model-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.model-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-input, rgba(255,255,255,0.05));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.model-checkbox:hover {
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

.model-checkbox.checked {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
}

.model-checkbox input {
    display: none;
}

.checkbox-mark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted, #64748b);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
}

.model-checkbox.checked .checkbox-mark {
    background: linear-gradient(135deg, #a855f7, #06b6d4);
    border-color: transparent;
}

.model-checkbox.checked .checkbox-mark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.model-name {
    font-size: 13px;
    color: var(--text-primary, #f8fafc);
}

.model-disabled {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

.default-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input, rgba(255,255,255,0.05));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
    border-radius: 8px;
    color: var(--text-primary, #f8fafc);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.default-select:hover {
    border-color: rgba(168, 85, 247, 0.4);
}

.default-select:focus {
    outline: none;
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.no-models {
    color: var(--text-muted, #64748b);
    font-size: 13px;
    padding: 12px;
    background: var(--bg-input, rgba(255,255,255,0.03));
    border-radius: 8px;
    text-align: center;
    width: 100%;
}

.empty-tip {
    color: var(--text-muted, #64748b);
    text-align: center;
    padding: 40px;
}

/* 浅色主题适配 */
:root.light-theme .tool-card,
body.light-theme .tool-card {
    background: #ffffff;
    border-color: #e2e8f0;
}

:root.light-theme .tool-card-header,
body.light-theme .tool-card-header {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(6, 182, 212, 0.08));
}

:root.light-theme .model-checkbox,
body.light-theme .model-checkbox {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

:root.light-theme .model-checkbox:hover,
body.light-theme .model-checkbox:hover {
    background: #e2e8f0;
}

:root.light-theme .default-select,
body.light-theme .default-select {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #1e293b;
}
