.header-logos {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: 1.5rem;
}

.logo-link {
    display: block;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-img {
    height: 28px;
    width: auto;
    display: block;
}

/* Optional lab logo (?logo=): inline SVG in header */
.logo-img.logo-img--lab {
    max-width: min(220px, 40vw);
}

.logo-img.logo-img--lab svg {
    display: block;
    height: 28px;
    width: auto;
    max-width: 100%;
}

body[data-logo-variant="white"] .logo-img.logo-img--lab {
    color: #fff;
}

body[data-logo-variant="navy"] .logo-img.logo-img--lab {
    color: var(--brand-primary, #003b70);
}

.logo-ntnu {
    filter: var(--logo-ntnu-filter, brightness(0) invert(1));
}

/* Nav tabs (FRISK): improved UI */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    padding-bottom: 0.25rem;
    border-top: 1px solid var(--nav-border-top, rgba(255, 255, 255, 0.15));
    align-items: center;
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--nav-tab-color, rgba(255, 255, 255, 0.9));
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    border-radius: 0.375rem;
    border: none;
    white-space: nowrap;
    box-shadow: none;
}

.nav-tab:hover {
    color: var(--header-text);
    background-color: var(--nav-tab-hover-bg, rgba(255, 255, 255, 0.12));
}

.nav-tab-active {
    color: var(--header-text);
    font-weight: 500;
    background-color: var(--nav-tab-active-bg, transparent);
    box-shadow: var(--nav-tab-active-shadow, inset 0 -3px 0 var(--accent));
}

.nav-tab-active:hover {
    background-color: var(--nav-tab-active-bg, transparent);
    box-shadow: var(--nav-tab-active-shadow, inset 0 -3px 0 var(--accent));
}

.icon-inline {
    margin-right: 0.5rem;
    vertical-align: -0.15em;
}

/* Main content */
.main-content {
    padding: 2rem 0;
}

/* Tab switch loading state (HTMX boost) */
.main-content.main-content-loading {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
}

/* Chat page: top section (intro + context bar); clean minimal UI */
.chat-top {
    margin-bottom: 1rem;
    shrink: 0;
}
.chat-top-lead {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--frisk-neutral-medium);
    margin: 0 0 0.75rem 0;
}
.chat-context-bar {
    background: var(--frisk-white);
    border: 1px solid var(--frisk-blue-border);
    border-radius: 1rem;
    padding: 0.875rem 1rem;
}
.chat-context-bar__label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--frisk-neutral-dark);
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}
.chat-context-bar__row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.chat-context-bar__input {
    flex: 1;
    min-width: 0;
    min-height: 2.5rem;
    max-height: 4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    resize: vertical;
    font-family: inherit;
}
.chat-context-bar__input:focus {
    outline: none;
    border-color: var(--frisk-logoblå-2);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.12);
}
.chat-context-bar__input::placeholder {
    color: #94a3b8;
}
.chat-context-bar__btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--frisk-white);
    background: var(--frisk-logoblå-2);
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-context-bar__btn:hover {
    background: var(--frisk-logoblå-1);
}
.chat-context-bar__hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0.375rem 0 0 0;
}

/* Chat page: maximize chat iframe height */
.chat-page-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 8rem);
}
.chat-iframe-wrapper {
    flex: 1 1 auto;
    min-height: 75vh;
    height: calc(100vh - 11rem);
}

/* Cards (FRISK landing) */
.frisk-card.card {
    background: var(--surface);
    border-radius: var(--card-radius, 1rem);
    box-shadow: var(--card-shadow, var(--frisk-shadow-md));
    padding: var(--card-padding, 2rem);
    margin-bottom: 2rem;
    border: var(--card-border-width, 1px) solid var(--card-border-color, var(--brand-primary));
    border-top: var(--card-top-stripe-width, 4px) solid var(--card-top-stripe-color, var(--accent));
    box-sizing: border-box;
    background-clip: padding-box;
}

.frisk-card .card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--frisk-logoblå-1);
    margin-bottom: 1rem;
}

/* Section divider */
.section-divider {
    margin: 1.5rem 0;
    padding: 1rem 0;
}

.section-divider::before {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--section-divider-bar, var(--accent));
    border-radius: 2px;
    margin: 0 auto;
    opacity: 0.95;
}

/* Info card & text */
.info-text {
    font-size: 1rem;
    color: var(--frisk-neutral-medium);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.info-card {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    border-left: 4px solid;
}

.info-card-blue {
    background: linear-gradient(
        135deg,
        var(--info-tint-from, var(--frisk-blue-light)) 0%,
        var(--info-tint-to, var(--frisk-blue-soft)) 100%
    );
    border: 1px solid var(--info-border, var(--frisk-blue-border));
    border-left: 4px solid var(--brand-primary-mid, var(--frisk-logoblå-2));
    color: var(--text-primary, var(--frisk-neutral-dark));
    box-shadow: var(--shadow-sm);
}

.info-card-green {
    background: color-mix(in srgb, #15803d 8%, var(--surface));
    border: 1px solid color-mix(in srgb, #15803d 28%, var(--surface));
    border-left: 4px solid #15803d;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.info-card-yellow {
    background: color-mix(in srgb, #ca8a04 10%, var(--surface));
    border: 1px solid color-mix(in srgb, #ca8a04 30%, var(--surface));
    border-left: 4px solid #ca8a04;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Index sections (landing quick links) */
.index-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.index-section {
    padding: 1.25rem;
    background: var(--surface-muted, var(--frisk-gray-50));
    border-radius: 0.75rem;
    border: 1px solid var(--frisk-blue-border);
    border-top: 3px solid var(--brand-primary-mid, var(--frisk-logoblå-2));
    transition: all 0.2s ease;
}

.index-section:hover {
    box-shadow: 0 6px 12px rgba(0, 102, 204, 0.12);
    transform: translateY(-2px);
    border-color: var(--frisk-logoblå-2);
}

.index-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--frisk-logoblå-1);
    margin-bottom: 0.5rem;
}

.index-section-desc {
    font-size: 0.875rem;
    color: var(--frisk-neutral-medium);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.btn,
.btn-secondary {
    display: inline-block;
    box-sizing: border-box;
    min-height: var(--btn-height-md);
    line-height: calc(var(--btn-height-md) - 1.25rem);
    background: var(--frisk-logoblå-2);
    color: var(--frisk-white);
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    border: 1px solid var(--frisk-logoblå-1);
}

.btn-secondary:hover {
    background: var(--frisk-logoblå-1);
    color: var(--frisk-white);
}

/* Dataset info (landing) */
.dataset-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.dataset-stat {
    padding: 1rem;
    background: var(--dataset-stat-bg, var(--surface-muted, var(--frisk-gray-50)));
    border-radius: 0.5rem;
    border: 1px solid var(--frisk-blue-border);
}

.dataset-stat-label {
    font-size: 0.875rem;
    color: var(--frisk-neutral-medium);
    margin-bottom: 0.25rem;
}

.dataset-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--frisk-logoblå-1);
}

/* Footer (FRISK) */
.footer {
    background: var(--footer-background, var(--frisk-gray-100));
    border-top: var(--footer-border-top-width, 3px) solid var(--footer-border-top-color, var(--brand-primary-mid));
    margin-top: 3rem;
    padding: 2rem 0;
    box-shadow: var(--footer-shadow);
}

.footer-text {
    text-align: center;
    color: var(--frisk-neutral-medium);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.footer-disclaimer {
    text-align: center;
    color: rgba(102, 102, 102, 0.8);
    font-size: 0.75rem;
}

/* ========== Shared: Visualisering & Overlappanalyse network graph ========== */
.viz-controls-card {
    background: linear-gradient(to bottom, #ffffff, #fafbfc);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.5rem;
}
/* Single-line controls row (Visualisering) */
.viz-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
}
.viz-controls-row .viz-controls-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e3a5f;
    margin: 0;
    margin-right: 0.25rem;
}
.viz-controls-row .viz-control-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.viz-controls-row .viz-control-item .viz-section-title {
    margin-bottom: 0;
    margin-right: 0.25rem;
}
.viz-controls-row .viz-category-legend {
    margin: 0;
}
.viz-controls-card .viz-controls-desc {
    margin-top: 0.5rem;
    margin-bottom: 0;
}
.viz-controls-card .viz-section {
    padding: 1rem 1.5rem;
}
.viz-controls-card .viz-section + .viz-section {
    border-top: 1px solid #e5e7eb;
}
.viz-controls-card .viz-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
}
.viz-controls-card .viz-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.viz-controls-card .viz-field label {
    font-size: 0.875rem;
    color: #374151;
    white-space: nowrap;
}
.viz-controls-card .viz-field input[type="number"] {
    width: 4.5rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}
.viz-controls-card .viz-field input:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 80, 158, 0.2);
}
/* Avanserte innstillinger (Visualisering) */
.viz-controls-card .viz-advanced-details {
    margin-top: 1rem;
    width: 100%;
}
.viz-controls-card .viz-advanced-details[open] .viz-controls-row {
    gap: 1rem 1.5rem;
}
.viz-controls-card .viz-advanced-details .viz-controls-row {
    align-items: flex-end;
}
.viz-adv-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 0;
}
.viz-adv-field > label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
}
.viz-adv-field-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.viz-adv-input {
    height: 2.25rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
    color: #111827;
    box-sizing: border-box;
    line-height: 1.25;
}
.viz-adv-input:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 80, 158, 0.2);
}
select.viz-adv-input {
    padding-right: 0.5rem;
    cursor: pointer;
}
.viz-adv-input-num {
    width: 5rem;
}
.viz-adv-field-action {
    margin-left: auto;
}
.viz-controls-card .viz-advanced-details .viz-adv-field-action .viz-btn-update {
    height: 2.25rem;
    padding: 0 1.1rem;
    line-height: 1;
}

.viz-graph-settings-grid {
    display: grid;
    grid-template-columns: minmax(5.25rem, 6.75rem) minmax(0, 1fr);
    gap: 0.65rem 0.85rem;
    align-items: center;
}
@media (min-width: 640px) {
    .viz-graph-settings-grid {
        grid-template-columns: 6.75rem 1fr;
        gap: 0.75rem 1rem;
    }
}
@media (max-width: 480px) {
    .viz-graph-settings-grid {
        grid-template-columns: 1fr;
        gap: 0.35rem 0;
    }
    .viz-graph-setting-label {
        margin-top: 0.35rem;
    }
    .viz-graph-setting-controls {
        width: 100%;
    }
    .viz-native-select {
        flex: 1;
        min-width: 0;
        width: 100%;
    }
}
.viz-graph-setting-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.35;
    padding-top: 0.1rem;
}
.viz-graph-setting-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}
.viz-native-select {
    min-height: 2.5rem;
    min-width: 10.75rem;
    padding: 0.45rem 2.35rem 0.45rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25;
    font-weight: 500;
    color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.45rem center;
    background-size: 1.125rem;
}
.viz-native-select:hover {
    border-color: #9ca3af;
}
.viz-native-select:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 80, 158, 0.2);
}
.viz-native-select:disabled {
    opacity: 0.52;
    cursor: not-allowed;
    background-color: #f3f4f6;
}
.viz-graph-num {
    min-height: 2.5rem;
    width: 4.85rem;
    padding: 0.45rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.viz-graph-num-wide {
    width: 5.85rem;
}
.viz-graph-num-xwide {
    width: 7rem;
    min-width: 7rem;
}
.viz-graph-num:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 80, 158, 0.2);
}

.viz-controls-card .viz-btn-update {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--brand-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}
.viz-controls-card .viz-btn-update:hover {
    background: var(--brand-primary-dark);
}
.viz-controls-card .viz-btn-update:active {
    transform: scale(0.98);
}
.viz-controls-card .viz-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 0.5rem;
}
.viz-controls-card .viz-section-desc {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
}
/* Category select (Visualisering) */
.viz-controls-card #viz-category-select {
    min-width: 240px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9375rem;
    color: #1f2937;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") right 0.5rem center/1.25rem no-repeat;
    appearance: none;
    cursor: pointer;
}
.viz-controls-card #viz-category-select:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 80, 158, 0.2);
}
/* Category legend (both pages): swatch + label */
.viz-category-legend,
#precomputed-category-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
}
.viz-legend-item,
.precomputed-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: #374151;
}
.viz-legend-swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    border: 1px solid #d1d5db;
    flex-shrink: 0;
}
.viz-graph-container {
    border: 2px solid var(--brand-primary);
    border-radius: 8px;
    background: #f9fafb;
}

/* ── Homepage: hero + feature grid ── */
.home-hero {
    text-align: center;
    padding: clamp(2.125rem, 5vw, 3.4375rem) 1.3125rem clamp(1.3125rem, 3.5vw, 2.125rem);
}
.home-eyebrow {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand-primary);
    margin-bottom: 0.8125rem;
    opacity: 0.85;
}
.home-title {
    font-size: clamp(1.5rem, 5vw, 2.25rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.025em;
    color: var(--text-heading);
    margin-bottom: 1.3125rem;
    text-wrap: balance;
}
.home-sub {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 52ch;
    margin: 0 auto 2.125rem;
    line-height: 1.618;
    text-wrap: balance;
}
.home-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(233px, 1fr));
    gap: 1.3125rem;
    margin-bottom: 2.125rem;
}
.home-feature-card {
    display: flex;
    flex-direction: column;
    padding: 1.3125rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.home-feature-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--brand-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.22s cubic-bezier(0, 0, 0.2, 1);
    border-radius: 0.75rem 0.75rem 0 0;
}
.home-feature-card:hover {
    box-shadow: 0 4px 8px rgba(0, 40, 80, 0.09), 0 10px 30px rgba(0, 40, 80, 0.06);
    border-color: color-mix(in srgb, var(--brand-primary) 40%, var(--border-subtle));
    transform: translateY(-1px);
}
.home-feature-card:hover::before { transform: scaleX(1); }
.home-feature-icon {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--brand-primary) 12%, var(--surface-muted));
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 0.8125rem;
    flex-shrink: 0;
}
.home-feature-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.home-feature-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    flex: 1;
    margin-bottom: 0.8125rem;
}
.home-feature-arrow {
    font-size: 1rem;
    color: var(--brand-primary);
    font-weight: 600;
    transition: transform 0.15s ease;
    display: inline-block;
    align-self: flex-start;
}
.home-feature-card:hover .home-feature-arrow { transform: translateX(4px); }

/* ── Scroll-to-top button ── */
#scroll-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 40;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background-color 0.2s ease;
    cursor: pointer;
}
#scroll-to-top:hover { background: var(--brand-primary-dark); }
#scroll-to-top.visible { opacity: 1; pointer-events: auto; }

