/* --- APP SHELL (Top Nav Variant) --- */
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    color: var(--fg);
}

.top-nav {
    width: 100%;
    height: 72px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-sizing: border-box;
    flex-shrink: 0;
    gap: 16px;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.top-nav-left,
.top-nav-center,
.top-nav-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.top-nav-left {
    flex: 0 0 auto;
    gap: 10px;
}

.top-nav-center {
    flex: 1 1 auto;
    justify-content: center;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    padding: 0 8px;
}

.top-nav-center.has-open-dropdown {
    overflow: visible;
}

.top-nav-center::-webkit-scrollbar {
    display: none;
}

.top-nav-right {
    flex: 0 0 auto;
    justify-content: flex-end;
}

.main {
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    padding: 32px 40px;
    position: relative;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- RESTORED: GRID SYSTEM (FIXES REGISTRY) --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    width: 100%;
}

/* --- RESTORED: LOGO STYLING --- */
.logo-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.logo-group img {
    height: 40px;
    width: auto;
    margin: 0;
}
.logo-group span {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-logo {
    cursor: pointer;
}

.nav-search {
    width: min(220px, 24vw) !important;
    margin: 0;
    min-width: 160px;
}

/* --- MAP VIEW SPECIFIC OVERRIDES --- */
body.map-mode {
    overflow: hidden;
}

body.map-mode .main {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - 72px) !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#plot-container {
    width: 100%;
    height: 100%;
    position: relative;
    background: var(--bg);
}

#plot {
    width: 100% !important;
    height: 100% !important;
}

.map-header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

/* --- COMPONENTS & MODALS --- */
.nav-link {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    cursor: pointer;
    color: var(--fg-soft);
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 7px 10px;
    white-space: nowrap;
}
.nav-link:hover { color: var(--accent); background: var(--surface-soft); }
.nav-link.active { color: var(--fg-soft); border-color: var(--border); background: var(--surface); }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(5px);
    z-index: 900;
    justify-content: center;
    align-items: center;
}

.modal-window {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
    width: 500px;
    max-width: 95vw;
}

.editor-panel {
    width: 400px;
    border-left: 1px solid var(--border);
    background: var(--surface);
    padding: 28px 24px;
    height: calc(100vh - 72px);
    position: fixed;
    right: 0;
    top: 72px;
    display: none;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 500;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.08);
}

.editor-panel.open { display: flex; }

.full-screen {
    position: fixed;
    inset: 0;
    background: var(--surface);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#tooltip-img {
    position: absolute;
    display: none;
    width: 120px !important;
    height: 160px !important;
    object-fit: cover;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    pointer-events: none;
    z-index: 100;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
}

#loading {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.72);
    z-index: 50;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 980px) {
    .top-nav {
        padding: 0 14px;
        height: 64px;
        gap: 10px;
    }

    .main {
        padding: 18px 16px;
    }

    .top-nav-center {
        justify-content: flex-start;
        padding: 0;
    }

    .nav-group {
        gap: 6px;
    }

    .nav-search {
        width: min(170px, 38vw) !important;
        min-width: 128px;
    }

    .logo-group span {
        display: none;
    }

    .logo-group img {
        height: 34px;
    }

    .editor-panel {
        width: min(92vw, 420px);
        top: 64px;
        height: calc(100vh - 64px);
    }
}
