:root {
    --navbar-height: 65px;
    --bg-base: #090d16;
    --bg-panel: #11182755;
    --bg-node: #1e293baa;
    --bg-node-hover: #273549;
    --border-color: #334155;

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

    --accent-blue: #38bdf8;
    --accent-purple: #c084fc;
    --accent-amber: #fbbf24;
    --accent-emerald: #34d399;
    --accent-rose: #fb7185;
}

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

html {
    min-height: 100%;
    background: #000000 url('../../static/images/pop_2008_map_bg.png') no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: transparent;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 10;
}

.navbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

input[type="text"] {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 0.85rem;
    color: var(--text-main);
    width: 260px;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent-blue);
}

.btn {
    background: var(--bg-node);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-node-hover);
    border-color: var(--accent-blue);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 1fr 440px;
    height: calc(100vh - var(--navbar-height));
    height: calc(100dvh - var(--navbar-height));
    flex: 0 0 auto;
    overflow: hidden;
}

/* Tree Styling */
.tree-viewport {
    padding: 24px 32px;
    overflow: auto;
}

.tree,
.tree ul {
    list-style-type: none;
    padding-left: 28px;
    position: relative;
}

.tree {
    padding-left: 0;
}

.tree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 12px;
    bottom: 12px;
    width: 1px;
    background: var(--text-main);
}

.tree li {
    position: relative;
    margin: 6px 0;
}

.tree li::before {
    content: '';
    position: absolute;
    top: 18px;
    left: -16px;
    width: 16px;
    height: 1px;
    background: var(--text-main);
}

.tree-node-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-node);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}

.tree-node-item:hover {
    background: var(--bg-node-hover);
    border-color: var(--accent-blue);
    transform: translateX(2px);
}

.tree-node-item.selected {
    background: #1e3a5f;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue);
}

.toggle-btn {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: var(--bg-base);
    color: var(--text-muted);
    font-size: 9px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

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

.node-label {
    font-weight: 600;
}

.badge-pill {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-list {
    background: rgba(192, 132, 252, 0.15);
    color: var(--accent-purple);
}

.badge-sequencer {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
}

.badge-fertile {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-emerald);
}

.req-condition-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cond-direct {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.cond-inverted {
    background: rgba(251, 113, 133, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(251, 113, 133, 0.3);
}

.collapsed>ul {
    display: none;
}

/* Inspector Aside */
aside {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.inspector-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(9, 13, 22, 0.4);
}

.inspector-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-card {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.825rem;
}

.meta-row:last-child {
    margin-bottom: 0;
}

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

.meta-value {
    font-family: ui-monospace, SFMono-Regular, monospace;
    color: var(--text-main);
}

.conn-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
}

.conn-item {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.825rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conn-item:hover {
    border-color: var(--accent-blue);
    transform: translateX(4px);
}

.raw-view {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.72rem;
    background: var(--bg-base);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Custom Scrollbars matching PoPRuns / PoP 2008 theme */
html, * {
    scrollbar-width: thin;
    scrollbar-color: rgba(211, 156, 10, 0.45) rgba(3, 10, 16, 0.35);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(3, 10, 16, 0.35);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(211, 156, 10, 0.4);
    border-radius: 4px;
    border: 1px solid rgba(211, 156, 10, 0.2);
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(252, 208, 120, 0.7);
    border-color: rgba(252, 208, 120, 0.4);
    box-shadow: 0 0 6px rgba(252, 208, 120, 0.35);
}

::-webkit-scrollbar-thumb:active {
    background: #fcd078;
}

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