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

body, html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
}

/* ── Layout ─────────────────────────────────────────── */
#app {
    display: flex;
    height: 100%;
    width: 100%;
}

#map {
    flex: 1;
    height: 100%;
    min-width: 0;
}

/* ── Sidebar ────────────────────────────────────────── */
#sidebar {
    position: relative;
    width: 320px;
    min-width: 0;
    height: 100%;
    background: #fafafa;
    border-left: 1px solid #ddd;
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-left: none;
}

#sidebar-inner {
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 320px;
}

#sidebar-toggle {
    position: absolute;
    top: 50%;
    left: -16px;
    transform: translateY(-50%);
    width: 16px;
    height: 48px;
    background: #fff;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    font-size: 10px;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 4px rgba(0,0,0,0.1);
    z-index: 2;
    padding: 0;
}

#sidebar.collapsed #sidebar-toggle {
    transform: translateY(-50%) scaleX(-1);
}

#sidebar-toggle:hover {
    background: #f0f0f0;
}

#sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    opacity: 1;
    transition: opacity 0.2s ease;
}

#sidebar.collapsed #sidebar-content {
    opacity: 0;
    pointer-events: none;
}

/* ── Sidebar innhold ────────────────────────────────── */
#sidebar-placeholder {
    color: #888;
    font-size: 14px;
    padding-top: 20px;
    text-align: center;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #eee;
}

.sidebar-ahn {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    background: #999;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-name {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.sidebar-section {
    margin-bottom: 14px;
}

.sidebar-section h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.sidebar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.sidebar-table td {
    padding: 4px 0;
    vertical-align: top;
}

.sidebar-table td:first-child {
    font-weight: 600;
    color: #555;
    padding-right: 12px;
    white-space: nowrap;
    width: 90px;
}

.sidebar-table td:last-child {
    color: #222;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

.sidebar-link:hover {
    filter: brightness(0.95);
}

.sidebar-link.histreg {
    background: #e8f4f0;
    color: #0d6e4f;
}

.sidebar-link.wikitree {
    background: #eef2ff;
    color: #3b5bdb;
}

.sidebar-link.lokalhistorie {
    background: #fdf4e7;
    color: #92400e;
}

/* ── Stedsbilde fra lokalhistoriewiki ───────────────── */
.sidebar-bilde {
    margin: -20px -16px 16px -16px;
    background: #f0f0f0;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-bilde-lenke {
    display: block;
    width: 100%;
}

.sidebar-bilde-lenke:hover .sidebar-bilde-img {
    opacity: 0.9;
}

.sidebar-bilde-img {
    display: block;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    transition: opacity 0.15s;
}

.sidebar-ingress {
    font-size: 13px;
    line-height: 1.6;
    color: #444;
    margin: 0;
}

.sidebar-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Info-panel (øverst høyre i kartet) ─────────────── */
#info-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding: 10px 13px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
    max-width: 220px;
    pointer-events: none;
    line-height: 1.4;
}

#proband-navn {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 4px;
}

#sentroid-koord {
    color: #64748b;
    font-size: 11px;
    font-family: monospace;
    margin-bottom: 2px;
}

#adresse-info {
    color: #64748b;
    font-size: 12px;
}

/* ── Tegnforklaring ─────────────────────────────────── */
#legend {
    position: absolute;
    bottom: 40px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
    max-width: 260px;
}

#legend h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    color: #444;
    line-height: 1.3;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.midtpunkt-swatch {
    background: #fff !important;
    border: 2.5px solid #333;
    border-radius: 50%;
}

.legend-midtpunkt {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
}

/* ── Legend: firkant/sirkel-rader ───────────────────── */
.legend-rad {
    margin: 3px 0;
}

.legend-par {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.leg-navn {
    font-size: 12px;
    color: #333;
    margin-right: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.leg-sym {
    display: inline-block;
    width: 11px;
    height: 11px;
    flex-shrink: 0;
    outline: 1.5px solid;
    outline-offset: 1px;
}

.leg-firkant {
    border-radius: 2px;
}

.leg-sirkel {
    border-radius: 50%;
}

.legend-symbolforklaring {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #666;
}

/* ── Proband-velger ─────────────────────────────────── */
#proband-velger {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 1;
}

.proband-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.proband-btn:hover {
    background: #f0f4ff;
    border-color: #93c5fd;
}

.proband-btn.aktiv {
    background: #3b82f6;
    color: #fff;
    border-color: #2563eb;
}

.proband-btn.laster {
    opacity: 0.6;
    cursor: wait;
}
