.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.btn-ghost {
    color: var(--text-muted);
}

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

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.25);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 0 14px;
    height: 40px;
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: var(--bg-elevated);
}

.input-wrapper i {
    color: var(--text-dim);
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.input-wrapper input {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    background: transparent;
}

.dashboard-hero {
    position: relative;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.06) 50%, rgba(23, 26, 36, 0.6) 100%);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 24px;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow-md);
}

.dashboard-hero::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.dashboard-hero-content {
    position: relative;
    z-index: 1;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dashboard-hero-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.dashboard-hero-sub {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dashboard-hero-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-secondary);
}

.hero-chip strong {
    color: var(--text-primary);
}

.hero-chip i {
    color: var(--accent-primary);
}

.dashboard-hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.filter-toolbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.filter-toolbar-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 0 14px;
    height: 42px;
    transition: all var(--transition-fast);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: var(--bg-tertiary);
}

.search-input-wrapper i {
    color: var(--text-dim);
    font-size: 14px;
}

.search-input-wrapper input {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

.search-clear-btn {
    color: var(--text-dim);
    cursor: pointer;
    display: none;
    font-size: 12px;
}

.search-clear-btn:hover {
    color: var(--text-primary);
}

.sort-select-wrapper select {
    height: 42px;
    padding: 0 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sort-select-wrapper select:hover {
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.category-chips::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.chip-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

.chip-btn.active {
    background: var(--accent-soft);
    color: var(--accent-primary);
    border-color: var(--accent-border);
    font-weight: 600;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 24px;
}

.char-card-create {
    border: 2px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
    background: rgba(23, 26, 36, 0.4);
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: center;
    padding: 24px;
}

.char-card-create:hover {
    border-color: var(--accent-primary);
    background: var(--accent-soft);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.create-icon-wrap {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-full);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--accent-primary);
    transition: transform var(--transition-normal);
}

.char-card-create:hover .create-icon-wrap {
    transform: scale(1.1);
    background: var(--accent-gradient);
    color: #ffffff;
}

.create-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.create-sub {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 200px;
    line-height: 1.4;
}

.char-card {
    background: var(--bg-glass-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-smooth);
    display: flex;
    flex-direction: column;
    position: relative;
    backdrop-filter: blur(12px);
}

.char-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(99, 102, 241, 0.15);
}

.char-card-photo {
    height: 170px;
    background: linear-gradient(135deg, #181b24 0%, #11131a 100%);
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}

.char-card-photo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-secondary) 0%, transparent 60%);
}

.char-card-photo i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    color: var(--text-dim);
    opacity: 0.5;
}

.char-badge-group {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
    pointer-events: none;
}

.char-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(8px);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.char-pill.public {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.char-pill.private {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.char-pill.stats {
    background: rgba(0, 0, 0, 0.55);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.char-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    background: var(--bg-secondary);
}

.char-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.char-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.char-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
}

.char-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    opacity: 0.85;
}

.char-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-primary);
    margin-top: auto;
}

.char-chat-btn {
    flex: 1;
    height: 34px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.char-chat-btn:hover {
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

.char-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    font-size: 13px;
    transition: all var(--transition-fast);
}

.char-icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

.char-icon-btn.delete:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    gap: 16px;
    grid-column: 1 / -1;
    background: var(--bg-glass-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.empty-state i {
    font-size: 40px;
    color: var(--accent-primary);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--radius-full);
    border: 1px solid var(--accent-border);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 340px;
    line-height: 1.5;
}

.pagination-loader {
    display: flex;
    justify-content: center;
    padding: 24px;
}

.pagination-loader .btn {
    padding: 0 24px;
    height: 40px;
    gap: 8px;
}

.loading-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 0, 0, 0.6);
    transform: scale(0.95) translateY(10px);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: var(--accent-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.char-public-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    height: 40px;
}

.toggle-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-icon i {
    color: var(--accent-primary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    transition: var(--transition-fast);
    border-radius: var(--radius-full);
}

.slider::before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

input:checked + .slider::before {
    transform: translateX(18px);
}

.photo-dropzone {
    height: 120px;
    border: 2px dashed var(--border-secondary);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.photo-dropzone:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-elevated);
}

.photo-dropzone.has-image {
    border-style: solid;
    border-color: var(--accent-border);
}

.photo-dropzone.has-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    transition: opacity var(--transition-fast);
}

.photo-dropzone.has-image:hover::after {
    background: rgba(0, 0, 0, 0.65);
}

.dropzone-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    position: relative;
    z-index: 1;
}

.dropzone-placeholder i {
    font-size: 24px;
    color: var(--accent-primary);
}

.char-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }
    .dashboard-hero-actions {
        width: 100%;
    }
    .dashboard-hero-actions .btn {
        flex: 1;
    }
    .filter-toolbar-top {
        flex-direction: column;
    }
    .sort-select-wrapper {
        width: 100%;
    }
    .sort-select-wrapper select {
        width: 100%;
    }
    .characters-grid {
        grid-template-columns: 1fr;
    }
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}