@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/FiraSans-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('fonts/FiraSans-SemiBold.woff2') format('woff2');
}

:root {
  --blue: #166bda;
  --blue-dark: #0d3e7d;
  --blue-soft: #e8f1fd;
  --ink: #30333d;
  --muted: #6d6f76;
  --line: #e5e5e5;
  --backdrop: #f7f7f7;
  --white: #fff;
  --danger: #d23261;
  --space-section: 24px;
  --space-card: 24px;
  --control-height: 44px;
  --interaction-duration: 150ms;
  --topics-sticky-top: 146px;
}

* { box-sizing: border-box; }
html { color: var(--ink); background: var(--backdrop); font-family: 'Fira Sans', sans-serif; line-height: 1.5; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
a { color: var(--blue); text-underline-offset: .18em; }
body a:hover { color: var(--blue-dark); }
:where(a, button, input, select, summary) { transition: color var(--interaction-duration) ease, background-color var(--interaction-duration) ease, border-color var(--interaction-duration) ease, box-shadow var(--interaction-duration) ease; }
body :focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
:where(button, select, input, summary, a, #topics-title) { scroll-margin-block: calc(var(--topics-sticky-top) + 24px) 24px; }

.site-header { position: sticky; top: 0; z-index: 10; height: 80px; display: flex; align-items: center; padding: 0 max(24px, calc((100% - 1180px) / 2)); background: var(--white); box-shadow: 0 2px 8px rgb(0 0 0 / 5%); }
.site-header.has-stuck-filters { box-shadow: none; }
.header-title { margin-left: 8px; font-size: 20px; font-weight: 600; white-space: nowrap; opacity: 0; }
.header-greeting { margin-left: auto; padding-left: 24px; min-width: 0; overflow-wrap: anywhere; text-align: right; color: var(--muted); }
.header-logout { white-space: nowrap; }
.header-logout a { color: var(--blue); }
.header-logout a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; font-size: 20px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; }

main { width: min(1180px, calc(100% - 48px)); margin: 32px auto 64px; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: var(--space-section); }
.title-row > div { min-width: 0; }
.title-tools { display: flex; flex-shrink: 0; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.view-links { display: flex; justify-content: flex-end; gap: 8px; }
.view-links a:not([hidden]) { display: inline-flex; align-items: center; text-decoration: none; }
.report-icon { flex-shrink: 0; vertical-align: middle; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: 32px; line-height: 1.25; font-weight: 600; color: var(--ink); }
h2 { margin-bottom: 0; font-size: 24px; line-height: 1.25; font-weight: 600; color: var(--ink); }
.intro, .muted { color: var(--muted); }
.intro { margin-bottom: 0; }
.muted { margin: 8px 0 16px; font-size: .9rem; }
.trend-explanation { margin: 16px 0 0; font-size: .75rem; }

.refresh, .text-button { border: 0; background: none; color: var(--blue); font-weight: 400; }
.refresh { align-items: center; justify-content: center; gap: 4px; min-height: var(--control-height); padding: 8px 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); white-space: nowrap; }
.refresh:not([hidden]) { display: inline-flex; }
.refresh > [data-icon] { display: inline-flex; }
.refresh:hover:not(:disabled) { color: var(--blue-dark); border-color: var(--blue); background: var(--blue-soft); }
.refresh[disabled] { cursor: wait; opacity: .55; }
.text-button { padding: 4px; text-decoration: underline; text-underline-offset: .18em; }
.text-button:hover { color: var(--blue-dark); }

.control-panel { margin-bottom: var(--space-section); overflow: hidden; background: var(--white); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 5px 5px; }
.filters { position: sticky; top: 80px; z-index: 9; display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding: 12px 24px; background: var(--white); border: 1px solid var(--line); border-radius: 5px 5px 0 0; }
.filters.is-stuck { width: 100vw; margin-left: calc(50% - 50vw); padding-inline: max(24px, calc((100vw - 1180px) / 2)); border-inline: 0; border-radius: 0; box-shadow: 0 2px 8px rgb(0 0 0 / 5%); }
.filters > label { align-self: center; font-weight: 700; }
.filter-options { display: flex; align-items: center; gap: 8px; margin-left: auto; }
select { appearance: none; min-width: 260px; height: var(--control-height); padding: 0 44px 0 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--backdrop) url('chevron-down.svg') no-repeat right 16px center; color: var(--ink); }
select:hover, .list-search:hover { border-color: var(--blue); }
#institution { flex: 1; min-width: 0; max-width: 370px; }
#device { min-width: 190px; }
fieldset { margin: 0; padding: 0; border: 0; }
.segmented { display: flex; flex-wrap: wrap; min-width: 0; margin-left: auto; gap: 4px; }
.segmented legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segmented button { white-space: nowrap; min-height: var(--control-height); padding: 8px 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--backdrop); color: var(--ink); }
.segmented button:hover { background: var(--blue-soft); border-color: var(--blue); }
.segmented button[aria-pressed="true"] { background: var(--blue); color: var(--white); font-weight: 700; }
#period-select { display: block; min-width: 160px; }
#period-filter button { display: none; }
#limit-filter { width: auto; min-width: 90px; }

.status { padding: 8px 24px; color: var(--muted); min-height: 38px; }
:where(.control-panel) .status, .status-toast { position: fixed; bottom: 24px; right: 24px; z-index: 11; max-width: min(560px, calc(100% - 32px)); padding: 12px 16px; background: var(--white); border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 2px 8px rgb(0 0 0 / 10%); pointer-events: none; }
.status:empty { display: none; }
#report[aria-busy="true"] { opacity: .65; }
#report[aria-busy="true"] .rank-list:empty,
#report[aria-busy="true"] .topic-list:empty { min-height: 260px; background: repeating-linear-gradient(transparent 0 20px, var(--backdrop) 20px 40px, transparent 40px 52px); }
.status.error { color: #a5254c; background: #fcf2f5; border-left: 2px solid var(--danger); padding: 12px 16px; margin: 16px 0; }
.control-panel .status.error, .status-toast.error { margin: 0; }
.summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) max-content; gap: 1px; overflow: hidden; background: var(--line); }
.summary[hidden] { display: none; }
.summary > div { padding: 12px var(--space-card); background: var(--white); }
.summary > div:last-child { text-align: right; }
.summary-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 14px; }
.summary strong { font-size: 1rem; }
#summary > div:first-child .summary-label { white-space: nowrap; }
@media (min-width: 781px) {
  #summary { grid-template-columns: minmax(max-content, 1fr) minmax(0, 2fr) max-content; }
}
@media (max-width: 1100px) {
  .summary-period-note { display: none; }
}
#date-range { white-space: normal; }
#total { color: var(--ink); }

.report-context { margin: 0 0 var(--space-section); padding: 16px var(--space-card); border-left: 3px solid var(--blue); border-radius: 5px; background: var(--blue-soft); overflow-wrap: anywhere; }
.report-context h2 { font-size: 20px; }
.report-context > :last-child { margin-bottom: 0; }
.report-context .muted { margin-bottom: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: var(--space-section); margin-bottom: var(--space-section); }
.card { min-width: 0; padding: var(--space-card); border: 1px solid var(--line); border-radius: 5px; background: var(--white); }
.access-page { max-width: 640px; margin-top: clamp(32px, 8vh, 80px); }
.access-card { padding: clamp(24px, 5vw, 48px); }
.access-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 24px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); }
.access-label { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.access-reason { margin-bottom: 28px; color: var(--muted); overflow-wrap: anywhere; }
.access-help { padding-top: 24px; border-top: 1px solid var(--line); }
.access-help h2 { margin-bottom: 8px; font-size: 18px; }
.access-help p { margin-bottom: 24px; }
.access-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 24px; }
.access-actions form { min-width: 0; max-width: 100%; }
.access-actions > a { text-decoration: none; }
.access-actions > a:not(.refresh):hover { text-decoration: underline; }
.access-actions .refresh { max-width: 100%; white-space: normal; text-align: center; text-decoration: none; }
.access-footer { margin: 20px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.card-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.books-card .card-heading .muted { margin-top: 4px; }
.book-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.list-search { width: 210px; height: var(--control-height); padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--white); }
.list-search::placeholder { color: var(--muted); }
.list-search:focus-visible, select:focus-visible { border-color: var(--blue); }
.rank-list, .topic-list { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.rank-list li, .topic-list li { counter-increment: rank; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.rank-list li { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 16px; padding-left: 8px; }
.rank-list li::before, .topic-list li::before { content: counter(rank); color: var(--muted); font-size: .8rem; }
.rank-list li > button { width: 100%; padding: 12px 0; border: 0; background: none; color: var(--blue); text-align: left; }
.book-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li > button:hover { color: var(--blue-dark); text-decoration: underline; }
.rank-list li.selected { margin: 0 -10px; padding: 0 10px 0 18px; border-radius: 5px; background: var(--blue-soft); }
.rank-list li.selected, .rank-list li.selected + li { border-top-color: transparent; }
.count { color: var(--ink); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-metrics { display: grid; grid-template-columns: minmax(3ch, 1fr) 88px 80px 60px; align-items: center; gap: 12px; }
.row-metrics .count { min-width: 3ch; text-align: right; }
.row-actions { display: flex; gap: 4px; }
.geography-link, .technical-link { display: grid; place-items: center; width: 28px; height: 32px; color: var(--blue); text-decoration: none; border-radius: 4px; scroll-margin-top: calc(var(--topics-sticky-top) + 200px); }
.geography-link:hover, .technical-link:hover { color: var(--blue); background: var(--blue-soft); }
.geography-link:focus-visible, .technical-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trend-placeholder { grid-column: 2 / 4; min-height: 30px; margin: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.trend-badge { display: flex; align-items: center; justify-content: space-between; gap: 3px; width: 88px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend-arrow { display: flex; flex-shrink: 0; }
.trend-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; transform: translateY(1px); }
.trend-badge.up { color: #137b45; background: #dcf2e3; border-color: #a9e1ba; }
.trend-badge.down { color: #b32653; background: #fbeaf0; border-color: #efbdcc; }
.trend-badge.flat { color: var(--muted); background: var(--backdrop); }
button.trend-badge:hover { filter: brightness(.96); }
button.trend-badge:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trend-dialog-data .trend-badge { margin-left: auto; }
.sparkline { width: 80px; height: 30px; flex: 0 0 80px; border-radius: 4px; background: var(--blue-soft); }
.sparkline polyline { fill: none; stroke: var(--blue); stroke-width: 1.5; stroke-linejoin: round; }
.sparkline-button { display: block; width: 80px; height: 30px; padding: 0; border: 0; border-radius: 4px; background: none; }
.sparkline-button:hover .sparkline { background: #d8e8fc; box-shadow: 0 0 0 1px var(--blue); }
.sparkline-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.rank-list li > button { grid-column: 2; }
.rank-list .row-metrics { grid-column: 3; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .9rem; }
.pagination[hidden] { display: none; }
.pagination-actions { display: flex; gap: 8px; }
.pagination button { min-height: var(--control-height); padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--blue); }
.pagination button:hover:not(:disabled) { background: var(--blue-soft); border-color: var(--blue); }
.pagination button:disabled { color: var(--muted); cursor: default; opacity: .55; }

.chart-card { position: relative; display: flex; flex-direction: column; min-width: 0; }
.daily-panel { position: relative; z-index: 2; display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0 calc(-1 * var(--space-card)) calc(-1 * var(--space-card)); padding: var(--space-card); border-top: 1px solid var(--line); border-radius: inherit; background: var(--white); box-shadow: 0 -3px 10px rgb(0 0 0 / 6%); }
.chart-card.daily-expanded .daily-panel { position: absolute; inset: 0; margin: 0; }
.daily-panel .hide-data, .daily-panel details[open] .show-data { display: none; }
.daily-panel details[open] .hide-data { display: inline; }
.chart-card .muted { margin: 4px 0 8px; font-size: .8rem; }
.trending-section { transition: opacity var(--interaction-duration) ease; }
.chart-card.daily-expanded .trending-section { opacity: 0; }
.trending-list { margin: 0; padding: 0; list-style: none; counter-reset: trending-rank; }
#trending-more { display: block; width: fit-content; margin: 16px 0 8px auto; padding: 4px 0; font-size: .75rem; color: var(--muted); }
#trending-more:hover { color: var(--blue-dark); }
.trending-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 24px; position: relative; padding: 8px 0 8px 24px; margin-top: 4px; font-size: .9rem; line-height: 1.25; counter-increment: trending-rank; }
.trending-list li::before { content: counter(trending-rank) "."; position: absolute; left: 0; top: 9px; color: var(--muted); font-size: .8rem; }
.trending-list .topic-title { overflow-wrap: anywhere; }
.trending-increase { color: var(--blue); font-weight: 600; font-variant-numeric: tabular-nums; }
.trending-comparison { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.chart-card .chart { flex: none; height: 80px; min-height: 80px; margin-top: auto; }
.daily-bar { fill: #cfe2ff; }
.chart-card .data-disclosure { margin-top: 8px; padding-top: 8px; }
.chart-card .data-disclosure .table-wrap { bottom: calc(1.5em + 17px); }
#chart-filter { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-content { position: relative; display: flex; flex-direction: column; flex: 1; }
.chart { position: relative; flex: 1; min-height: 270px; }
.chart svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .area { fill: none; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .point { fill: var(--white); stroke: var(--blue); stroke-width: 2; }
.data-disclosure { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.data-disclosure summary { color: var(--blue); font-weight: 400; }
.data-disclosure .table-wrap { position: absolute; inset: 0 0 calc(1.5em + 25px); z-index: 1; overflow: auto; background: var(--white); }
.data-disclosure thead { position: sticky; top: 0; background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.daily-panel tbody tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { text-align: right; }
.trend-dialog-data th:nth-child(2), .trend-dialog-data td:nth-child(2) { text-align: right; }
.sortable-table th button { border: 0; padding: 5px 0; background: none; color: var(--blue); font-weight: 600; text-align: inherit; }
.sortable-table th button:hover { color: var(--blue-dark); text-decoration: underline; }
.sortable-table th[aria-sort="ascending"] button::after { content: ' ↑'; }
.sortable-table th[aria-sort="descending"] button::after { content: ' ↓'; }
.sortable-table tbody tr:hover { background: var(--blue-soft); }

.trend-dialog { width: min(860px, calc(100% - 32px)); max-height: min(760px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white); box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
.trend-dialog::backdrop { background: rgb(20 28 40 / 58%); }
.trend-dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.trend-dialog-header > :first-child { min-width: 0; overflow-wrap: anywhere; }
.trend-dialog-header .muted { margin-bottom: 0; }
.dialog-close { flex: 0 0 auto; width: var(--control-height); height: var(--control-height); padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--white); font-size: 27px; line-height: 1; }
.dialog-close:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.dialog-close:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trend-dialog-summary { margin: 20px 0 4px; }
.trend-dialog-content { position: relative; --dialog-view-height: 360px; }
.trend-dialog-chart { height: var(--dialog-view-height); min-height: var(--dialog-view-height); }
.trend-dialog-content:has(.trend-dialog-data[open]) .trend-dialog-chart { visibility: hidden; }
.trend-dialog-data { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.trend-dialog-data summary { color: var(--blue); }
.trend-dialog-data summary:focus-visible, .trend-dialog-data .table-wrap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trend-dialog-data .show-chart, .trend-dialog-data[open] .show-data { display: none; }
.trend-dialog-data[open] .show-chart { display: inline; }
.trend-dialog-data .table-wrap { position: absolute; inset: 0 0 auto; height: var(--dialog-view-height); overflow: auto; background: var(--white); }
.trend-dialog-data thead { position: sticky; top: 0; background: var(--white); }

.topics-card { padding-top: 0; }
.topics-heading { position: sticky; top: var(--topics-sticky-top); z-index: 8; align-items: center; flex-wrap: wrap; margin-bottom: 0; padding-top: var(--space-card); padding-bottom: 12px; border-bottom: 1px solid var(--line); background: var(--white); }
.topics-heading.is-stuck { box-shadow: 0 3px 5px -5px rgb(0 0 0 / 35%); }
.topics-heading .muted { margin: 0; }
.topics-heading > div:first-child { flex: 1 1 260px; min-width: 0; max-width: 100%; }
.limit-control { position: relative; flex: 0 0 auto; font-size: .85rem; }
#limit-filter { width: 84px; min-width: 0; color: transparent; }
#limit-filter option { color: var(--ink); }
#limit-value { position: absolute; inset: 0 auto 0 12px; display: flex; align-items: center; color: var(--ink); pointer-events: none; }
.topic-actions { display: flex; margin-left: auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.compact { flex: 0 0 auto; }
.compact button { min-width: 48px; padding-inline: 11px; }
#topic-sort { margin-left: 0; }
#topic-sort button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; font-weight: 700; }
.sort-info { display: inline-flex; cursor: help; }
.topic-increase { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.topic-list li { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 16px; padding: 12px 0 12px 8px; }
.topic-list li:first-child { border-top: 0; }
.topic-list .row-metrics { width: 24rem; max-width: 100%; }
/* Reserve the growth detail line in both sort modes. */
.topic-list .count { min-height: calc(1lh + .78rem * 1.5); align-content: center; }
.topic-main { min-width: 0; }
.topic-title { display: block; color: var(--blue); font-weight: 700; text-decoration: none; }
.topic-title:hover { text-decoration: underline; }
.topic-book { display: block; color: var(--muted); font-size: .84rem; }
.topic-title, .topic-book, #topics-title, #topics-filter { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px 0; color: var(--muted); text-align: center; }
footer { padding: 24px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .82rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .trending-section { display: none; }
  .daily-panel { margin-top: calc(-1 * var(--space-card)); }
}

@media (max-width: 640px) {
  .rank-list li > button { grid-column: 2 / -1; padding-bottom: 0; }
  .rank-list .row-metrics { grid-column: 2 / -1; padding-bottom: 12px; }
}

@media (max-width: 780px) {
  :root { --space-section: 16px; --space-card: 16px; }
  .brand { gap: 8px; font-size: 18px; }
  .header-title { font-size: 18px; }
  .header-greeting { padding-left: 16px; font-size: 14px; line-height: 1.3; }
  .brand-mark { width: 30px; height: 30px; }
  main { width: min(100% - 32px, 1180px); margin-top: 24px; }
  h1 { font-size: 28px; }
  .title-row { flex-wrap: wrap; align-items: flex-start; gap: 16px; }
  .title-tools { width: 100%; margin-left: 0; justify-content: flex-start; }
  .view-links { justify-content: flex-start; }
  .filters { align-items: stretch; flex-direction: column; gap: 8px; padding-inline: var(--space-card); }
  .filters.is-stuck { padding-inline: 16px; }
  .filters > label { align-self: auto; }
  .filter-options { margin-left: 0; }
  select { width: 100%; min-width: 0; }
  #institution { flex: none; max-width: none; }
  #device { flex: 1; min-width: 0; }
  #period-filter { flex: 0 0 auto; width: auto; }
  #period-select { width: 140px; min-width: 0; }
  .segmented { width: 100%; margin-left: 0; }
  .segmented button { flex: 1; }
  .summary { grid-template-columns: 1fr; }
  .summary > div:last-child { text-align: left; }
  .topics-heading { align-items: stretch; flex-direction: column; }
  .topics-heading > div:first-child { flex: none; }
  .topic-actions { width: 100%; gap: 8px; }
  .topic-actions .compact { width: auto; }
  .topic-actions #topic-sort { flex: 1; min-width: 0; flex-wrap: nowrap; }
  #topic-sort button { min-width: 0; padding-inline: 8px; gap: 6px; font-size: .875rem; }
  #topic-sort [data-topic-sort="growth"] { flex-grow: 1.7; }
  #topic-sort .sort-info { display: none; }
  .topic-actions .list-search { width: 100%; margin-left: auto; }
  .compact { width: auto; align-self: start; }
  .rank-list li, .topic-list li { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; padding-left: 0; }
  .rank-list li.selected { padding-left: 10px; }
  .topic-main { grid-column: 2 / -1; }
  .topic-list .row-metrics { grid-column: 2 / -1; }
  .topic-list .count { min-height: 0; }
  .topic-increase { display: none; }
  #topics-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 600px) {
  .title-tools .refresh { padding-inline: 8px; }
  .title-tools #refresh { width: var(--control-height); flex-shrink: 0; padding-inline: 0; }
  .title-tools .refresh-label { display: none; }
}

@media (max-width: 460px) {
  .site-header { padding-inline: 16px; }
  .header-title { display: none; }
  .title-row { display: block; }
  .title-tools { margin-top: 16px; }
  .card { padding: var(--space-card); }
  .access-card { padding: 24px; }
  .topics-card { padding-top: 0; }
  .topics-heading { padding-top: var(--space-card); }
  .books-card .card-heading { align-items: stretch; flex-direction: column; }
  .book-actions { justify-content: space-between; }
  .book-actions .list-search { min-width: 0; width: 100%; }
  .topic-actions { flex-wrap: wrap; }
  #topic-sort button { padding-inline: 6px; font-size: clamp(.75rem, 3.5vw, .875rem); }
  #limit-filter { width: 60px; }
  .filter-options select { padding-inline: 10px 28px; background-position: right 8px center; font-size: .875rem; }
  #period-select { width: 7em; }
  .topic-actions .list-search { width: 100%; }
  .row-metrics { grid-template-columns: minmax(max-content, 1fr) 72px minmax(24px, 80px) 60px; gap: 6px; }
  .row-metrics .count { font-size: .875rem; }
  .row-metrics .trend-badge { width: 72px; padding-inline: 5px; }
  .row-metrics .sparkline-button, .row-metrics .sparkline { width: 100%; }
  .rank-list .row-metrics, .topic-list .row-metrics { grid-column: 1 / -1; }
  .filters, .status { padding-inline: 16px; }
  .summary > div { padding: 12px var(--space-card); }
  .chart { min-height: 230px; overflow: hidden; }
  .trend-dialog { padding: var(--space-card); }
  .trend-dialog-content { --dialog-view-height: 280px; }
}

@media (max-width: 380px) {
  .title-tools .report-label { display: none; }
  .title-tools .view-links .refresh { width: var(--control-height); padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --interaction-duration: 0ms; }
  * { scroll-behavior: auto !important; }
}
