:root {
    /* Slate Blue Palette */
    --primary: #636E72;
    --primary-hover: #b2bec3;
    --secondary: #B2BEC3;
    --accent: #6C5CE7;
    --bg-dark: #0D1117;
    --bg-panel: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(0, 0, 0, 0.2);
    --border: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(108, 92, 231, 0.5);

    --type-obj: #3498db;
    --type-scalar: #e67e22;
    --type-enum: #9b59b6;
    --type-interface: #1abc9c;
    --type-root: #e74c3c;

    --text-main: #E1E4E8;
    --text-muted: #8B949E;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms ease;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

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

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

.hidden {
    display: none !important;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(13, 17, 23, 0.95);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.logo {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.input-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    font-weight: 600;
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-text:hover {
    text-decoration: underline;
}

textarea {
    width: 100%;
    height: 150px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: vertical;
    transition: border-color var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.error-msg {
    color: #ff7675;
    font-size: 0.8rem;
    background: rgba(255, 118, 117, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 118, 117, 0.3);
}

/* Explorer Navigation */
.explorer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.search-box svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 99px;
    color: var(--text-main);
    padding: 0.5rem 1rem 0.5rem 2.2rem;
    font-size: 0.9rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.nav-group h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.count {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 99px;
    font-size: 0.7rem;
}

.type-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.type-item {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background var(--transition);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.type-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.type-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: #fff;
    font-weight: 500;
}

.type-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.icon-obj {
    background: var(--type-obj);
}

.icon-scalar {
    background: var(--type-scalar);
}

.icon-enum {
    background: var(--type-enum);
}

.icon-interface {
    background: var(--type-interface);
}

.icon-root {
    background: var(--type-root);
    box-shadow: 0 0 8px var(--type-root);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, rgba(108, 92, 231, 0.03) 0%, transparent 70%);
}

.top-bar {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: center;
}

.view-toggles {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition);
}

.toggle-btn:hover {
    color: var(--text-main);
}

.toggle-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.views-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view-panel {
    position: absolute;
    inset: 0;
    outline: none;
    display: flex;
    flex-direction: column;
}

/* Empty State */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.empty-state .illustration {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.empty-state p {
    color: var(--text-muted);
    max-width: 400px;
}

/* Docs View */
#docs-view {
    overflow-y: auto;
    padding: 3rem;
}

.docs-header {
    max-width: 800px;
    margin: 0 auto 3rem auto;
    width: 100%;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
}

.type-kind-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: rgba(52, 152, 219, 0.2);
    color: var(--type-obj);
    margin-bottom: 0.75rem;
}

.docs-header h2 {
    font-size: 2.5rem;
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.desc-text {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.docs-body {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.docs-body h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.fields-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.field-item {
    display: flex;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.01);
    transition: background 0.2s;
}

.field-item:last-child {
    border-bottom: none;
}

.field-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.field-main {
    flex: 1;
}

.field-signature {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.field-name {
    color: var(--text-main);
    font-weight: 600;
}

.field-args {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.field-type {
    color: var(--accent);
    cursor: pointer;
}

.field-type:hover {
    text-decoration: underline;
}

.field-required {
    color: var(--type-root);
}

.field-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.relations-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.relation-tag {
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.relation-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Graph View */
#graph-view {
    position: relative;
}

.network-container {
    width: 100%;
    height: 100%;
    outline: none;
}

.graph-toolbar {
    position: absolute;
    top: 1rem;
    right: 2rem;
    z-index: 10;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(4px);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Buttons & Utils */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
}

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

.btn.primary:hover {
    background: #5a4bcf;
    transform: translateY(-1px);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.full-width {
    width: 100%;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        overflow: auto;
    }

    body {
        overflow: auto;
        height: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .explorer-nav {
        max-height: 400px;
    }

    .main-content {
        min-height: 600px;
    }

    #docs-view {
        padding: 1.5rem;
    }
}