:root {
    --font-sans: 'Inter', -apple-system, sans-serif;
    --bg: #F9FAFB;
    --surface: #FFFFFF;
    --surface-2: #F3F4F6;
    --border: rgba(0, 0, 0, .08);
    --border-hover: rgba(99, 102, 241, .3);
    --primary: #6366F1;
    --primary-glow: rgba(99, 102, 241, .15);
    --accent: #EC4899;
    --text: #111827;
    --text-muted: #6B7280;
    --text-dim: #9CA3AF;
    --green: #10B981;
    --red: #EF4444;
    --radius: 12px;
    --radius-sm: 8px
}

[data-theme="dark"] {
    --bg: #0F1219;
    --surface: #181D2A;
    --surface-2: #1F2537;
    --border: rgba(99, 102, 241, .1);
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #64748B
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background .3s, color .3s
}

.header {
    padding: .85rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, .1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary)
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text)
}

.header-actions {
    display: flex;
    gap: .35rem
}

.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 2rem 3rem
}

.search-bar {
    margin-bottom: 1rem
}

.search-input {
    width: 100%;
    padding: .65rem .85rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .9rem;
    outline: none;
    transition: border-color .2s
}

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

.search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: .4rem
}

.result-count {
    font-size: .7rem;
    color: var(--text-dim)
}

.cat-filter {
    padding: .25rem .4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .75rem;
    outline: none
}

.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: .5rem
}

.entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem;
    text-align: center;
    cursor: pointer;
    transition: all .15s ease
}

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

.entity-card.fav {
    border-color: var(--accent)
}

.ec-char {
    font-size: 1.6rem;
    line-height: 1.2;
    margin-bottom: .2rem
}

.ec-name {
    font-size: .6rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.ec-code {
    font-size: .55rem;
    color: var(--text-dim);
    font-family: monospace
}

.preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px)
}

.preview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    position: relative;
    animation: fadeIn .3s ease
}

.preview-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem
}

.preview-char {
    font-size: 4rem;
    text-align: center;
    margin-bottom: .75rem;
    line-height: 1
}

.preview-details {
    font-size: .8rem
}

.pd-row {
    display: flex;
    justify-content: space-between;
    padding: .3rem 0;
    border-bottom: 1px solid var(--border)
}

.pd-key {
    color: var(--text-muted);
    font-weight: 500
}

.pd-val {
    font-family: monospace;
    color: var(--text);
    font-weight: 600
}

.pd-actions {
    display: flex;
    gap: .5rem;
    margin-top: .75rem
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap
}

.btn--primary {
    background: var(--primary);
    color: #fff;
    padding: .45rem .75rem;
    font-weight: 600
}

.btn--primary:hover {
    opacity: .9
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .3rem .5rem
}

.btn--ghost:hover {
    background: var(--surface-2);
    color: var(--text)
}

.btn--sm {
    font-size: .75rem;
    padding: .25rem .45rem
}

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 200
}

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

@media(max-width:600px) {
    .header {
        padding: .75rem 1rem
    }

    .main {
        padding: 1rem
    }

    .entity-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr))
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(.96)
    }

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