/* ═══════════════════ Chart colors ═══════════════════ */
.substance-page {
    --chart-green: rgb(144, 238, 144);
    --chart-orange: rgb(255, 165, 0);
    --chart-red-orange: rgb(255, 99, 71);
    --chart-red: rgb(255, 69, 0);
    --chart-blue: rgb(100, 149, 237);
    --chart-text: #1a1a1a;
    --chart-text-dim: #888;
    --chart-grid-line: rgba(128, 128, 128, 0.2);
}
body.dark .substance-page {
    --chart-green: rgb(110, 200, 110);
    --chart-orange: hsl(39, 90%, 45%);
    --chart-red-orange: rgb(210, 75, 55);
    --chart-red: rgb(200, 55, 20);
    --chart-text: #e0e0e0;
    --chart-text-dim: #777;
    --chart-grid-line: rgba(255, 255, 255, 0.08);
}

/* ═══════════════════ Warning banners ═══════════════════ */
.warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    line-height: 1.5;
    border-left: 4px solid;
}
.warning-banner .warning-icon {
    flex-shrink: 0;
    font-size: 1.15rem;
    line-height: 1.45;
}
.warning-banner .warning-text {
    flex: 1;
    min-width: 0;
}

/* Caution — yellow */
.warning-banner.warning-caution {
    background-color: #fff8e1;
    border-left-color: #f9a825;
    color: #5d4200;
}
body.dark .warning-banner.warning-caution {
    background-color: rgba(249, 168, 37, 0.12);
    border-left-color: #f9a825;
    color: #ffd54f;
}

/* Danger — red */
.warning-banner.warning-danger {
    background-color: #fce4ec;
    border-left-color: #d32f2f;
    color: #6a1b1b;
}
body.dark .warning-banner.warning-danger {
    background-color: rgba(211, 47, 47, 0.12);
    border-left-color: #ef5350;
    color: #ef9a9a;
}

.warning-banners-container {
    margin-bottom: 1.5rem;
}

/* ═══════════════════ Perspectives / Featured Quotes ═══════════════════ */
.perspectives-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.perspective-quote {
    margin: 0;
    padding: 0.85rem 1.1rem;
    border-radius: 6px;
    border-left: 3px solid;
    position: relative;
}
.perspective-nervewing {
    background: rgba(56, 178, 172, 0.06);
    border-left-color: #38b2ac;
}
.perspective-shulgin {
    background: rgba(124, 77, 255, 0.06);
    border-left-color: #7c4dff;
}
.perspective-dub {
    background: rgba(211, 153, 63, 0.06);
    border-left-color: #d3993f;
}
body.dark .perspective-nervewing {
    background: rgba(56, 178, 172, 0.08);
    border-left-color: #4fd1c5;
}
body.dark .perspective-shulgin {
    background: rgba(179, 136, 255, 0.08);
    border-left-color: #b388ff;
}
body.dark .perspective-dub {
    background: rgba(211, 153, 63, 0.08);
    border-left-color: #e8b04a;
}
.perspective-text {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
    font-style: italic;
}
.perspective-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.perspective-author {
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
}
a.perspective-author:hover {
    opacity: 0.7;
}
.perspective-nervewing .perspective-author {
    color: #38b2ac;
}
.perspective-shulgin .perspective-author {
    color: #7c4dff;
}
body.dark .perspective-nervewing .perspective-author {
    color: #4fd1c5;
}
body.dark .perspective-shulgin .perspective-author {
    color: #b388ff;
}
.perspective-dub .perspective-author {
    color: #d3993f;
}
body.dark .perspective-dub .perspective-author {
    color: #e8b04a;
}
.perspective-dose {
    font-size: 0.73rem;
    color: #888;
    background: rgba(0,0,0,0.04);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}
body.dark .perspective-dose {
    background: rgba(255,255,255,0.08);
    color: #999;
}

/* PiHKAL/TiHKAL links */
.pihkal-link {
    border-left: 3px solid #7c4dff;
}
body.dark .pihkal-link {
    border-left-color: #b388ff;
}

/* Shulgin entry wrapper */
.shulgin-entry {
    margin-bottom: 1.2rem;
}
.shulgin-entry:last-child {
    margin-bottom: 0;
}

/* Shulgin qualitative comment quote */
.shulgin-quote {
    margin: 0.6rem 0 0 0;
    padding: 0.8rem 1rem;
    border-left: 3px solid #7c4dff;
    background: rgba(124, 77, 255, 0.04);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    position: relative;
    max-height: 6.5em;
    overflow: hidden;
}
.shulgin-quote::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.5em;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.95));
    pointer-events: none;
}
body.dark .shulgin-quote {
    background: rgba(179, 136, 255, 0.06);
    border-left-color: #b388ff;
}
body.dark .shulgin-quote::after {
    background: linear-gradient(transparent, rgba(30, 30, 30, 0.95));
}

.shulgin-quote-text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #444;
}
body.dark .shulgin-quote-text {
    color: #c0b8d0;
}

.shulgin-quote-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    font-style: normal;
}
.shulgin-quote-footer cite {
    color: #7c4dff;
    font-style: normal;
    font-weight: 500;
}
body.dark .shulgin-quote-footer cite {
    color: #b388ff;
}
.shulgin-dose {
    color: #888;
    font-size: 0.75rem;
    background: rgba(0,0,0,0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}
body.dark .shulgin-dose {
    background: rgba(255,255,255,0.08);
    color: #999;
}

/* ═══════════════════ Page ═══════════════════ */
.substance-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.5rem 0;
    width: 100%;
    overflow-x: hidden;
}

/* ═══════════════════ Header block ═══════════════════ */
.substance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.substance-info {
    flex: 1;
    min-width: 0;
}

.substance-info h1 {
    text-align: center;
    margin: 0 0 0.75rem 0;
    font-size: 2.8rem;
    font-weight: 700;
}

.aliases {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
}
.aliases strong {
    color: var(--text);
}

.category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-tag {
    padding: 0.3rem 0.75rem;
    border-radius: 5px;
    color: #333;
    font-weight: bold;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.2s;
}
.category-tag:hover {
    opacity: 0.85;
    text-decoration: none;
}
.category-tag-plain { cursor: default; }
.category-tag-plain:hover { opacity: 1; }

/* SVG molecular structure */
.substance-svg {
    width: 200px;
    height: 200px;
    max-width: 40vw;
    object-fit: contain;
    background: transparent;
    mix-blend-mode: multiply;
    filter: brightness(1.1);
    flex-shrink: 1;
}
body.dark .substance-svg {
    mix-blend-mode: screen;
    filter: invert(1) hue-rotate(180deg);
}
/* Webp structures may need different blend handling */
.structure-webp {
    mix-blend-mode: normal;
    filter: none;
}
body.dark .structure-webp {
    mix-blend-mode: normal;
    filter: invert(1);
}

/* ═══════════════════ Sections ═══════════════════ */
.section-block {
    margin-bottom: 2.5rem;
}

.section-block h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: var(--text);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.section-block p {
    margin: 0 0 0.6rem 0;
    line-height: 1.7;
    font-size: 1rem;
    color: var(--text-dim);
}

/* Source tags (small labels next to h2) */
.source-tags {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}
.source-tag {
    font-size: 0.6rem;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--bg-alt);
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
a.source-tag:hover {
    background: var(--bg-elevated);
    text-decoration: none;
}

/* ═══════════════════ Dose layout: chart + table side by side ═══════════════════ */
.dose-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.dose-layout .chart-container {
    flex: 1;
    min-width: 0;
}
.dose-layout .dose-table-wrapper {
    flex: 0 1 auto;
    max-width: 55%;
    min-width: 0;
    overflow: hidden;
}

/* Dose chart */
.chart-container {
    position: relative;
    width: 100%;
}
.chart-container canvas {
    width: 100% !important;
}

/* Custom HTML legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
    color: var(--text);
    font-size: 0.85rem;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text);
}
.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* Interactive legend toggles */
.legend-toggle {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
}
.legend-toggle:hover {
    opacity: 0.75;
}
.legend-toggle.legend-hidden {
    opacity: 0.35;
}
.legend-toggle.legend-hidden .legend-label {
    text-decoration: line-through;
}
.legend-toggle.legend-hidden .legend-swatch {
    opacity: 0.3;
}

/* Dose table */
.dose-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto;
}

.dose-table th,
.dose-table td {
    padding: 0.55rem 0.6rem;
    text-align: center;
    color: var(--text);
    border: 1px solid var(--border);
    word-break: break-word;
}

.dose-table thead th {
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--bg-alt);
    color: var(--text-dim);
}

/* Color-coded dose cells (data rows only, not headers) */
.dose-table td[data-level="light"] {
    background-color: var(--chart-green);
    color: #222;
    font-weight: 600;
}
.dose-table td[data-level="common"] {
    background-color: var(--chart-orange);
    color: #222;
    font-weight: 600;
}
.dose-table td[data-level="strong"] {
    background-color: var(--chart-red-orange);
    color: #fff;
    font-weight: 600;
}
.dose-table td[data-level="heavy"] {
    background-color: var(--chart-red);
    color: #fff;
    font-weight: 600;
}

.dose-table .roa-label {
    font-weight: 600;
    text-align: left;
    background: var(--bg-alt);
    color: var(--text);
}

.dose-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
}

/* Bioavailability annotation in ROA label */
.roa-bio {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgb(100, 149, 237);
    margin-top: 0.1rem;
    letter-spacing: 0.01em;
}
body.dark .roa-bio {
    color: rgb(130, 170, 255);
}

/* ═══════════════════ Duration ═══════════════════ */
.time-course-container {
    position: relative;
    width: 100%;
    height: 350px;
    margin-bottom: 1rem;
}
.time-course-container canvas {
    width: 100% !important;
}

.roa-block h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.4rem 0;
    color: var(--text);
}

/* Old duration list fallback */
.duration-phase-list {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0 0 0.5rem 0;
}
.duration-phase-list > li {
    margin-bottom: 0.35rem;
    line-height: 1.5;
    font-weight: 600;
}
.duration-roa-list {
    list-style: circle;
    padding-left: 1.25rem;
    margin: 0.15rem 0 0 0;
    font-weight: 400;
}
.duration-roa-list li { margin-bottom: 0.1rem; font-size: 0.95rem; }
.duration-roa-list li strong { font-weight: 600; }

/* ═══════════════════ Tolerance ═══════════════════ */
.tolerance-section {
    border-left: 4px solid #4a90d9;
    padding-left: 1.25rem;
}
body.dark .tolerance-section {
    border-left-color: #5c9eed;
}

.tolerance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.tolerance-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.tolerance-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.tolerance-value {
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-dim);
}

.tolerance-cross {
    margin-top: 0.25rem;
}

.tolerance-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.3rem;
}

.tolerance-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(74, 144, 217, 0.1);
    color: #4a90d9;
    transition: background 0.15s, transform 0.1s;
}
.tolerance-tag:hover {
    background: rgba(74, 144, 217, 0.2);
    transform: translateY(-1px);
    text-decoration: none;
}
body.dark .tolerance-tag {
    background: rgba(92, 158, 237, 0.12);
    color: #7eb3f5;
}
body.dark .tolerance-tag:hover {
    background: rgba(92, 158, 237, 0.22);
}

@media (max-width: 700px) {
    .tolerance-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .tolerance-section { padding-left: 0.85rem; }
}

/* ═══════════════════ Effects ═══════════════════ */
.collapsible {
    background: var(--bg-alt);
    color: var(--text);
    cursor: pointer;
    padding: 0.65rem 1rem;
    width: 100%;
    border: none;
    border-radius: 5px;
    text-align: left;
    outline: none;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    transition: background 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
}
.collapsible:hover { background: var(--bg-elevated); }
.collapsible::after {
    content: "+";
    float: right;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.collapsible.active::after {
    content: "−";
}

.collapse-content {
    display: none;
    padding: 0.5rem 0;
}

/* Two-column positive / negative layout */
.effects-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    margin-bottom: 0.6rem;
}
.effects-col {
    min-width: 0;
}

/* Column labels */
.effects-col-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    margin-bottom: 0.35rem;
}
.effects-col-label-positive {
    color: #2e7d32;
    background: rgba(76, 175, 80, 0.1);
}
.effects-col-label-negative {
    color: #c62828;
    background: rgba(229, 57, 53, 0.1);
}
.effects-col-label-neutral {
    color: var(--text-muted);
    background: var(--bg-alt);
}
body.dark .effects-col-label-positive {
    color: #66bb6a;
    background: rgba(102, 187, 106, 0.1);
}
body.dark .effects-col-label-negative {
    color: #ef5350;
    background: rgba(239, 83, 80, 0.1);
}

.effects-list {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 2rem;
}
.effects-list-single {
    columns: 1;
}
.effects-list li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    break-inside: avoid;
    color: var(--text-dim);
}
.effects-list li:last-child { border-bottom: none; }

/* Positive / negative effect highlights */
.effects-list li.effect-positive {
    border-left: 3px solid #4caf50;
    padding-left: 0.6rem;
    color: var(--text);
}
.effects-list li.effect-negative {
    border-left: 3px solid #e53935;
    padding-left: 0.6rem;
    color: var(--text);
}
body.dark .effects-list li.effect-positive {
    border-left-color: #66bb6a;
}
body.dark .effects-list li.effect-negative {
    border-left-color: #ef5350;
}

/* ═══════════════ General Dosage Calculator ═══════════════ */
.calc-roa-header {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.75rem 0 0.25rem;
    color: var(--text);
}
.calc-roa-header:first-child {
    margin-top: 0.5rem;
}
.dose-level-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* ═══════════════════ Dosing Calculator ═══════════════════ */
.calc-description {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 1rem;
}
.calc-container {
    margin-top: 0.75rem;
}
.calc-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.calc-input-row label {
    font-weight: 600;
    font-size: 0.95rem;
}
.calc-input {
    width: 6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
}
.calc-input:focus { border-color: var(--accent, #e91e8a); }
.calc-sep {
    font-size: 0.92rem;
    color: var(--text-dim);
}
.calc-select-wide {
    min-width: 14rem;
}
.calc-form-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: -0.5rem 0 0.75rem;
    min-height: 1.2em;
    font-style: italic;
}
.calc-select {
    padding: 0.45rem 0.5rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
}

/* Results table */
.calc-results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.75rem;
}
.calc-results-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.calc-results-table td {
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.calc-results-table tbody tr:last-child td { border-bottom: none; }

/* Plateau badges (DXM) */
.plateau-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
}
.p-1st  { background: rgba(76, 175, 80, 0.15); color: #4caf50; }
.p-2nd  { background: rgba(255, 193, 7, 0.15); color: #f9a825; }
.p-3rd  { background: rgba(255, 152, 0, 0.15); color: #ff9800; }
.p-4th  { background: rgba(244, 67, 54, 0.15); color: #f44336; }
body.dark .p-1st { color: #66bb6a; }
body.dark .p-2nd { color: #ffca28; }
body.dark .p-3rd { color: #ffa726; }
body.dark .p-4th { color: #ef5350; }

/* Ketamine badges */
.ket-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
}
.ket-threshold { background: rgba(100, 149, 237, 0.12); color: #5c86d1; }
.ket-light     { background: rgba(76, 175, 80, 0.15); color: #4caf50; }
.ket-common    { background: rgba(255, 193, 7, 0.15); color: #f9a825; }
.ket-strong    { background: rgba(255, 152, 0, 0.15); color: #ff9800; }
.ket-khole     { background: rgba(156, 39, 176, 0.15); color: #ab47bc; }
body.dark .ket-threshold { color: #7ea8f0; }
body.dark .ket-light     { color: #66bb6a; }
body.dark .ket-common    { color: #ffca28; }
body.dark .ket-strong    { color: #ffa726; }
body.dark .ket-khole     { color: #ce93d8; }

/* Plateau row left borders */
.plateau-row-1st td:first-child { border-left: 3px solid #4caf50; }
.plateau-row-2nd td:first-child { border-left: 3px solid #f9a825; }
.plateau-row-3rd td:first-child { border-left: 3px solid #ff9800; }
.plateau-row-4th td:first-child { border-left: 3px solid #f44336; }
.ket-row-threshold td:first-child { border-left: 3px solid #5c86d1; }
.ket-row-light td:first-child     { border-left: 3px solid #4caf50; }
.ket-row-common td:first-child    { border-left: 3px solid #f9a825; }
.ket-row-strong td:first-child    { border-left: 3px solid #ff9800; }
.ket-row-khole td:first-child     { border-left: 3px solid #ab47bc; }

/* Warning note */
.calc-note {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
    padding: 0.65rem 0.85rem;
    background: rgba(244, 67, 54, 0.06);
    border-left: 3px solid #f44336;
    border-radius: 4px;
    margin-top: 0.5rem;
}
body.dark .calc-note {
    background: rgba(244, 67, 54, 0.08);
}

/* Plateau info descriptions */
.calc-plateaus-info { margin-bottom: 1rem; }
.plateau-descriptions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding-top: 0.5rem;
}
.plateau-item {
    padding: 0.65rem 0.85rem;
    border-radius: 5px;
    background: var(--bg-alt);
    border-left: 3px solid var(--border);
}
.plateau-item strong { font-size: 0.92rem; }
.plateau-item p {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin: 0.3rem 0 0;
    line-height: 1.5;
}
.plateau-range {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}
.plateau-1st { border-left-color: #4caf50; }
.plateau-2nd { border-left-color: #f9a825; }
.plateau-3rd { border-left-color: #ff9800; }
.plateau-4th { border-left-color: #f44336; }

@media (max-width: 700px) {
    .plateau-descriptions { grid-template-columns: 1fr; }
    .calc-mg-kg-col { display: none; }
}

/* ═══════════════════ Combinations ═══════════════════ */

/* Pill grid */
.combo-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.combo-pill {
    border: none;
    border-radius: 100px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
    outline: none;
    white-space: nowrap;
}
.combo-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.18);
}
.combo-pill.active {
    transform: translateY(-1px);
    box-shadow: 0 0 0 2px var(--text), 0 3px 8px rgba(0,0,0,0.18);
}
body.dark .combo-pill.active {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 3px 8px rgba(0,0,0,0.3);
}

/* Pill status colors */
.combo-pill-dangerous        { background: #e53935; color: #fff; }
.combo-pill-unsafe           { background: #f57c00; color: #fff; }
.combo-pill-caution          { background: #fdd835; color: #333; }
.combo-pill-low-risk-synergy { background: #43a047; color: #fff; }
.combo-pill-low-risk-decrease { background: #5c9eed; color: #fff; }
.combo-pill-low-risk-no-synergy { background: #78909c; color: #fff; }

body.dark .combo-pill-dangerous        { background: #c62828; }
body.dark .combo-pill-unsafe           { background: #e65100; }
body.dark .combo-pill-caution          { background: #f9a825; color: #1a1a1a; }
body.dark .combo-pill-low-risk-synergy { background: #2e7d32; }
body.dark .combo-pill-low-risk-decrease { background: #3a7bd5; }
body.dark .combo-pill-low-risk-no-synergy { background: #607d8b; }

/* Detail panel */
.combo-detail {
    display: none;
    border-left: 3px solid var(--text-muted);
    border-radius: 0 6px 6px 0;
    background: var(--bg-alt);
    padding: 0.65rem 0.9rem;
    margin-bottom: 0.6rem;
    animation: comboSlide 0.15s ease-out;
}
.combo-detail.open {
    display: block;
}
@keyframes comboSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.combo-detail-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.3rem;
}
.combo-detail-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.combo-detail-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}
.combo-detail-status {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
}
.combo-detail-note {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-dim);
}

/* Detail panel accent colors */
.combo-detail-dangerous        { border-left-color: #e53935; }
.combo-detail-unsafe           { border-left-color: #f57c00; }
.combo-detail-caution          { border-left-color: #fdd835; }
.combo-detail-low-risk-synergy { border-left-color: #43a047; }
.combo-detail-low-risk-decrease { border-left-color: #5c9eed; }
.combo-detail-low-risk-no-synergy { border-left-color: #78909c; }

.combo-detail-dangerous .combo-detail-status  { color: #e53935; }
.combo-detail-unsafe .combo-detail-status     { color: #f57c00; }
.combo-detail-caution .combo-detail-status    { color: #c6a700; }
.combo-detail-low-risk-synergy .combo-detail-status { color: #43a047; }
.combo-detail-low-risk-decrease .combo-detail-status { color: #5c9eed; }
.combo-detail-low-risk-no-synergy .combo-detail-status { color: #78909c; }
body.dark .combo-detail-caution .combo-detail-status { color: #fdd835; }

/* Dot colors (reused in detail header) */
.combo-dot-dangerous        { background: #e53935; }
.combo-dot-unsafe           { background: #f57c00; }
.combo-dot-caution          { background: #fdd835; }
.combo-dot-low-risk-synergy { background: #43a047; }
.combo-dot-low-risk-decrease { background: #5c9eed; }
.combo-dot-low-risk-no-synergy { background: #78909c; }

/* Legend / category toggles */
.combo-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.combo-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    padding: 0.22rem 0.65rem;
    background: transparent;
    font-family: inherit;
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
    outline: none;
    user-select: none;
}
.combo-legend-item:hover {
    border-color: var(--text-dim);
    color: var(--text-dim);
}
.combo-legend-item.active {
    background: var(--bg-alt);
    border-color: var(--text-dim);
    color: var(--text);
    font-weight: 600;
}
.combo-legend-item:not(.active) {
    opacity: 0.5;
}
.combo-legend-item:not(.active) .combo-legend-dot {
    opacity: 0.4;
}
.combo-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.combo-legend-dangerous        { background: #e53935; }
.combo-legend-unsafe           { background: #f57c00; }
.combo-legend-caution          { background: #fdd835; }
.combo-legend-low-risk-synergy { background: #43a047; }
.combo-legend-low-risk-decrease { background: #5c9eed; }
.combo-legend-low-risk-no-synergy { background: #78909c; }

/* ═══════════════════ Resource links ═══════════════════ */
.links-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.modern-link {
    display: block;
    padding: 0.65rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--bg-alt);
    border-radius: 5px;
    transition: background 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modern-link:hover {
    background: var(--bg-elevated);
    text-decoration: none;
}
.nervewing-link {
    border-left: 3px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Trip report author tag */
.report-author {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

/* Duration table */
.duration-table td {
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
}

/* ═══════════════════ Mobile ═══════════════════ */
@media (max-width: 700px) {
    .warning-banner { font-size: 0.82rem; padding: 0.6rem 0.75rem; }
    .warning-banner .warning-icon { font-size: 1rem; }
    .substance-page { padding: 0.5rem 0.25rem; }
    .substance-header { flex-direction: column; gap: 1rem; }
    .substance-info h1 { font-size: 2rem; }
    .substance-svg { width: 130px; height: 130px; max-width: 40vw; align-self: center; }
    .dose-layout { flex-direction: column; }
    .dose-layout .chart-container { width: 100%; }
    .dose-layout .dose-table-wrapper { max-width: 100%; width: 100%; }
    .chart-container { height: auto; }
    .time-course-container { height: 280px; }
    .dose-table { font-size: 0.7rem; }
    .dose-table th, .dose-table td { padding: 0.3rem 0.25rem; font-size: 0.7rem; }
    .dose-table .roa-label { font-size: 0.7rem; }
    .effects-list { columns: 1; }
    .effects-columns { grid-template-columns: 1fr; gap: 0.8rem; }
    .section-block h2 { font-size: 1.3rem; }
    .chart-legend { gap: 0.5rem; font-size: 0.75rem; }
    .legend-swatch { width: 10px; height: 10px; }
    .aliases { font-size: 0.85rem; word-break: break-word; }
    .category-list { gap: 0.35rem; }
    .category-tag { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
}

@media (max-width: 400px) {
    .substance-page { padding: 0.25rem 0.15rem; }
    .substance-info h1 { font-size: 1.6rem; }
    .dose-table th, .dose-table td { padding: 0.2rem 0.15rem; font-size: 0.6rem; }
    .section-block h2 { font-size: 1.1rem; }
    .section-block p { font-size: 0.85rem; }
    .modern-link { font-size: 0.8rem; padding: 0.5rem 0.75rem; }
    .collapsible { font-size: 0.85rem; padding: 0.5rem 0.75rem; }
}
