/* ============================================================
   Fanqie Rank Tracker - Tomato Signal Dashboard
   Based on Open Design "dashboard": compact cards, cool surfaces,
   status-first information design. Adapted with Fanqie tomato red
   and readable Chinese data typography.
   ============================================================ */

:root {
    --bg: #f3f6fb;
    --bg-strong: #e8eef7;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-tint: #fff4f0;
    --surface-cool: #eef6ff;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-solid: #ffffff;
    --border: #dbe4ef;
    --border-soft: #edf2f7;
    --border-strong: #c8d4e3;

    --text-primary: #172033;
    --text-secondary: #475569;
    --text-muted: #7b8798;
    --text-faint: #a8b3c3;

    --accent: #f04f38;
    --accent-strong: #d83b27;
    --accent-soft: rgba(240, 79, 56, 0.1);
    --accent-wash: #fff0eb;
    --accent-on: #ffffff;

    --info: #0ea5e9;
    --info-soft: rgba(14, 165, 233, 0.1);
    --green: #10b981;
    --green-soft: rgba(16, 185, 129, 0.12);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.1);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.13);
    --purple: #7c3aed;

    --shadow-card: 0 18px 46px rgba(25, 39, 64, 0.1);
    --shadow-hover: 0 22px 54px rgba(25, 39, 64, 0.16);
    --ring: 0 0 0 4px rgba(240, 79, 56, 0.14);

    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 7px;
    --radius-pill: 999px;

    --sidebar-w: 282px;
    --font-display: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-body: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
}

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

html {
    color-scheme: light;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(240, 79, 56, 0.12), transparent 360px),
        radial-gradient(circle at 85% 0, rgba(14, 165, 233, 0.12), transparent 320px),
        linear-gradient(180deg, var(--bg) 0%, #eef3f9 100%);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(23, 32, 51, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 32, 51, 0.035) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 70%);
    z-index: -1;
}

button,
select,
input {
    font: inherit;
}

button,
a,
select {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

::selection {
    background: rgba(240, 79, 56, 0.2);
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd6e4;
    border: 3px solid transparent;
    border-radius: var(--radius-pill);
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #aebbd0;
    border: 3px solid transparent;
    background-clip: content-box;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 100vh;
    padding: 24px 14px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.78);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
}

.sidebar-header {
    margin-bottom: 22px;
    padding: 14px 12px 18px;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-header h1 {
    position: relative;
    padding-left: 18px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 760;
    line-height: 1.2;
}

.sidebar-header h1::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.18em;
    width: 8px;
    height: 1.05em;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, var(--accent), var(--info));
}

.sidebar-subtitle {
    margin-top: 7px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 650;
}

.update-date {
    display: inline-flex;
    margin-top: 10px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 650;
}

.category-nav ul {
    list-style: none;
}

.category-nav li {
    min-height: 38px;
    margin-bottom: 4px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 620;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.category-nav li:hover {
    background: var(--surface-soft);
    border-color: var(--border);
    color: var(--text-primary);
    transform: translateX(2px);
}

.category-nav li.active {
    background: var(--accent-wash);
    border-color: rgba(240, 79, 56, 0.22);
    color: var(--accent-strong);
}

.cat-badge {
    min-width: 28px;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 760;
    text-align: center;
}

.cat-badge.new {
    background: var(--green-soft);
    color: #087f5b;
}

/* ===== Main Layout ===== */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 28px 34px 48px;
}

.main-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.header-left {
    flex-shrink: 0;
    min-width: 0;
}

.main-header h2 {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(1.65rem, 2.4vw, 2.35rem);
    font-weight: 780;
    line-height: 1.08;
    letter-spacing: 0;
}

.main-header h2::after {
    content: "排名追踪 / 趋势信号";
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 650;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.github-link-btn,
.trend-link-btn,
.preset-btn,
.date-picker-btn,
.date-nav-btn,
.mobile-menu-btn,
.range-btn,
.category-chip,
.back-link,
.source-link-btn,
.hot-type-row,
.book-copy-btn {
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.github-link-btn {
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
}

.github-link-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex: 0 0 auto;
}

.github-link-btn:hover {
    border-color: var(--text-primary);
    background: var(--text-primary);
    color: #ffffff;
    transform: translateY(-1px);
}

.trend-link-btn {
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid rgba(240, 79, 56, 0.24);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--accent-on);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 10px 20px rgba(240, 79, 56, 0.18);
}

.trend-link-btn:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.date-presets,
.trend-range {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
}

.preset-btn,
.range-btn {
    height: 28px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 720;
    white-space: nowrap;
}

.preset-btn:hover,
.range-btn:hover {
    background: var(--surface-soft);
    color: var(--text-primary);
}

.preset-btn.active,
.range-btn.active {
    background: var(--text-primary);
    color: #ffffff;
}

.date-picker-wrap {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.date-picker-btn {
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 650;
    white-space: nowrap;
}

.date-picker-btn:hover {
    border-color: rgba(240, 79, 56, 0.28);
    color: var(--accent-strong);
}

.date-picker-btn .date-icon {
    color: var(--accent);
    font-size: 0.76rem;
}

.date-nav-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
}

.date-nav-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-strong);
    transform: translateY(-1px);
}

.date-nav-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.date-picker-btn.is-historical {
    background: var(--accent-wash);
    border-color: rgba(240, 79, 56, 0.28);
    color: var(--accent-strong);
}

.date-input-hidden {
    position: absolute;
    top: 100%;
    right: 0;
    width: 0;
    height: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
}

.mobile-menu-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Trend Panel ===== */
.trend-panel {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 20px;
}

.trend-ai {
    position: relative;
    min-height: 160px;
    padding: 22px 24px 24px;
    border: 1px solid rgba(240, 79, 56, 0.18);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, rgba(255, 244, 240, 0.9), rgba(255, 255, 255, 0.96)),
        var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.trend-ai::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, var(--accent), var(--amber), var(--info));
}

.ai-label,
.panel-kicker,
.back-link {
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 760;
    letter-spacing: 0;
    text-transform: uppercase;
}

.ai-label {
    margin-bottom: 12px;
}

.ai-content {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.85;
    white-space: pre-wrap;
    user-select: text;
}

.ai-content strong,
.summary-item strong {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 760;
}

.ai-content em {
    color: #087f5b;
    font-style: normal;
    font-weight: 720;
}

.ai-content .cursor {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 2px;
    background: var(--accent);
    vertical-align: text-bottom;
    animation: blink 0.8s steps(1) infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.ai-loading,
.muted-line {
    color: var(--text-muted);
    font-size: 0.86rem;
}

/* ===== Book Grid ===== */
.books-waterfall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
    gap: 16px;
    align-items: start;
}

.book-card {
    position: relative;
    display: grid;
    grid-template-columns: 98px minmax(0, 1fr);
    min-height: 188px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-card);
    user-select: text;
    -webkit-user-select: text;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.book-card:hover {
    border-color: rgba(240, 79, 56, 0.3);
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.book-cover {
    min-height: 188px;
    background:
        linear-gradient(135deg, rgba(240, 79, 56, 0.18), rgba(14, 165, 233, 0.12)),
        var(--surface-cool);
    overflow: hidden;
    position: relative;
}

.book-cover img {
    width: 100%;
    height: 100%;
    min-height: 188px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.book-card:hover .book-cover img {
    transform: scale(1.04);
}

.no-cover {
    height: 100%;
    min-height: 188px;
    padding: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    text-align: center;
}

.book-info {
    min-width: 0;
    padding: 14px 14px 13px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-title {
    color: var(--text-primary);
    display: -webkit-box;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 760;
    letter-spacing: 0;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.book-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.book-author {
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-reads {
    flex-shrink: 0;
    padding: 3px 7px;
    border: 1px solid rgba(240, 79, 56, 0.18);
    border-radius: var(--radius-pill);
    background: var(--accent-wash);
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
}

.book-intro {
    color: var(--text-muted);
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.78rem;
    line-height: 1.65;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.book-rank {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 10;
    min-width: 32px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: var(--radius-md);
    background: rgba(23, 32, 51, 0.78);
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 800;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.rank-1 {
    background: linear-gradient(135deg, #ff6a3d, #f59e0b);
    border-color: transparent;
}

.rank-2 {
    background: linear-gradient(135deg, #64748b, #94a3b8);
    border-color: transparent;
}

.rank-3 {
    background: linear-gradient(135deg, #9a6b3d, #d19b61);
    border-color: transparent;
}

.book-change {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 10;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 800;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.book-change.up {
    color: #087f5b;
}

.book-change.down {
    color: #b91c1c;
}

.book-change.new {
    color: #9a5b00;
}

.book-copy-btn {
    width: max-content;
    max-width: 100%;
    margin-top: auto;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 720;
    white-space: nowrap;
}

.book-copy-btn:hover {
    border-color: rgba(240, 79, 56, 0.28);
    background: var(--accent-wash);
    color: var(--accent-strong);
    transform: translateY(-1px);
}

.book-copy-btn.copied {
    border-color: rgba(16, 185, 129, 0.24);
    background: var(--green-soft);
    color: #087f5b;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 56px 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-secondary);
    text-align: center;
}

.empty-state p {
    margin-bottom: 6px;
    font-size: 1rem;
    font-weight: 720;
}

.empty-state .empty-hint {
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
}

/* ===== Book Detail Page ===== */
.book-page {
    min-height: 100vh;
}

.book-shell {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.book-topbar {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.book-detail-page {
    display: grid;
    gap: 16px;
}

.book-loading,
.book-empty-state {
    padding: 42px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--panel-solid);
    color: var(--text-secondary);
    box-shadow: var(--shadow-card);
    text-align: center;
}

.book-empty-state p {
    margin-bottom: 14px;
    font-weight: 720;
}

.book-detail-hero {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, rgba(255, 244, 240, 0.88), rgba(255, 255, 255, 0.95)),
        var(--surface);
    box-shadow: var(--shadow-card);
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 22px;
}

.detail-cover {
    min-height: 256px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(240, 79, 56, 0.18), rgba(14, 165, 233, 0.12)),
        var(--surface-cool);
}

.detail-cover img {
    width: 100%;
    height: 100%;
    min-height: 256px;
    object-fit: cover;
    display: block;
}

.detail-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.detail-main h1 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1.12;
}

.detail-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 650;
}

.detail-stats {
    width: 100%;
    margin: 18px 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.detail-stats span {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
}

.detail-stats strong,
.detail-stats small {
    display: block;
}

.detail-stats strong {
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 800;
}

.detail-stats small {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.detail-intro {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.9;
}

.source-link-btn {
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid rgba(240, 79, 56, 0.24);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--accent-on);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 10px 20px rgba(240, 79, 56, 0.18);
}

.detail-actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.detail-actions .book-copy-btn {
    min-height: 38px;
    margin-top: 0;
}

.source-link-btn:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.book-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 16px;
}

.detail-panel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--panel-solid);
    box-shadow: var(--shadow-card);
}

.detail-panel h2 {
    margin-bottom: 14px;
    color: var(--text-primary);
    font-size: 1.18rem;
    font-weight: 760;
}

.reads-chart-wrap {
    width: 100%;
    overflow-x: auto;
}

.reads-chart-frame {
    position: relative;
    min-width: 620px;
}

.reads-chart {
    display: block;
    width: 100%;
    height: auto;
}

.chart-grid {
    stroke: rgba(219, 228, 239, 0.72);
    stroke-width: 1;
}

.chart-axis-base {
    stroke: var(--border-strong);
    stroke-width: 1;
}

.chart-axis-label,
.chart-date-label {
    fill: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 650;
}

.reads-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-hover-line {
    opacity: 0;
    stroke: var(--border-strong);
    stroke-dasharray: 4 4;
    stroke-width: 1;
}

.chart-hover-line.show {
    opacity: 1;
}

.reads-hover-point {
    opacity: 0;
    fill: var(--accent);
    stroke: #ffffff;
    stroke-width: 2.4;
}

.reads-hover-point.show {
    opacity: 1;
}

.chart-hit-area {
    fill: transparent;
    cursor: crosshair;
    pointer-events: all;
}

.reads-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 178px;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    color: var(--text-secondary);
    pointer-events: none;
}

.reads-tooltip time {
    display: block;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 650;
}

.reads-tooltip div {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

.reads-tooltip i {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-pill);
    background: var(--accent);
}

.reads-tooltip strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 800;
}

.book-history-list {
    display: flex;
    flex-direction: column;
}

.book-history-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: minmax(76px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.book-history-row:last-child {
    border-bottom: 0;
}

.book-history-row time {
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 760;
}

.book-history-row strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-history-row span {
    color: #087f5b;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 800;
}

.copy-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 9999;
    padding: 10px 18px;
    border: 1px solid rgba(16, 185, 129, 0.22);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-card);
    color: #087f5b;
    font-size: 0.8rem;
    font-weight: 720;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(16px);
    transition: all 0.22s ease;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Trend Analysis Page ===== */
.trend-page {
    background:
        radial-gradient(circle at 18% -10%, rgba(240, 79, 56, 0.14), transparent 340px),
        radial-gradient(circle at 90% 0, rgba(14, 165, 233, 0.14), transparent 360px),
        linear-gradient(180deg, #f3f6fb 0%, #eef3f9 100%);
}

.trend-shell {
    width: min(1220px, calc(100% - 48px));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.trend-topbar {
    margin-bottom: 18px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid rgba(240, 79, 56, 0.24);
    border-radius: var(--radius-md);
    background: var(--accent-wash);
    color: var(--accent-strong);
    text-decoration: none;
    font-family: var(--font-body);
    text-transform: none;
}

.back-link:hover {
    background: var(--accent);
    color: var(--accent-on);
    transform: translateY(-1px);
}

.trend-topbar h1 {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 780;
    line-height: 1.02;
}

.trend-topbar p {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.trend-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.market-board,
.trend-grid {
    display: grid;
    gap: 14px;
}

.market-board {
    grid-template-columns: minmax(320px, 1.15fr) minmax(230px, 0.9fr) minmax(220px, 0.86fr) minmax(260px, 1fr);
    margin-bottom: 14px;
}

.type-filter-panel {
    margin-bottom: 14px;
}

.trend-category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-chip {
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 720;
    line-height: 1;
    white-space: nowrap;
}

.category-chip:hover {
    border-color: rgba(240, 79, 56, 0.28);
    background: var(--accent-wash);
    color: var(--accent-strong);
    transform: translateY(-1px);
}

.category-chip.active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-on);
    box-shadow: 0 10px 20px rgba(240, 79, 56, 0.16);
}

.trend-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.market-summary-card,
.market-card,
.trend-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--panel-solid);
    box-shadow: var(--shadow-card);
}

.market-summary-card {
    padding: 22px 24px;
    background:
        linear-gradient(135deg, rgba(255, 244, 240, 0.88), rgba(255, 255, 255, 0.95)),
        var(--surface);
}

.market-summary-card h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 760;
    line-height: 1.22;
}

.market-summary-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.85;
}

.market-source {
    display: inline-flex;
    margin-top: 12px;
    padding: 5px 8px;
    border: 1px solid rgba(240, 79, 56, 0.18);
    border-radius: var(--radius-sm);
    background: var(--accent-wash);
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 760;
}

.market-card,
.trend-block {
    padding: 18px;
}

.panel-kicker {
    display: block;
    margin-bottom: 8px;
}

.hot-list,
.compact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hot-type-row {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    color: inherit;
    cursor: pointer;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    text-align: left;
}

.hot-type-row:not(.hot-type-row-static):hover {
    border-color: rgba(240, 79, 56, 0.24);
    background: var(--accent-wash);
    transform: translateY(-1px);
}

.hot-type-row-static {
    cursor: default;
}

.hot-type-row span {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--accent-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 800;
}

.hot-type-row strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hot-type-row small {
    grid-column: 2 / 3;
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hot-type-row em {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    color: #087f5b;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-style: normal;
    font-weight: 800;
}

.genre-row strong {
    color: var(--accent-strong);
}

.theme-cloud {
    display: flex;
    align-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
}

.theme-chip {
    padding: 7px 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background: var(--surface-soft);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.77rem;
    font-weight: 720;
}

.theme-chip small {
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.68rem;
}

.trend-block {
    min-height: 250px;
}

.trend-block-wide {
    grid-column: 1 / -1;
}

.trend-block h2 {
    margin-bottom: 14px;
    color: var(--text-primary);
    font-size: 1.18rem;
    font-weight: 760;
    line-height: 1.25;
}

.compact-row {
    padding: 9px 0;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.compact-row-link {
    color: inherit;
    text-decoration: none;
}

.compact-row-link:hover strong {
    color: var(--accent-strong);
}

.compact-row:last-child {
    border-bottom: 0;
}

.compact-row strong {
    color: var(--text-primary);
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.88rem;
    font-weight: 720;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.compact-row small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.compact-row span {
    flex-shrink: 0;
    padding: 4px 7px;
    border-radius: var(--radius-sm);
    background: var(--green-soft);
    color: #087f5b;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 800;
}

.summary-feed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.summary-item {
    padding: 14px 15px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}

.summary-item time {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-strong);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 760;
}

.summary-item div {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.75;
}

.book-mark {
    color: var(--accent-strong);
    font-weight: 760;
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
    .trend-panel,
    .market-board {
        grid-template-columns: 1fr;
    }

    .trend-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1000;
        width: min(86vw, 300px);
        box-shadow: 18px 0 48px rgba(25, 39, 64, 0.24);
        transform: translateX(-100%);
    }

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

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 999;
        display: none;
        background: rgba(23, 32, 51, 0.34);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        padding: 18px 14px 36px;
    }

    .main-header {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr);
        align-items: flex-start;
        column-gap: 10px;
        row-gap: 12px;
    }

    .trend-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .mobile-menu-btn {
        grid-column: 1;
        grid-row: 1;
        margin-top: 2px;
    }

    .header-left {
        grid-column: 2;
        grid-row: 1;
    }

    .header-right {
        grid-column: 1 / -1;
    }

    .header-right,
    .trend-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .books-waterfall,
    .book-detail-grid,
    .trend-grid {
        grid-template-columns: 1fr;
    }

    .trend-shell {
        width: min(100% - 28px, 1220px);
        padding-top: 18px;
    }

    .book-shell {
        width: min(100% - 28px, 1120px);
        padding-top: 18px;
    }

}

@media (max-width: 560px) {
    body::before {
        background-size: 28px 28px;
    }

    .main-header h2 {
        font-size: 1.46rem;
    }

    .header-right {
        gap: 8px;
    }

    .github-link-btn,
    .trend-link-btn,
    .date-picker-btn {
        min-height: 34px;
    }

    .date-presets,
    .date-picker-wrap,
    .trend-range {
        width: 100%;
        min-width: 0;
    }

    .date-presets .preset-btn,
    .trend-range .range-btn {
        flex: 1;
        min-width: 0;
        padding-inline: 6px;
    }

    .date-picker-btn {
        flex: 1;
        justify-content: center;
    }

    .trend-range {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .trend-shell {
        width: 100%;
        padding-inline: 14px;
    }

    .book-shell {
        width: 100%;
        padding-inline: 14px;
    }

    .book-detail-hero {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .detail-cover {
        width: min(180px, 100%);
        min-height: 252px;
    }

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

    .reads-chart-frame {
        min-width: 560px;
    }

    .book-history-row {
        grid-template-columns: 1fr auto;
    }

    .book-history-row time {
        grid-column: 1 / -1;
    }

    .trend-topbar,
    .market-board,
    .trend-grid {
        width: 100%;
        max-width: 100%;
    }

    .market-summary-card,
    .market-card,
    .trend-block {
        min-width: 0;
    }

    .book-card {
        grid-template-columns: 84px minmax(0, 1fr);
        min-height: 170px;
    }

    .book-cover,
    .book-cover img,
    .no-cover {
        min-height: 170px;
    }

    .book-info {
        padding: 12px;
    }

    .book-intro {
        -webkit-line-clamp: 2;
    }

    .trend-ai,
    .trend-topbar,
    .market-summary-card,
    .market-card,
    .trend-block {
        border-radius: var(--radius-lg);
    }
}
