/* Reading Container */
.reading-container {
    max-width: 680px; margin: 0 auto; padding: 0 16px 40px; position: relative;
}

.chapter-title-bar {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    position: sticky; top: 0; z-index: 10; background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.chapter-title-bar .chapter-label { flex: 1; }
.chapter-title-bar.hidden {
    transform: translateY(-100%); opacity: 0; pointer-events: none;
}

/* Chapter Content */
.chapter-content {
    padding: 16px 0; font-size: 1.05em; line-height: 2;
    text-align: justify; word-break: break-all;
}
.chapter-content p { text-indent: 2em; margin-bottom: 0.8em; }

/* Annotation Styles - Light Mode */
.annot-light {
    position: relative; cursor: pointer; display: inline;
    -webkit-tap-highlight-color: transparent;
}
.annot-light small {
    font-size: 0.7em; color: var(--text-tertiary); margin-left: 0.1em;
    pointer-events: none;
}
.annot-light::before {
    content: ''; display: inline-block; width: 4px; height: 4px;
    border-radius: 50%; margin-right: 1px; vertical-align: middle;
}
.annot-light.freq-high::before { background: var(--freq-high); }
.annot-light.freq-mid::before { background: var(--freq-mid); }
.annot-light.freq-low::before { background: var(--freq-low); }
.annot-light.bookmarked { background: var(--bookmark-bg); border-radius: 2px; }

/* Annotation Styles - Detail Mode */
.annot-detail {
    border-bottom: 1.5px dashed var(--accent); cursor: pointer;
    display: inline; -webkit-tap-highlight-color: transparent;
}
.annot-detail em {
    font-size: 0.82em; color: var(--accent); margin-left: 0.15em;
    font-style: normal; font-weight: 500; pointer-events: none;
}
.annot-detail.freq-high { border-bottom-color: var(--freq-high); }
.annot-detail.freq-high em { color: var(--freq-high); }
.annot-detail.freq-mid { border-bottom-color: var(--freq-mid); }
.annot-detail.freq-mid em { color: var(--freq-mid); }
.annot-detail.freq-low { border-bottom-color: var(--freq-low); }
.annot-detail.freq-low em { color: var(--freq-low); }
.annot-detail.bookmarked { background: var(--bookmark-bg); border-radius: 2px; }

/* Annotation Styles - Reinforcement Mode */
.annot-reinf {
    display: inline; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.annot-reinf strong {
    color: var(--freq-high); font-size: 0.9em; font-weight: 700;
    text-transform: lowercase;
}
.annot-reinf small {
    font-size: 0.65em; color: var(--text-tertiary); margin-left: 0.2em;
    pointer-events: none;
}
.annot-reinf.bookmarked { background: var(--bookmark-bg); border-radius: 2px; padding: 1px 2px; }

/* Annotated word tap target */
.annot-light, .annot-detail, .annot-reinf { padding: 3px 0; }

/* Chapter Navigation */
.chapter-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; gap: 10px;
}
.chapter-indicator { font-size: 0.85em; color: var(--text-secondary); white-space: nowrap; }

/* Scroll Progress */
.scroll-progress {
    position: fixed; top: 0; left: 0; height: 2px; background: var(--accent);
    z-index: 100; transition: width 0.1s;
}

/* Chapter Sidebar */
.chapter-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw;
    background: var(--bg-primary); z-index: 101;
    transform: translateX(-100%); transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15); display: flex; flex-direction: column;
}
.chapter-sidebar.open { transform: translateX(0); }
.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px; border-bottom: 1px solid var(--border-color);
}
.sidebar-header h3 { font-size: 1.1em; }
.sidebar-search {
    display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-color);
}
.sidebar-search input {
    flex: 1; padding: 8px 12px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary);
    width: 80px;
}
.chapter-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.chapter-list-item {
    padding: 10px 20px; cursor: pointer; font-size: 0.9em;
    border-bottom: 1px solid var(--border-color); transition: background 0.15s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-list-item:hover, .chapter-list-item.active { background: var(--bg-tertiary); color: var(--accent); }
.chapter-list-item .ch-num { color: var(--text-tertiary); margin-right: 6px; font-size: 0.85em; }

/* Word Detail Drawer */
.word-drawer {
    position: fixed; bottom: 0; left: 0; right: 0; max-width: 768px; margin: 0 auto;
    max-height: 55vh; background: var(--bg-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2); z-index: 101;
    transform: translateY(100%); transition: transform 0.3s ease;
    overflow-y: auto; padding: 0 20px 24px;
}
.word-drawer.open { transform: translateY(0); }
.drawer-handle {
    width: 40px; height: 4px; background: var(--text-tertiary);
    border-radius: 2px; margin: 12px auto; opacity: 0.5;
}
.word-main { display: flex; align-items: center; margin-bottom: 10px; }
.word-english { font-size: 1.5em; font-weight: 700; }
.word-defs { color: var(--text-secondary); margin-bottom: 8px; font-size: 0.95em; line-height: 1.7; }
.word-pos { color: var(--text-tertiary); font-size: 0.8em; margin-bottom: 16px; }
.drawer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.drawer-actions .btn { flex: 1; min-width: 80px; }
.btn-familiar { background: #16A34A; color: #fff; }
.btn-familiar:hover { background: #15803D; }

/* Floating Mode Switch */
.mode-switch-float {
    position: fixed; bottom: 80px; right: 16px; z-index: 50;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--accent); color: #fff;
    box-shadow: var(--shadow-md); display: flex; flex-direction: column;
    align-items: center; justify-content: center; font-size: 0.65em;
    transition: transform 0.2s;
}
.mode-switch-float:active { transform: scale(0.9); }
.mode-switch-float .mode-icon { font-size: 1.3em; }
.mode-switch-float .mode-label { font-size: 0.65em; line-height: 1; }

/* Immersive reading: hide bottom bar */
#bottom-tab-bar.immersive-hidden {
    transform: translateY(100%); opacity: 0; pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
#bottom-tab-bar {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Immersive reading: chapter nav and mode switch also fade */
.chapter-nav.immersive-hidden,
.mode-switch-float.immersive-hidden {
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}

/* Desktop hover enhancement */
@media (hover: hover) {
    .annot-detail:hover { background: rgba(37, 99, 235, 0.05); }
    .word-drawer { transition: transform 0.2s ease; }
}
