:root {
    --bg-base: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.8);
    --bg-input: #ffffff;
    --bg-hover: rgba(59, 130, 246, 0.08);

    --border-light: rgba(15, 23, 42, 0.1);
    --border-highlight: rgba(59, 130, 246, 0.3);

    --text-main: #0f172a;
    --text-muted: #64748b;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #6366f1;

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

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

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

[data-theme="dark"] {
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-input: #1e293b;
    --bg-hover: rgba(56, 189, 248, 0.15);

    --border-light: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(56, 189, 248, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --secondary: #818cf8;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

svg {
    display: block;
}

.w-3 {
    width: 0.75rem;
}

.h-3 {
    height: 0.75rem;
}

.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;
}

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
}

.max-w-2xl {
    max-width: 42rem;
}

.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;
}

.mt-6 {
    margin-top: 1.5rem;
}

.ml-1 {
    margin-left: 0.25rem;
}

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

.justify-start {
    justify-content: flex-start !important;
}

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

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

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

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

.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.625rem 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(--primary-hover);
    border-color: var(--primary-hover);
}

[data-theme="dark"] .btn-primary {
    color: #000;
}

.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);
}

/* Forms Input */
.form-input,
.form-select {
    background: var(--bg-input);
    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;
    width: 100%;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Layout Grid */
.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: 1.5rem;
    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: var(--bg-hover);
    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;
    overflow-y: auto;
}

.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);
    font-weight: 500;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

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

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

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

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

.search-input {
    width: 100%;
    background: var(--bg-input);
    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: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.content-area {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* Snippet List View */
.view-layer {
    padding: 2rem;
}

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.snippet-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: 260px;
    overflow: hidden;
}

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

.snippet-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.snippet-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    word-break: break-word;
}

.snippet-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

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

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

.btn-fav.active {
    color: var(--warning);
    opacity: 1 !important;
}

.snippet-card:has(.btn-fav.active) .snippet-actions {
    opacity: 1;
}

.snippet-preview {
    flex: 1;
    padding: 1rem;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    position: relative;
}

[data-theme="dark"] .snippet-preview {
    background: rgba(0, 0, 0, 0.15);
}

.snippet-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--bg-panel));
    pointer-events: none;
}

.snippet-preview pre {
    margin: 0;
}

.snippet-preview code {
    background: transparent !important;
    padding: 0 !important;
}

.snippet-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
}

.snippet-footer::-webkit-scrollbar {
    display: none;
}

.lang-badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-badge {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.625rem;
}

/* Editor View */
.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.editor-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.editor-title-input {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-meta {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .editor-meta {
    background: rgba(0, 0, 0, 0.2);
}

.row-group {
    flex-direction: row;
    align-items: center;
}

.row-group label {
    width: 80px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.editor-body {
    flex: 1;
    position: relative;
    background: var(--bg-input);
}

.code-editor-textarea {
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    resize: none;
    outline: none;
    line-height: 1.6;
    tab-size: 4;
}

/* 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;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-base);
    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;
}