/* === Scroll offset for anchor links === */
[id] {
    scroll-margin-top: 32px;
}

/* === Fonts === */
/* Libre Franklin is loaded via <link> tag in <head> — no @font-face needed here */

@font-face {
    font-family: 'IBM Plex Mono';
    font-weight: 400 700;
    font-display: swap;
    src: url('IBMPlexMono-Regular.ttf') format('truetype')
}

/* === Reset & Body === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: 'Libre Franklin', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #152a47;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.65;
}

/* === Header === */
.cc-header-wrap { border-bottom: 1px solid #e2e8f0; background: #fff; }
.cc-header {
    max-width: 1200px; margin: 0 auto; padding: 24px 20px 20px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.cc-logo { height: 32px; margin: 0; }
.cc-htxt h1 { font-size: 20px; font-weight: 700; color: #152a47; line-height: 1.2; margin-bottom: 0; padding-top: 5px; }
.cc-htxt p { font-size: 14px; color: #64748b; margin-top: 2px; margin-bottom: 0; line-height: 1.3; }

/* === Main content area === */
.cc-twrap {
    max-width: 1200px; margin: 0 auto; padding: 16px 20px 32px;
    width: 100%; flex: 1;
}

/* === Footer === */
.cc-footer { border-top: 1px solid #e2e8f0; background: #fff; margin-top: 8px; }
.cc-footer-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 14px 20px 16px;
}
.cc-footer-info { font-size: 11px; color: #94a3b8; line-height: 1.5; }
.cc-footer-info span { display: block; }
.cc-footer-info span a { color: #64748b; text-decoration: underline; font-weight: 400; }
.cc-footer-info span a:hover { color: #2e5f8a; }
.cc-footer-links { display: inline-flex; gap: 12px; margin-top: 6px; }
.cc-footer-links a { font-size: 11px; color: #64748b; text-decoration: underline; font-weight: 400; }
.cc-footer-links a:hover { color: #2e5f8a; }

/* === Typography === */
h1, h2, h3, h4 { color: #152a47; line-height: 1.25; }
h2 { font-size: 20px; margin-top: 32px; margin-bottom: 10px; }
h3 { font-size: 17px; margin-top: 24px; margin-bottom: 8px; }
h4 { font-size: 15px; margin-top: 20px; margin-bottom: 6px; }
p { margin-bottom: 16px; }
ul, ol { margin-bottom: 16px; padding-left: 24px; }
li { margin-bottom: 4px; }

/* === Links === */
a {
    font-weight: 600;
    color: #152a47;
    text-decoration: underline;
    text-decoration-color: #c0c8d4;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}
a:hover {
    text-decoration-color: #152a47;
}

/* Footer links override (no underline) */
.cc-footer-info a,
.cc-footer-links a {
    text-decoration: underline;
}

hr {
    border: none;
    height: 1px;
    background: #e2e8f0;
    margin: 24px 0;
}

code {
    font-size: 13px;
    background: #f1f5f9;
    padding: 2px 3px;
    border-radius: 4px;
    color: #3a5068;
}

/* === Page content spacing === */
.cc-twrap > div {
    margin-bottom: 40px;
}

/* === Hero section (masthead + metadata) === */
.cc-hero {
    background: #fff;
    overflow: hidden;
}
.cc-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 16px;
}
.cc-hero .full-width-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 0;
    will-change: transform, opacity;
    -webkit-user-drag: none;
    user-select: none;
}
.update-bar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}
.update-info {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 13px;
    color: #94a3b8;
}
.update-info span {
    white-space: nowrap;
}
.update-info a {
    color: #64748b;
    font-weight: 600;
    text-decoration: none;
    text-decoration-color: transparent;
}
.update-info a:hover {
    color: #152a47;
    text-decoration: underline;
    text-decoration-color: #c0c8d4;
}
.update-sep {
    display: inline-block;
    width: 3px;
    height: 3px;
    background: #c0c8d4;
    border-radius: 50%;
    margin: 0 10px;
    vertical-align: middle;
}

/* === Images === */
img {
    max-width: 90%;
    height: auto;
    display: block;
    margin: 20px auto;
}

/* Prevent logo from being centered by the img rule */
.cc-logo {
    display: block;
    margin: 0;
    max-width: none;
}

/* === Download buttons === */
.download {
    margin-bottom: 32px;
}
.download h2 {
    margin-top: 0;
}
.download-button {
    margin-right: 8px;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    background: #fff;
    color: #152a47;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid #dde2e9;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.download-button:hover {
    background: #f8fafb;
    border-color: #cbd5e1;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
.download-button i {
    margin-right: 8px;
    font-size: 13px;
    color: #94a3b8;
}

/* === Tabbed rank panel === */
.rank-tabbed {
    margin: 8px 0 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}
.rank-tabs {
    display: flex;
    padding: 4px;
    background: #e9eff6;
    border-radius: 8px;
    margin: 10px 14px 0;
    position: relative;
}
.rank-tabs::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background: #b6cbe1;
    border-radius: 6px;
    transition: transform 0.25s ease;
    z-index: 0;
}
.rank-tabs[data-active="1"]::before {
    transform: translateX(100%);
}
.rank-tab {
    flex: 1;
    padding: 6px 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #375e87;
    cursor: pointer;
    border-radius: 6px;
    position: relative;
    z-index: 1;
    transition: color 0.15s;
}
.rank-tab:hover {
    color: #152a47;
}
.rank-tab.active {
    color: #152a47;
}
.rank-body {
    padding: 14px 16px;
}
.rank-content {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.35s ease, opacity 0.3s ease;
}
.rank-content.open {
    grid-template-rows: 1fr;
    opacity: 1;
}
.rank-content-inner {
    overflow: hidden;
    min-height: 0;
}
.rank-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}
.rank-controls select {
    flex: 1;
    min-width: 0;
    max-width: none;
}
.rank-controls .search-container {
    flex: 1;
    margin: 0;
    min-width: 0;
}
.rank-controls .search-input-wrap {
    flex: 1;
    min-width: 0;
}
.rank-controls select,
.rank-controls .search-input {
    height: 40px;
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
}
.rank-controls .search-input {
    padding: 9px 30px 9px 12px;
}
.search-input-wrap {
    position: relative;
    width: 100%;
}
.search-input-wrap .search-input {
    width: 100%;
}
.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    display: none;
}
.search-clear.visible {
    display: block;
}
.search-clear:hover {
    color: #152a47;
    background: #e9eff6;
}
.rank-panel {
    padding: 0;
}
.rank-panel[hidden] {
    display: none;
}
.rank-panel .placeholder-msg {
    margin: 0;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
}

/* === Select dropdowns === */
select {
    width: 100%;
    max-width: 340px;
    padding: 9px 36px 9px 12px;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    background-color: #fff;
    color: #152a47;
    font-size: 14px;
    font-weight: 400;
    font-family: inherit;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%2364748b" viewBox="0 0 16 16"%3E%3Cpath fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"%3E%3C/path%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus {
    border-color: #b8c9e0;
    box-shadow: 0 0 0 3px rgba(46,95,138,0.08);
}
select:hover {
    border-color: #cbd5e1;
}

/* === Tables === */
.table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid #dde2e9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.table-scroll-wrap table {
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: auto;
    min-width: 100%;
}
table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border: 1px solid #dde2e9;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}

th, td {
    padding: 10px 14px;
    text-align: left;
}

th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    background: #f8fafb;
    border-bottom: 2px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
    position: relative;
}

th:hover {
    color: #152a47;
}

td {
    font-size: 13px;
    color: #152a47;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-family: 'IBM Plex Mono', monospace;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f8fafc;
}

/* Active sort column */
th[data-sort="asc"],
th[data-sort="desc"] {
    color: #2e5f8a;
}
th[data-sort="asc"]::after {
    content: " \25B2";
    color: #2e5f8a;
    font-size: 9px;
}
th[data-sort="desc"]::after {
    content: " \25BC";
    color: #2e5f8a;
    font-size: 9px;
}

/* Table header content wrapper */
.header-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    width: 100%;
    height: 100%;
}

.sort-indicator {
    display: inline-block;
    color: #94a3b8;
    font-size: 10px;
}

/* Rank table rows */
.rank-panel table tbody tr {
    display: table-row;
}
.rank-panel table tbody tr[style*="display: none"] {
    display: none !important;
}

/* === Pagination === */
.pagination-controls {
    margin: 12px 0 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.pagination-controls .page-info {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}
.page-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.page-btn:hover:not([disabled]):not(.active) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}
.page-btn.active {
    background: #b6cbe1;
    border-color: #b6cbe1;
    color: #152a47;
}
.page-btn[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}
.page-prev, .page-next {
    font-size: 16px;
    font-weight: 600;
}
.page-ellipsis {
    min-width: 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    user-select: none;
}

/* === Search === */
.search-container {
    margin: 0.75rem 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    padding: 10px 14px;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    width: 240px;
    max-width: 100%;
    font-size: 14px;
    font-family: inherit;
    color: #152a47;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
    border-color: #b8c9e0;
    box-shadow: 0 0 0 3px rgba(46,95,138,0.08);
}
.search-input::placeholder {
    color: #94a3b8;
}
.search-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.search-count {
    color: #64748b;
    white-space: nowrap;
    font-size: 13px;
}
.rank-controls .search-container {
    gap: 0;
}
.rank-controls .search-count:not(:empty) {
    margin-left: 8px;
}
.surt-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.surt-toggle input { display: none; }
.surt-slider {
    position: relative;
    height: 40px;
    background: #f1f5f9;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    transition: background 0.25s ease, border-color 0.25s ease;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 0 10px 0 22px;
}
.surt-slider::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 3px;
    width: 10px;
    height: calc(100% - 8px);
    background: #cbd5e1;
    border-radius: 3px;
    transition: left 0.25s ease, background 0.25s ease;
}
.surt-slider .surt-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    position: relative;
    z-index: 1;
    transition: color 0.25s ease;
    user-select: none;
    -webkit-user-select: none;
}
.surt-toggle input:checked + .surt-slider {
    background: #b6cbe1;
    border-color: #a3bbd6;
    padding: 0 22px 0 10px;
}
.surt-toggle input:checked + .surt-slider::before {
    left: calc(100% - 13px);
    background: #fff;
}
.surt-toggle input:checked + .surt-slider .surt-label {
    color: #152a47;
}
.surt-toggle:hover .surt-slider { border-color: #b8c9e0; }
.surt-toggle input:checked:hover + .surt-slider {
    background: #a3bbd6;
    border-color: #8facc8;
}

/* === Code blocks === */
pre,
pre[class*="hljs"],
.hljs {
    color: #3a5068 !important;
    background: #fff !important;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

pre code,
pre code.hljs {
    background: none !important;
    padding: 0;
    border-radius: 0;
    border: none;
    color: inherit !important;
}

/* Highlight.js token overrides to match palette */
.hljs-comment,
.hljs-quote { color: #94a3b8; }
.hljs-keyword,
.hljs-selector-tag,
.hljs-addition { color: #2e5f8a; }
.hljs-string,
.hljs-attribute,
.hljs-template-variable,
.hljs-variable { color: #5a7a6a; }
.hljs-number,
.hljs-literal { color: #8a5a3a; }
.hljs-title,
.hljs-section,
.hljs-name,
.hljs-type { color: #152a47; font-weight: 600; }

/* === Layout containers === */
.container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.text-section {
    flex: 1;
    max-width: 33.33%;
}
.image-section {
    flex: 2;
}
.tt-image {
    width: 100%;
    height: auto;
    display: block;
}

/* === Chart containers === */
.chart-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chart-container img {
    max-width: 100%;
    margin: 12px auto;
    border-radius: 4px;
}
.chart-container h4 {
    margin-top: 0;
}
.chart-container p:last-child {
    margin-bottom: 0;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

/* === Interactive chart canvas === */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 12px 0;
}
.chart-wrapper canvas {
    max-width: 100%;
    display: block;
}

/* === Range slider === */
.chart-range-slider {
    position: relative;
    margin: 4px 0 24px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.rs-track {
    position: relative;
    height: 32px;
    background: #f5f7fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
}

.rs-spark {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.rs-window {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(55, 94, 135, 0.07);
    border-left: 2px solid #b6cbe1;
    border-right: 2px solid #b6cbe1;
    cursor: grab;
    transition: background 0.1s;
}
.rs-window:hover {
    background: rgba(55, 94, 135, 0.11);
}
.rs-window:active {
    cursor: grabbing;
}

.rs-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ew-resize;
    z-index: 2;
}
.rs-handle-l { left: -7px; }
.rs-handle-r { right: -7px; }

.rs-handle span {
    display: block;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: #94a3b8;
    transition: background 0.1s;
}
.rs-handle:hover span {
    background: #64748b;
}

/* === Equation cards === */
.eq-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.eq-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
}
.eq-card:hover {
    border-color: #b8c9e0;
}

.eq-header {
    padding: 10px 14px 8px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.eq-name {
    font-size: 13px;
    font-weight: 600;
    color: #152a47;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.eq-body {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    background: #f8fafb;
    flex: 1;
}
.eq-body img {
    width: 90%;
    max-width: 360px;
    height: auto;
}

.eq-footer {
    padding: 8px 14px 10px;
    border-top: 1px solid #e2e8f0;
}

.eq-source {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #64748b;
    word-break: break-all;
}

/* === TOC === */
.toc li a {
    font-weight: normal;
}

/* === Domain Lookup === */
.domain-lookup {
    background: #fff;
    border: 2px solid #375e87;
    border-radius: 10px;
    padding: 20px 24px 24px;
    margin: 24px 0;
    box-shadow: 0 1px 3px rgba(55,94,135,0.08);
}
.domain-search-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.domain-search-row .search-input-wrap {
    flex: 1;
    min-width: 0;
}
.domain-search-input {
    width: 100%;
    padding: 10px 30px 10px 14px;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: #152a47;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.domain-search-input:focus {
    border-color: #b8c9e0;
    box-shadow: 0 0 0 3px rgba(46,95,138,0.08);
}
.domain-search-input::placeholder {
    color: #94a3b8;
}
.domain-search-btn {
    padding: 10px 18px;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    background: #fff;
    color: #375e87;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.domain-search-btn:hover {
    background: #f0f4f8;
    border-color: #375e87;
}
.domain-search-msg {
    margin-top: 10px;
    font-size: 14px;
    color: #64748b;
    min-height: 0;
}
.domain-search-msg.error {
    color: #875567;
}
.domain-chart-wrap {
    margin-top: 16px;
}

/* === Info cards (Related Reading, Credits) === */
.info-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 32px 0 24px;
    align-items: start;
}
.info-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px 24px 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.info-card h3 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
    color: #152a47;
}
.info-card h3 a {
    color: inherit;
    text-decoration: none;
}
.info-card h3 a:hover {
    text-decoration: underline;
}
.info-card ul {
    margin: 0;
    padding-left: 20px;
}
.info-card li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #334155;
}
.info-card li:last-child {
    margin-bottom: 0;
}
.info-card a {
    color: #375e87;
}
.info-card a:hover {
    text-decoration: underline;
}

/* === Floating back-to-top button === */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    color: #64748b;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background 0.15s;
    z-index: 50;
    text-decoration: none;
}
.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}
.back-to-top:hover {
    background: #f8fafb;
    border-color: #cbd5e1;
    color: #334155;
    text-decoration: none;
}

/* === Collapsible TOC === */
.toc {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}
.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
.toc-header:hover {
    color: #152a47;
}
.toc.open .toc-header {
    border-bottom-color: #e2e8f0;
}
.toc-toggle {
    font-size: 12px;
    transition: transform 0.2s;
}
.toc.open .toc-toggle {
    transform: rotate(180deg);
}
.toc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.toc.open .toc-body {
    max-height: 600px;
}
.toc ul {
    padding: 12px 16px 14px 20px;
    margin: 0;
    columns: 3;
    column-gap: 20px;
    list-style: none;
}
.toc li {
    break-inside: avoid;
    margin-bottom: 6px;
    padding-left: 18px;
    position: relative;
}
.toc li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #b6cbe1;
    background: transparent;
}
.toc li a {
    font-weight: normal;
    font-size: 14px;
}

/* Legacy inline back-to-top link — hide in favor of floating button */
a[href="#"].legacy-top {
    display: none;
}

/* === Responsive === */
@media (max-width: 860px) {
    .cc-header { padding: 20px 16px 16px; }
    .cc-hero-inner { padding: 16px 16px 14px; }
    .cc-twrap { padding: 14px 16px 24px; }
    .cc-footer-inner { padding: 14px 16px; }
    .toc ul { columns: 2; }
}

@media (max-width: 480px) {
    .cc-header { padding: 16px 14px 14px; gap: 8px; }
    .cc-logo { height: 26px; }
    .cc-htxt h1 { font-size: 17px; }
    .cc-htxt p { font-size: 13px; }
    .cc-hero-inner { padding: 14px 14px 12px; }
    .update-info { flex-wrap: wrap; gap: 0; padding: 10px 14px; }
    .update-sep { display: none; }
    .update-info span { display: block; }
    .cc-twrap { padding: 12px 14px 20px; }
    .cc-footer-inner { padding: 12px 14px; }
    .rank-body { padding: 10px 12px; }
    .rank-controls .search-input { width: 100%; }

}

@media (max-width: 768px) {
    .rank-body { padding: 12px 14px; }

    .chart-wrapper {
        height: 280px;
    }

    /* Larger touch targets for range slider on mobile */
    .rs-track { height: 40px; }
    .rs-handle { width: 22px; }
    .rs-handle-l { left: -11px; }
    .rs-handle-r { right: -11px; }
    .rs-handle span { width: 4px; height: 18px; }

    .search-container { flex-wrap: wrap; }
    .search-input { width: 100%; }

    /* Equation cards stack vertically */
    .eq-grid { grid-template-columns: 1fr; }

    /* Select dropdowns go full width */
    select { max-width: 100%; }

    /* TOC single column */
    .toc ul { columns: 1; }

    /* Info cards stack */
    .info-cards {
        grid-template-columns: 1fr;
        gap: 14px;
        margin: 24px 0 20px;
    }
    .info-card { padding: 16px 18px 18px; }

    /* Floating button: smaller and closer to edge */
    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .domain-lookup { padding: 16px; }
}

/* === Narrow portrait phones (≤480px) === */
@media (max-width: 480px) {
    /* Domain lookup: stack inputs on narrow phones */
    .domain-search-row { flex-direction: column; }
    .domain-search-btn { width: 100%; justify-content: center; }
    .chart-container {
        padding: 12px 10px 14px;
        margin-bottom: 16px;
    }
    .chart-container h4 { font-size: 14px; }
    .chart-container p:last-child { font-size: 13px; line-height: 1.45; }

    .chart-wrapper {
        height: 260px;
        margin: 8px -4px;  /* bleed slightly into padding for more chart width */
    }
    .chart-range-slider {
        margin: 4px -4px 0;
    }

    /* Code blocks: smaller and scrollable on narrow */
    pre,
    pre[class*="hljs"],
    .hljs {
        font-size: 11px;
        line-height: 1.5;
        padding: 14px;
        -webkit-overflow-scrolling: touch;
    }

    /* Domain lookup: tighter on narrow */
    .domain-lookup { padding: 14px 10px 16px; }
    .domain-chart-wrap .chart-wrapper {
        height: 280px;     /* dual-axis needs a bit more height */
    }

    /* Tighter table cells on narrow */
    th, td { padding: 8px 10px; }
    th { font-size: 10px; }
    td { font-size: 12px; }

    /* Pagination: compact layout */
    .pagination-controls .page-info { font-size: 12px; }
    .page-btn {
        min-width: 30px;
        height: 30px;
        padding: 0 5px;
        font-size: 11px;
    }
    .page-prev, .page-next { font-size: 14px; }
    .page-ellipsis { min-width: 16px; font-size: 12px; }

    /* Rank controls stack vertically */
    .rank-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    .rank-controls select,
    .rank-controls .search-container { flex: 1 1 100%; }

    /* Tabs: tighter */
    .rank-tabs {
        margin: 8px 10px 0;
    }
    .rank-tab {
        padding: 5px 0;
        font-size: 11px;
    }

    /* Hero: remove bottom padding since image goes to edge */
    .cc-hero-inner { padding: 10px 10px 8px; }

    /* Update bar tighter */
    .update-info { padding: 8px 10px; font-size: 12px; }

    /* Headings and text: tighter for portrait */
    h2 { font-size: 18px; margin-top: 24px; margin-bottom: 8px; }
    h3 { font-size: 15px; margin-top: 18px; margin-bottom: 6px; }
    h4 { font-size: 14px; margin-top: 16px; margin-bottom: 4px; }
    p { font-size: 14px; margin-bottom: 12px; }

    /* Tighter section spacing */
    .cc-twrap > div { margin-bottom: 28px; }

    /* TOC: compact */
    .toc-header span:first-child { font-size: 12px; }
    .toc li { margin-bottom: 4px; padding-left: 14px; }
    .toc li::before { width: 6px; height: 6px; top: 6px; }
    .toc li a { font-size: 13px; }
    .toc ul { padding: 10px 12px 12px 16px; }

    /* Equation cards: tighter */
    .eq-card { border-radius: 8px; }
    .eq-header { padding: 8px 10px 6px; }
    .eq-name { font-size: 12px; }
    .eq-body { padding: 18px 10px; min-height: 70px; }
    .eq-body img { width: 95%; max-width: 300px; }
    .eq-footer { padding: 6px 10px 8px; }
    .eq-source { font-size: 11px; }
}

/* === Embed mode === */
.embed-mode body,
.embed-mode { background: #fff; }
.embed-mode .cc-header-wrap,
.embed-mode .cc-hero,
.embed-mode .update-bar,
.embed-mode .cc-footer,
.embed-mode .back-to-top,
.embed-mode noscript { display: none !important; }
.embed-mode main { padding: 0; }
.embed-mode article { padding: 0; }
.embed-mode .cc-twrap { max-width: none; padding: 0; margin: 0; }
.embed-mode .cc-twrap > * { display: none !important; }
.embed-mode .cc-twrap > .domain-lookup {
    display: block !important;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 12px 16px 8px;
}
.embed-mode .domain-lookup > p { margin-bottom: 8px; }
/* === Embed bar (top bar inside domain-lookup box) === */
.embed-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin: -4px 0 8px;
    font-size: 11px;
    color: #94a3b8;
}
.embed-attribution { display: none; }
.embed-mode .embed-attribution { display: inline; }
.embed-bar-updated { margin-right: auto; }
.embed-attribution a { color: #375e87; text-decoration: none; }
.embed-attribution a:hover { text-decoration: underline; }

/* === Embed help (collapsible) === */
.embed-help { display: inline; position: relative; }
.embed-help summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 12px;
    list-style: none;
    display: inline-block;
    transition: color 0.15s;
}
.embed-help summary:hover { color: #375e87; }
.embed-help summary::-webkit-details-marker { display: none; }
.embed-help .embed-help-content {
    position: absolute;
    top: 22px;
    right: 0;
    width: 480px;
    max-width: calc(100vw - 40px);
    text-align: left;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 13px;
    line-height: 1.6;
    z-index: 10;
}
.embed-help .embed-help-content code {
    font-size: 12px;
}
.embed-help .embed-help-content pre {
    margin: 8px 0;
    padding: 10px 12px;
    background: #f5f7fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
}
.embed-help .embed-help-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}
