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

body {
    font-family: "Microsoft YaHei", "SimSun", "Noto Serif SC", serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#desktop {
    width: 100vw;
    height: calc(100vh - 42px);
    position: relative;
    overflow: hidden;
    overflow-y: auto;
}

#desktop-icons {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 20px;
    gap: 20px;
}

.desktop-group-header {
    width: 100%;
    color: white;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 4px 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-top: 8px;
}

.desktop-icon {
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.15s;
    user-select: none;
}

.desktop-icon:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.desktop-icon:active {
    transform: scale(0.95);
}

.desktop-icon.selected {
    background: rgba(255,255,255,0.25);
    outline: 1px solid rgba(255,255,255,0.4);
}

.icon-img {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    margin-bottom: 8px;
}

.icon-label {
    color: white;
    font-size: 13px;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    line-height: 1.3;
    word-break: break-all;
}

#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 42px;
    background: rgba(20, 20, 30, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 10000;
}

#start-btn {
    padding: 6px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s;
    position: relative;
}

#start-btn:hover {
    transform: scale(1.05);
}

/* Start Menu */
#start-menu {
    position: fixed;
    bottom: 50px;
    left: 12px;
    width: 420px;
    max-height: calc(100vh - 100px);
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    padding: 16px;
    z-index: 20000;
    overflow-y: auto;
    animation: startMenuIn 0.2s ease;
}

@keyframes startMenuIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.start-menu-header {
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 4px 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.start-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.start-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.start-menu-item:hover {
    background: rgba(255,255,255,0.12);
}

.start-menu-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.start-menu-label {
    color: white;
    font-size: 12px;
    text-align: center;
    line-height: 1.3;
}

#taskbar-items {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.taskbar-item {
    padding: 5px 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.taskbar-item:hover {
    background: rgba(255,255,255,0.2);
}

.taskbar-item.active {
    background: rgba(255,255,255,0.25);
    border-bottom: 2px solid #667eea;
}

#clock {
    color: white;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Book Window */
.book-window {
    position: absolute;
    background: #faf8f3;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 600px;
    min-height: 400px;
    border: 1px solid rgba(0,0,0,0.1);
}

.book-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 42px) !important;
    border-radius: 0;
}

.window-titlebar {
    height: 38px;
    background: linear-gradient(90deg, #3a3a4a, #4a4a5a);
    display: flex;
    align-items: center;
    padding: 0 12px;
    cursor: default;
    user-select: none;
}

.window-title {
    flex: 1;
    color: white;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-controls {
    display: flex;
    gap: 6px;
}

.window-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: none;
}

.window-btn:hover {
    transform: scale(1.2);
}

.window-btn.minimize { background: #f1c40f; }
.window-btn.maximize { background: #2ecc71; }
.window-btn.close { background: #e74c3c; }

.window-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.15) 50%);
}

.book-window.maximized .resize-handle {
    display: none;
}

/* Fullscreen reading mode */
.book-window.fullscreen-mode {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

.book-window.fullscreen-mode .window-titlebar {
    height: 28px;
    padding: 0 8px;
}

.book-window.fullscreen-mode .window-title {
    font-size: 12px;
}

/* Dynasty timeline */
.dynasty-timeline {
    display: flex;
    width: 100%;
    padding: 8px 20px;
    gap: 4px;
    background: rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    position: sticky;
    top: 0;
    z-index: 100;
}
.dynasty-segment {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    min-width: 60px;
}
.dynasty-segment:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}
.dynasty-bar {
    width: 100%;
    height: 6px;
    border-radius: 3px;
}
.dynasty-name {
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
}

/* Global search modal */
.global-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}
.global-search-box {
    background: #fff;
    border-radius: 16px;
    width: 560px;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.global-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}
.global-search-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}
.global-search-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.global-search-close:hover {
    background: rgba(0,0,0,0.06);
}
.global-search-input {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 16px;
    outline: none;
    color: #333;
}
.global-search-status {
    padding: 8px 20px;
    font-size: 12px;
    color: #666;
    min-height: 28px;
}
.global-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 16px;
}
.global-search-result {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 6px;
    border: 1px solid transparent;
    transition: all 0.2s;
    background: #f8f8f8;
}
.global-search-result:hover {
    background: #f0f0f0;
    border-color: #ddd;
}
.global-search-result-book {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 2px;
}
.global-search-result-chapter {
    font-size: 14px;
    color: #333;
}
.global-search-empty {
    text-align: center;
    padding: 30px 0;
    color: #999;
    font-size: 14px;
}

/* Window animations */
@keyframes windowOpen {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes windowClose {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}
.window-opening {
    animation: windowOpen 0.25s ease forwards;
}
.window-closing {
    animation: windowClose 0.2s ease forwards;
    pointer-events: none;
}

/* Onboarding */
.onboarding-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.onboarding-step {
    background: #fff;
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: startMenuIn 0.3s ease;
}
.onboarding-step h3 {
    margin: 0 0 12px;
    font-size: 18px;
    color: #333;
}
.onboarding-step p {
    margin: 0 0 20px;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}
.onboarding-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.onboarding-buttons button {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.onboarding-next {
    background: #667eea;
    color: #fff;
}
.onboarding-next:hover {
    background: #5a6fd6;
}
.onboarding-skip {
    background: #f0f0f0;
    color: #666;
}
.onboarding-skip:hover {
    background: #e0e0e0;
}

/* ========================
   PHASE 2: RESPONSIVE SHELL
   ======================== */
#desktop {
    overflow-x: hidden;
}

@media (max-width: 768px) {
    #desktop-icons {
        padding: 12px;
        gap: 10px;
    }
    .desktop-icon {
        width: 74px;
        padding: 6px;
    }
    .icon-img {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    .icon-label {
        font-size: 12px;
    }
    .dynasty-timeline {
        padding: 6px 10px;
    }
    #start-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    .taskbar-item {
        max-width: 96px;
        font-size: 11px;
        padding: 5px 8px;
    }
    #start-menu {
        left: 8px;
        right: 8px;
        width: auto;
    }
    .global-search-overlay {
        padding-top: 40px;
    }
}

/* ========================
   PHASE 3: SHELL DARK THEME (follows OS preference)
   ======================== */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #10131f, #2a1530, #3d2b1f);
        background-size: 400% 400%;
    }
    #taskbar {
        background: rgba(10, 10, 18, 0.9);
    }
    .global-search-box {
        background: #1e1f26;
    }
    .global-search-header {
        border-bottom-color: #33343d;
    }
    .global-search-header h3 {
        color: #e6e6e6;
    }
    .global-search-close {
        color: #9a9aa5;
    }
    .global-search-close:hover {
        background: rgba(255,255,255,0.08);
    }
    .global-search-input {
        background: #1e1f26;
        color: #e6e6e6;
        border-bottom-color: #33343d;
    }
    .global-search-status {
        color: #9a9aa5;
    }
    .global-search-result {
        background: #26272f;
    }
    .global-search-result:hover {
        background: #2e2f3a;
        border-color: #3c3d49;
    }
    .global-search-result-chapter {
        color: #e0e0e0;
    }
    .global-search-empty {
        color: #77777f;
    }
    .onboarding-step {
        background: #1e1f26;
    }
    .onboarding-step h3 {
        color: #eeeeee;
    }
    .onboarding-step p {
        color: #bbbbbb;
    }
    .onboarding-skip {
        background: #33343d;
        color: #bbbbbb;
    }
    .onboarding-skip:hover {
        background: #3d3e49;
    }
}

/* Elements toggled with the `hidden` attribute below carry explicit
   `display` rules, which beat the UA stylesheet's [hidden] { display:none }.
   Restore the attribute's meaning. */
[hidden] {
    display: none !important;
}

/* ============================================================
   EXPORT SHEET · IMPORT DIALOG · BACKUP / STORAGE BARS
   These live on document.body, outside the .book-window scope where the
   --reader-* theme variables are defined, so they carry their own palette.
   ============================================================ */
.export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    padding: 20px 20px 62px;
}
.export-sheet {
    width: min(720px, 100%);
    max-height: min(86vh, 780px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    color: #1e1e22;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    overflow: hidden;
}
.export-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e6e6ea;
}
.export-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.export-close {
    border: none;
    background: transparent;
    font-size: 16px;
    color: #7a7a85;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 6px;
}
.export-close:hover {
    background: rgba(0,0,0,0.06);
}
.export-body {
    padding: 14px 18px;
    overflow-y: auto;
    flex: 1;
}
.export-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.export-label {
    width: 48px;
    flex-shrink: 0;
    font-size: 12px;
    color: #77777f;
    padding-top: 6px;
}
.export-choices,
.export-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}
.export-chip {
    padding: 5px 13px;
    border: 1px solid #dcdce2;
    border-radius: 15px;
    background: #ffffff;
    color: #44444c;
    font-size: 12px;
    cursor: pointer;
}
.export-chip:hover {
    border-color: #8b6914;
}
.export-chip.active {
    background: #8b6914;
    border-color: #8b6914;
    color: #fff;
}
.export-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #44444c;
    cursor: pointer;
}
.export-check.disabled {
    opacity: 0.42;
    cursor: default;
}
.export-summary {
    font-size: 12px;
    color: #77777f;
    margin: 4px 0 8px;
}
.export-inline-btn {
    border: none;
    background: transparent;
    color: #8b6914;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
.export-preview-wrap {
    border: 1px solid #e6e6ea;
    border-radius: 8px;
    overflow: hidden;
}
.export-preview {
    width: 100%;
    height: 240px;
    padding: 10px 12px;
    border: none;
    outline: none;
    resize: vertical;
    background: #fbfbfd;
    color: #33333a;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
    font-size: 12px;
    line-height: 1.7;
    box-sizing: border-box;
}
.export-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e6e6ea;
    background: #fafafc;
}
.export-status {
    flex: 1;
    font-size: 12px;
    color: #6b6b73;
}
.export-btn {
    padding: 7px 16px;
    border: 1px solid #dcdce2;
    border-radius: 7px;
    background: #ffffff;
    color: #33333a;
    font-size: 13px;
    cursor: pointer;
}
.export-btn:hover {
    border-color: #8b6914;
    color: #8b6914;
}
.export-btn-primary {
    background: #8b6914;
    border-color: #8b6914;
    color: #fff;
}
.export-btn-primary:hover {
    background: #75590f;
    color: #fff;
}
.export-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: #77777f;
}

/* --- import dialog --- */
.import-summary {
    font-size: 13px;
    line-height: 1.9;
    padding: 10px 12px;
    background: #f6f4ee;
    border-radius: 8px;
    margin-bottom: 10px;
}
.import-books {
    max-height: 190px;
    overflow-y: auto;
    margin-bottom: 12px;
}
.import-book {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 2px;
    font-size: 12px;
    border-bottom: 1px dotted #e6e6ea;
}
.import-nums {
    color: #77777f;
    flex-shrink: 0;
}
.import-note {
    font-size: 12px;
    color: #77777f;
    line-height: 1.7;
    padding: 8px 10px;
    background: #f7f7f9;
    border-radius: 6px;
}
.import-note-warn {
    background: #fdf0ee;
    color: #b03a2b;
}
.import-error {
    font-size: 13px;
    line-height: 1.8;
    color: #b03a2b;
}

/* --- storage warning / backup nudge bars --- */
.storage-warning-bar,
.backup-nudge {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 54px;
    z-index: 3500;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(680px, calc(100vw - 24px));
    padding: 9px 14px;
    border-radius: 9px;
    font-size: 12.5px;
    line-height: 1.6;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
}
.storage-warning-bar {
    background: #7a1618;
    color: #fff;
}
.backup-nudge {
    background: #23242c;
    color: #ececf0;
}
.storage-warning-export,
.backup-nudge-btn {
    flex-shrink: 0;
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
}
.storage-warning-export:hover,
.backup-nudge-btn:hover {
    background: rgba(255,255,255,0.16);
}
.storage-warning-close,
.backup-nudge-close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    font-size: 13px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 5px;
}
.storage-warning-close:hover,
.backup-nudge-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.16);
}

/* --- offline indicator in the taskbar --- */
.offline-indicator {
    display: none;
    padding: 3px 9px;
    border-radius: 4px;
    background: rgba(192, 57, 43, 0.9);
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
}
.offline-indicator.visible {
    display: block;
}

/* ============================================================
   批注中心 (cross-book annotation centre)
   ============================================================ */
.annotation-center {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    color: #1e1e22;
}
.ac-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e6e6ea;
    background: #fafafc;
}
.ac-stats {
    font-size: 12.5px;
    color: #55555d;
    margin-bottom: 9px;
}
.ac-unsaved {
    color: #b03a2b;
}
.ac-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.ac-select,
.ac-search {
    padding: 5px 8px;
    border: 1px solid #dcdce2;
    border-radius: 6px;
    background: #fff;
    color: #33333a;
    font-size: 12px;
    outline: none;
}
.ac-search {
    flex: 1;
    min-width: 140px;
}
.ac-bulk {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.ac-bulk-spacer {
    flex: 1;
}
.ac-selected-count {
    font-size: 12px;
    color: #8b6914;
}
.ac-btn {
    padding: 4px 11px;
    border: 1px solid #dcdce2;
    border-radius: 6px;
    background: #fff;
    color: #44444c;
    font-size: 12px;
    cursor: pointer;
}
.ac-btn:hover:not(:disabled) {
    border-color: #8b6914;
    color: #8b6914;
}
.ac-btn:disabled {
    opacity: 0.45;
    cursor: default;
}
.ac-btn-primary {
    background: #8b6914;
    border-color: #8b6914;
    color: #fff;
}
.ac-btn-primary:hover:not(:disabled) {
    background: #75590f;
    color: #fff;
}
.ac-btn-danger:hover:not(:disabled) {
    border-color: #c0392b;
    color: #c0392b;
}
.ac-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 14px 20px;
}
.ac-group {
    position: sticky;
    top: 0;
    background: #ffffff;
    padding: 10px 0 5px;
    font-size: 12px;
    font-weight: 600;
    color: #8b6914;
    border-bottom: 1px solid #eeeef1;
    z-index: 1;
}
.ac-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 4px;
    border-bottom: 1px solid #f1f1f4;
    border-radius: 4px;
}
.ac-item:hover {
    background: #fafafc;
}
.ac-check {
    margin-top: 4px;
    flex-shrink: 0;
}
.ac-item-main {
    flex: 1;
    min-width: 0;
}
.ac-item-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 3px;
}
.ac-tag {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 9px;
    background: #f0eee8;
    color: #7a6a45;
}
.ac-item-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}
.ac-empty {
    padding: 60px 20px;
    text-align: center;
    color: #88888f;
    font-size: 13px;
    line-height: 2;
}
.annotation-center .ann-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #f2f2f5;
    color: #66666e;
    border: 1px solid #e4e4e9;
}
.annotation-center .ann-item-quote {
    font-size: 12.5px;
    color: #66666e;
    border-left: 3px solid #c8a86b;
    padding-left: 8px;
    margin: 3px 0;
    line-height: 1.7;
}
.annotation-center .ann-item-text {
    font-size: 13.5px;
    line-height: 1.75;
    white-space: pre-wrap;
    color: #24242a;
}
.annotation-center .ann-item-date {
    font-size: 10.5px;
    color: #9a9aa2;
}
.annotation-center .ann-act {
    padding: 2px 10px;
    border: 1px solid #dcdce2;
    border-radius: 4px;
    background: #fff;
    color: #66666e;
    font-size: 11px;
    cursor: pointer;
}
.annotation-center .ann-act:hover {
    border-color: #8b6914;
    color: #8b6914;
}
.annotation-center .ann-act-del:hover {
    border-color: #c0392b;
    color: #c0392b;
}

@media (max-width: 700px) {
    .export-overlay { padding: 0 0 42px; align-items: flex-end; }
    .export-sheet { width: 100%; max-height: calc(100vh - 56px); border-radius: 12px 12px 0 0; }
    .export-preview { height: 150px; }
    .export-actions { flex-wrap: wrap; }
    .export-btn { flex: 1; min-height: 40px; }
    .export-status { flex: 100%; }
    .ac-item-actions { flex-direction: row; }
    .storage-warning-bar, .backup-nudge { flex-wrap: wrap; bottom: 48px; }
}

@media (prefers-color-scheme: dark) {
    .export-sheet { background: #1e1f26; color: #e6e6ea; }
    .export-head { border-bottom-color: #33343d; }
    .export-close { color: #9a9aa5; }
    .export-close:hover { background: rgba(255,255,255,0.08); }
    .export-label, .export-summary, .export-status, .import-nums { color: #9a9aa5; }
    .export-chip { background: #26272f; border-color: #3a3b45; color: #d3d3da; }
    .export-check { color: #d3d3da; }
    .export-preview-wrap { border-color: #33343d; }
    .export-preview { background: #16171d; color: #cfcfd6; }
    .export-actions { background: #1a1b21; border-top-color: #33343d; }
    .export-btn { background: #26272f; border-color: #3a3b45; color: #d3d3da; }
    .export-btn-ghost { background: transparent; border-color: transparent; color: #9a9aa5; }
    .import-summary { background: #26272f; }
    .import-note { background: #23242b; color: #9a9aa5; }
    .import-note-warn { background: #3a2422; color: #e8a79c; }
    .import-book { border-bottom-color: #2e2f38; }
    .annotation-center { background: #1a1b21; color: #e6e6ea; }
    .ac-header { background: #1e1f26; border-bottom-color: #33343d; }
    .ac-stats { color: #b6b6be; }
    .ac-select, .ac-search { background: #26272f; border-color: #3a3b45; color: #d3d3da; }
    .ac-btn { background: #26272f; border-color: #3a3b45; color: #d3d3da; }
    .ac-group { background: #1a1b21; border-bottom-color: #2e2f38; color: #c9a961; }
    .ac-item { border-bottom-color: #26272d; }
    .ac-item:hover { background: #212229; }
    .ac-tag { background: #33323a; color: #cdbb92; }
    .ac-empty { color: #8a8a92; }
    .annotation-center .ann-badge { background: #2a2b33; border-color: #3a3b45; color: #a9a9b2; }
    .annotation-center .ann-item-quote { color: #a9a9b2; border-left-color: #7a6234; }
    .annotation-center .ann-item-text { color: #e6e6ea; }
    .annotation-center .ann-act { background: #26272f; border-color: #3a3b45; color: #a9a9b2; }
}

/* ============================================================
   3D BOOKSHELF ENTRY VIEW
   Alternative to the desktop icons; both fill #desktop and are
   swapped by Desktop.setEntryView().
   ============================================================ */
#shelf-root {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 320px;
    overflow: hidden;
}

/* The shelf owns the full viewport height; the icon grid scrolls, the
   canvas must not. */
body.entry-shelf #desktop {
    overflow: hidden;
}

.shelf-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}
.shelf-canvas:active {
    cursor: grabbing;
}

/* Along the bottom, not the top: the 匾额 hangs over the case and the hint pill
   used to sit across it. */
.shelf-hud {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 16px;
    border-radius: 999px;
    background: rgba(15, 12, 10, 0.5);
    backdrop-filter: blur(8px);
    color: rgba(255, 246, 234, 0.9);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}
.shelf-count {
    color: #e0c48c;
}

.shelf-tooltip {
    position: absolute;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(18, 14, 11, 0.92);
    border: 1px solid rgba(216, 192, 138, 0.35);
    color: #f3e9d8;
    font-size: 13px;
    line-height: 1.45;
    pointer-events: none;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
}
.shelf-tooltip span {
    font-size: 11px;
    color: #bda87f;
}

.shelf-message {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(255, 245, 230, 0.85);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}
.shelf-loading::before {
    content: '';
    width: 26px;
    height: 26px;
    border: 2px solid rgba(224, 196, 140, 0.3);
    border-top-color: #e0c48c;
    border-radius: 50%;
    animation: shelfSpin 0.9s linear infinite;
}
@keyframes shelfSpin {
    to { transform: rotate(360deg); }
}
.shelf-fallback-btn {
    padding: 7px 18px;
    border: 1px solid rgba(224, 196, 140, 0.5);
    border-radius: 7px;
    background: transparent;
    color: #e0c48c;
    font-size: 13px;
    cursor: pointer;
}
.shelf-fallback-btn:hover {
    background: rgba(224, 196, 140, 0.14);
}

/* Real, focusable controls mirroring the 3D books. Off-screen until focused,
   so keyboard and screen-reader users can reach every book on the shelf. */
.shelf-a11y {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    margin: 0;
    padding: 0;
    list-style: none;
}
.shelf-a11y-btn {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    background: transparent;
    color: inherit;
}
.shelf-a11y-btn:focus-visible {
    position: static;
    width: auto;
    height: auto;
    margin: 10px;
    padding: 8px 16px;
    overflow: visible;
    clip-path: none;
    border-radius: 8px;
    background: rgba(18, 14, 11, 0.95);
    border: 2px solid #e0c48c;
    color: #f3e9d8;
    font-size: 13px;
    cursor: pointer;
}

/* Taskbar toggle */
#view-toggle {
    flex-shrink: 0;
    padding: 5px 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
#view-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}
#view-toggle.active {
    background: rgba(224, 196, 140, 0.22);
    border-color: rgba(224, 196, 140, 0.6);
    color: #f0dcb4;
}

@media (max-width: 700px) {
    .shelf-hud {
        font-size: 11px;
        gap: 8px;
        padding: 5px 12px;
    }
    #view-toggle {
        padding: 5px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shelf-loading::before {
        animation-duration: 2.4s;
    }
}
