:root {
    --primary: #EC4899;
    --secondary: #F472B6;
    --accent: #FBCFE8;
    --bg-dark: #1A1A2E;
    --bg-darker: #121220;
    --surface-dark: rgba(30, 30, 50, 0.6);
    --border-dark: rgba(255, 255, 255, 0.08);
    --text-primary: #FFFFFF;
    --text-secondary: #9BA1B0;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;

    --bg-current: var(--bg-dark);
    --surface-current: var(--surface-dark);
    --border-current: var(--border-dark);
    --text-main: var(--text-primary);
    --text-muted: var(--text-secondary);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
    --bg-current: #F8FAFC;
    --surface-current: rgba(255, 255, 255, 0.8);
    --border-current: rgba(0, 0, 0, 0.08);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --bg-darker: #E2E8F0;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-current);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.glass {
    background: var(--surface-current);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-current);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-current);
    z-index: 10;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    color: var(--primary);
}

.logo h2 {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-box {
    margin: 0 16px 16px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: var(--bg-darker);
    border: 1px solid var(--border-current);
    color: var(--text-main);
    border-radius: 8px;
    padding: 10px 10px 10px 40px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.2);
}

.categories {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.categories::-webkit-scrollbar {
    width: 4px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    border: border: 1px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: var(--surface-current);
    color: var(--text-main);
    border-color: var(--border-current);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.2);
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item-left i {
    width: 18px;
    height: 18px;
}

.count-badge {
    background: var(--bg-darker);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 600;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-current);
    z-index: 5;
}

.header-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

.primary-btn,
.secondary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.primary-btn:hover {
    background: var(--secondary);
    transform: translateY(-1px);
}

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

.secondary-btn:hover {
    background: var(--surface-current);
}

/* Grid */
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    align-content: start;
}

.recipe-card {
    background: var(--surface-current);
    border: 1px solid var(--border-current);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.recipe-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 40px -10px rgba(236, 72, 153, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.card-badges {
    display: flex;
    gap: 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
}

.cat-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.diff-badge.easy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.diff-badge.medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.diff-badge.hard {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    flex: 1;
    line-height: 1.5;
}

.card-regex {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-darker);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-current);
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--border-current);
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.fav-btn:hover i {
    color: var(--primary);
}

.fav-btn.active i {
    color: var(--primary);
    fill: var(--primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 18, 32, 0.8);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

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

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: var(--bg-darker);
    border: 1px solid var(--border-current);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--surface-current);
    color: var(--text-main);
    border-color: var(--primary);
}

.icon-btn.active.heart i {
    color: var(--primary);
    fill: var(--primary);
}

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

.info-badges {
    display: flex;
    gap: 10px;
}

.pattern-desc {
    color: var(--text-muted);
    line-height: 1.6;
}

.regex-display-container {
    background: var(--bg-darker);
    border: 1px solid var(--border-current);
    border-radius: 12px;
    overflow: hidden;
}

.regex-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-current);
    background: rgba(255, 255, 255, 0.02);
}

.lang-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lang-tabs {
    display: flex;
    gap: 4px;
}

.lang-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-tab.active {
    background: var(--surface-current);
    color: var(--primary);
}

.regex-code-block {
    padding: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.regex-code-block code {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 1.1rem;
    word-break: break-all;
    padding-right: 40px;
}

.copy-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.tester-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tester-section h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
}

textarea {
    width: 100%;
    background: var(--bg-darker);
    border: 1px solid var(--border-current);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: vertical;
    transition: all 0.2s;
    min-height: 100px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

.match-status {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-current);
    color: var(--text-muted);
    border: 1px solid var(--border-current);
    pointer-events: none;
}

.match-status.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.match-status.fail {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
}

.match-status i {
    width: 14px;
    height: 14px;
}

.match-results h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.match-output {
    background: var(--bg-darker);
    border: 1px solid var(--border-current);
    border-radius: 12px;
    padding: 16px;
    min-height: 80px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
}

.match-highlight {
    background: rgba(236, 72, 153, 0.2);
    color: var(--accent);
    border-radius: 4px;
    padding: 0 2px;
    font-weight: 700;
    border: 1px solid rgba(236, 72, 153, 0.4);
}

.match-group {
    background: rgba(0, 210, 211, 0.15);
    border: 1px dotted rgba(0, 210, 211, 0.5);
    border-radius: 2px;
    padding: 0 1px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-current);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Animations & Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border-current);
    }

    .logo h2 {
        display: none;
    }

    .search-box {
        flex: 1;
        margin: 0;
    }

    .categories {
        display: none;
    }

    .sidebar-footer {
        padding: 0 16px;
        border: none;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 16px;
    }

    .content-body {
        padding: 16px;
    }

    .modal {
        max-height: 100vh;
        border-radius: 0;
    }
}