/* Drawer component tokens and interaction states. */
/* Drawer, question list, table of contents, and file browser layout. */
        /* --- 抽屉与遮罩 --- */
        .drawer-mask {
            position: fixed; left: 0; width: 100%; background: rgba(0,0,0,0.3);
            backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
        }
        .drawer-mask.active { opacity: 1; pointer-events: auto; }

        #file-drawer-mask, #settings-drawer-mask, #stats-drawer-mask { top: var(--header-height); height: calc(100% - var(--header-height)); z-index: var(--z-drawer-mask); }
        #question-drawer-mask, #toc-drawer-mask { top: 0; height: 100%; z-index: var(--z-header); }

        .drawer-panel {
            position: fixed; top: var(--header-height); left: 0; width: 100%; background: var(--card-bg);
            z-index: var(--z-drawer-mask); border-radius: 0 0 20px 20px; box-shadow: 0 10px 20px rgba(0,0,0,0.05);
            overflow: hidden; 
            transform: translateY(-110%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            display: flex; flex-direction: column; max-height: 70vh;
        }
        .drawer-panel.active { transform: translateY(0); }

        .drawer-scroll-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0; background: var(--card-bg); }
        .drawer-scroll-content.stats-container { min-height: 0; box-sizing: border-box; padding: 25px 20px max(20px, var(--safe-bottom)); }
        .stats-container .stats-reset-group { margin-top: 20px; }
        .stats-reset-group .btn-reset { margin-top: 0; }

        .drawer-header-row {
            padding: 15px 20px; border-bottom: 1px solid var(--border-color); 
            font-weight:600; text-align:center; position: relative;
            display: flex; align-items: center; justify-content: center; gap: 6px;
        }

        .info-icon {
            width: 44px; height: 44px; border-radius: 50%; padding: 0;
            border: none; background: transparent; color: var(--sub-text-color);
            display: flex; align-items: center; justify-content: center;
            cursor: pointer; transition: background var(--duration-fast);
        }
        .info-icon:hover, .info-icon:active { background: var(--bg-color); color: var(--highlight-text); }

        .tooltip-popover {
            position: absolute; top: calc(100% - 8px); left: 50%; transform: translateX(-50%) translateY(10px);
            width: 290px; padding: 15px; background: var(--bg-color); 
            border: 1px solid var(--border-color); border-radius: 12px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.15);
            font-size: 13px; color: var(--sub-text-color); line-height: 1.6; text-align: left;
            opacity: 0; pointer-events: none; transition: opacity var(--duration-fast), transform var(--duration-fast); z-index: var(--z-header);
        }
        .tooltip-popover.active { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
        .tooltip-popover::before {
            content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
            border-left: 6px solid transparent; border-right: 6px solid transparent;
            border-bottom: 6px solid var(--border-color);
        }
        [data-theme="dark"] .tooltip-popover { background: #252525; border-color: #333; }
        [data-theme="dark"] .tooltip-popover::before { border-bottom-color: #333; }

        .bottom-drawer {
            position: fixed; bottom: 0; left: 0; width: 100%; height: 80vh; background: var(--card-bg);
            z-index: var(--z-bottom-drawer); border-radius: 24px 24px 0 0; box-shadow: 0 -5px 30px rgba(0,0,0,0.15);
            transform: translateY(110%); transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
            display: flex; flex-direction: column;
        }
        .bottom-drawer.active { transform: translateY(0); }
        
        .bottom-drawer-header { padding: 10px 20px 15px 20px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; text-align: center; position: relative; }
        .drawer-handle { width: 40px; height: 5px; background: var(--border-color); border-radius: 10px; margin: 0 auto 15px auto; opacity: 0.8; margin-bottom: 0px; }
        .bottom-drawer-title { font-size: 16px; font-weight: 600; color: var(--text-color); display: flex; justify-content: space-between; align-items: center; }
        .btn-drawer-close { background: var(--bg-color); border: none; width: 44px; height: 44px; border-radius: 50%; color: var(--sub-text-color); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }

        .bottom-drawer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 15px; padding-top: 10px; background: var(--bg-color); overscroll-behavior-y: contain; }
        
        .list-end-footer {
            padding: 5px 0 5px 0; text-align: center; font-size: 12px; color: var(--sub-text-color); opacity: 0.6;
            display: flex; align-items: center; justify-content: center; gap: 12px; user-select: none;
        }
        .list-end-footer::before, .list-end-footer::after { content: ''; display: block; width: 30px; height: 1px; background-color: var(--border-color); }

        .q-item {
            position: relative; display: flex; align-items: center; padding: 14px 16px; margin-bottom: 10px;
            background: var(--card-bg); border-radius: 12px; cursor: pointer; transition: transform 0.1s, background-color 0.2s;
            border: 1px solid transparent; box-shadow: 0 1px 2px rgba(0,0,0,0.03); overflow: visible;
        }
        .q-item:active { transform: scale(0.985); background-color: var(--bg-color); }
        .q-item::before {
            content: ''; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
            width: 4px; height: 18px; border-radius: 4px; background-color: var(--border-color);
            transition: background-color 0.3s, height 0.3s;
        }
        .q-item-content { display: flex; align-items: center; width: 100%; padding-left: 22px; }
        .q-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; color: var(--text-color); font-size: 15px; font-family: 'Roboto Mono', monospace; }
        
        .q-item.answered::before { background-color: var(--success-pill); height: 24px; }
        .q-item.wrong::before { background-color: var(--error-pill); height: 24px; }
        .q-item.partial::before { background-color: var(--partial-pill); height: 24px; }
        .q-item.current { border-color: var(--primary-color); box-shadow: 0 4px 12px var(--shadow-color); z-index: 2; }
        .q-item.current:not(.answered):not(.wrong):not(.partial)::before { background-color: var(--primary-color); height: 24px; }
        .q-item.current .q-text { font-weight: 600; color: var(--text-color); }

        .toc-item {
            padding: 12px 16px; margin-bottom: 6px; cursor: pointer;
            border-radius: 8px; color: var(--text-color); font-size: 14px;
            transition: background 0.2s, color 0.2s;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .toc-item:active { background: var(--border-color); }
        .toc-item.active {
            background-color: var(--primary-color);
            color: var(--card-bg); 
            font-weight: 700;
        }
        .toc-item.active.toc-h1,
        .toc-item.active.toc-h2,
        .toc-item.active.toc-h3,
        .toc-item.active.toc-h4,
        .toc-item.active.toc-h5,
        .toc-item.active.toc-h6 {
            color: #fbfbfb;
        }

        .toc-h1 { font-weight: 700; }
        .toc-h2 { padding-left: 30px; }
        .toc-h3 { padding-left: 45px; font-size: 13px; color: var(--sub-text-color); }
        .toc-h4 { padding-left: 60px; font-size: 13px; color: var(--sub-text-color); }
        .toc-h5 { padding-left: 75px; font-size: 13px; color: var(--sub-text-color); }
        .toc-h6 { padding-left: 90px; font-size: 13px; color: var(--sub-text-color); }

        .upload-area { padding: 20px 20px; padding-bottom: 20px; background: var(--card-bg); border-top: 1px solid var(--border-color); flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
        .btn-upload-redesign {
            width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
            background: var(--highlight-bg); color: var(--highlight-text); padding: 14px;
            border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s;
        }
        .btn-upload-redesign:active { transform: scale(0.98); opacity: 0.8; }

        /* 常驻「返回首页」（2026-10-08，需求 §7.5）：与「上传本地题库」同几何、同触控尺寸，
           但走**次级**配色 —— 它是返回动作，不该抢主操作的视觉权重。
           已在欢迎页时由 `updateHomeEntry()` 置为 `disabled`（不隐藏，保持操作区高度稳定）。 */
        .btn-home-redesign {
            width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
            min-height: 44px; padding: 14px;
            background: transparent; color: var(--text-color);
            border: 1px solid var(--border-color); border-radius: 12px;
            font-size: 15px; font-weight: 600; cursor: pointer;
            transition: all 0.2s;
        }
        .btn-home-redesign:active { transform: scale(0.98); opacity: 0.8; }
        .btn-home-redesign:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
        .btn-home-redesign:disabled { color: var(--border-color); cursor: default; opacity: 0.6; }
        .btn-home-redesign:disabled:active { transform: none; opacity: 0.6; }
        
        .online-file-item { 
            padding: 15px 20px; border-bottom: none; cursor: pointer; font-size: 15px; 
            color: var(--text-color); display: flex; align-items: center; justify-content: space-between; 
            transition: background 0.2s; 
        }
        .online-file-item:active { background: var(--border-color); }
        .file-info-left { display: flex; align-items: center; overflow: hidden; }
        .file-icon { display: inline-flex; margin-right: 12px; color: var(--sub-text-color); flex-shrink: 0; }
        .file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .version-tag {
            font-size: 0.8em; padding: 3px 8px; border-radius: 10px; background-color: var(--bg-color);
            color: var(--sub-text-color); font-weight: 800; font-family: Roboto, sans-serif;
            margin-left: 10px; flex-shrink: 0; border: 1px solid var(--border-color);
        }
        [data-theme="dark"] .version-tag { background-color: rgba(255,255,255,0.05); }
        .folder-group { border-bottom: none; }
        .folder-header { padding: 14px 20px; background: var(--card-bg); color: var(--text-color); cursor: pointer; font-weight: 600; font-size: 14px; display: flex; align-items: center; user-select: none; border-top: 1px solid var(--border-color); }
        .folder-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .folder-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--duration-slow) var(--ease-drawer); }
        .folder-items.is-expanded { grid-template-rows: 1fr; }
        .folder-items-inner { min-height: 0; overflow: hidden; }
        .folder-items .online-file-item { padding-left: 20px; background: var(--card-bg); }
        .drawer-section-title { padding: 10px 20px; padding-top: 15px; font-size: 13px; font-weight: 600; color: var(--sub-text-color); letter-spacing: 0.5px; background: var(--card-bg); opacity: 0.8; }
.drawer-panel,
.bottom-drawer {
  transition-duration: var(--duration-slow);
  transition-timing-function: var(--ease-drawer);
}

.drawer-panel { z-index: var(--z-drawer-mask); }
.bottom-drawer { z-index: var(--z-bottom-drawer); }
