:root {
    --bg-color: #ffffff;
    --panel-color: #ffffff;
    --panel-border: rgba(32, 38, 52, 0.06);
    --text-color: #1f2937;
    --muted-color: #5f6b7a;
    --accent-color: #2c7a7b;
    --accent-strong: #185a59;
    --shadow: 0 12px 30px rgba(31, 41, 55, 0.06);
}

[data-theme="dark"] {
    --bg-color: #0f1720;
    --panel-color: rgba(15, 23, 32, 0.8);
    --panel-border: rgba(148, 163, 184, 0.16);
    --text-color: #e5eef7;
    --muted-color: #9fb0c3;
    --accent-color: #5cc8c6;
    --accent-strong: #8ee7e4;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
}

html { font-size: 100%; }

body {
    margin: 0;
    color: var(--text-color);
    background: var(--bg-color);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    transition: background-color 0.15s ease, color 0.15s ease;
}

header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem 1rem;
    background: var(--panel-color);
    border-bottom: 1px solid var(--panel-border);
}

.header-content {
    width: min(80vw, 1800px);
    margin: 0 auto;
    text-align: center;
}

/* Generic page block styling */
.block { width: min(80vw, 1800px); margin: 1.25rem auto; background: var(--panel-color); border: 1px solid var(--panel-border); border-radius: 12px; box-shadow: var(--shadow); box-sizing: border-box; overflow: hidden; }
.block .block-inner { padding: 1.25rem 1.5rem; box-sizing: border-box; }
.block h2 { margin: 0 0 0.75rem 0; font-size: 1.45rem; color: var(--text-color); font-weight: 400; }
.block.highlights { border-left: 4px solid var(--accent-color); }
.block.pointclouds { border-left: 4px solid var(--accent-strong); }
.block.acknowledgments { border-left: 4px solid rgba(0,0,0,0.06); }

/* Adjust viewer-container inside block-inner */
.block .viewer-container { padding: 0; margin: 0; }

/* Ensure components inside blocks do not exceed block width */
.block .tabs { width: 100%; box-sizing: border-box; }

.plots-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.plot-card {
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    background: var(--panel-color);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.plot-teaser {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
    gap: 1rem;
    padding: 1rem;
    align-items: stretch;
}

.plot-teaser-media {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 4fr);
    gap: 0.75rem;
    align-items: stretch;
    min-width: 0;
    align-self: stretch;
    padding: 0.75rem;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: rgba(255,255,255,0.35);
    box-shadow: var(--shadow);
    height: clamp(128px, 10vw, 168px);
}

.plot-teaser-media > img {
    margin: 0;
    min-height: 0;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
}

.plot-teaser-media > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    display: block;
}

/* Button to toggle dataset viewer: triangle + label */
.show-dataset-toggle {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: var(--accent-color);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.15rem 0;
    font-size: 0.95rem;
}
.show-dataset-toggle svg { transition: transform 0.12s ease; width: 0.95rem; height: 0.95rem; }
.show-dataset-toggle.open svg { transform: rotate(90deg); }

.plot-teaser-body { display:flex; flex-direction:column; gap: 0.55rem; }
.plot-title { margin: 0; font-size: 1.25rem; color: var(--text-color); }
.plot-title { font-weight: 400; }
.plot-title-plot,
.plot-title-species { font-weight: 700; }
.plot-meta { color: var(--muted-color); font-size: 1.2rem; }
.plot-link-wrap { margin-top: 0.3rem; }

.timetable-figure {
    margin: 0;
}

.timetable-figure img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

/* Ensure teaser image fills the block width like the timetable */
.block.teaser .figure-container img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

.download-link-box { margin: 0 0 1rem 0; }
.download-link-card {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid rgba(44, 122, 123, 0.25);
    background: linear-gradient(135deg, rgba(44, 122, 123, 0.08), rgba(24, 90, 89, 0.04));
    box-shadow: 0 10px 24px rgba(31, 41, 55, 0.08);
}
.download-link-card--missing {
    background: rgba(95, 107, 122, 0.08);
    border-color: rgba(95, 107, 122, 0.18);
    color: var(--muted-color);
    font-weight: 600;
}
.download-link-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.download-link-species {
    font-size: 1.05rem;
    color: var(--muted-color);
    margin-bottom: 0.6rem;
}
.download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: var(--accent-color);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, background-color 0.12s ease;
}
.download-link:hover { transform: translateY(-1px); background: var(--accent-strong); }
.download-link--compact { width: fit-content; }

.plot-details {
    border-top: 1px solid var(--panel-border);
    background: rgba(255,255,255,0.35);
}

.plot-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.95rem 1rem;
    font-weight: 700;
    color: var(--text-color);
    background: linear-gradient(135deg, rgba(44, 122, 123, 0.07), rgba(24, 90, 89, 0.03));
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.plot-summary::-webkit-details-marker { display: none; }
.plot-summary svg { width: 0.95rem; height: 0.95rem; transition: transform 0.12s ease, color 0.12s ease; color: #c53030; }
.plot-summary .summary-text { color: #b91c1c; }
.plot-summary:hover svg,
.plot-summary:hover .summary-text { color: #9f1239; }
.plot-details[open] .plot-summary svg { transform: rotate(90deg); color: #991b1b; }

.plot-viewer {
    padding: 1rem;
}

.plot-viewer .slider-container {
    width: 100%;
    margin-bottom: 4.5rem;
}

.plot-viewer .image-viewer {
    width: 100%;
    margin: 0;
}

.plot-viewer .image-viewer.combined-image {
    grid-template-columns: 1fr;
}

.plot-viewer .image-viewer.combined-image .viewer-right {
    display: none !important;
}

.plot-viewer .image-viewer.combined-image .figure-container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.plot-viewer .image-viewer.combined-image .figure-container img {
    max-width: calc(100% - 1.5rem);
    max-height: 80vh;
}

.plot-viewer .tick-label { font-size: 1rem; }
.plot-viewer .slider-container > label { font-size: 1.05rem; }

.plot-viewer .current-date-label {
    font-weight: 700;
}

.download-link-card--missing {
    display: inline-flex;
    width: fit-content;
}

.ack-text, .ack-text p { font-size: 1.2rem; color: var(--muted-color); line-height: 1.6; }

/* Ensure consistent body text size inside all page blocks (exclude headings) */
.block .block-inner p,
.block .block-inner .license-text,
.block .block-inner .plot-meta,
.block .block-inner .download-link-species,
.block .block-inner .ack-text,
.block .block-inner .download-link-card,
.block .block-inner .download-link-card--missing {
    font-size: 1.2rem;
    color: var(--muted-color);
    line-height: 1.6;
}

.block .slider-container { width: 100%; box-sizing: border-box; }
.block .slider-wrapper { max-width: 100%; box-sizing: border-box; }
.block .image-viewer { width: 100%; box-sizing: border-box; margin: 0; }
.block .image-viewer img { max-width: 100%; height: auto; max-height: 65vh; display: block; }

/* Ensure tick container stays within the block */
.block .slider-ticks { left: 0; right: 0; max-width: 100%; box-sizing: border-box; }

header h1 { margin: 0; font-size: clamp(1.9rem, 2.6vw, 3rem); font-weight: 400; }
header p { margin: 0.35rem 0 0; color: var(--muted-color); font-size: 0.98rem; }

.dataset-description {
    margin-top: 1rem;
    color: var(--muted-color);
    text-align: justify; /* Blocksatz */
    text-justify: inter-word;
    line-height: 1.6;
    max-width: 100%;
    font-size: 1.2rem; /* increased for visibility */
}

/* Ensure paragraph elements inside header-content get the intended size (override header p) */
.header-content .dataset-description,
.header-content .dataset-description p {
    font-size: 1.2rem;
}

/* Teaser image shown under the main title */
.header-teaser { margin-top: 1rem; }
.header-teaser img {
    width: 100%;
    height: auto;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    display: block;
}

.theme-toggle {
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-strong));
    color: white;
    border: none;
    border-radius: 999px;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    position: absolute;
    right: 1.5rem;
    top: 1rem;
}

/* Tabs (plot selection) — constrained to the same content width as images */
.tabs {
    display: flex;
    gap: 1.2rem;
    width: min(80vw, 1800px);
    margin: 0.6rem auto 1rem;
    padding: 0.6rem 0;
    background: var(--panel-color);
    border-bottom: 1px solid var(--panel-border);
    justify-content: center;
    flex-wrap: wrap;
}

.tab {
    padding: 0.6rem 1rem;
    background: rgba(255,255,255,0.6);
    color: var(--text-color);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    border-radius: 999px;
    font-size: 0.95rem;
}
.tab.active { background: var(--accent-color); color: #fff; border-color: transparent; }

.viewer-container {
    padding: 2rem 1.5rem 3rem;
    max-width: 2000px;
    margin: 0 auto;
}

.slider-container {
    margin-bottom: 5.5rem; /* increase space below slider */
    position: relative;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.slider-wrapper { position: relative; margin-top: 10px; }

input[type="range"] { width: 100%; margin: 0; cursor: pointer; height: 24px; display:block; }
input[type="range"]::-webkit-slider-thumb { width: 32px; height: 32px; }
input[type="range"]::-moz-range-thumb { width: 32px; height: 32px; }

.slider-ticks {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 24px); /* push ticks further down from the slider */
    height: 42px;
    overflow: visible;
    pointer-events: none; /* let underlying slider receive events unless container overrides */
}

.tick-container {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto; /* allow clicks on tick container */
}

.tick-label {
    font-size: 1.2rem; /* increase tick label size */
    color: var(--muted-color);
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* show "..." if label too long */
    max-width: 7.5rem; /* limit label width so it can't exceed the image area */
    display: inline-block;
}
/* first/last anchors removed — tick positions are computed in JS to align with slider track */
.tick-label::before { content:''; display:block; width:2px; height:8px; background-color:var(--panel-border); margin:0 auto 4px; }

.slider-container > label { font-size: 1.02rem; color: var(--muted-color); }
#current-date-label { font-weight: 600; margin-left: 0.35rem; }

.image-viewer { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: stretch; width: 100%; margin: 2rem 0 0; }
.image-viewer.combined-layout { grid-template-columns: 1fr; width: min(80vw, 1800px); }
.viewer-column { display:flex; flex-direction:column; gap:1.5rem; }
.viewer-right .figure-tall { height:100%; display:flex; flex-direction:column; }
.viewer-right .figure-tall img { flex-grow:1; object-fit:contain; }
.figure-container { width:100%; padding-bottom:0.75rem; }

.image-viewer img { width:100%; height:auto; object-fit:contain; max-height:65vh; border:1px solid var(--panel-border); border-radius:16px; background: rgba(255,255,255,0.16); box-shadow: var(--shadow); }
.image-viewer.combined-layout #nadir-view { width:100%; }

/* Combined image inline: fill block width with small horizontal gaps */
.image-viewer.combined-image { grid-template-columns: 1fr; }
.image-viewer.combined-image .figure-container { padding: 0; }
.image-viewer.combined-image .figure-container img { width: 100%; max-width: 100%; margin: 0; max-height: 90vh; border-radius: 12px; }

/* Acknowledgments font size should match the description */
.ack-text, .ack-text p { font-size: 1.2rem; color: var(--muted-color); line-height: 1.6; }

@media (max-width:900px) {
    html { font-size: 95%; }

    header, .tabs, .viewer-container { padding-left:0.75rem; padding-right:0.75rem; }
    header { flex-direction: column; align-items: stretch; gap: 0.75rem; padding-top: 1rem; }

    .header-content,
    .block,
    .tabs,
    .viewer-container,
    .site-badge {
        width: min(94vw, 100%);
    }

    .block .block-inner { padding: 1rem 1rem; }
    .block h2 { font-size: 1.25rem; }

    .plot-teaser {
        grid-template-columns: 1fr;
        gap: 0.85rem;
        padding: 0.85rem;
    }

    .plot-teaser-media {
        gap: 0.65rem;
        height: clamp(118px, 18vw, 150px);
        grid-template-columns: minmax(0, 1fr) minmax(0, 4fr);
    }

    .plot-title { font-size: 1.1rem; }
    .plot-meta,
    .block .block-inner p,
    .block .block-inner .license-text,
    .block .block-inner .plot-meta,
    .block .block-inner .download-link-species,
    .block .block-inner .ack-text,
    .block .block-inner .download-link-card,
    .block .block-inner .download-link-card--missing {
        font-size: 1rem;
    }

    .image-viewer { grid-template-columns: 1fr; width:100%; gap: 1rem; }
    .tabs { width: 100%; gap: 0.75rem; }
    .tab { font-size: 0.9rem; padding: 0.5rem 0.8rem; }
    .slider-container { width: 100%; margin-bottom: 4rem; }
    .tick-label { display: none; }
    .slider-ticks { height: 16px; top: calc(100% + 14px); }

    .theme-toggle {
        position: static;
        width: 100%;
        right: auto;
        top: auto;
    }
}

/* Footer-aligned PHENOROB badge */
.site-badge {
    position: static;
    width: min(80vw, 1800px);
    margin: 2.5rem auto 3.5rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    background: var(--panel-color);
    padding: 0.35rem 0 0;
    border-radius: 4px;
    box-shadow: none;
}
.site-badge-logos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: end;
    width: 100%;
}
.site-badge-logo {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
}
.site-badge-logo--left { justify-content: flex-start; align-items: flex-start; }
.site-badge-logo--right { justify-content: flex-end; align-items: flex-end; }
.site-badge-logo img { height: auto; display: block; background: transparent; }
.site-badge-logo--left img { width: 180px; }
.site-badge-logo--right img { width: 180px; }
.site-badge .copyright {
    font-size: 0.95rem;
    color: var(--muted-color);
    text-align: center;
    padding-left: 0;
    margin-top: 0.35rem;
}

@media (max-width: 900px) {
    .site-badge-logos {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .site-badge-logo--right { justify-content: flex-start; }
    .site-badge-logo img { width: min(45vw, 160px); }
    .site-badge .copyright { font-size: 0.85rem; }
}

@media (max-width: 600px) {
    header h1 { font-size: clamp(1.5rem, 7vw, 2rem); }
    .header-content,
    .block,
    .tabs,
    .viewer-container,
    .site-badge {
        width: min(96vw, 100%);
    }

    .block .block-inner { padding: 0.85rem 0.8rem; }
    .plot-teaser { padding: 0.75rem; }
    .plot-teaser-media {
        gap: 0.5rem;
        height: clamp(108px, 28vw, 132px);
        grid-template-columns: minmax(0, 1fr) minmax(0, 4fr);
    }
    .download-link { width: 100%; justify-content: center; }
    .download-link--compact { width: 100%; }
    .slider-container { margin-bottom: 3.5rem; }
    .tick-label { font-size: 0.9rem; max-width: 5.5rem; }
}
