:root {
    --bg-base: #1A0D24;
    /* Royal Purple Base */
    --bg-panel: rgba(30, 15, 41, 0.7);
    /* Deep Glass Panel */
    --bg-hover: rgba(155, 89, 182, 0.15);

    --border-light: rgba(155, 89, 182, 0.2);
    --border-highlight: rgba(155, 89, 182, 0.4);

    --text-main: #f8fafc;
    --text-muted: #a395b0;

    --primary: #9B59B6;
    --primary-hover: #b871d4;
    --secondary: #8E44AD;

    --success: #10b981;
    --danger: #ef4444;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 15px rgba(155, 89, 182, 0.2);

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    background-image: radial-gradient(circle at 15% 50%, rgba(155, 89, 182, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(142, 68, 173, 0.08), transparent 25%);
    background-size: cover;
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.w-16 {
    width: 4rem;
}

.h-16 {
    height: 4rem;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
}

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

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

.text-danger {
    color: var(--danger);
}

.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xl {
    font-size: 1.25rem;
}

.font-medium {
    font-weight: 500;
}

.opacity-50 {
    opacity: 0.5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

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

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

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--border-highlight);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

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

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.375rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--bg-hover);
    border-color: var(--border-light);
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.form-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.2);
}

/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }
}

/* Sidebar */
.sidebar {
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 2rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    outline: none;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(155, 89, 182, 0.2);
    color: var(--primary);
    font-weight: 600;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0 1rem;
    margin-bottom: 0.75rem;
}

.tags-section {
    flex: 1;
}

.tags-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.tag-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.tag-item.active {
    color: var(--primary);
}

.monitoring-status {
    margin-top: auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--success);
    animation: pulse 2s infinite;
}

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

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

/* Workspace & Topbar */
.workspace {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.topbar {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-radius: 0;
    border-top: none;
    border-right: none;
    border-left: none;
    z-index: 5;
}

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
}

.search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.625rem 1rem 0.625rem 2.75rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.test-capture-area {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-light);
    background: rgba(0, 0, 0, 0.1);
}

/* Clips Grid */
.clips-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.clip-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    height: 200px;
    overflow: hidden;
}

.clip-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.clip-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
}

.clip-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.clip-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.clip-card:hover .clip-actions {
    opacity: 1;
}

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

.btn-pin.pinned {
    color: var(--primary);
    opacity: 1 !important;
}

.clip-card:has(.btn-pin.pinned) .clip-actions {
    opacity: 1;
}

.clip-body {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    color: var(--text-main);
    white-space: pre-wrap;
    word-break: break-all;
    cursor: pointer;
}

.clip-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.1);
    align-items: center;
}

.clip-tag {
    background: rgba(155, 89, 182, 0.2);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.clip-tag .remove-tag {
    cursor: pointer;
    opacity: 0.7;
}

.clip-tag .remove-tag:hover {
    opacity: 1;
}

.add-tag-btn {
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.add-tag-btn:hover {
    color: var(--primary);
}

/* Modals & Toast */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}