/* Smell Dataset Website - Single Page Layout */

:root {
    /* Retimed to the project page: the same warm paper, ink and sign-red the
       main site is built from, so moving between them does not feel like
       moving between two sites. Variable names are unchanged, so the 1400
       lines below did not have to be rewritten. */
    --accent: #c9402a;              /* the roundels on the station sign */
    --accent-rgb: 201, 64, 42;
    --accent-light: #d9573f;
    --accent-hover: #ad3421;

    --accent-warm: #c2571b;         /* subway orange, darkened to hold on paper */

    /* Backgrounds -- the tile wall, not a terminal */
    --bg-primary: #f4f2ea;
    --bg-secondary: #eae7dc;
    --bg-card: #ffffff;
    --bg-hover: #e2ddcd;

    /* Text */
    --text-primary: #232c2a;
    --text-secondary: #5f6763;   /* 5.2:1 on paper, 4.7:1 on the sidebar */
    --border-color: #d9d4c6;
    --sidebar-width: 320px;

    --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
}

.header-brand {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo {
    font-family: 'Barlow Condensed', 'Helvetica Neue', sans-serif;
    font-weight: 700;
    font-size: 1.75rem;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

.logo .accent {
    color: var(--accent);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.logo-link,
.tagline-link {
    text-decoration: none;
    color: inherit;
}

.tagline-link:hover .tagline {
    color: var(--accent);
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.header-stat {
    text-align: center;
}

.header-stat .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.header-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Main Layout */
.main-layout {
    display: flex;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    position: fixed;
    top: 85px;
    left: 0;
    height: calc(100vh - 85px);
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sidebar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.clear-btn:hover {
    background: var(--bg-hover);
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.accordion-item {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid transparent;
    color: var(--category-color, var(--text-primary));
}

.accordion-item:hover {
    background: var(--bg-hover);
}

.accordion-item.active {
    border-color: var(--category-color, currentColor);
    background: rgba(var(--category-color-rgb, 74, 144, 217), 0.2);
}

.accordion-item.active:hover {
    background: rgba(var(--category-color-rgb, 74, 144, 217), 0.3);
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    cursor: pointer;
}

.accordion-chevron {
    font-size: 0.65rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    user-select: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    transition: transform 0.2s ease-out, background 0.15s ease;
}

.accordion-item.expanded .accordion-chevron {
    transform: rotate(90deg);
}

.accordion-item.active .accordion-chevron {
    color: var(--category-color, var(--accent));
}

.accordion-chevron:hover {
    background: rgba(var(--category-color-rgb, 74, 144, 217), 0.5);
}

.accordion-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
}


.accordion-label svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    flex-shrink: 0;
}

.accordion-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.accordion-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.2s ease-out;
}

.accordion-body > .accordion-body-inner {
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0 0.75rem;
}

.accordion-body.expanded {
    grid-template-rows: 1fr;
}

.accordion-body.expanded > .accordion-body-inner {
    padding: 0.5rem 0.75rem 0.75rem;
}

.subcategory-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 16px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-transform: capitalize;
}

.subcategory-pill:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.subcategory-pill.active {
    background: rgba(var(--category-color-rgb, 74, 144, 217), 0.2);
    color: var(--category-color, var(--accent));
    border-color: var(--category-color, var(--accent));
}


/* Environment Filter Pills */
.env-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.env-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
}

.env-pill svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    flex-shrink: 0;
}

.env-pill:hover {
    background: var(--bg-hover);
}

.env-pill.active {
    border-color: currentColor;
}

/* Temperature Colors */
.env-pill[data-temp="cold"] { color: #3d7094; }
.env-pill[data-temp="cold"].active { background: rgba(61, 112, 148, 0.14); }

.env-pill[data-temp="warm"] { color: #8a632e; }
.env-pill[data-temp="warm"].active { background: rgba(138, 99, 46, 0.14); }

.env-pill[data-temp="hot"] { color: #ae4f37; }
.env-pill[data-temp="hot"].active { background: rgba(174, 79, 55, 0.14); }

/* Humidity Colors */
.env-pill[data-humidity="dry"] { color: #856751; }
.env-pill[data-humidity="dry"].active { background: rgba(133, 103, 81, 0.14); }

.env-pill[data-humidity="moderate"] { color: #3b7845; }
.env-pill[data-humidity="moderate"].active { background: rgba(59, 120, 69, 0.14); }

.env-pill[data-humidity="humid"] { color: #357382; }
.env-pill[data-humidity="humid"].active { background: rgba(53, 115, 130, 0.14); }

/* Location Pills */
.location-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.location-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #54717d;
}

.location-pill svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    flex-shrink: 0;
}

.location-pill:hover {
    background: var(--bg-hover);
}

.location-pill.active {
    border-color: currentColor;
    background: rgba(84, 113, 125, 0.14);
}

.location-pill .count {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Clear All Button */
.clear-all-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 500;
    cursor: pointer;
}

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

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    margin-left: var(--sidebar-width);
}

/* Active Filters - hidden by default, shown when has-filters */
.active-filters {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

.active-filters.has-filters {
    display: flex;
}

.filter-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--tag-color, var(--accent));
    color: var(--bg-card);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.filter-tag .remove {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.filter-tag .remove:hover {
    opacity: 1;
}

/* Results Count (in filter bar, right-aligned) */
.results-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-left: auto;
}

/* Sample Grid */
.sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Sample Card */
.sample-card {
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.sample-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(52, 44, 30, 0.14);
    border-color: var(--text-secondary);
}

.image-container {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-secondary);
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Radial Smellprint Overlay */
.radial-smell {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 60px;
    height: 60px;
    pointer-events: none;
}

/* Environmental Info Overlay */
.env-info {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    gap: 4px;
    pointer-events: none;
}

.env-info span {
    background: rgba(244, 242, 234, 0.86);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-primary);
}

.env-temp {
    color: #ae4f37 !important;
}

.env-humidity {
    color: #3d7094 !important;
}

/* Card Info */
.card-info {
    padding: 0.5rem 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-label-row {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    font-size: 0.7rem;
    line-height: 1.4;
    min-width: 0;
}

.card-label-type {
    color: var(--text-secondary);
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    width: 22px;
    flex-shrink: 0;
}

.card-label-cat {
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-label-arrow {
    color: var(--text-secondary);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.card-label-fine {
    font-weight: 500;
    color: var(--text-primary);
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-label-fine.placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-weight: 400;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(244, 242, 234, 0.93);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-card);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    z-index: 10;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: 1.5rem;
}

/* Modal Detail Layout - 2x2 Grid */
.modal-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.25rem;
}

.modal-quadrant {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.modal-quadrant h3 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-align: center;
}

.modal-quadrant .modal-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.modal-quadrant .modal-image img {
    width: 100%;
    height: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 4px;
    background: var(--bg-secondary);
}

.modal-heatmap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.heatmap-inline {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0.5rem;
    padding-left: 2rem;
}

.heatmap-inline .heatmap-phase-labels {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 0.375rem;
}

.heatmap-inline .heatmap-y-label {
    position: absolute;
    left: 0.25rem;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: left center;
    font-size: 0.6rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.heatmap-inline .signal-heatmap {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 4px;
}

.heatmap-inline .heatmap-x-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.375rem;
}

/* Cleaned up metadata section */
.metadata-content {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.meta-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 80px;
    flex-shrink: 0;
}

.meta-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.meta-value .placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.modal-metadata {
    justify-content: flex-start;
}

.no-data {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.modal-info-row {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.modal-labels {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.modal-label-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.modal-label-title {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.modal-hierarchy {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
}

.modal-hierarchy-cat {
    font-size: 1rem;
    font-weight: 600;
}

.modal-hierarchy-arrow {
    font-size: 1rem;
    color: var(--text-secondary);
}

.modal-hierarchy-fine {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.modal-hierarchy-fine.placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-weight: 400;
}

.modal-info-row .modal-meta {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
    margin-top: 0;
}

.modal-info-row .meta-item {
    padding: 0.5rem 0.75rem;
}

.modal-image-section {
    display: flex;
    flex-direction: column;
}

.modal-image-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    text-align: center;
}

.modal-image {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    background: var(--bg-card);
}

.modal-image .radial-smell-large {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 120px;
    height: 120px;
}

.modal-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    text-transform: capitalize;
}


.modal-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.meta-item {
    background: var(--bg-card);
    padding: 0.75rem;
    border-radius: 8px;
}

.meta-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.meta-item .value {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Smellprint Bar Chart in Modal */
.smellprint-section {
    grid-column: 1 / -1;
    margin-top: 1.5rem;
}

.smellprint-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.smellprint-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 60px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
}

.smell-bar {
    flex: 1;
    min-width: 4px;
    background: linear-gradient(to top, #3b4cc0, #f4f2ea, #c9402a);
    border-radius: 2px 2px 0 0;
    transition: opacity 0.2s;
}

.smell-bar:hover {
    opacity: 0.8;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
    grid-column: 1 / -1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state .clear-filters-btn {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.empty-state .clear-filters-btn:hover {
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
    }

    .modal-detail {
        grid-template-columns: 1fr 1fr;
    }

    .modal-quadrant .modal-image img {
        max-height: 220px;
    }

    .modal-smellprint .radial-smell-large {
        width: 160px;
        height: 160px;
    }
}

@media (max-width: 600px) {
    .modal-detail {
        grid-template-columns: 1fr;
    }

    .modal-meta-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Toggle Button - Hidden on desktop */
.sidebar-toggle {
    display: none;
}

/* Sidebar Overlay - Hidden by default */
.sidebar-overlay {
    display: none;
}

@media (max-width: 1024px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .header-stats {
        display: none;
    }

    .active-filters {
        position: fixed;
        top: 95px;
        left: 0;
        right: 0;
        margin: 0;
        max-width: none;
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
        z-index: 90;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        background: var(--bg-card);
    }

    body.has-mobile-filters .main-content {
        padding-top: 3.5rem;
    }

    body.has-mobile-filters .sidebar {
        top: calc(95px + 3rem);
        height: calc(100vh - 95px - 3rem);
    }

    /* Show sidebar toggle on tablet/mobile */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-primary);
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
    }

    .sidebar-toggle:hover {
        background: var(--bg-hover);
        border-color: var(--accent);
    }

    .sidebar-toggle svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
    }

    /* Sidebar - slide in from left */
    .sidebar {
        position: fixed;
        left: 0;
        top: 85px;
        height: calc(100vh - 85px);
        width: var(--sidebar-width);
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 99;
        border-right: 1px solid var(--border-color);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        top: 85px;
        background: rgba(244, 242, 234, 0.82);
        z-index: 98;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .sample-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-content {
        max-height: 95vh;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Signal Heatmap Section */
.signal-heatmap-section {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.25rem;
}

.signal-heatmap-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    text-align: center;
}

.signal-heatmap-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 2rem;
}

.heatmap-y-label {
    position: absolute;
    left: 0;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: left center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.heatmap-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1;
}

.signal-heatmap {
    display: block;
    width: 100%;
    flex: 1;
    border-radius: 4px;
    background: var(--bg-primary);
}

.heatmap-phase-labels {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 0.5rem;
}

.phase-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.heatmap-x-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.5rem;
    text-align: center;
}

/* Smell Analysis Row - Full Width */
.modal-analysis-row {
    grid-column: 1 / -1;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.modal-analysis-row h3 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.analysis-matrix-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.analysis-matrix {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 200px;
}

.matrix-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    padding-left: 1rem; /* Align with canvas (account for y-label) */
}

.matrix-subtitle {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
    padding-left: 1rem; /* Align with canvas (account for y-label) */
}

.matrix-wrapper {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.matrix-y-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.55rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-right: 0.25rem;
}

.channel-correlation-matrix,
.time-similarity-matrix {
    border-radius: 4px;
    background: var(--bg-primary);
}

.matrix-x-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 0.25rem;
    text-align: center;
    padding-left: 1rem; /* Offset to align with canvas (account for y-label) */
}

/* Phase matrix with Baseline/Sample labels */
.matrix-y-labels {
    display: flex;
    flex-direction: column;
    height: 200px; /* Match canvas height */
    margin-right: 0.25rem;
}

.matrix-y-labels span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.matrix-x-labels {
    display: flex;
    width: 200px;
    margin-top: 0.25rem;
    padding-left: 1rem; /* Offset to align with canvas (account for y-labels) */
}

.matrix-x-labels span {
    flex: 1;
    text-align: center;
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Breathing Radar Canvas */
.breathing-radar-canvas {
    border-radius: 4px;
    background: transparent;
}

.breathing-radar {
    min-width: 200px;
}

/* Remove y-label padding offset for breathing radar (no y-label) */
.breathing-radar .matrix-title,
.breathing-radar .matrix-subtitle {
    padding-left: 0;
}

/* Responsive: Stack matrices on mobile */
@media (max-width: 600px) {
    .analysis-matrix-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .analysis-matrix {
        width: 100%;
        max-width: 250px;
    }

    .channel-correlation-matrix,
    .time-similarity-matrix,
    .breathing-radar-canvas {
        width: 100%;
        height: auto;
        max-width: 200px;
    }
}
