:root {
    color-scheme: light;
    --bg: #f6f3ef;
    --surface: #ffffff;
    --surface-2: #f1f4f6;
    --surface-raised: rgba(255, 255, 255, 0.88);
    --surface-reader: #fbfaf7;
    --text: #17212f;
    --text-strong: #0f1724;
    --text-secondary: #566376;
    --muted: #8490a1;
    --line: #dce3ea;
    --line-light: #e9edf2;
    --blue: #d7ecf7;
    --blue-strong: #2f87b4;
    --blue-deep: #1f6f96;
    --red: #ffd4dc;
    --red-strong: #c64b63;
    --green: #d8efdf;
    --green-strong: #34865a;
    --amber: #fff1c7;
    --amber-strong: #b97913;
    --plum: #eadff6;
    --plum-strong: #7357a3;
    --status-unknown-color: #b9dff0;
    --status-known-color: #f8f6f1;
    --status-new-color: #ffaebd;
    --reader-font-size: 22px;
    --reader-line-height: 2;
    --reader-pane-x: 56px;
    --reader-side-blank: 24px;
    --reader-toc-width: 280px;
    --shadow-sm: 0 1px 2px rgba(25, 32, 43, 0.06), 0 1px 3px rgba(25, 32, 43, 0.04);
    --shadow: 0 8px 24px rgba(25, 32, 43, 0.08), 0 2px 8px rgba(25, 32, 43, 0.04);
    --shadow-lg: 0 22px 58px rgba(25, 32, 43, 0.14), 0 6px 18px rgba(25, 32, 43, 0.06);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 8px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, #fbfaf7 0, var(--bg) 360px),
        var(--bg);
    color: var(--text);
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

:focus-visible {
    outline: 2px solid var(--blue-strong);
    outline-offset: 2px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    padding: 0 28px;
    background: rgba(251, 250, 247, 0.82);
    border-bottom: 1px solid rgba(220, 227, 234, 0.72);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.68), 0 10px 28px rgba(25, 32, 43, 0.05);
    backdrop-filter: blur(20px) saturate(1.22);
}

.topbar-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar .topbar-center {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.topbar .nav {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.brand {
    flex: 0 0 auto;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
    color: var(--text);
    transition: opacity 0.2s;
}

.brand:hover {
    opacity: 0.7;
}

.nav {
    display: flex;
    gap: 6px;
}

.nav a,
.button,
.sort-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid rgba(210, 219, 229, 0.9);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,249,250,0.94));
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.nav a:hover,
.button:hover,
.sort-link:hover {
    border-color: var(--line);
    background: #fff;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.nav a.active,
.sort-link.active,
.button.primary,
.button.active {
    border-color: var(--blue-strong);
    background: linear-gradient(180deg, #dff3fb, var(--blue));
    color: var(--blue-deep);
    font-weight: 600;
    box-shadow: 0 8px 22px rgba(47, 135, 180, 0.14);
}

.nav a.active:hover,
.sort-link.active:hover,
.button.primary:hover,
.button.active:hover {
    background: var(--blue-strong);
    color: #fff;
}

.button.danger {
    border-color: #f0c4ce;
    background: #fff0f3;
    color: #b0283c;
    font-weight: 500;
}

.button.danger:hover {
    background: #fce0e5;
    border-color: var(--red-strong);
}

.flash-wrap {
    max-width: 1120px;
    margin: 12px auto 0;
    padding: 0 24px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line-light);
    cursor: pointer;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.2s, max-height 0.2s;
}

.flash.error {
    border-color: #f5c6d0;
    background: #fff5f7;
    color: #b0283c;
}

.flash.success {
    border-color: #b8e0c4;
    background: #f2fdf5;
    color: #2d7a44;
}

.page-shell {
    width: min(1120px, calc(100vw - 32px));
    margin: 28px auto 56px;
}

.page-shell.bookshelf-cards {
    width: min(1360px, calc(100vw - 48px));
    margin: 24px auto 48px;
}

.page-shell.bookshelf-table {
    width: 100%;
    margin: 28px 0 56px;
}

.page-shell.terms-shell {
    width: 100%;
    margin: 28px 0 56px;
    padding: 0 16px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-heading p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.import-form,
.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.import-form input,
.search-form input,
.search-form select {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.import-form input:focus,
.search-form input:focus,
.search-form select:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
}

.sortbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.book-list {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
}

.book-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    border: 1px solid rgba(215, 222, 231, 0.9);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(249,247,243,0.92)),
        var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s, transform 0.3s, border-color 0.3s;
    position: relative;
    overflow: visible;
}

.book-row::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 5px;
    background: linear-gradient(180deg, var(--blue-strong) 0%, #5bb8e8 50%, var(--blue-strong) 100%);
    border-radius: 0 4px 4px 0;
    transition: width 0.3s, opacity 0.3s;
    opacity: 0.35;
    z-index: 0;
}

.book-row::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: radial-gradient(500px circle at 80% 10%, rgba(56,152,201,0.06), transparent 70%);
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.3s;
}

.book-row:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: #ccd7e1;
}

.book-row:hover::before {
    width: 6px;
    opacity: 1;
}

.book-select {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.book-select input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--blue-strong);
    cursor: pointer;
}

.book-row > .action-dropdown {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 10;
}

.book-row > .action-dropdown .nav-dropdown-trigger {
    min-height: 30px;
    padding: 0 6px;
    font-size: 16px;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.book-row > .action-dropdown .nav-dropdown-trigger:hover {
    color: var(--text);
    background: var(--surface-2);
}

.book-row > .action-dropdown .nav-dropdown-trigger::after {
    display: none;
}

.book-row > .action-dropdown .floating-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 160px;
    max-width: 90vw;
    z-index: 1000;
}

.book-cover {
    display: grid;
    place-items: center;
    width: 110px;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 4px 8px 8px 4px;
    background: linear-gradient(160deg, #eef1f6 0%, #e2e7ef 100%);
    border: none;
    font-weight: 800;
    font-size: 22px;
    color: var(--blue-strong);
    box-shadow:
        -2px 0 6px rgba(0,0,0,0.06),
        3px 3px 8px rgba(0,0,0,0.08),
        0 0 0 1px rgba(0,0,0,0.04);
    transition: box-shadow 0.3s, transform 0.3s;
    position: relative;
    z-index: 1;
}

.book-cover::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(0,0,0,0.06);
    border-radius: 1px;
    z-index: 2;
    pointer-events: none;
}

.book-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 4px 8px 8px 4px;
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 0%, transparent 8%, transparent 92%, rgba(255,255,255,0.15) 100%);
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 3;
}

.book-cover:hover {
    box-shadow:
        -2px 0 8px rgba(0,0,0,0.08),
        6px 6px 16px rgba(0,0,0,0.12),
        0 0 0 1px rgba(56,152,201,0.2);
    transform: translateY(-3px) scale(1.03);
}

.book-cover img,
.reader-book img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover img {
    position: relative;
    z-index: 1;
}

.book-cover span {
    text-align: center;
    padding: 8px;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.book-info {
    min-width: 0;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-title-row {
    display: block;
}

.book-title-row h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.2px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    color: #1a2433;
}

.book-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--line-light);
}

.book-footer form {
    margin: 0;
}

.book-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.book-tag-row.compact {
    margin-top: 2px;
}

.book-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.2px;
    line-height: 1.5;
    border: 1px solid transparent;
    background: #f0f3f8;
    color: var(--text-secondary);
}

.book-tag.difficulty-easy {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.book-tag.difficulty-medium {
    background: #fffbeb;
    color: #92400e;
    border-color: #fcd34d;
}

.book-tag.difficulty-hard {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.book-tag.difficulty-unknown {
    background: #f0f3f8;
    color: var(--muted);
    border-color: #e2e8f2;
}

.book-tag.comprehension-tag {
    font-weight: 700;
}

.book-tag.comprehension-ready {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.book-tag.comprehension-warmup {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde047;
}

.book-tag.comprehension-challenge {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.book-tag.comprehension-unknown {
    background: #f1f5f9;
    color: #64748b;
    border-color: #cbd5e1;
}

.tag-category-btn {
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    padding: 2px 8px;
    min-width: 24px;
    justify-content: center;
    background: #e8edf5;
}

.tag-category-btn:hover {
    border-color: var(--blue-strong);
    transform: scale(1.05);
    background: var(--blue);
}

.book-tag-chip {
    font-weight: 500;
    padding: 2px 8px;
}

.tag-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
}

.tag-editor-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    width: min(520px, 94vw);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tag-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tag-editor-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.tag-editor-close {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 18px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.tag-editor-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.tag-editor-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-editor-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.tag-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
    font-family: inherit;
    min-height: 32px;
}

.tag-option:hover {
    border-color: var(--blue-strong);
    background: #eef3f9;
    color: var(--blue-deep);
}

.tag-option.active {
    background: linear-gradient(135deg, var(--blue-strong) 0%, #2b8ec9 100%);
    color: #fff;
    border-color: transparent;
}

.tag-option-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-option-del {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    color: var(--muted);
    transition: all 0.15s;
}

.tag-option-del:hover {
    background: var(--red);
    color: var(--red-strong);
}

.tag-option.active .tag-option-del:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

.tag-editor-custom {
    display: flex;
    gap: 6px;
}

.tag-editor-custom input {
    flex: 1;
    min-height: 34px;
    padding: 4px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.2s;
}

.tag-editor-custom input:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56,152,201,0.12);
    outline: none;
}

.tag-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line-light);
}

.book-meta,
.book-description {
    color: var(--muted);
}

.book-meta {
    display: flex;
    gap: 10px;
    margin: 6px 0 0;
    font-size: 12px;
    color: #8899b0;
}

.book-font-warning {
    margin: 6px 0 0;
    color: #9f4f00;
    font-size: 12px;
    line-height: 1.45;
    padding: 6px 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
}

.book-font-warning.compact {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    padding: 2px 6px;
}

.book-description {
    display: -webkit-box;
    margin: 12px 0 0;
    overflow: hidden;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.book-stat-stack {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.book-stat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: #f7f8f8;
    border: 1px solid var(--line-light);
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.2s;
}

.book-stat-row:hover {
    background: #fff;
    border-color: #cbd8e4;
    box-shadow: 0 6px 18px rgba(47, 135, 180, 0.08);
    transform: translateX(2px);
}

.book-stat-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.book-stat-line strong {
    color: var(--blue-deep);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e8f1fb;
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.book-stat-line span {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.book-stat-line b {
    color: var(--text);
    font-weight: 700;
}

.book-stat-row .status-progress {
    flex: 1 1 60px;
    min-width: 40px;
    max-width: 200px;
}

.status-progress {
    display: flex;
    width: 100%;
    height: 8px;
    overflow: hidden;
    border: none;
    border-radius: 4px;
    background: #e8edf4;
}

.progress-segment {
    display: block;
    min-width: 0;
    height: 100%;
    transition: width 0.5s ease;
}

.book-table-wrap {
    overflow: visible;
    border: 1px solid #e8ecf3;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.book-table-scroll {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.book-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.book-data-table thead th {
    padding: 12px 14px;
    border-bottom: 1px solid #e8ecf3;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    white-space: nowrap;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 2;
    overflow: visible;
}

.book-data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f3f6;
    vertical-align: middle;
    transition: background 0.15s;
}

.book-data-table tbody tr:hover td {
    background: #f6f9fc;
}

.book-data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-cover-cell {
    width: 48px;
}

.table-cover {
    display: grid;
    place-items: center;
    width: 48px;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 3px 5px 5px 3px;
    background: linear-gradient(160deg, #eef1f6 0%, #e2e7ef 100%);
    border: none;
    font-weight: 800;
    color: var(--blue-strong);
    font-size: 12px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.06);
}

.table-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-data-table col.col-check { width: 40px; }
.book-data-table col.col-num { width: 56px; }
.book-data-table col.col-progress { width: 68px; }
.book-data-table col.col-date { width: 76px; }
.book-data-table col.col-action { width: 60px; }

.table-title-cell {
    overflow: visible;
    white-space: normal;
}

.table-book-title {
    white-space: normal;
    text-align: left;
}

.table-meta-cell {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.table-progress-cell {
    min-width: 80px;
    width: 100px;
    vertical-align: middle;
}

.table-progress-cell .status-progress {
    height: 8px;
}

.table-cover-cell,
.table-title-cell {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
}

.book-data-table tbody tr:hover .table-cover-cell,
.book-data-table tbody tr:hover .table-title-cell {
    background: #f6f9fc;
}

.book-data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.book-data-table th.sortable:hover {
    color: var(--accent);
}

.book-data-table th .sort-icon {
    display: inline-block;
    font-size: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.book-data-table th .sort-arrow {
    opacity: 0.3;
}

.book-data-table th .sort-arrow.active {
    opacity: 1;
}

.book-data-table th.sortable:hover .sort-arrow {
    opacity: 0.5;
}

.book-data-table th.sortable:hover .sort-arrow.active {
    opacity: 1;
}

.book-data-table th .resize-handle,
.book-table-wrap th .resize-handle,
.table-wrap th .resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    z-index: 10;
    background: transparent;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
    pointer-events: auto;
}

.book-data-table th .resize-handle:hover,
.book-data-table th .resize-handle.active,
.book-table-wrap th .resize-handle:hover,
.book-table-wrap th .resize-handle.active,
.table-wrap th .resize-handle:hover,
.table-wrap th .resize-handle.active {
    background: rgba(47, 135, 180, 0.15);
    border-left-color: var(--blue-strong);
}

.book-data-table.resizing,
.book-table-wrap table.resizing,
.table-wrap table.resizing {
    user-select: none;
}

.book-data-table.resizing *,
.book-table-wrap table.resizing *,
.table-wrap table.resizing * {
    cursor: col-resize !important;
}

.stat-grid,
.reader-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 0;
}

.stat-grid div,
.reader-stats div,
.summary-strip a,
.summary-chip {
    padding: 12px 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface-2);
    transition: background 0.2s, border-color 0.2s;
}

.stat-grid div:hover,
.reader-stats div:hover {
    background: var(--surface);
    border-color: var(--line);
}

dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

dd {
    margin: 4px 0 0;
    font-weight: 800;
    font-size: 20px;
}

.empty-state {
    padding: 72px 32px;
    text-align: center;
    border: 2px dashed #d8dfe8;
    border-radius: var(--radius-lg);
    background: #fafbfd;
    grid-column: 1 / -1;
}

.empty-state::before {
    content: "📚";
    display: block;
    font-size: 52px;
    margin-bottom: 18px;
    opacity: 0.55;
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}

.empty-state p {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.summary-strip a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-strip a.active {
    border-color: var(--blue-strong);
    background: var(--blue);
    color: var(--blue-deep);
    font-weight: 600;
}

.summary-chip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    user-select: none;
}

.summary-chip:hover {
    background: var(--surface);
    border-color: var(--blue-strong);
}

.summary-chip.active {
    border-color: var(--blue-strong);
    background: var(--blue);
    color: var(--blue-deep);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(56, 152, 201, 0.15);
}

.terms-import-row,
.bulk-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.import-form.compact input {
    max-width: min(360px, 100%);
}

.bulk-toolbar {
    padding: 12px 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
}

.bulk-toolbar select {
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}

.check-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.term-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.muted-text {
    color: var(--muted);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.word-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    min-width: 720px;
}

.word-table th,
.word-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line-light);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

.word-table th {
    overflow: visible;
}

.word-table col.col-select { width: 52px; }
.word-table col.col-freq   { width: 100px; }
.word-table col.col-time   { width: 130px; }

.word-table th:nth-child(1),
.word-table td:nth-child(1) {
    text-align: center;
}

.word-table th:nth-child(3),
.word-table td:nth-child(3) {
    text-align: center;
}

.word-table th:nth-child(4),
.word-table td:nth-child(4) {
    text-align: center;
    white-space: nowrap;
}

.word-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--surface-2);
    position: relative;
    user-select: none;
}

.word-table th .th-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.word-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.word-table th.sortable:hover {
    color: var(--accent);
}

.word-table th .sort-icon {
    display: inline-block;
    font-size: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.word-table th .sort-arrow {
    opacity: 0.3;
}

.word-table th .sort-arrow.active {
    opacity: 1;
}

.word-table th.sortable:hover .sort-arrow {
    opacity: 0.5;
}

.word-table th.sortable:hover .sort-arrow.active {
    opacity: 1;
}

.word-table tbody tr {
    transition: background 0.15s;
}

.word-table tbody tr:hover {
    background: var(--surface-2);
}

.word-display {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.2px;
}

.inline-status-actions,
.word-panel-actions,
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.status-card-grid .status-chip,
.status-card-grid .button {
    min-height: 42px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    justify-content: center;
    width: 100%;
}

.word-panel-actions-extra {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line-light);
    justify-content: flex-end;
}

.word-panel-actions-extra .button {
    font-size: 13px;
    min-height: 32px;
    padding: 0 10px;
}

.status-chip,
.legend-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-light);
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.status-chip:hover {
    border-color: var(--line);
}

.status-chip.active {
    border-color: var(--text);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.status-unknown {
    background: var(--status-unknown-color);
}

.status-known {
    background: var(--status-known-color);
}

.status-new {
    background: var(--status-new-color);
}

.progress-unknown {
    background: var(--status-unknown-color);
}

.progress-known {
    background: var(--status-known-color);
}

.progress-new {
    background: var(--status-new-color);
}

.progress-order-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-order-field > span {
    font-size: 14px;
    color: var(--muted);
}

.progress-order-sorter {
    display: flex;
    flex-direction: row;
    gap: 6px;
    user-select: none;
}

.sort-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: grab;
    transition: all 0.2s;
}

.sort-item:active {
    cursor: grabbing;
}

.sort-item.drag-over {
    border-color: var(--blue-strong);
    background: var(--blue-light, #e8f4fd);
    box-shadow: 0 0 0 2px var(--blue-strong);
}

.sort-item.dragging {
    opacity: 0.4;
}

.sort-handle {
    color: var(--text-tertiary, #999);
    font-size: 12px;
    line-height: 1;
    letter-spacing: 1px;
}

.sort-color {
    width: 16px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid var(--line);
    flex-shrink: 0;
}

.sort-item span:last-child {
    font-size: 12px;
    font-weight: 500;
}

.progress-order-list {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
}

.progress-order-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid #d8e3ef;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(23, 33, 43, 0.06);
    color: var(--text);
    font-size: 14px;
    font-weight: 750;
    cursor: grab;
    user-select: none;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.progress-order-item:hover {
    border-color: var(--blue-strong);
    box-shadow: 0 6px 14px rgba(56, 152, 201, 0.14);
    transform: translateY(-1px);
}

.progress-order-item:active {
    cursor: grabbing;
    transform: translateY(0);
}

.progress-order-swatch {
    width: 28px;
    height: 12px;
    flex: 0 0 auto;
    border: 1px solid rgba(23, 33, 43, 0.14);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.progress-order-grip {
    margin-left: 2px;
    color: #91a3b6;
    font-size: 13px;
    line-height: 1;
}

.pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.pager-top {
    justify-content: space-between;
    margin-bottom: 10px;
    margin-top: 0;
}

.pager-bottom {
    justify-content: space-between;
}

.reader-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 820px);
    gap: 24px;
    width: min(1110px, calc(100vw - 32px));
    margin: 24px auto 72px;
    align-items: start;
}

.reader-main {
    min-height: calc(100vh - 64px);
}

.reader-shell-clean {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, max(360px, calc(100vw - var(--reader-side-blank) - var(--reader-side-blank))));
    gap: 14px;
}

.reader-shell-clean.reader-shell-pdf {
    width: min(920px, max(360px, calc(100vw - var(--reader-side-blank) - var(--reader-side-blank))));
}

.reader-topbar {
    align-items: center;
}

.reader-top-summary {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
}

.reader-top-title {
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-top-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.reader-top-meta b {
    color: var(--text);
}

.meta-divider {
    width: 1px;
    height: 14px;
    background: var(--line);
}

.reader-save-state {
    color: var(--blue-strong);
}

.reader-menu {
    position: relative;
}

.menu-trigger,
.menu-item,
.drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.menu-item:hover {
    background: var(--surface-2);
    border-color: var(--line);
}

.menu-item.active {
    background: var(--blue);
    border-color: var(--blue-strong);
    font-weight: 700;
}
.menu-trigger {
    width: 42px;
    padding: 0;
    overflow: hidden;
    text-indent: -999px;
}

.menu-trigger::before {
    content: "☰";
    text-indent: 0;
    font-size: 18px;
}

.reader-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 70;
    display: grid;
    gap: 8px;
    width: min(320px, calc(100vw - 28px));
    padding: 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.menu-item {
    width: 100%;
    padding: 0 12px;
    text-align: center;
}

.menu-section {
    max-height: 240px;
    overflow: auto;
}

.menu-section-title {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.reader-settings {
    padding: 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.reader-settings summary {
    cursor: pointer;
    font-weight: 800;
}

.reader-settings label {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.reader-settings input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
}

.reader-settings input[type="color"] {
    width: 46px;
    min-height: 30px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.reader-settings .button {
    width: 100%;
    margin-top: 10px;
}

.reader-page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 44px;
    padding: 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

.reader-chapter-done {
    font-size: 20px;
    min-height: 42px;
    min-width: 48px;
    padding: 0 8px;
    border-color: var(--green-strong);
    background: linear-gradient(180deg, #eaf7ef, var(--green));
    color: var(--green-strong);
    box-shadow: 0 4px 14px rgba(52, 134, 90, 0.14);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.reader-chapter-done:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 22px rgba(52, 134, 90, 0.24);
    border-color: var(--green-strong);
    background: linear-gradient(180deg, #dcf5e5, #b8e6cc);
}

.reader-completion-toggle {
    font-size: 14px;
    font-weight: 700;
    min-height: 42px;
    padding: 0 18px;
    border-radius: var(--radius);
    border-color: var(--accent);
    background: linear-gradient(180deg, #eaf2fb, var(--blue));
    color: var(--accent);
    box-shadow: 0 4px 14px rgba(56, 152, 201, 0.14);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.reader-completion-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 22px rgba(56, 152, 201, 0.24);
    border-color: var(--accent);
    background: linear-gradient(180deg, #dce8f5, #b8d8ee);
}

.reader-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 0 4px;
}

.reader-progress-bar {
    flex: 1 1 auto;
    height: 4px;
    background: var(--line-light);
    border-radius: 2px;
    overflow: hidden;
}

.reader-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--blue-strong);
    border-radius: 2px;
    transition: width 0.3s ease;
    min-width: 0;
}

.reader-progress-page {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.reader-page-nav span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-page-nav-bottom {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-light);
}

.legend {
    gap: 6px;
}

.page-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.keyboard-hint {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.reader-content {
    min-height: 70vh;
    padding: clamp(24px, 5vw, 56px) var(--reader-pane-x);
    border: 1px solid rgba(215, 222, 231, 0.78);
    border-radius: var(--radius-lg);
    background: var(--surface-reader);
    box-shadow: 0 18px 50px rgba(25, 32, 43, 0.1), 0 2px 8px rgba(25, 32, 43, 0.05);
    font-size: var(--reader-font-size);
    line-height: var(--reader-line-height);
    overflow-wrap: anywhere;
}

.reader-content.reader-content-pdf {
    max-width: 920px;
    margin: 0 auto;
    text-align: left;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    text-wrap: pretty;
}

.chapter-anchor {
    display: block;
    height: 0;
    scroll-margin-top: 92px;
}

.token.word {
    display: inline;
    position: relative;
    margin: 0 1px;
    padding: 1px 2px;
    border: 0;
    border-radius: 5px;
    color: inherit;
    line-height: inherit;
    cursor: pointer;
}

.token.word.cjk-token {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

.token.word:hover {
    outline: 2px solid var(--blue-strong);
}

.token.word.word-focus {
    outline: 3px solid var(--red-strong);
    background: #fff5f5;
}

.token.word.word-focus.status-unknown {
    background: var(--status-unknown-color);
    outline-color: var(--status-unknown-color);
}

.token.word.word-focus.status-known {
    background: var(--status-known-color);
    outline-color: var(--status-known-color);
}

.token.word.word-focus.status-new {
    background: var(--status-new-color);
    outline-color: var(--status-new-color);
}

.token.word.word-status-changed {
    animation: word-status-changed-flash 0.9s ease-out;
}

.token.word.word-status-changed-unknown {
    --word-status-changed-color: var(--status-unknown-color);
}

.token.word.word-status-changed-known {
    --word-status-changed-color: var(--status-known-color);
}

.token.word.word-status-changed-new {
    --word-status-changed-color: var(--status-new-color);
}

@keyframes word-status-changed-flash {
    0% {
        background: var(--word-status-changed-color);
        box-shadow: 0 0 0 0 rgba(56, 152, 201, 0);
        transform: translateY(0);
    }
    35% {
        background: var(--word-status-changed-color);
        box-shadow: 0 0 0 5px color-mix(in srgb, var(--word-status-changed-color) 58%, transparent);
        transform: translateY(-1px);
    }
    100% {
        background: var(--word-status-changed-color);
        box-shadow: 0 0 0 0 rgba(56, 152, 201, 0);
        transform: translateY(0);
    }
}

.token.word.reader-position-word::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -0.42em;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--blue-strong);
    box-shadow: 0 0 0 2px var(--paper);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
}

.token.phrase-term {
    box-shadow: inset 0 -2px 0 rgba(23, 33, 43, 0.22);
}

.reader-content.phrase-mode .token.word[data-token-id] {
    outline: 1px dashed var(--blue-strong);
}

.phrase-selected {
    outline: 3px solid var(--red-strong) !important;
}

.drag-selected {
    outline: 3px solid var(--blue-strong) !important;
}

.token.punct {
    white-space: pre-wrap;
}

.reader-image {
    margin: 24px 0;
}

.reader-image img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
}

.reader-image figcaption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.reader-heading {
    display: block;
    margin: 28px 0 12px;
    padding: 0;
    font-size: 1.3em;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-strong);
    border: 0;
    white-space: pre-wrap;
}

.reader-heading:first-child {
    margin-top: 0;
}

.chapter-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(23, 33, 43, 0.24);
}

.chapter-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(360px, calc(100vw - 28px));
    border-right: 1px solid var(--line-light);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.chapter-drawer header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--line-light);
}

.chapter-drawer h2 {
    margin: 0;
    font-size: 22px;
}

.chapter-drawer p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.drawer-close {
    width: 36px;
    padding: 0;
    font-size: 22px;
}

.chapter-drawer-list {
    overflow: auto;
    padding: 12px;
}

.chapter-drawer-list a {
    display: block;
    padding: 10px;
    border-radius: 8px;
    color: var(--muted);
    line-height: 1.35;
}

.chapter-drawer-list a:hover,
.chapter-drawer-list a.active {
    background: var(--blue);
    color: var(--text);
}

.word-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(23, 33, 43, 0.22);
}

.word-panel {
    position: fixed;
    z-index: 50;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 32px));
    display: flex;
    flex-direction: row;
    gap: 0;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transition: width 0.25s ease;
}

.word-panel-explain-open {
    width: min(780px, calc(100vw - 32px));
}

.word-panel-left {
    flex: 0 0 auto;
    width: 100%;
    padding: 24px;
    overflow-y: auto;
}

.word-panel-explain-open .word-panel-left {
    flex: 0 0 380px;
    width: 380px;
    min-width: 0;
    border-right: 1px solid var(--line-light);
}

.word-panel-right {
    display: none;
    flex: 1 1 auto;
    padding: 24px 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.word-panel-explain-open .word-panel-right {
    display: block;
}

.word-panel-explain-open .word-panel-right[hidden] {
    display: none !important;
}

.word-panel h2 {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.word-panel p {
    margin: 8px 0 16px;
    color: var(--muted);
    font-size: 14px;
}

.term-image-box {
    margin: 12px 0;
}

.term-image-box img {
    display: block;
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.term-image-form {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.term-image-form input {
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
}

.panel-close {
    margin-top: 16px;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 24px 16px;
    font-size: 14px;
}

code {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 0.9em;
}

/* statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.stats-card {
    padding: 16px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    transition: box-shadow 0.2s;
}

.stats-card:hover {
    box-shadow: var(--shadow);
}

.stats-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.stats-card strong {
    display: block;
    margin-top: 6px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.stats-card small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.statistics-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats-panel {
    padding: 20px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stats-panel h2 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.stats-chart {
    display: grid;
    gap: 12px;
}

.chart-row {
    display: grid;
    gap: 6px;
}

.chart-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chart-row-head span {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-row-head b {
    flex: 0 0 auto;
    color: var(--blue-strong);
    font-weight: 700;
}

.chart-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line-light);
}

.chart-fill {
    display: block;
    height: 100%;
    border-radius: 8px;
    background: var(--blue-strong);
    transition: width 0.6s ease;
}

.chart-fill-green {
    background: var(--green-strong);
}

.chart-row small {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.chart-card {
    position: relative;
    padding: 14px 0;
    min-height: 320px;
}

.chart-card .chart-wrap {
    position: relative;
    width: 100%;
    height: 340px;
}

.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

/* settings */
.settings-grid {
    display: grid;
    gap: 20px;
}

.settings-panel {
    padding: 24px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.settings-panel h2 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.settings-panel label {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 14px;
}

.settings-panel input[type="text"],
.settings-panel input[type="url"],
.settings-panel input[type="password"] {
    grid-column: 1 / -1;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-panel input[type="text"]:focus,
.settings-panel input[type="url"]:focus,
.settings-panel input[type="password"]:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
}

.settings-panel input[type="range"] {
    grid-column: 1 / -1;
}

.settings-panel input[type="color"] {
    width: 46px;
    min-height: 30px;
    padding: 2px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.reader-theme-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 18px;
}

.settings-panel .reader-theme-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,249,250,0.94));
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.reader-theme-option input {
    margin: 0;
    accent-color: var(--blue-strong);
}

.reader-theme-option:has(input:checked) {
    border-color: var(--blue-strong);
    background: linear-gradient(180deg, #dff3fb, var(--blue));
    color: var(--blue-deep);
    box-shadow: 0 8px 22px rgba(47, 135, 180, 0.14);
}

.settings-panel .button {
    margin-top: 10px;
}

.settings-hint {
    margin: -8px 0 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.settings-panel button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.settings-panel button:disabled:hover {
    background: var(--surface);
    border-color: var(--line-light);
}

.settings-panel textarea {
    grid-column: 1 / -1;
    min-height: 160px;
    padding: 10px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 15px;
    line-height: 1.7;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-panel textarea:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
}

.import-shell {
    padding-top: 40px;
}

.import-cards {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 800px;
    margin: 0 auto;
}

.import-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 36px 32px 32px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.import-card:hover {
    box-shadow: var(--shadow);
}

.import-card-icon {
    font-size: 40px;
    margin-bottom: 12px;
    line-height: 1;
}

.import-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
}

.import-card .muted-text {
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.6;
    max-width: 280px;
}

.import-target {
    display: flex;
    gap: 8px;
    width: min(100%, 280px);
    margin-bottom: 16px;
}

.import-target label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.import-target input {
    margin: 0;
}

.import-file-card .import-select-btn {
    min-height: 40px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.import-submit {
    width: 100%;
    min-height: 40px;
    font-size: 14px;
    font-weight: 600;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.shortcut-key-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-weight: 800;
    font-size: 16px;
    transition: all 0.2s;
}

.shortcut-key-btn:hover {
    border-color: var(--blue-strong);
    background: var(--blue);
}

.shortcut-key-btn.recording {
    border-color: var(--red-strong);
    background: var(--red);
    animation: pulse-recording 0.8s infinite;
}

@keyframes pulse-recording {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.reader-layout {
    display: flex;
    min-height: calc(100vh - 80px);
}

.sidebar-toggle {
    position: fixed;
    top: 82px;
    left: 0;
    z-index: 70;
    width: 24px;
    min-height: 40px;
    padding: 4px;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}

.sidebar-toggle.sidebar-hidden {
    left: 0;
}

.reader-sidebar {
    flex: 0 0 220px;
    min-width: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
    overflow: hidden;
    transition: flex-basis 0.2s;
}

.reader-sidebar.hidden {
    flex: 0 0 0;
    border-right: 0;
}

.sidebar-inner {
    width: 220px;
    padding: 16px;
    display: grid;
    gap: 10px;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

.reader-book-placeholder {
    display: grid;
    place-items: center;
    width: 64px;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-weight: 800;
    color: var(--blue-strong);
    font-size: 20px;
}

.reader-main {
    flex: 1 1 auto;
    min-width: 280px;
    position: relative;
    padding-right: 8px;
    transition: margin-left 0.2s ease;
}

.reader-main.toc-open {
    margin-left: calc(var(--reader-toc-width) + 14px);
}

.reader-main.toc-open .reader-shell-clean {
    width: min(100%, max(360px, calc(100vw - var(--reader-toc-width) - 14px - var(--reader-side-blank) - var(--reader-side-blank))));
}

.reader-main.toc-open .reader-shell-clean.reader-shell-pdf {
    width: min(880px, max(360px, calc(100vw - var(--reader-toc-width) - 14px - var(--reader-side-blank) - var(--reader-side-blank))));
}

.toc-backdrop {
    display: none;
}

.toc-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    z-index: 18;
    width: var(--reader-toc-width);
    max-width: 45vw;
    height: calc(100vh - 64px);
    background: var(--surface);
    border-right: 1px solid var(--line-light);
    box-shadow: var(--shadow);
}

.toc-sidebar[hidden] {
    display: none !important;
}

.toc-inner {
    height: 100%;
    overflow-y: auto;
}

.toc-inner h2 {
    margin: 0;
    padding: 20px 16px 12px;
    font-size: 18px;
}

.toc-nav {
    display: grid;
    gap: 4px;
    padding: 0 12px;
}

.toc-nav .button {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
}

.toc-nav .button.active {
    border-color: var(--blue-strong);
    background: var(--blue);
    font-weight: 700;
}

.toc-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 5;
}

.toc-resize-handle:hover,
.toc-resize-handle:active {
    background: rgba(73, 167, 214, 0.2);
}

.explain-term {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-strong);
    word-break: break-all;
}

.explain-context {
    margin: 0 0 16px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

.explain-context:empty {
    display: none;
}

.explain-content {
    font-size: 16px;
    line-height: 1.75;
    color: var(--text);
}

.explain-text {
    margin: 0;
    white-space: pre-line;
}

.explain-loading {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.explain-error {
    margin: 0;
    color: var(--red-strong);
    font-size: 14px;
}

.explain-toggle {
    min-width: 72px;
}

.explain-toggle.active {
    background: var(--blue-strong);
    color: #fff;
    border-color: var(--blue-strong);
}

.reader-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 5;
}

.reader-resize-handle:hover,
.reader-resize-handle:active {
    background: rgba(73, 167, 214, 0.15);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-dropdown-trigger:hover {
    border-color: var(--line);
    background: var(--surface-2);
}

.nav-dropdown-trigger::after {
    content: "▼";
    font-size: 9px;
    opacity: 0.5;
}

.floating-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 80;
    display: grid;
    gap: 6px;
    width: 160px;
    padding: 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.floating-panel a,
.floating-panel .button {
    width: 100%;
    text-align: center;
}

.terms-top-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.shelf-sort-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
}

.shelf-sort-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.shelf-sort-chips .summary-chip {
    text-decoration: none;
    color: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line-light);
    transition: all 0.25s;
}

.shelf-sort-chips .summary-chip:hover {
    background: var(--surface-2);
    border-color: var(--blue-strong);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(56, 152, 201, 0.12);
}

.shelf-sort-chips .summary-chip.active {
    background: linear-gradient(135deg, var(--blue-strong) 0%, #2b8ec9 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(56, 152, 201, 0.3);
    font-weight: 600;
}

.bookshelf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.bookshelf-toolbar .bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bookshelf-toolbar .bulk-actions label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
}

.bookshelf-filters {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookshelf-filters select {
    min-height: 36px;
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238899b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bookshelf-filters select:hover {
    border-color: var(--blue-strong);
}

.bookshelf-filters select:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
    outline: none;
}

.book-inline-select {
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    width: 100%;
}

.book-select-dropdown .floating-panel {
    width: 240px;
    right: 50%;
    left: auto;
    transform: translateX(50%);
    padding: 8px;
    gap: 4px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--line-light);
}

.book-select-dropdown .floating-panel .button {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s;
    justify-content: flex-start;
    text-align: left;
}

.book-select-dropdown .floating-panel .button:hover {
    background: #eef3f9;
    border-color: #d0daea;
    color: var(--blue-deep);
}

.book-select-dropdown .floating-panel .button.active {
    background: linear-gradient(135deg, #dbeafe 0%, #c9e8fc 100%);
    border-color: var(--blue-strong);
    color: var(--blue-deep);
    font-weight: 600;
}

.book-select-dropdown .nav-dropdown-trigger {
    width: 100%;
    padding: 0 18px;
    min-height: 42px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--surface) 0%, #f7f9fc 100%);
    border: 1px solid var(--line-light);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    transition: all 0.2s;
}

.book-select-dropdown .nav-dropdown-trigger:hover {
    border-color: var(--blue-strong);
    background: linear-gradient(135deg, #eef3f9 0%, #dbeafe 100%);
    box-shadow: 0 2px 8px rgba(56, 152, 201, 0.12);
}

.terms-search-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.terms-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.terms-search-form input[type="search"] {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    min-width: 240px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.terms-search-form input[type="search"]:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
    outline: none;
}

.terms-search-form select {
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}

.file-name-hint {
    font-size: 12px;
    color: var(--muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.35);
}

.term-create-modal {
    position: fixed;
    z-index: 91;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.term-create-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-light);
}

.modal-word-display {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--muted);
    transition: all 0.2s;
}

.modal-close:hover {
    border-color: var(--red-strong);
    color: var(--red-strong);
    background: #fff0f3;
}

.term-create-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.term-create-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

.term-create-form select,
.term-create-form textarea,
.term-create-form input[type="file"] {
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}

.term-create-form textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

.term-create-form input[type="file"] {
    font-size: 13px;
}

.term-create-form .button {
    margin-top: 4px;
    min-height: 42px;
    font-weight: 600;
    font-size: 15px;
}

.status-pick-modal {
    position: fixed;
    z-index: 91;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 32px));
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.status-pick-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-light);
    font-weight: 700;
    font-size: 16px;
}

.status-pick-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
}

.status-pick-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.15s;
}

.status-pick-option:hover {
    border-color: var(--blue-strong);
    background: var(--blue);
}

.status-pick-option.status-unknown:hover {
    border-color: var(--blue-strong);
    background: var(--status-unknown-color);
}

.status-pick-option.status-known:hover {
    border-color: #999;
    background: var(--surface-2);
}

.status-pick-option.status-new:hover {
    border-color: var(--red-strong);
    background: var(--status-new-color);
}

.progress-modal {
    position: fixed;
    z-index: 91;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(380px, calc(100vw - 32px));
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-light);
}

.progress-title {
    font-weight: 700;
    font-size: 16px;
}

.progress-body {
    padding: 20px 18px;
}

.progress-bar-track {
    width: 100%;
    height: 10px;
    background: var(--surface-2);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-strong), var(--blue));
    border-radius: 5px;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.edit-page-header {
    width: min(920px, calc(100vw - 32px));
    margin: 24px auto 56px;
}

.edit-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.edit-page-header h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 32px);
}

.edit-page-shell {
    width: min(100%, max(360px, calc(100vw - var(--reader-side-blank) - var(--reader-side-blank))));
    margin: 24px auto 72px;
}

.edit-chapter-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

.edit-chapter-form select {
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}

.edit-page-form textarea {
    width: 100%;
    min-height: 60vh;
    padding: 16px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--surface);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.8;
    resize: vertical;
    transition: border-color 0.2s;
}

.edit-page-form textarea:focus {
    border-color: var(--blue-strong);
    box-shadow: 0 0 0 3px rgba(56, 152, 201, 0.12);
}

.edit-page-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.edit-page-buttons {
    display: flex;
    gap: 8px;
}

@media (max-width: 960px) {
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        flex-wrap: wrap;
        padding: 14px 18px;
    }

    .topbar .topbar-left,
    .topbar .nav {
        flex: 0 0 auto;
    }

    .topbar .nav {
        justify-content: flex-start;
    }

    .topbar .topbar-center {
        flex: 1 1 100%;
        order: 3;
        align-items: flex-start;
    }

    .reader-topbar .reader-top-summary {
        order: 3;
        text-align: left;
    }

    .reader-topbar .reader-top-meta {
        justify-content: flex-start;
    }

    .nav {
        flex-wrap: wrap;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .statistics-layout {
        grid-template-columns: 1fr;
    }

    .shortcut-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .book-list {
        grid-template-columns: 1fr;
    }

    .page-shell.bookshelf-cards {
        width: min(1120px, calc(100vw - 32px));
    }
}

@media (max-width: 780px) {
    .summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .book-row {
        grid-template-columns: 80px minmax(0, 1fr);
        gap: 14px;
        padding: 16px;
    }

    .book-select {
        top: 10px;
        left: 8px;
    }

    .book-cover {
        width: 80px;
        font-size: 16px;
    }

    .book-row > .action-dropdown {
        top: 6px;
        right: 8px;
    }

    .book-row > .action-dropdown .nav-dropdown-trigger {
        font-size: 14px;
        min-height: 26px;
        padding: 0 4px;
    }

    .book-stat-line {
        gap: 3px 8px;
    }

    .book-stat-line strong {
        font-size: 9px;
        padding: 2px 6px;
    }

    .book-stat-line span {
        font-size: 11px;
    }

    .book-stat-row .status-progress {
        flex: 1 1 60px;
        min-width: 40px;
        max-width: 120px;
    }

    .shelf-sort-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .shelf-sort-chips {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .shelf-sort-chips::-webkit-scrollbar {
        display: none;
    }

    .shelf-sort-chips .summary-chip {
        flex: 0 0 auto;
        width: auto;
        min-width: 86px;
    }

    .stat-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-form,
    .import-form,
    .reader-tools,
    .page-nav {
        width: 100%;
    }

    .search-form input,
    .search-form select,
    .search-form .button,
    .import-form input,
    .import-form .button,
    .bulk-toolbar select,
    .bulk-toolbar .button {
        width: 100%;
    }

    .reader-sidebar {
        position: fixed;
        top: 64px;
        bottom: 0;
        left: 0;
        z-index: 60;
        box-shadow: var(--shadow);
    }

    .reader-sidebar.hidden {
        flex: 0 0 0;
        left: -220px;
    }

    .sidebar-inner {
        max-height: calc(100vh - 64px);
    }

    .reader-content {
        padding: 22px min(var(--reader-pane-x), 34px);
        font-size: var(--reader-font-size);
        line-height: var(--reader-line-height);
    }

    .word-table {
        min-width: 600px;
    }

    .edit-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-grid {
        gap: 14px;
    }

    .settings-panel {
        padding: 16px;
    }

    .import-cards {
        flex-direction: column;
    }

    .terms-search-row {
        flex-direction: column;
    }

    .terms-search-form {
        flex-wrap: wrap;
    }

    .terms-search-form input[type="search"] {
        min-width: 0;
        flex: 1;
    }
}

@media (max-width: 780px) {
    .bookshelf-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .bookshelf-toolbar .bulk-actions {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .bookshelf-toolbar .bulk-actions::-webkit-scrollbar {
        display: none;
    }

    .bookshelf-toolbar .bulk-actions > * {
        flex: 0 0 auto;
    }

    .bookshelf-toolbar .bulk-actions .button {
        min-width: 72px;
    }
}

@media (max-width: 460px) {
    .page-shell,
    .reader-shell {
        width: min(100vw - 16px, 100%);
        margin-top: 12px;
    }

    .page-shell.bookshelf-table {
        width: 100%;
        margin-top: 12px;
    }

    .page-shell.terms-shell {
        width: 100%;
        margin-top: 12px;
        padding: 0 8px;
    }

    .topbar {
        position: static;
        flex-wrap: nowrap;
        gap: 5px;
        min-height: 48px;
        padding: 6px 8px;
        overflow: visible;
        transition: transform 0.22s ease, box-shadow 0.22s ease;
        will-change: transform;
    }

    .topbar.reader-route-topbar {
        position: sticky;
        top: 0;
        z-index: 2500;
    }

    .topbar.reader-mobile-topbar-hidden {
        transform: translateY(calc(-100% - 8px));
        pointer-events: none;
    }

    .topbar .topbar-left {
        flex: 0 0 auto;
        gap: 5px;
    }

    .topbar .topbar-center {
        flex: 0 1 auto;
        min-width: 42px;
    }

    .topbar .nav {
        flex: 1 1 auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        max-width: 64vw;
        overflow: visible;
        scrollbar-width: none;
    }

    .topbar .nav::-webkit-scrollbar {
        display: none;
    }

    .vue-nav-popover {
        left: 0;
        right: auto;
    }

    .vue-nav-menu:last-child .vue-nav-popover {
        left: auto;
        right: 0;
    }

    .reader-route-topbar .reader-menu-panel {
        position: fixed;
        top: 52px;
        left: 8px;
        z-index: 3200;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .brand {
        font-size: 17px;
    }

    .nav a,
    .button,
    .sort-link {
        padding: 0 8px;
        min-height: 30px;
        font-size: 12px;
    }

    .nav {
        gap: 4px;
    }

    .nav-dropdown-trigger {
        font-size: 13px;
        padding: 0 12px;
    }

    .reader-top-meta {
        display: none;
    }

    .reader-top-meta .meta-divider {
        display: none;
    }

    .reader-top-title {
        font-size: 14px;
        line-height: 1.15;
    }

    .reader-top-summary {
        text-align: left;
    }

    .reader-shell {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .reader-sidebar {
        display: none;
    }

    .reader-resize-handle {
        display: none;
    }

    .toc-sidebar {
        width: 80vw;
        max-width: 300px;
    }

    .word-panel-explain-open {
        width: calc(100vw - 32px);
        flex-direction: column;
    }

    .word-panel-explain-open .word-panel-left {
        flex: 0 0 auto;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line-light);
    }

    .word-panel-explain-open .word-panel-right {
        max-height: 36vh;
        padding-top: 16px;
    }

    .reader-content {
        padding: 18px 16px;
        font-size: var(--reader-font-size);
        line-height: var(--reader-line-height);
        border-radius: var(--radius);
        touch-action: pan-y;
    }

    .reader-page-nav {
        flex-wrap: wrap;
        gap: 6px;
    }

    .reader-page-nav .button {
        width: 100%;
    }

    .word-panel {
        width: calc(100vw - 32px);
        max-width: 380px;
        max-height: 80vh;
    }

    .book-row {
        padding: 14px 12px;
        gap: 10px;
        grid-template-columns: 58px minmax(0, 1fr);
        border-radius: var(--radius);
    }

    .book-select {
        top: 8px;
        left: 6px;
    }

    .book-row > .action-dropdown {
        top: 4px;
        right: 6px;
    }

    .book-row > .action-dropdown .nav-dropdown-trigger {
        font-size: 12px;
        min-height: 24px;
        padding: 0 3px;
    }

    .book-cover {
        width: 58px;
        font-size: 12px;
    }

    .book-title-row h2 {
        font-size: 14px;
    }

    .book-stat-line {
        gap: 2px 6px;
        font-size: 11px;
    }

    .book-stat-row {
        gap: 4px 6px;
        padding: 8px 10px;
    }

    .book-stat-line strong {
        font-size: 9px;
        padding: 2px 6px;
    }

    .book-stat-line span {
        font-size: 10px;
    }

    .book-stat-row .status-progress {
        flex: 1 1 50px;
        min-width: 30px;
        max-width: 100px;
        height: 5px;
    }

    .book-stat-stack {
        gap: 8px;
    }

    .book-data-table {
        min-width: 620px;
    }

    .book-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .summary-strip,
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-card strong {
        font-size: 22px;
    }

    .terms-top-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .summary-chip {
        padding: 8px 10px;
        font-size: 13px;
    }

    .summary-chip strong {
        font-size: 16px;
    }

    .terms-search-row {
        flex-direction: column;
        gap: 8px;
    }

    .terms-search-form {
        width: 100%;
    }

    .terms-search-form input[type="search"] {
        width: 100%;
    }

    .bulk-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .bulk-toolbar select,
    .bulk-toolbar .button {
        flex: 1;
        min-width: 0;
    }

    .bulk-toolbar .button {
        white-space: nowrap;
    }

    .pager {
        flex-wrap: wrap;
        gap: 6px;
    }

    .word-table {
        min-width: 460px;
    }

    .import-cards {
        flex-direction: column;
        gap: 16px;
    }

    .import-card {
        padding: 20px 16px;
    }

    .import-card h2 {
        font-size: 18px;
    }

    .settings-panel {
        padding: 14px;
    }

    .settings-grid {
        gap: 14px;
    }

    .shortcut-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-card .chart-wrap {
        height: 260px;
    }

    .edit-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .flash-wrap {
        left: 8px;
        right: 8px;
    }

    .modal-backdrop {
        z-index: 55;
    }

    .reader-menu-panel {
        left: 0;
        right: auto;
    }

    .floating-panel {
         min-width: 140px;
     }
 }

@keyframes reader-panel-up {
    from {
        opacity: 0.88;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 780px), (max-height: 560px) and (pointer: coarse) {
    .reader-main {
        padding: 0 max(10px, env(safe-area-inset-left)) 24px max(10px, env(safe-area-inset-right));
        box-sizing: border-box;
    }

    .reader-shell-clean {
        width: 100%;
        max-width: none;
        margin-top: 12px;
        margin-bottom: 42px;
    }

    .reader-content {
        padding: 20px max(20px, calc(env(safe-area-inset-right) + 16px)) 24px max(20px, calc(env(safe-area-inset-left) + 16px));
        border-radius: var(--radius);
    }

    .word-panel {
        top: auto;
        right: max(8px, env(safe-area-inset-right));
        bottom: 0;
        left: max(8px, env(safe-area-inset-left));
        width: auto;
        max-width: none;
        max-height: min(86dvh, calc(100dvh - env(safe-area-inset-top) - 18px));
        transform: translateY(0);
        flex-direction: column;
        overflow: hidden;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: reader-panel-up 0.18s ease-out;
    }

    .word-panel-left {
        width: 100%;
        flex: 1 1 auto;
        max-height: calc(86dvh - 24px);
        padding: 18px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .word-panel-explain-open .word-panel-left {
        flex: 0 0 auto;
        width: 100%;
        max-height: 42dvh;
        border-right: 0;
        border-bottom: 1px solid var(--line-light);
    }

    .word-panel-right {
        max-height: 40dvh;
        padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .word-panel-search-open .word-panel-left,
    .word-panel-raised .word-panel-left {
        max-height: 74dvh;
    }

    .word-panel-explain-open.word-panel-raised .word-panel-left {
        max-height: 42dvh;
    }

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

@media (max-height: 560px) and (pointer: coarse) {
    .reader-shell-clean {
        margin-top: 8px;
        margin-bottom: 16px;
    }

    .reader-content {
        min-height: auto;
        padding-top: 16px;
        padding-bottom: 18px;
    }

    .word-panel {
        right: 8px;
        bottom: 4px;
        left: 8px;
        max-height: calc(100dvh - 8px);
        border-radius: var(--radius-lg);
    }

    .word-panel-left {
        max-height: calc(100dvh - 24px);
        padding: 14px;
    }

    .word-panel-explain-open {
        flex-direction: row;
    }

    .word-panel-explain-open .word-panel-left {
        flex: 0 0 min(42vw, 320px);
        width: min(42vw, 320px);
        max-height: calc(100dvh - 20px);
        border-right: 1px solid var(--line-light);
        border-bottom: 0;
    }

    .word-panel-explain-open .word-panel-right {
        max-height: calc(100dvh - 20px);
    }

    .term-image-search-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.readme-shell {
    width: min(900px, calc(100vw - 40px));
    margin: 0 auto 72px;
}

.readme-hero {
    margin: 28px 0 36px;
    padding: 48px 40px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--blue) 0%, var(--surface) 60%);
    text-align: center;
}

.readme-hero-title {
    margin: 0;
    font-size: 36px;
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--blue-deep);
}

.readme-hero-sub {
    margin: 8px 0 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.readme-hero-desc {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--muted);
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.readme-content {
    padding: 32px 40px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
}

.readme-content h1 {
    display: none;
}

.readme-content h2 {
    margin: 36px 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--blue-strong);
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.readme-content h2:first-of-type {
    margin-top: 0;
}

.readme-content h3 {
    margin: 24px 0 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.readme-content h3:first-child {
    margin-top: 0;
}

.readme-content p {
    margin: 0 0 12px;
}

.readme-content ul {
    margin: 0 0 16px;
    padding-left: 22px;
}

.readme-content li {
    margin-bottom: 6px;
    padding-left: 2px;
}

.readme-content li::marker {
    color: var(--blue-strong);
}

.readme-content strong {
    font-weight: 700;
    color: var(--text);
}

.readme-content code {
    padding: 2px 7px;
    border: 1px solid var(--line-light);
    border-radius: 4px;
    background: var(--surface-2);
    font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    color: var(--blue-deep);
}

.readme-content pre {
    margin: 0 0 20px;
    padding: 18px 22px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: #1e1e2e;
    overflow-x: auto;
}

.readme-content pre code {
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    font-size: 13px;
    line-height: 1.6;
    color: #cdd6f4;
}

.readme-content table {
    width: 100%;
    margin: 0 0 20px;
    border-collapse: collapse;
    font-size: 14px;
}

.readme-content th {
    padding: 10px 14px;
    border-bottom: 2px solid var(--blue-strong);
    background: var(--surface-2);
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.readme-content td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-light);
}

.readme-content tr:hover td {
    background: var(--surface-2);
}

.readme-content a {
    color: var(--blue-strong);
    text-decoration: none;
    font-weight: 500;
}

.readme-content a:hover {
    text-decoration: underline;
}

.readme-content hr {
    margin: 28px 0;
    border: none;
    border-top: 1px solid var(--line-light);
}

@media (max-width: 780px) {
    .readme-hero {
        padding: 32px 20px;
    }

    .readme-hero-title {
        font-size: 28px;
    }

    .readme-hero-sub {
        font-size: 16px;
    }

    .readme-content {
        padding: 24px 20px;
        font-size: 14px;
    }

    .readme-content h2 {
        font-size: 20px;
    }

    .readme-content pre {
        padding: 14px 16px;
    }
}

.color-picker-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.color-picker-row label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.color-picker-row input[type="color"] {
    width: 64px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.settings-actions {
    margin-top: 16px;
}

body[data-reader-theme="dark"]:has(#readerContent) {
    color-scheme: dark;
    --bg: #11151d;
    --surface: #1a202b;
    --surface-2: #202836;
    --surface-raised: rgba(29, 36, 48, 0.88);
    --surface-reader: #151a23;
    --text: #e8edf4;
    --text-strong: #f8fafc;
    --text-secondary: #bcc7d6;
    --muted: #8794a8;
    --line: #313b4a;
    --line-light: #26303d;
    --blue: #18384b;
    --blue-strong: #6db7de;
    --blue-deep: #9bd6f3;
    --red: #522434;
    --red-strong: #ff9bae;
    --green: #173b2a;
    --green-strong: #82d5a4;
    --amber: #4b3515;
    --amber-strong: #f0c46b;
    --status-unknown-color: #275b74;
    --status-known-color: #222937;
    --status-new-color: #7d3145;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 26px 70px rgba(0, 0, 0, 0.46);
    background:
        linear-gradient(180deg, #171d28 0, #11151d 420px),
        #11151d;
}

body[data-reader-theme="dark"]:has(#readerContent) .topbar,
body[data-reader-theme="dark"]:has(#readerContent) .vue-topbar {
    background: rgba(18, 23, 31, 0.82);
    border-bottom-color: rgba(61, 72, 88, 0.72);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 34px rgba(0, 0, 0, 0.34);
}

body[data-reader-theme="dark"]:has(#readerContent) .nav a,
body[data-reader-theme="dark"]:has(#readerContent) .button,
body[data-reader-theme="dark"]:has(#readerContent) .sort-link,
body[data-reader-theme="dark"]:has(#readerContent) .menu-trigger,
body[data-reader-theme="dark"]:has(#readerContent) .menu-item,
body[data-reader-theme="dark"]:has(#readerContent) .drawer-close {
    border-color: #313b4a;
    background: linear-gradient(180deg, #202838, #19202c);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

body[data-reader-theme="dark"]:has(#readerContent) .nav a:hover,
body[data-reader-theme="dark"]:has(#readerContent) .button:hover,
body[data-reader-theme="dark"]:has(#readerContent) .sort-link:hover,
body[data-reader-theme="dark"]:has(#readerContent) .menu-item:hover {
    border-color: #455266;
    background: #252e3d;
    box-shadow: var(--shadow);
}

body[data-reader-theme="dark"]:has(#readerContent) .nav a.active,
body[data-reader-theme="dark"]:has(#readerContent) .button.primary,
body[data-reader-theme="dark"]:has(#readerContent) .button.active,
body[data-reader-theme="dark"]:has(#readerContent) .menu-item.active {
    border-color: rgba(109, 183, 222, 0.72);
    background: linear-gradient(180deg, #214b62, #18384b);
    color: #d5f0ff;
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-content {
    border-color: rgba(76, 88, 106, 0.7);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.02), transparent 160px),
        var(--surface-reader);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-top-meta b,
body[data-reader-theme="dark"]:has(#readerContent) .reader-top-title,
body[data-reader-theme="dark"]:has(#readerContent) .reader-heading {
    color: var(--text-strong);
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-menu-panel,
body[data-reader-theme="dark"]:has(#readerContent) .word-panel,
body[data-reader-theme="dark"]:has(#readerContent) .toc-sidebar {
    border-color: #313b4a;
    background: #171d27;
    box-shadow: var(--shadow-lg);
}

body[data-reader-theme="dark"]:has(#readerContent) .word-panel-backdrop,
body[data-reader-theme="dark"]:has(#readerContent) .toc-backdrop,
body[data-reader-theme="dark"]:has(#readerContent) .chapter-drawer-backdrop {
    background: rgba(6, 9, 13, 0.62);
    backdrop-filter: blur(4px);
}

body[data-reader-theme="dark"]:has(#readerContent) .token.word.word-focus {
    background: rgba(255, 155, 174, 0.16);
}

body[data-reader-theme="dark"]:has(#readerContent) .token.word.word-focus.status-unknown {
    background: var(--status-unknown-color);
}

body[data-reader-theme="dark"]:has(#readerContent) .token.word.word-focus.status-known {
    background: var(--status-known-color);
}

body[data-reader-theme="dark"]:has(#readerContent) .token.word.word-focus.status-new {
    background: var(--status-new-color);
}

body[data-reader-theme="dark"]:has(#readerContent) .token.word.reader-position-word::after {
    background: #7dd3fc;
    box-shadow: 0 0 0 2px #121821;
}

body[data-reader-theme="dark"]:has(#readerContent) .status-progress {
    background: #283240;
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-chapter-done {
    border-color: #4a9168;
    background: linear-gradient(180deg, #1d3d2b, #173b2a);
    color: #82d5a4;
    box-shadow: 0 4px 14px rgba(130, 213, 164, 0.1);
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-chapter-done:hover {
    background: linear-gradient(180deg, #224a32, #1d412a);
    border-color: #82d5a4;
    box-shadow: 0 8px 22px rgba(130, 213, 164, 0.18);
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-completion-toggle {
    border-color: #5a9ec9;
    background: linear-gradient(180deg, #1d3040, #172d3a);
    color: #82c4e8;
    box-shadow: 0 4px 14px rgba(130, 196, 232, 0.1);
}

body[data-reader-theme="dark"]:has(#readerContent) .reader-completion-toggle:hover {
    background: linear-gradient(180deg, #223a48, #1d3a46);
    border-color: #82c4e8;
    box-shadow: 0 8px 22px rgba(130, 196, 232, 0.18);
}

.completed-books-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.completed-book-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.completed-book-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.completed-book-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--bg-muted);
}

.completed-book-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--muted);
    background: linear-gradient(135deg, var(--bg), var(--bg-muted));
}

.completed-book-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
}

.completed-book-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.completed-book-meta {
    font-size: 11px;
    color: var(--muted);
}

.completed-toggle-wrap {
    margin-top: 12px;
    text-align: center;
}

.heatmap-container {
    margin-top: 10px;
}

.heatmap-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
}

.heatmap-nav-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    min-width: 100px;
    text-align: center;
}

.heatmap-nav .button {
    min-height: 32px;
    padding: 0 10px;
}

.heatmap-dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.heatmap-calendar {
    min-width: 0;
}

.heatmap-month-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    margin-bottom: 6px;
}

.heatmap-calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-col-labels {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.heatmap-col-label {
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    line-height: 20px;
}

.heatmap-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.heatmap-day-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text);
    min-width: 0;
    transition: transform 0.1s ease;
}

.heatmap-day-cell:not(.empty):hover {
    transform: scale(1.15);
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.heatmap-day-cell.empty {
    background: transparent;
}

.heatmap-day-cell.is-today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 12px;
}

.heatmap-legend-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.heatmap-legend-label {
    margin: 0 4px;
}

@media (max-width: 780px) {
    .completed-books-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .heatmap-dual {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .completed-books-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.vue-avatar-btn {
    gap: 6px;
    padding: 5px 12px 5px 6px;
}

.vue-avatar-email {
    font-size: 0.78em;
    color: var(--text-secondary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
