:root {
    --bg-base: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-card: #ffffff;

    --border-light: rgba(15, 23, 42, 0.1);
    --border-highlight: rgba(99, 102, 241, 0.3);

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

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;

    --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(129, 140, 248, 0.15);
    --bg-card: rgba(30, 41, 59, 0.5);

    --border-light: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(129, 140, 248, 0.4);

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

    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --secondary: #f472b6;

    --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-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-xl {
    max-width: 36rem;
}

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

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

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

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

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

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

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

.text-lg {
    font-size: 1.125rem;
}

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

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

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.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-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-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:not(:disabled) {
    color: var(--text-main);
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

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

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

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

    .detail-sidebar {
        position: fixed;
        right: -400px;
        width: 320px;
        height: 100vh;
        z-index: 50;
        transition: right 0.3s ease;
    }

    .detail-sidebar.open {
        right: 0;
    }
}

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

    .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.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

.blocks-section {
    flex: 1;
    overflow-y: auto;
}

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

.block-item {
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.block-item.active {
    color: var(--primary);
    font-weight: 500;
}

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

/* Main Workspace */
.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: 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(99, 102, 241, 0.2);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-indicator {
    color: var(--text-muted);
    padding: 0 0.5rem;
}

.view-header {
    padding: 1.5rem 2rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

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

.char-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: var(--shadow-sm);
    aspect-ratio: 1;
}

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

.char-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.char-display {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.5rem;
    font-family: sans-serif;
}

.char-hex {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
}

/* Detail Sidebar */
.detail-sidebar {
    width: 320px;
    border-radius: 0;
    border-right: none;
    border-top: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.detail-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.char-huge-display {
    font-size: 6rem;
    line-height: 1;
    text-align: center;
    padding: 2rem 0;
    font-family: sans-serif;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

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

.data-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.data-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.data-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.data-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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