/* Tipitaka Pali Web Reader - Modern Professional Theme */

@font-face {
    font-family: 'Pyidaungsu';
    src: url('/static/Pyidaungsu-2.5.3_Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-pali: 'Pyidaungsu', 'Walone', 'Tharlon', 'Padauk', 'Noto Sans Myanmar', 'Myanmar Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-roman-pali: 'Charis SIL', 'Gentium Plus', 'Noto Serif', 'Times New Roman', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 'Pyidaungsu', 'Padauk', 'Myanmar Text', sans-serif;
    
    /* Layout */
    --header-height: 56px;
    --sidebar-width: 320px;
    --dict-width: 380px;

    /* Transition */
    --transition-speed: 0.2s;
}

/* Paper Theme (Default - Warm reading parchment) */
body.theme-paper, [data-theme="paper"] {
    --bg-app: #f5f2eb;
    --bg-header: #ebe6dc;
    --bg-sidebar: #f0ebe0;
    --bg-paper: #f8f1df;
    --bg-surface: #f3eee3;
    --bg-hover: #e5ded2;
    --border-color: #ded6c8;
    --text-primary: #282420;
    --text-secondary: #585047;
    --text-muted: #6d665e;
    --accent: #9c4b18;
    --accent-light: #fbeee6;
    --accent-hover: #823d12;
    --active-tab: #9c4b18;
    --shadow-color: rgba(60, 40, 20, 0.08);
    --dict-bg: #f9f7f2;
    --highlight-bg: #fff0a6;
    --card: #f8f1df;
    --border: #ded6c8;

    /* Semantic + accessibility tokens */
    --on-solid: #ffffff;
    --danger: #b91c1c;
    --success: #047857;
    --info: #1d4ed8;
    --warning: #b45309;
    --shadow-sm: 0 1px 2px var(--shadow-color);
}

/* Crisp Light Theme */
body.theme-light, [data-theme="light"] {
    --bg-app: #f4f6f9;
    --bg-header: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-paper: #ffffff;
    --bg-surface: #f1f4f8;
    --bg-hover: #e8ecf2;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #616b79;
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --accent-hover: #1d4ed8;
    --active-tab: #2563eb;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --dict-bg: #f8fafc;
    --highlight-bg: #fef08a;
    --card: #ffffff;
    --border: #e2e8f0;

    /* Semantic + accessibility tokens */
    --on-solid: #ffffff;
    --danger: #b91c1c;
    --success: #047857;
    --info: #1d4ed8;
    --warning: #b45309;
    --shadow-sm: 0 1px 2px var(--shadow-color);
}

/* Night Theme (Dark Mode) */
body.theme-night, [data-theme="night"] {
    --bg-app: #121519;
    --bg-header: #1a1e24;
    --bg-sidebar: #161a20;
    --bg-paper: #1c2128;
    --bg-surface: #222730;
    --bg-hover: #2d333f;
    --border-color: #2e3540;
    --text-primary: #e6edf3;
    --text-secondary: #9aa5b5;
    --text-muted: #86909d;
    --accent: #e28743;
    --accent-light: #2c221c;
    --accent-hover: #f09a58;
    --active-tab: #e28743;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --dict-bg: #161a20;
    --highlight-bg: #4a3b10;
    --card: #222730;
    --border: #2e3540;

    /* Semantic + accessibility tokens */
    --on-solid: #16191f;
    --danger: #f87171;
    --success: #34d399;
    --info: #60a5fa;
    --warning: #fbbf24;
    --shadow-sm: 0 1px 2px var(--shadow-color);
}

/* Reset & Basics */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-pali);
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: text;
}

button, input, select {
    font-family: var(--font-pali);
}

/* ------------------------------------------------------------
   Accessibility: visible keyboard focus, disabled & motion
   ------------------------------------------------------------ */
/* Show a clear focus ring for keyboard users only (no ring on mouse/touch). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
.icon-btn:disabled,
.icon-btn-sm:disabled,
.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Respect the OS "reduce motion" setting. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* App Header */
.app-header {
    height: var(--header-height);
    min-height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 50;
    box-shadow: 0 1px 3px var(--shadow-color);
    flex-shrink: 0;
    gap: 8px;
    position: relative;
    overflow: visible; /* Allow dropdowns to overflow; clipping is handled per-section */
    min-width: 0;      /* Required for flex children to shrink correctly */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;   /* Never shrink: the JS overflow manager only gives up
                         right-side tools, so Home / edition / book title
                         stay visible at any width or browser zoom. */
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;   /* Page nav never shrinks — it is a core reading control. */
    white-space: nowrap;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;   /* Takes the remaining space; the JS overflow manager
                         moves tools that do not fit into the More ⋮ menu. */
    justify-content: flex-end;
    white-space: nowrap;
    min-width: 0;
    overflow: visible; /* Ensure dropdowns are not clipped */
}

/* Current Book Badge */
.current-book-badge {
    display: flex;
    flex-direction: column;
    margin-left: 4px;
    max-width: 175px;
    overflow: hidden;
    white-space: nowrap;
}

.book-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-primary);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Navigation Controls in Header */
.page-nav-controls {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px 4px;
    gap: 2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-btn {
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--transition-speed);
}

.nav-btn:hover {
    background: var(--bg-hover);
}

.page-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.page-indicator input {
    width: 48px;
    padding: 4px 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-paper);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: bold;
    flex-shrink: 0;
}

.page-total {
    margin-left: 4px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Buttons */
.icon-btn, .tool-btn, .icon-btn-sm {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition-speed);
}

.icon-btn {
    width: 34px;
    height: 34px;
}

.icon-btn-sm {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
    font-weight: bold;
}

.tool-btn {
    padding: 4px 12px;
    height: 34px;
    gap: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.icon-btn:hover, .tool-btn:hover, .icon-btn-sm:hover {
    background: var(--bg-hover);
}

.search-trigger-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.search-trigger-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.kbd-shortcut {
    font-size: 0.75rem;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--text-muted);
}

.dict-toggle-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Font Controls */
.font-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px 4px;
}

#fontSizeDisplay {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: center;
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.theme-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--transition-speed);
}

.theme-btn.active {
    background: var(--bg-paper);
    box-shadow: 0 1px 2px var(--shadow-color);
}

/* Dropdown */
.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 260px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px var(--shadow-color);
    display: none;
    z-index: 100;
}

.dropdown-wrapper.open .dropdown-menu {
    display: block;
}

.dropdown-header {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-list {
    max-height: 250px;
    overflow-y: auto;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

/* App Layout Grid */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Left Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-speed) ease, width var(--transition-speed) ease;
    z-index: 20;
}

.app-sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    border-right: none;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: bold;
}

/* Sidebar Panels */
.sidebar-tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-tab-panel.active {
    display: flex;
}

/* Basket Filter in Books Tab */
.basket-filter-bar {
    display: flex;
    padding: 8px;
    gap: 4px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.basket-btn {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-paper);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.basket-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
}

/* Sidebar Search Box */
.sidebar-search-box {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.toc-search-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toc-search-box input {
    flex: 1;
    min-width: 0;
}

.toc-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-paper);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.toc-toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Tree Lists */
.books-tree-list, .toc-list, .sutta-list, .bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.category-group {
    margin-bottom: 8px;
}

.category-header {
    padding: 12px 8px 4px 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    background: none;
    text-align: center;
    letter-spacing: 0.2px;
}

.book-item-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition-speed);
}

.book-item-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.book-item-btn.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: bold;
}

.book-pages-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Printed-volume badge, e.g. "အံ၊ ဒုတွဲ" next to the book name */
.book-volume-badge {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 0 8px;
    margin-left: 6px;
    white-space: nowrap;
    vertical-align: middle;
}

/* TOC Items */
.toc-item-btn, .sutta-item-btn, .bookmark-item-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-speed);
}

.toc-item-btn:hover, .sutta-item-btn:hover, .bookmark-item-btn:hover {
    background: var(--bg-hover);
}

.toc-item-btn.type-chapter {
    font-weight: bold;
    color: var(--accent);
}

.toc-item-btn.type-title {
    padding-left: 20px;
}

.toc-item-btn.type-subhead {
    padding-left: 28px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.item-page-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 8px;
    white-space: nowrap;
}

/* Hierarchical TOC Tree */
.toc-node-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.toc-item-row {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    border-radius: 8px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-speed);
}

.toc-item-row:hover {
    background: var(--bg-hover);
}

.toc-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: color 0.15s ease, background 0.15s ease;
}

.toc-toggle-btn:hover {
    color: var(--accent);
    background: rgba(0, 0, 0, 0.05);
}

.toc-toggle-btn .toc-chevron {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toc-toggle-btn.expanded .toc-chevron {
    transform: rotate(90deg);
}

.toc-spacer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
}

.toc-spacer::after {
    content: "•";
    color: var(--text-muted);
    font-size: 9px;
    opacity: 0.35;
}

.toc-item-row .toc-item-btn {
    flex: 1;
    min-width: 0;
    margin: 0;
    border-bottom: none;
    padding-left: 4px;
}

.toc-children-list {
    margin-left: 16px;
    padding-left: 6px;
    border-left: 1px dashed var(--border-color);
}


/* Sticky Current Reading Chapter Tracker Card */
.toc-current-card {
    margin: 8px 8px 8px 8px;
    padding: 12px 12px;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.toc-current-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--accent);
}

.toc-current-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.toc-current-tag {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.toc-current-page-pill {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent);
    color: var(--on-solid);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.toc-current-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.toc-current-range {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* TOC & Sutta Active State Tracking */
.toc-item-title-wrapper, .sutta-item-title-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-bullet-icon {
    display: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent);
    flex-shrink: 0;
}

.toc-item-btn.active, .sutta-item-btn.active {
    background: var(--accent-light, rgba(230, 81, 0, 0.12)) !important;
    color: var(--accent) !important;
    font-weight: 600 !important;
    border-left: 4px solid var(--accent);
    padding-left: 8px;
    border-bottom-color: transparent;
}

.toc-item-btn.active .toc-bullet-icon, .sutta-item-btn.active .toc-bullet-icon {
    display: inline-block;
    box-shadow: 0 0 5px var(--accent);
    animation: tocPulse 2s infinite ease-in-out;
}

.toc-item-btn.active .item-page-badge, .sutta-item-btn.active .item-page-badge {
    background: var(--accent);
    color: var(--on-solid) !important;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
}

@keyframes tocPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.75; }
}

@keyframes tocFlash {
    0% { background: var(--accent); color: var(--on-solid); }
    100% { background: var(--accent-light, rgba(230, 81, 0, 0.12)); color: var(--accent); }
}

.toc-flash-highlight {
    animation: tocFlash 1s ease-out;
}

/* Mobile & Tablet Dynamic Chapter Breadcrumb (Sticky Tappable Bar) */
/* Mobile sticky header: breadcrumb + edition pills (v7.60) */
.mobile-sticky-header {
    display: none; /* Displayed via media query on mobile & tablet */
    position: sticky;
    top: 0;
    z-index: 70;
    width: 100%;
    max-width: 860px;
    background: var(--bg-app);
    box-sizing: border-box;
}

.mobile-breadcrumb-wrapper {
    display: flex; /* Always flex inside sticky header */
    width: 100%;
    padding: 8px 0;
    box-sizing: border-box;
}

/* Edition Pills Bar removed in v7.61 (superseded by the Edition Switcher modal) */

.mobile-chapter-breadcrumb {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--shadow-color, rgba(0, 0, 0, 0.05));
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, transform 0.1s ease;
    box-sizing: border-box;
}

.mobile-chapter-breadcrumb:active {
    transform: scale(0.99);
    background: var(--bg-hover);
}

.breadcrumb-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.breadcrumb-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
}

.breadcrumb-book {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 120px;
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.breadcrumb-chapter {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.breadcrumb-page {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent);
    color: var(--on-solid);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.breadcrumb-arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: bold;
}

/* Feed Divider Chapter Styling */
.badge-chapter {
    font-weight: 600;
    color: var(--accent);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-sep {
    color: var(--text-muted);
    margin: 0 1px;
}

/* Center Reader */
.reader-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 40px 16px;
    background: var(--bg-app);
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
}

.reader-paper {
    width: 100%;
    max-width: 860px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow-color);
    padding: 40px 48px;
    min-height: calc(100vh - 120px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: auto;
    flex-shrink: 0;
    margin-bottom: 32px;
    position: relative;
    font-size: 1.25rem;
    line-height: 2.15 !important;
    letter-spacing: 0.015em;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1;
    -webkit-font-smoothing: antialiased;
}

.reader-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.meta-book {
    font-weight: bold;
    color: var(--accent);
}

/* Pali Native Content Styling */
.pali-content {
    flex: 1 0 auto;
    width: 100%;
    overflow: visible;
}

.pali-content p,
.split-pane-body p {
    margin-bottom: 1.4em;
    text-align: justify;
    text-justify: inter-character;
}

/* Prevent line-break splitting of stacked consonants (virama +).
   .pali-word allows natural wrapping at safe <wbr> boundaries and spaces,
   while retaining the complete semantic word for dictionary lookup. */
.no-split {
    white-space: nowrap;
}

.pali-content .nikaya {
    text-align: center;
    font-size: 1.4em;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 0.5em;
}

.pali-content .book {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.6em;
}

.pali-content .chapter {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent);
    margin: 1.2em 0 0.8em 0;
}

.pali-content .centered {
    text-align: center;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 1.2em;
}

.pali-content .paranum {
    display: inline-block;
    font-weight: bold;
    color: var(--accent);
    margin-right: 8px;
    background: var(--accent-light);
    padding: 0 8px;
    border-radius: 6px;
    line-height: 1.5;
}

.pali-content .bodytext,
.split-pane-body .bodytext {
    text-indent: 2em;
    text-align: justify;
}

.pali-content .noindentbodytext,
.split-pane-body .noindentbodytext {
    text-indent: 0;
    text-align: justify;
}

.split-pane-body .indented,
.split-pane-body .indent {
    text-align: justify;
}


.pali-content .hangnum {
    float: left;
    clear: left;
    width: 4.5rem;
    margin: 0;
    padding: 0;
    line-height: inherit;
    text-align: left;
    white-space: nowrap;
}

.pali-content .gatha1,
.pali-content .gatha2,
.pali-content .gatha3,
.pali-content .gatha4,
.pali-content .gathalast,
.split-pane-body .gatha1,
.split-pane-body .gatha2,
.split-pane-body .gatha3,
.split-pane-body .gatha4,
.split-pane-body .gathalast {
    margin-left: 4.8rem;
    text-indent: 0 !important;
    text-align: left;
    margin-top: 0;
    margin-bottom: 0.35em;
    color: var(--text-primary);
}

.pali-content .gathalast,
.split-pane-body .gathalast {
    margin-bottom: 1.4em;
}

/* Gāthā Pāda Styling: Desktop inline couplets (အတွဲလိုက်), Mobile/Split one-pāda-per-line (တစ်ပါဒ တစ်ကြောင်း) */
.gatha-pada {
    display: inline;
}
.gatha-pada.pada1 {
    margin-right: 0.8em;
}

@media (max-width: 768px) {
    .pali-content .hangnum,
    .split-pane-body .hangnum {
        width: 3.4rem;
    }
    .pali-content .gatha1,
    .pali-content .gatha2,
    .pali-content .gatha3,
    .pali-content .gatha4,
    .pali-content .gathalast,
    .split-pane-body .gatha1,
    .split-pane-body .gatha2,
    .split-pane-body .gatha3,
    .split-pane-body .gatha4,
    .split-pane-body .gathalast {
        margin-left: 3.6rem;
    }

    /* Mobile: တစ်ပါဒ ပြီးလျှင် နောက်တစ်ကြောင်းတွင် တစ်ပါဒ ပြသခြင်း */
    .gatha-pada {
        display: block !important;
        margin-right: 0 !important;
    }
    .gatha-pada.pada1 {
        margin-bottom: 0.2em;
    }
    .pali-content .gatha1,
    .pali-content .gatha2,
    .pali-content .gatha3,
    .pali-content .gatha4,
    .split-pane-body .gatha1,
    .split-pane-body .gatha2,
    .split-pane-body .gatha3,
    .split-pane-body .gatha4 {
        margin-bottom: 0.65em;
    }
}

/* Split View: Panes are narrow, display one pāda per line */
.split-pane-body .gatha-pada {
    display: block !important;
    margin-right: 0 !important;
}
.split-pane-body .gatha-pada.pada1 {
    margin-bottom: 0.2em;
}
.split-pane-body .gatha1,
.split-pane-body .gatha2,
.split-pane-body .gatha3,
.split-pane-body .gatha4 {
    margin-bottom: 0.65em;
}

/* Footnotes / Variant Readings */
.note {
    font-size: 0.88em;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 2px 4px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    margin: 0 2px;
    display: inline;
}

body.hide-notes .note {
    display: none !important;
}

.notes-toggle-btn.active {
    background: var(--accent-light) !important;
    border-color: var(--accent) !important;
    color: var(--accent) !important;
    font-weight: bold;
}

/* Interactive Word Highlight on Hover */
.pali-content {
    cursor: pointer;
}

/* Page Scroll Indicator & Floating Toast */
.scroll-page-toast {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--accent);
    color: var(--on-solid);
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: bold;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.page-scroll-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 28px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-speed);
    width: 100%;
    box-sizing: border-box;
}

.page-scroll-indicator:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.page-scroll-indicator .indicator-icon {
    font-size: 0.75rem;
    color: var(--accent);
    animation: bounceDown 1.6s infinite ease-in-out;
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

.scroll-opt-btn.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: bold;
}

.mobile-scroll-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    font-weight: bold;
    border-color: var(--accent);
}

/* Facebook Style Continuous Feed Scroll */
.feed-page-item {
    margin-bottom: 24px;
    animation: fadeInFeed 0.3s ease-out;
}

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

.page-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px 0 28px 0;
    gap: 16px;
    user-select: none;
    position: relative;
}

.page-divider .divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.page-divider .divider-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.page-divider .divider-badge:hover {
    border-color: var(--accent);
}

/* v7.42: badges are tappable again — a tap opens the inline jump row right
   below the badge. This restores the pre-v7.39 learned interaction; v7.39 had
   made badges static, which stranded continuous-scroll readers (the footer
   pill is unreachable while infinite scroll keeps appending pages). */
.page-divider .divider-badge {
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.page-divider .divider-badge .badge-text {
    border-bottom: 1px dotted var(--text-muted);
    padding-bottom: 1px;
}

/* Load Previous Page Box */
.load-prev-box {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.load-prev-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-sm);
}

.load-prev-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Infinite Sentinel & Loader */
.infinite-sentinel {
    min-height: 20px;
    padding: 16px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.sentinel-loading {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 12px 16px;
}

.sentinel-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: sentinelSpin 0.75s infinite linear;
}

@keyframes sentinelSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sentinel-end {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
    padding: 12px 0;
}

/* Footer Navigation */
.reader-footer-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 100%;
}

.footer-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.footer-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.footer-page-info {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Right Dictionary Sidebar */
.dict-sidebar {
    width: var(--dict-width);
    background: var(--dict-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-speed) ease, width var(--transition-speed) ease;
    z-index: 20;
}

.dict-sidebar.collapsed {
    transform: translateX(100%);
    width: 0;
    border-left: none;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}

.dict-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
}

.dict-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: var(--accent);
    font-size: 1rem;
}

.dict-search-bar {
    display: flex;
    padding: 8px;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.dict-search-bar input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.dict-search-btn {
    padding: 8px 12px;
    background: var(--accent);
    border: none;
    color: var(--on-solid);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
}

.dict-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.dict-welcome {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.dict-welcome h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.125rem;
}

.dict-welcome p {
    font-size: 0.875rem;
    line-height: 1.7;
    margin-bottom: 16px;
}

.dict-sources-info {
    text-align: left;
    background: var(--bg-surface);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dict-sources-info ul {
    margin-left: 20px;
    margin-top: 8px;
}

/* Dictionary Results Styling */
.dict-result-header {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.dict-result-word {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent);
}

.dict-stem-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dict-entry-card {
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px var(--shadow-color);
}

.dict-book-badge {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.dict-def-body {
    font-size: 0.95rem;
    line-height: 1.8;
}

.dict-def-body .word {
    font-weight: bold;
    color: var(--accent);
}

.dict-def-body .gender {
    color: var(--warning);
    font-style: italic;
}

.dict-def-body .viggaha {
    background: var(--bg-surface);
    padding: 4px 8px;
    border-radius: 6px;
    margin: 8px 0;
    font-size: 0.88rem;
}

.dict-def-body .reference, .dict-def-body .source {
    display: block;
    text-align: right;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Universal Search Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    z-index: 200;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-paper);
    width: 90%;
    max-width: 680px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
}

.clear-search-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Search Modal Scope Bar (Tier 1: Pali vs Myanmar Toggle) */
.search-scope-bar {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.search-scope-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-paper);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.search-scope-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.search-scope-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.search-scope-btn .scope-icon {
    font-size: 1rem;
    line-height: 1;
}

.search-scope-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Book scope row: keep the current-book name from overflowing its pill */
.book-scope-bar .search-scope-btn {
    min-width: 0;
}

.book-scope-bar .search-scope-btn span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Search Modal Subtabs / Action Pills (Tier 2) */
.search-subtabs-container {
    padding: 8px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.modal-tabs-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.modal-tab-btn {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-paper);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-speed);
}

.modal-tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.modal-tab-btn.active {
    background: var(--accent-light, rgba(230, 81, 0, 0.12));
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.modal-tab-btn .tab-icon {
    font-size: 0.95rem;
    line-height: 1;
    flex-shrink: 0;
}

.modal-tab-btn > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Very small phones: hide pill icons so all 4 pills fit without overflow */
@media (max-width: 380px) {
    .modal-tab-btn .tab-icon {
        display: none;
    }
}

@media (max-width: 480px) {
    .search-scope-bar {
        padding: 6px 10px;
        gap: 6px;
    }
    .search-scope-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        gap: 4px;
    }
    .search-subtabs-container {
        padding: 6px 10px;
    }
    .modal-tabs-group {
        gap: 4px;
    }
    .modal-tab-btn {
        padding: 6px 4px;
        font-size: 0.76rem;
        gap: 2px;
    }
    .modal-tab-btn .tab-icon {
        font-size: 0.82rem;
    }
}

.search-summary {
    padding: 8px 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    display: none;
}

.search-results-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.search-hint {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.search-result-item {
    display: block;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    color: inherit;
    background: var(--bg-paper);
}

.search-result-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.res-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.res-book {
    font-weight: bold;
    color: var(--accent);
    font-size: 0.875rem;
}

.res-page {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.res-snippet {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.res-snippet mark.search-highlight {
    background: rgba(245, 158, 11, 0.28);
    color: var(--accent);
    font-weight: 600;
    border-radius: 3px;
    padding: 1px 3px;
}

/* Quick Popover */
.dict-quick-popover {
    position: absolute;
    width: 280px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 150;
    padding: 12px;
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.popover-word {
    font-weight: bold;
    color: var(--accent);
}

.popover-close {
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--text-muted);
}

.popover-body {
    font-size: 0.875rem;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
}

.popover-full-btn {
    width: 100%;
    margin-top: 8px;
    padding: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
}

/* Empty / Loading States */
.loading-state, .empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Edition Switcher */
.edition-switcher {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    margin-left: 2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.edition-btn {
    border: none;
    background: none;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-speed);
    white-space: nowrap;
    flex-shrink: 0;
}

.edition-btn:hover {
    color: var(--text-primary);
}

.edition-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    font-weight: bold;
    box-shadow: 0 1px 3px var(--shadow-color);
}

/* Cross Link Button */
.cross-link-btn {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
}

.cross-link-btn:hover {
    background: var(--accent);
    color: var(--on-solid);
}

/* Unified Edition Switcher hub ("ကျမ်းရွေး") — the primary, always-visible way
   to move between Pāḷi ⇄ Aṭṭhakathā ⇄ Ṭīkā ⇄ မြန်မာပြန် ⇄ နိဿယ. Filled accent
   so it reads as the main action, while quick cross-links stay outline style. */
.edition-hub-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-solid);
}

.edition-hub-btn:hover {
    background: var(--accent);
    color: var(--on-solid);
    filter: brightness(1.08);
}

.meta-edition-tag {
    font-size: 0.75rem;
    background: var(--accent-light);
    color: var(--accent);
    padding: 1px 8px;
    border-radius: 6px;
    font-weight: bold;
}

/* Dual Split View (Pali + Myanmar Side by Side) */
.split-view-container {
    display: flex;
    width: 100%;
    max-width: 1300px;
    gap: 16px;
    min-height: calc(100vh - 100px);
}

.split-pane {
    flex: 1;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 16px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.split-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    font-size: 0.875rem;
    gap: 8px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.split-pane-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.split-pane-title {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-pane-title strong {
    color: var(--accent);
}

/* Dynamic Companion Tabs Bar in Split View Right Pane */
.companion-tabs-bar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-paper);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.comp-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-speed);
}

.comp-tab:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.comp-tab.active {
    color: var(--on-solid);
    background: var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Companion Volume Selector */
.comp-volume-box {
    display: inline-flex;
    align-items: center;
}

.comp-volume-select {
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-paper);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.comp-volume-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* Enhanced Companion Dropdown Menu */
.companion-dropdown-menu {
    width: 340px !important;
    max-height: 480px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.dropdown-wrapper.open .companion-dropdown-menu {
    display: flex;
}

.companion-dropdown-menu .dropdown-header {
    background: var(--bg-surface);
    color: var(--accent);
    font-weight: bold;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.companion-dropdown-menu .dropdown-list {
    overflow-y: auto;
    max-height: 420px;
    padding: 8px 12px;
}

.comp-group {
    margin-bottom: 12px;
}

.comp-group:last-child {
    margin-bottom: 2px;
}

.comp-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    padding: 4px 8px 2px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comp-group-badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.75rem;
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.comp-card-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 12px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--transition-speed);
}

.comp-card-item:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.comp-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.comp-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comp-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.comp-btn-split {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.comp-btn-split:hover {
    background: var(--accent);
    color: var(--on-solid);
}

.comp-btn-goto {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-paper);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.comp-btn-goto:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.split-pane-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.split-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.split-nav-btn:hover:not(:disabled) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.split-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.split-nav-page-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-paper);
    padding: 2px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.split-nav-input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--bg-surface);
    outline: none;
    -moz-appearance: textfield;
}

.split-nav-input::-webkit-outer-spin-button,
.split-nav-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.split-nav-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.split-nav-total {
    font-weight: 500;
    color: var(--text-muted);
}

.split-sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.split-sync-btn:hover {
    background: var(--accent);
    color: var(--on-solid);
    box-shadow: 0 2px 8px var(--shadow-color);
}

/* Clickable Paragraph Numbers in Split View */
.split-pane-body .paranum,
.split-pane-body .paragraph {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 0 2px;
}

.split-pane-body .paranum:hover,
.split-pane-body .paragraph:hover {
    background: var(--accent-light);
    color: var(--accent);
    text-decoration: underline;
}

/* Flash highlight animation when jumping to matching paragraph */
@keyframes paraFlashHighlight {
    0% { background-color: var(--accent-light); transform: scale(1.02); }
    50% { background-color: rgba(234, 179, 8, 0.4); }
    100% { background-color: transparent; transform: scale(1); }
}

.para-highlight-pulse {
    animation: paraFlashHighlight 2s ease-out;
    border-radius: 4px;
}

.split-pane-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    font-size: 1.15rem;
    line-height: 2;
    scroll-behavior: smooth;
}

/* Myanmar Translation Typography Enhancements */
.split-pane-body h1, .pali-content h1 {
    font-size: 1.35em;
    color: var(--accent);
    text-align: center;
    margin: 0.8em 0 0.5em 0;
}

.split-pane-body h2, .pali-content h2 {
    font-size: 1.2em;
    color: var(--accent);
    margin: 0.8em 0 0.4em 0;
}

.split-pane-body h3, .pali-content h3 {
    font-size: 1.1em;
    color: var(--text-primary);
    margin: 0.6em 0 0.3em 0;
}

.split-pane-body blockquote, .pali-content blockquote {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    margin: 1em 0;
    border-radius: 0 6px 6px 0;
}

.split-pane-body .paragraph, .pali-content .paragraph {
    display: inline-block;
    font-weight: bold;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0 8px;
    border-radius: 4px;
    margin-right: 4px;
}

.split-pane-body .unindent, .pali-content .unindent {
    text-indent: 0;
}

.split-pane-body .pali_title, .pali-content .pali_title {
    color: var(--accent);
    font-style: italic;
    font-size: 0.95em;
}

.split-pane-body .ending, .pali-content .ending {
    text-align: center;
    color: var(--accent);
    font-weight: bold;
    margin-top: 1.5em;
}

/* User Guide / Help Modal Styling */
.help-modal-dialog {
    max-width: 820px;
    max-height: 88vh;
}

.help-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--accent);
}

.help-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    font-size: 1rem;
    line-height: 1.8;
}

.guide-nav-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.guide-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.guide-nav-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.guide-nav-tab.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.guide-tab-panel {
    display: none;
}

.guide-tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

.guide-welcome-box {
    background: var(--bg-surface);
    border-left: 4px solid var(--accent);
    border-radius: 0 16px 16px 0;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.guide-welcome-box h3 {
    font-size: 1.125rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.guide-section {
    margin-bottom: 28px;
}

.guide-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.guide-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-solid);
    font-size: 0.875rem;
    font-weight: bold;
}

.guide-desc {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.guide-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.guide-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    transition: transform var(--transition-speed);
}

.guide-card.highlight-card {
    background: var(--accent-light);
    border-color: var(--accent);
}

.guide-card .card-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.guide-card h5 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.guide-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.guide-info-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px 20px;
}

.guide-info-box ul {
    margin-left: 20px;
}

.guide-info-box li {
    margin-bottom: 8px;
}

.guide-badge {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: bold;
    display: inline-block;
}

.guide-feature-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.guide-feature-row:last-child {
    margin-bottom: 0;
}

.feature-badge-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.guide-shortcut-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.guide-shortcut-table th, .guide-shortcut-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.guide-shortcut-table th {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: bold;
}

.guide-shortcut-table code {
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--accent);
    font-weight: bold;
}

/* ============================================================
   Header More (⋮) Overflow Dropdown
   ============================================================ */

/* "More" dropdown wrapper — hidden by default on large screens */
.header-more-dropdown {
    display: none;  /* Only shown via media queries when overflow items are hidden */
}

.header-more-btn {
    gap: 4px;
}

.header-more-menu {
    min-width: 220px;
    right: 0;
    left: auto;
}

.header-more-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 0.875rem;
}

/* Sync dict active state in more menu */
.header-more-menu .more-menu-dict.dict-active {
    color: var(--accent);
    background: var(--accent-light);
}

/* Tools moved into the More menu by the header overflow manager (JS).
   They are the real buttons, only re-presented as menu rows, so every
   handler keeps working. Labels are forced visible here even when a
   narrow-width media query hides .btn-text in the bar (the JS also sets
   the label's inline display, which wins over those rules). */
.header-more-menu .in-more-menu {
    display: flex !important;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    height: auto;
    min-height: 40px;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 0.875rem;
    white-space: normal;
    flex-shrink: 0;
}
.header-more-menu .font-controls.in-more-menu,
.header-more-menu .theme-switcher.in-more-menu {
    justify-content: center;
    padding: 10px 16px;
}
.header-more-menu .in-more-menu .btn-icon {
    flex-shrink: 0;
}

/* ============================================================
   Responsive Media Queries & Screen Adaptations
   ============================================================ */

/* Stage 1: Large Laptops & Standard Monitors (<= 1720px) */
@media (max-width: 1720px) {
    .kbd-shortcut {
        display: none !important;
    }
    .chapter-title {
        display: none !important;
    }
    .current-book-badge {
        max-width: 130px;
    }
    /* Hide text on secondary utilities first */
    #btnOpenHelp .btn-text,
    #btnToggleFullscreen .btn-text {
        display: none !important;
    }
}

/* Stage 2: Medium Laptops & Standard Desktops (<= 1560px) - Prevents header buttons clipping */
@media (max-width: 1560px) {
    .app-header {
        padding: 0 8px;
        gap: 4px;
    }
    .header-left {
        gap: 4px;
    }
    .header-right {
        gap: 4px;
    }
    .tool-btn {
        padding: 4px 8px;
        gap: 4px;
    }
    /* Collapse text for search, history, related commentary, and dictionary */
    #btnOpenSearch .btn-text,
    #btnRelated .btn-text,
    #btnOpenHistory .btn-text,
    #btnToggleDict .btn-text {
        display: none !important;
    }
    /* Show clean arrows only in page navigation */
    .nav-btn span {
        display: none !important;
    }
    .nav-btn {
        padding: 4px 8px;
    }
    .current-book-badge {
        max-width: 110px;
    }
    /* Hide Help & Fullscreen from header bar — moved to More ⋮ dropdown */
    #btnOpenHelp,
    #btnToggleFullscreen {
        display: none !important;
    }
    /* Show the More dropdown button to give access to hidden items */
    .header-more-dropdown {
        display: flex;
    }
    .header-more-btn .more-btn-label {
        display: none !important; /* Icon-only at this size */
    }
}


/* Stage 3: Compact Laptops & Split Windows (<= 1380px) */
@media (max-width: 1380px) {
    /* Collapse remaining text labels into clean, sleek icon buttons */
    #btnToggleNotes .btn-text,
    #btnScrollMode .btn-text,
    #crossLinkLabel,
    #editionHubLabel,
    #nissayaCrossLinkLabel {
        display: none !important;
    }
    .current-book-badge {
        max-width: 90px;
    }
    .edition-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    .font-controls {
        padding: 1px 4px;
        gap: 2px;
    }
    #fontSizeDisplay {
        min-width: 32px;
        font-size: 0.75rem;
    }
    .icon-btn-sm {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }
    .theme-switcher {
        padding: 1px;
        gap: 1px;
    }
    .theme-btn {
        padding: 4px 4px;
        font-size: 0.875rem;
    }
    /* Hide History button entirely to free space */
    #btnOpenHistory {
        display: none !important;
    }
}

/* Stage 4: Small Displays & Landscape Tablets (<= 1180px) */
@media (max-width: 1180px) {
    .app-header {
        gap: 4px;
        padding: 0 8px;
    }
    .current-book-badge {
        display: none !important;
    }
    .edition-btn-text {
        display: none !important; /* Shows icons ☸️, 🇲🇲, 📖 only */
    }
    .edition-btn {
        padding: 4px 8px;
        min-width: 32px;
        text-align: center;
    }
    .tool-btn {
        min-width: 32px;
        height: 32px;
        padding: 4px 8px;
    }
    .icon-btn {
        width: 32px;
        height: 32px;
    }
    /* 44px touch targets: expand tap area without changing visual layout */
    .icon-btn, .nav-btn, .tool-btn { position: relative; }
    .icon-btn::after, .nav-btn::after, .tool-btn::after {
        content: '';
        position: absolute;
        inset: -6px;
    }
    .icon-btn-sm::after {
        content: '';
        position: absolute;
        inset: -9px;
    }
    .icon-btn-sm { position: relative; }
    /* Hide font controls and dict from header bar — accessible from mobile drawer / More menu */
    .font-controls,
    #btnToggleDict {
        display: none !important;
    }
    /* Show More dropdown (if not already shown) */
    .header-more-dropdown {
        display: flex;
    }
}


/* Sidebar Backdrop for Mobile Drawers */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 85;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transition: opacity var(--transition-speed);
}
.sidebar-backdrop.active {
    display: block;
}

/* Mobile Drawer Controls */
.mobile-drawer-controls {
    display: none;
    padding: 12px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}
.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
/* Tappable header row: collapses/expands the quick-controls body */
.mobile-drawer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 8px 4px;
    margin: -8px -4px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    flex: 1;
    text-align: left;
    min-height: 40px;
}
.drawer-chevron {
    font-size: 0.875rem;
    line-height: 1;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}
.mobile-drawer-controls.controls-collapsed .drawer-chevron {
    transform: rotate(180deg);
}
.mobile-drawer-controls.controls-collapsed .mobile-drawer-body {
    display: none;
}
.mobile-drawer-controls.controls-collapsed .mobile-drawer-header {
    margin-bottom: 0;
}
.mobile-drawer-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-secondary);
}
.mobile-edition-switcher {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.mobile-edition-switcher .edition-btn {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
}
.mobile-edition-switcher .edition-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    font-weight: bold;
    border-color: var(--accent);
}
.mobile-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Tablets (<= 992px) */
@media (max-width: 992px) {
    .mobile-drawer-controls {
        display: block;
    }
    /* Keep the five drawer tabs on one line in the narrow drawer */
    .tab-btn {
        font-size: 0.75rem;
        white-space: nowrap;
        padding: 8px 2px;
        gap: 4px;
        min-width: 0;
    }
    .tab-btn span {
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .tab-btn svg {
        width: 14px;
        height: 14px;
    }
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 310px;
        max-width: 85vw;
        z-index: 100;
        background: var(--bg-sidebar) !important;
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
        transition: transform var(--transition-speed) ease;
    }
    .app-sidebar.collapsed {
        display: none !important;
        width: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateX(-100%) !important;
    }
    .dict-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: 360px;
        max-width: 88vw;
        z-index: 100;
        background: var(--dict-bg) !important;
        box-shadow: -4px 0 24px rgba(0,0,0,0.35);
        transition: transform var(--transition-speed) ease;
    }
    .dict-sidebar.collapsed {
        display: none !important;
        width: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateX(100%) !important;
    }
    .edition-switcher,
    .theme-switcher,
    .font-controls,
    .current-book-badge,
    #relatedDropdownWrapper,
    #btnBookmarkToggle {
        display: none !important;
    }
    .reader-paper {
        padding: 24px 20px;
        font-size: 1.15rem;
    }
    .reader-container {
        padding-top: 0 !important;
    }
    .mobile-sticky-header {
        display: block;
    }
    .toc-item-btn {
        padding: 8px 12px;
        min-height: 42px;
        font-size: 0.875rem;
    }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    :root {
        --header-height: 50px;
    }
    .app-header {
        padding: 0 8px;
        overflow-x: hidden !important;
    }
    .header-left, .header-center, .header-right {
        gap: 4px;
    }
    
    /* Ensure all text labels inside tool buttons are hidden on mobile header */
    .tool-btn .btn-text,
    .tool-btn .kbd-shortcut {
        display: none !important;
    }

    /* Cross-link button: compact badge */
    .cross-link-btn {
        padding: 4px 8px !important;
        font-size: 0.875rem !important;
    }

    /* Hide redundant tools from mobile header (Dict is in drawer, Help is in drawer) */
    #btnOpenHelp,
    #btnToggleDict,
    .header-more-dropdown {
        display: none !important;
    }

    /* Page Navigation Controls on Mobile */
    .page-nav-controls {
        padding: 1px 2px;
        gap: 2px;
    }
    .nav-btn {
        padding: 4px 8px;
        font-size: 0.875rem;
    }
    .nav-btn span {
        display: none !important; /* Icon only (< and >) on mobile */
    }
    .page-indicator input {
        width: 44px;
        padding: 2px 0;
        font-size: 0.875rem;
        text-align: center;
    }
    .page-total {
        font-size: 0.75rem;
        margin-left: 2px;
    }
    
    /* Toolbar Buttons on Mobile */
    .tool-btn {
        height: 32px;
        min-width: 32px;
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    .icon-btn {
        width: 32px;
        height: 32px;
    }
    #crossLinkLabel {
        font-size: 0.75rem;
    }

    /* Dropdown Menus on Mobile (Ensure they never clip off-screen) */
    .dropdown-menu {
        position: fixed !important;
        top: calc(var(--header-height) + 4px) !important;
        right: 8px !important;
        left: auto !important;
        max-width: calc(100vw - 16px) !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
    }
    
    /* Reader Canvas on Mobile */
    .reader-container {
        padding: 0 8px 84px 8px !important;
    }
    .reader-paper {
        padding: 20px 16px !important;
        font-size: 1.12rem !important;
        line-height: 2 !important;
        border-radius: 16px;
        margin-bottom: 20px;
    }
    .reader-header-meta {
        font-size: 0.75rem;
        margin-bottom: 16px;
        padding-bottom: 8px;
    }
    .reader-footer-nav {
        flex-direction: row;
        justify-content: space-between;
        margin-top: 24px;
        padding-top: 16px;
        gap: 8px;
    }
    .footer-nav-btn {
        padding: 8px 12px;
        font-size: 0.875rem;
        gap: 4px;
    }
    .footer-page-info {
        font-size: 0.875rem;
    }

    /* Modal dialogs full-width on mobile */
    .modal-dialog {
        width: 95% !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
    }
    .help-modal-dialog {
        max-width: 95% !important;
    }
    .help-modal-body {
        padding: 16px !important;
    }
    .guide-nav-tabs {
        padding: 8px 12px !important;
        gap: 6px !important;
    }
    .guide-nav-tab {
        padding: 6px 12px !important;
        font-size: 0.82rem !important;
    }

    /* Mobile Bottom Sheet Popover */
    .dict-quick-popover {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        bottom: 12px !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        max-height: 52vh !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 32px rgba(0,0,0,0.4) !important;
        z-index: 1000 !important;
    }

    /* Split View stacked vertically on mobile */
    .split-view-container {
        flex-direction: column !important;
        gap: 12px;
        min-height: auto;
    }
    .split-pane {
        min-height: 44vh;
        max-height: 55vh;
    }
    .split-pane-body {
        padding: 16px 16px !important;
        font-size: 1.05rem !important;
    }
}

/* ============================================================
   Home Page / APK Style Catalog View (တိပိဋက မာတိကာ စာမျက်နှာ)
   ============================================================ */
body.view-home .app-header {
    display: none !important;
}

body.view-home .dict-sidebar.collapsed {
    display: none !important;
}

body.view-home .app-sidebar.collapsed {
    display: none !important;
}

body.view-home .dict-sidebar:not(.collapsed) {
    display: flex !important;
}

body.view-home .app-sidebar:not(.collapsed) {
    display: flex !important;
}

body.view-home .reader-container {
    display: none !important;
}

body.view-home .split-view-container {
    display: none !important;
}

body.view-home .home-page-container {
    display: flex !important;
}

body.view-reader .home-page-container {
    display: none !important;
}

.home-page-container {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    background: var(--bg-app);
    position: relative;
    overflow: hidden;
    z-index: 10;
}

.home-page-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px 0 20px;
    flex-shrink: 0;
}

.home-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.home-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-app-icon {
    font-size: 1.5rem;
}

.home-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.home-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-mode-toggle-btn {
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-speed);
}

.home-mode-toggle-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* 4 Basket Tabs matching APK: ပါဠိ, အဋ္ဌကထာ, ဋီကာ, အည */
.home-basket-tabs {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.home-basket-tab {
    flex: 1;
    text-align: center;
    padding: 12px 4px;
    background: none;
    border: none;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.home-basket-tab:hover {
    color: var(--text-primary);
}

.home-basket-tab.active {
    color: var(--text-primary);
    font-weight: bold;
    border-bottom: 3px solid var(--accent);
}

/* Home Catalog Scroll Area */
.home-catalog-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 84px 16px; /* 84px for bottom nav & FAB clearance */
}

/* Continue Reading card (ဆက်ဖတ်ရန်) — layered design */
.home-continue-card {
    margin: 12px 16px 0 16px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 1px 3px var(--shadow-color, rgba(0, 0, 0, 0.06));
}
.home-continue-card:active {
    transform: scale(0.98);
}
.home-continue-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.home-continue-book {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.home-continue-page {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.home-catalog-inner {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

.home-cat-section {
    margin-bottom: 20px;
}

.home-cat-header {
    text-align: center;
    color: #ff6b35;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 24px 0 12px 0;
    letter-spacing: 0.3px;
}

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

.home-book-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.125rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.home-book-row:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.home-book-row:active {
    background: var(--accent-light);
}

.home-book-name {
    font-weight: 400;
}

/* Floating Sutta Button (သုတ္တ) matching APK */
.floating-sutta-btn {
    position: fixed;
    bottom: 74px;
    right: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-solid);
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px var(--shadow-color);
    border: none;
    cursor: pointer;
    z-index: 99;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-sutta-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px var(--shadow-color);
}

.floating-sutta-btn:active {
    transform: scale(0.96);
}

/* Bottom Navigation Bar matching APK */
.bottom-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
}

.bottom-nav-item {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s ease;
}

.bottom-nav-item svg {
    stroke: currentColor;
    transition: stroke 0.15s ease;
}

.bottom-nav-item:hover {
    color: var(--text-primary);
}

.bottom-nav-item.active {
    color: var(--accent);
    font-weight: 600;
}

.bottom-nav-item.active svg {
    stroke: var(--accent);
}

/* Adjust reader container padding to avoid overlap with bottom nav */
.reader-container {
    padding-bottom: 76px !important;
}

/* Active basket button in sidebar matching APK */
.basket-filter-bar {
    display: flex;
    gap: 4px;
    padding: 8px 8px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.basket-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: all var(--transition-speed);
}

.basket-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
    font-weight: bold;
}

/* ==========================================================================
   Comprehensive History Modal (Reading & Search History)
   ========================================================================== */

.history-modal-dialog {
    width: 92%;
    max-width: 760px;
    max-height: 86vh;
    border-radius: 16px;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.history-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-modal-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

/* Short title shown only on small screens (long title hidden there) */
.history-title-short {
    display: none;
}

.history-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.history-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-paper);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-surface);
}

.history-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-clear-btn:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.35);
}

.history-toolbar {
    padding: 12px 20px 8px 20px;
    background: var(--bg-paper);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-search-wrapper {
    width: 100%;
}

.history-nav-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.history-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.history-tab-btn.active {
    background: var(--bg-surface);
    color: var(--accent);
    font-weight: 600;
    border-color: var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.history-badge-count {
    background: var(--border-color);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-tab-btn.active .history-badge-count {
    background: var(--accent);
    color: var(--on-solid);
}

.history-filter-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.history-pill {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.history-pill.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
    font-weight: 600;
}

.history-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 24px 20px;
}

.history-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 8px 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    border-bottom: 1px dashed var(--border-color);
    margin-top: 16px;
    margin-bottom: 8px;
}

.history-date-header:first-child {
    margin-top: 0;
}

.history-date-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

.history-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-item-card:hover {
    border-color: var(--accent);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.history-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.history-card-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.history-mode-badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-mode-badge.badge-pali {
    background: rgba(230, 81, 0, 0.12);
    color: #e65100;
    border: 1px solid rgba(230, 81, 0, 0.25);
}

.history-mode-badge.badge-mm {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, 0.25);
}

.history-mode-badge.badge-split {
    background: rgba(103, 58, 183, 0.12);
    color: #673ab7;
    border: 1px solid rgba(103, 58, 183, 0.25);
}

.history-mode-badge.badge-search {
    background: rgba(2, 136, 209, 0.12);
    color: #0288d1;
    border: 1px solid rgba(2, 136, 209, 0.25);
}

.history-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.history-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.meta-dot {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.history-time-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-delete-history {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-delete-history:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.history-empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.history-empty-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.history-empty-state p {
    font-size: 1rem;
    margin-bottom: 8px;
}

.history-empty-state .empty-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .history-modal-dialog {
        width: 95% !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
    }
    .history-modal-header {
        padding: 12px 16px;
    }
    .history-toolbar {
        padding: 12px 16px 8px 16px;
    }
    .history-modal-body {
        padding: 12px 16px 20px 16px;
    }
    .history-item-card {
        padding: 8px 12px;
        gap: 8px;
    }
    .history-mode-badge {
        font-size: 0.75rem;
        padding: 2px 8px;
    }
    .history-item-title {
        font-size: 0.875rem;
    }
    .history-item-meta {
        font-size: 0.75rem;
    }
    .history-time-tag {
        font-size: 0.75rem;
    }
}

/* Compact history modal on phones: the header + toolbar chrome took too much
   vertical space, leaving little room for the actual history list. */
@media (max-width: 640px) {
    .history-modal-dialog {
        width: 97% !important;
        max-height: 94dvh !important;
    }
    .history-modal-header {
        padding: 8px 12px;
        gap: 8px;
    }
    .history-modal-title {
        font-size: 1rem;
        gap: 8px;
        white-space: nowrap;
    }
    .history-modal-title svg {
        width: 18px;
        height: 18px;
    }
    .history-title-long {
        display: none;
    }
    .history-title-short {
        display: inline;
    }
    .history-header-actions {
        gap: 4px;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    /* Icon-only action buttons on phones */
    .history-action-btn,
    .history-clear-btn {
        padding: 8px 8px;
        font-size: 0.75rem;
    }
    .history-action-btn span,
    .history-clear-btn span {
        display: none;
    }
    #btnCloseHistory {
        padding: 8px;
    }
    .history-toolbar {
        padding: 8px 12px 8px 12px;
        gap: 8px;
    }
    .history-search-wrapper input {
        padding: 8px 12px 8px 36px;
        font-size: 0.875rem;
    }
    .history-nav-tabs {
        gap: 4px;
        padding-bottom: 4px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .history-nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .history-tab-btn {
        padding: 4px 12px;
        font-size: 0.75rem;
        gap: 4px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .history-badge-count {
        font-size: 0.75rem;
    }
    .history-filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        margin-top: 0;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .history-filter-pills::-webkit-scrollbar {
        display: none;
    }
    .history-pill {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.75rem;
        padding: 4px 12px;
    }
    .history-modal-body {
        padding: 8px 12px 16px 12px;
    }
}

/* ==========================================================================
   Dhamma Reading Insights & Analytics Styling
   ========================================================================== */

.insights-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0 16px 0;
}

.insights-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(230, 81, 0, 0.08);
    border-left: 4px solid var(--accent);
    border-radius: 0 16px 16px 0;
}

.insights-banner-icon {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.insights-banner-text h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.insights-banner-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

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

.insight-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.insight-stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.insight-stat-card .stat-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.insight-stat-card.card-accent { border-top: 3px solid #e65100; }
.insight-stat-card.card-gold { border-top: 3px solid #f57f17; }
.insight-stat-card.card-green { border-top: 3px solid #2e7d32; }
.insight-stat-card.card-blue { border-top: 3px solid #0288d1; }

.stat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.insights-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
}

.insights-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insights-top-books {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-book-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.top-book-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.top-book-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.top-book-count {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    flex-shrink: 0;
}

.top-book-bar-track {
    width: 100%;
    height: 7px;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.top-book-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff9800);
    border-radius: 999px;
    transition: width 0.4s ease;
}

.insights-backup-card {
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.backup-card-info {
    flex: 1;
    min-width: 240px;
}

.backup-card-info h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.backup-card-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.backup-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-action-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent);
    color: var(--on-solid);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-action-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-paper);
}

@media (max-width: 768px) {
    .insights-grid {
        grid-template-columns: 1fr;
    }
    .insights-backup-card {
        flex-direction: column;
        align-items: stretch;
    }
    .backup-card-actions {
        width: 100%;
    }
    .btn-action-primary, .btn-action-secondary {
        flex: 1;
        justify-content: center;
    }
}

/* -------------------------------------------------------------
   Focus / Zen Fullscreen Reading Mode (Tap-to-Toggle)
   ------------------------------------------------------------- */
.app-header {
    transition: margin-top 0.25s ease, transform 0.25s ease;
}

.bottom-nav-bar {
    transition: transform 0.25s ease;
}

body.focus-mode .app-header {
    margin-top: calc(-1 * var(--header-height));
}

body.focus-mode.focus-bars-revealed .app-header {
    margin-top: 0;
}

body.focus-mode .bottom-nav-bar {
    transform: translateY(100%);
}

body.focus-mode.focus-bars-revealed .bottom-nav-bar {
    transform: translateY(0);
}

body.focus-mode .mobile-sticky-header {
    display: none !important;
}

body.focus-mode.focus-bars-revealed .mobile-sticky-header {
    display: block !important;
}

body.focus-mode .app-layout {
    height: 100vh;
}

body.focus-mode .reader-container {
    padding-top: 20px !important;
    padding-bottom: 32px !important;
}

body.focus-mode.focus-bars-revealed .reader-container {
    padding-bottom: 84px !important;
}

/* Floating Exit Button in Focus Mode */
.floating-exit-focus-btn {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 1200;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.15s ease, background 0.15s ease;
    user-select: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.floating-exit-focus-btn:hover,
.floating-exit-focus-btn:active {
    opacity: 1;
    transform: scale(1.03);
    background: var(--bg-hover);
}

body.focus-mode .floating-exit-focus-btn {
    display: flex;
}

@media (max-width: 992px) {
    body.focus-mode.focus-bars-revealed .floating-exit-focus-btn {
        bottom: 76px;
    }
}

/* iOS Safari Pseudo-Fullscreen Fallback */
body.ios-fullscreen-fallback {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    height: -webkit-fill-available !important;
    overflow: hidden !important;
    z-index: 9999 !important;
}

body.ios-fullscreen-fallback .app-layout {
    height: 100dvh !important;
    height: -webkit-fill-available !important;
}

body.ios-fullscreen-fallback .reader-container {
    height: 100dvh !important;
    height: -webkit-fill-available !important;
    padding-top: 16px !important;
}




/* ============================================================
   Paragraph Annotation System
   ============================================================ */

.annotatable-para {
    position: relative;
    border-radius: 4px;
    transition: background 0.15s;
    padding-left: 4px;
    /* Suppress the native iOS long-press callout on annotatable text so our
       selection toolbar (which includes Copy) owns the interaction */
    -webkit-touch-callout: none;
}
.annotatable-para:hover {
    background: rgba(128,128,128,0.05);
}
/* Inline text-selection highlights (Kindle-style) */
.ann-sel { border-radius: 3px; padding: 1px 0; }
.ann-sel-amber { background: rgba(245,158,11,0.38); }
.ann-sel-blue  { background: rgba(59,130,246,0.30); }
.ann-sel-green { background: rgba(16,185,129,0.32); }
.ann-sel-red   { background: rgba(239,68,68,0.32); }
/* Flash effect when jumping to an annotation from the sidebar */
.ann-flash { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.annotatable-para.ann-amber { background: rgba(245,158,11,0.12) !important; border-left: 3px solid #f59e0b; padding-left: 8px; }
.annotatable-para.ann-blue  { background: rgba(59,130,246,0.10) !important; border-left: 3px solid #3b82f6; padding-left: 8px; }
.annotatable-para.ann-green { background: rgba(16,185,129,0.10) !important; border-left: 3px solid #10b981; padding-left: 8px; }
.annotatable-para.ann-red   { background: rgba(239,68,68,0.10) !important;  border-left: 3px solid #ef4444; padding-left: 8px; }
.annotation-popup {
    position: fixed;
    z-index: 9999;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 16px;
    width: 280px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.ann-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.ann-popup-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.ann-popup-close {
    border: none; background: none; cursor: pointer;
    color: var(--text-muted); font-size: 0.875rem; padding: 2px 8px;
    border-radius: 8px; line-height: 1;
}
.ann-popup-close:hover { background: var(--border); }
.ann-color-row { display: flex; gap: 12px; margin-bottom: 12px; }
.ann-color-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid transparent; cursor: pointer;
    transition: transform 0.15s, border-color 0.15s; flex-shrink: 0;
}
.ann-color-btn:hover { transform: scale(1.15); }
.ann-color-btn.selected { border-color: var(--text-primary); transform: scale(1.1); }
.ann-note-input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 0.875rem;
    background: var(--card); color: var(--text-primary);
    resize: vertical; min-height: 56px; font-family: inherit;
    box-sizing: border-box; margin-bottom: 12px;
}
.ann-note-input:focus { outline: none; border-color: var(--accent); }
.ann-popup-actions { display: flex; gap: 8px; }
.ann-save-btn {
    flex: 1; padding: 8px 12px; border-radius: 8px; border: none;
    background: var(--accent); color: var(--on-solid); font-size: 0.875rem;
    font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
.ann-save-btn:hover { opacity: 0.85; }
.ann-delete-btn {
    padding: 8px 12px; border-radius: 8px;
    border: 1px solid var(--border); background: none;
    color: var(--danger); font-size: 0.875rem; cursor: pointer;
}
.ann-delete-btn:hover { background: rgba(239,68,68,0.08); }
.annotation-tab-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 12px 8px; border-bottom: 1px solid var(--border);
}
.annotation-tab-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.annotation-color-legend {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.ann-legend-item {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.75rem; color: var(--text-muted);
}
.ann-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.annotation-list { padding: 8px 4px; overflow-y: auto; }
.annotation-item {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    transition: background 0.15s; margin-bottom: 2px;
}
.annotation-item:hover { background: rgba(128,128,128,0.08); }
.ann-item-color {
    width: 4px; min-height: 36px; border-radius: 2px;
    flex-shrink: 0; margin-top: 2px;
}
.ann-item-body { flex: 1; min-width: 0; }
.ann-item-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.ann-item-preview {
    font-size: 0.75rem; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ann-item-note {
    font-size: 0.75rem; color: var(--accent); font-style: italic;
    margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ann-item-del {
    border: none; background: none; color: var(--text-muted);
    cursor: pointer; padding: 2px 4px; font-size: 0.75rem;
    border-radius: 8px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s;
}
.annotation-item:hover .ann-item-del { opacity: 1; }
.ann-item-del:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

/* --- Mini selection toolbar (Medium-style) --- */
.ann-select-toolbar {
    position: fixed;
    z-index: 10000;
    display: flex;
    gap: 4px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    animation: ann-tb-pop 0.12s ease-out;
}
@keyframes ann-tb-pop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.ann-tb-btn {
    border: none;
    background: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
}
.ann-tb-btn:hover { background: var(--border); }
.ann-tb-btn:active { transform: scale(0.92); }

/* --- Annotation tab: actions + sync status --- */
.annotation-tab-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}
.sync-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 12px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}
.sync-status.ok span { color: var(--success); }
.sync-status.syncing span { color: var(--info); }
.sync-status.error span { color: var(--danger); }

/* --- Sync modal --- */
.sync-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.sync-modal-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    width: 340px;
    max-width: 100%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}
.sync-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.sync-modal-title { font-size: 0.875rem; font-weight: 700; }
.sync-desc { font-size: 0.75rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.6; }
.sync-primary-btn {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--info);
    color: var(--on-solid);
}
.sync-primary-btn:disabled { opacity: 0.6; cursor: default; }
.sync-secondary-btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
}
.sync-danger-btn {
    border: 1px solid var(--danger);
    background: none;
    color: var(--danger);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    flex: 1;
}
.sync-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.sync-divider::before, .sync-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
.sync-label { font-size: 0.75rem; font-weight: 600; display: block; margin-bottom: 8px; }
.sync-join-row { display: flex; gap: 8px; }
.sync-code-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 12px;
    font-size: 1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: monospace;
    min-width: 0;
}
.sync-msg { font-size: 0.75rem; color: var(--text-muted); margin-top: 12px; min-height: 1.2em; }
.sync-code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}
.sync-code {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 3px;
}
.sync-info { font-size: 0.75rem; color: var(--text-muted); margin: 12px 0; }
.sync-actions { display: flex; gap: 8px; }
.sync-actions .sync-primary-btn { flex: 2; width: auto; }

/* --- Mobile: annotation popup becomes a bottom sheet --- */
@media (max-width: 640px) {
    .annotation-popup {
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        top: auto !important;
        width: auto !important;
        max-height: 46vh;
        overflow-y: auto;
    }
    /* Bigger tap targets for the selection toolbar on touch screens */
    .ann-tb-btn {
        font-size: 1.5rem;
        padding: 12px 16px;
    }
}

/* --- Small phones (<= 480px): header cannot fit every tool, and
   .app-header uses overflow-x: hidden, so the rightmost buttons would be
   silently clipped. These three tools also live in the mobile drawer /
   bottom nav, so hide their header copies instead of clipping. --- */
@media (max-width: 480px) {
    #btnToggleNotes,
    #relatedDropdownWrapper,
    #btnOpenHistory {
        display: none !important;
    }
    /* v7.78: the unified "ကျမ်းရွေး" hub button covers Pāḷi ⇄ မြန်မာပြန် ⇄ နိဿယ
       jumping, so drop the two quick cross-link buttons here to keep the
       rightmost tools (theme, ›More) from being clipped by overflow-x:hidden. */
    #btnCrossLink,
    #btnCrossLinkNissaya {
        display: none !important;
    }
    .page-indicator input {
        width: 38px;
    }
    .header-left, .header-center, .header-right {
        gap: 2px;
    }
    .app-header {
        gap: 4px;
    }
}

/* ---------- Book export (Word/PDF download) ---------- */
.export-book-btn {
    margin-left: auto;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-primary);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}
.export-book-btn:hover {
    background: var(--bg-hover);
}
@media (max-width: 1180px) {
    .export-book-btn::after {
        content: "";
        position: absolute;
        inset: -6px;
    }
}
.export-form { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.export-book-name { font-size: 1.125rem; font-weight: 700; }
.export-book-meta { font-size: 0.875rem; color: var(--text-muted); }
.export-group-label { font-size: 0.875rem; font-weight: 600; margin-bottom: 8px; display: block; }
.export-radio-row {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 8px; cursor: pointer; font-size: 0.875rem;
}
.export-radio-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.export-range-inputs { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-left: 28px; }
.export-range-inputs input {
    width: 80px; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 1rem; background: var(--card); color: var(--text-primary); text-align: center;
}
.export-dl-btn {
    padding: 12px; border: none; border-radius: 8px; cursor: pointer;
    background: var(--accent); color: var(--on-solid);
    font-size: 1rem; font-weight: 600;
}
.export-dl-btn:disabled { opacity: 0.6; cursor: wait; }
.export-status { font-size: 0.875rem; min-height: 20px; text-align: center; }
.export-status.error { color: var(--danger); }

/* ============================================================
   Page Jump Sheet (v6.11): tap footer "စာမျက်နှာ X / Y" to open.
   Bottom sheet with slider + live bubble, section ticks, exact input.
   ============================================================ */
.footer-page-info.jump-trigger {
    cursor: pointer;
    border-bottom: 1px dotted var(--text-muted);
    padding-bottom: 2px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* v7.38: block iOS/WebKit long-press callout */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
/* v7.38 hardening: no text selection anywhere in the footer nav cluster —
   a finger landing on the pill's edge must not start a selection.
   (Actual container is .reader-footer-nav; there is no .footer-bar.) */
.reader-footer-nav,
.reader-footer-nav * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
/* ============================================================
   Inline page jump (v7.39): replaces the jump sheet overlay.
   The pill toggles this row in normal flow above the footer —
   no overlay, no dialog, no fixed positioning, no DOM moves.
   ============================================================ */
.jump-inline-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card);
    border-top: 1px solid var(--border-color);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.jump-inline-row[hidden] {
    display: none;
}
.jump-inline-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.jump-inline-input {
    width: 110px;
    padding: 8px 12px;
    font-size: 1rem;
    text-align: center;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* The input must stay editable: override the row's no-select. */
    user-select: text;
    -webkit-user-select: text;
}
.jump-inline-input:focus {
    outline: none;
    border-color: var(--accent);
}
.jump-inline-go {
    padding: 8px 16px;
    min-height: 44px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--on-solid);
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
}
.jump-inline-close {
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
    font-size: 1rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
}


/* ============================================================
   App toast (v6.14): non-blocking user-visible warnings, e.g.
   the hang watchdog's "page froze for N seconds" notice.
   ============================================================ */
.app-toast {
    position: fixed;
    left: 50%;
    bottom: 88px;
    transform: translate(-50%, 16px);
    z-index: 10005;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(92vw, 480px);
    background: #2d2a26;
    color: #fff;
    border-radius: 12px;
    padding: 12px 12px 12px 16px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    font-size: 0.875rem;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.app-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.app-toast-msg { flex: 1; }
.app-toast-action {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: transparent;
    color: #ffd97a;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.app-toast-close {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
}

/* ============================================================
   Search Term Highlighting in Reader
   ============================================================ */
mark.search-match-highlight {
    background: #ffeb3b;
    color: #111111;
    padding: 1px 4px;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(255, 235, 59, 0.75);
    font-weight: 600;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="night"] mark.search-match-highlight {
    background: var(--warning);
    color: var(--on-solid);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

/* ============================================================
   Mobile Reader Header & Ergonomic Action Sheet (APK Reference)
   ============================================================ */

/* Mobile Breadcrumb Header Overhaul */
.mobile-breadcrumb-wrapper {
    display: none;
    position: sticky;
    top: 0;
    z-index: 70;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color, rgba(0, 0, 0, 0.04));
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .mobile-breadcrumb-wrapper {
        display: flex;
    }
}

.mobile-back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

.mobile-back-btn:active {
    transform: scale(0.92);
    background: var(--bg-hover);
}

.mobile-chapter-breadcrumb {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.mobile-chapter-breadcrumb:active {
    background: var(--bg-hover);
}

.mobile-chapter-breadcrumb .breadcrumb-book {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-chapter-breadcrumb .breadcrumb-sep {
    margin: 0 5px;
    color: var(--text-muted);
}

.mobile-chapter-breadcrumb .breadcrumb-chapter {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-right-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.breadcrumb-page-badge {
    padding: 4px 10px;
    border-radius: 14px;
    background: var(--accent-light, rgba(234, 88, 12, 0.12));
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    transition: transform 0.15s ease;
}

.breadcrumb-page-badge:active {
    transform: scale(0.92);
}

.breadcrumb-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.breadcrumb-icon-btn:active {
    transform: scale(0.92);
    background: var(--bg-hover);
    color: var(--accent);
}

.mobile-header-more-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.mobile-header-more-btn:active {
    transform: scale(0.92);
    background: var(--bg-hover);
}

/* ============================================================
   Mobile Dedicated Reader Toolbar (Option A: 5 Actions on Mobile <= 768px)
   ============================================================ */
.mobile-reader-toolbar {
    display: none; /* Displayed only when in reader view on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px var(--shadow-color, rgba(0, 0, 0, 0.05));
    z-index: 100;
    padding: 0 4px;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-around;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    /* Mobile Reader Chrome: hide desktop header & general bottom nav, display reader toolbar */
    body.view-reader .app-header {
        display: none !important;
    }
    body.view-reader .bottom-nav-bar {
        display: none !important;
    }
    body.view-reader .mobile-reader-toolbar {
        display: flex !important;
    }

    /* Mobile Home Chrome: hide reader sticky header & reader toolbar, display general bottom nav */
    body.view-home .mobile-sticky-header,
    body.view-home .mobile-breadcrumb-wrapper,
    body.view-home .mobile-reader-toolbar {
        display: none !important;
    }
    body.view-home .bottom-nav-bar {
        display: flex !important;
    }

    body.view-reader .reader-container {
        padding-bottom: 70px !important;
    }
    body.view-reader .split-view-container {
        padding-bottom: 70px !important;
    }
    .mobile-sticky-header,
    .mobile-breadcrumb-wrapper {
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    body.chrome-hidden .mobile-sticky-header,
    body.chrome-hidden .mobile-breadcrumb-wrapper {
        transform: translateY(-115%);
    }
    body.chrome-hidden .mobile-reader-toolbar {
        transform: translateY(115%);
    }
    /* Mobile: companion (ယှဉ်တွဲ) system removed — edition switching only.
       The side-by-side split buttons and the ယှဉ်တွဲ mode stay desktop-only.
       (setReaderMode already redirects mobile split → edition switcher.) */
    .comp-btn-split,
    .mobile-mode-btn[data-mode="split"] {
        display: none !important;
    }
}

.reader-toolbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    min-width: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 8px;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.reader-toolbar-item:active {
    transform: scale(0.92);
    color: var(--accent);
    background: var(--bg-hover);
}

.reader-toolbar-icon {
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
}

.reader-toolbar-label {
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ============================================================
   Unified Edition Switcher ("ကျမ်းရွေး") Modal
   ============================================================ */
.edition-switcher-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.edition-switcher-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.edition-switcher-sheet {
    width: 100%;
    max-width: 480px;
    background: var(--bg-surface);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
    padding: 12px 16px 26px 16px;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}

.edition-switcher-backdrop.active .edition-switcher-sheet {
    transform: translateY(0);
}

@media (min-width: 600px) {
    .edition-switcher-backdrop {
        align-items: center;
    }
    .edition-switcher-sheet {
        border-radius: 20px;
        transform: scale(0.92);
        transition: transform 0.22s ease;
    }
    .edition-switcher-backdrop.active .edition-switcher-sheet {
        transform: scale(1);
    }
}

.action-sheet-handle {
    width: 40px;
    height: 4.5px;
    background: var(--border-color);
    border-radius: 3px;
    margin: 0 auto 10px auto;
}

.edition-switcher-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.edition-switcher-title-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.edition-switcher-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
}

.edition-switcher-subtitle {
    font-size: 0.76rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edition-switcher-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}

.edition-switcher-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.edition-switcher-card:hover,
.edition-switcher-card:active {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: scale(0.99);
}

.edition-switcher-card.active-edition {
    background: var(--accent-light, rgba(234, 88, 12, 0.08));
    border-color: var(--accent);
}

.edition-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.edition-card-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.edition-card-texts {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.edition-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edition-card-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edition-card-badge {
    font-size: 0.72rem;
    padding: 3px 9px;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.edition-card-badge.badge-active {
    background: var(--success);
    color: var(--on-solid);
}

.edition-card-badge.badge-jump {
    background: var(--accent);
    color: var(--on-solid);
}

.edition-card-badge.badge-muted {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* Explainer shown at the top of the switcher: every card lands on the page
   that matches the reader's current position. */
.edition-switcher-hint {
    font-size: 0.74rem;
    line-height: 1.45;
    color: var(--text-muted);
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 8px 11px;
    margin-bottom: 2px;
}

/* Group heading for the related-edition cards (Aṭṭhakathā / Ṭīkā …). */
.edition-switcher-section-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 8px 2px 2px 2px;
    letter-spacing: 0.01em;
}

/* ↩ Return-to-origin card — always the first card while a swap is pending, so
   the reader has a one-tap way back to the exact book + page they left. */
.edition-return-card {
    border-color: var(--accent);
    background: var(--accent-light);
}

.edition-return-card:hover,
.edition-return-card:active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.edition-return-card .edition-card-icon {
    font-weight: 700;
    color: var(--accent);
}

.edition-card-badge.badge-return {
    background: var(--accent);
    color: var(--on-solid);
}

/* ============================================================
   Reader More Sheet ("အခြား") Modal
   ============================================================ */
.reader-more-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.reader-more-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.reader-more-sheet {
    width: 100%;
    max-width: 480px;
    background: var(--bg-surface);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
    padding: 12px 16px 26px 16px;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.reader-more-backdrop.active .reader-more-sheet {
    transform: translateY(0);
}

@media (min-width: 600px) {
    .reader-more-backdrop {
        align-items: center;
    }
    .reader-more-sheet {
        border-radius: 20px;
        transform: scale(0.92);
        transition: transform 0.22s ease;
    }
    .reader-more-backdrop.active .reader-more-sheet {
        transform: scale(1);
    }
}

.reader-more-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.reader-more-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Quick Settings Hub at Top of More Sheet */
.reader-more-quick-settings {
    background: var(--bg-hover);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.qs-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.qs-font-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qs-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
}

.qs-btn:active {
    background: var(--accent);
    color: var(--on-solid);
}

.qs-font-display {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 44px;
    text-align: center;
}

.qs-theme-picker {
    display: inline-flex;
    gap: 6px;
}

.qs-theme-btn {
    padding: 4px 9px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
}

.qs-theme-btn.active {
    border-color: var(--accent);
    background: var(--accent-light, rgba(234, 88, 12, 0.12));
    color: var(--accent);
    font-weight: 700;
}

.qs-toggle-btn {
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
}

/* Vertical Action List */
.reader-more-action-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reader-more-action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--bg-surface);
    cursor: pointer;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.reader-more-action-item:hover,
.reader-more-action-item:active {
    background: var(--bg-hover);
    border-color: var(--border-color);
    transform: scale(0.99);
}

.more-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #ffffff;
}

.more-item-icon.circle-dict {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.more-item-icon.circle-copy {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.more-item-icon.circle-toc {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.more-item-icon.circle-home {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.more-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.more-item-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
}

.more-item-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Myanmar Nissaya gloss layer — per-paragraph word-by-word glosses */
.nissaya-gloss {
    font-size: 0.86em;
    line-height: 1.75;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 8px 12px;
    margin: 6px 0 14px 0;
    white-space: pre-wrap;
}
/* Dedicated Nissaya reading mode: Hide Pali text completely, show only pure Nissaya paragraphs naturally like Myanmar translation */
.nissaya-mode p:not(.nissaya-mode-para) {
    display: none !important;
}

.nissaya-mode .paranum,
.nissaya-mode .note,
.nissaya-mode .namo {
    display: none !important;
}

.nissaya-mode-block {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.nissaya-mode-label {
    display: none !important;
}

.nissaya-mode-para {
    display: block !important;
    text-indent: 2em;
    text-align: justify;
    line-height: 2.15;
    margin: 0 0 1.25em 0;
    color: var(--text-primary);
    font-size: inherit;
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

.nissaya-mode-text {
    font-size: inherit;
    line-height: 2.15;
    color: var(--text-primary);
    text-align: justify;
    text-indent: 2em;
    white-space: pre-wrap;
    word-break: break-word;
}

.nissaya-mode-notice {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.tool-btn.nissaya-toggle-btn.active {
    background: var(--accent);
    color: var(--on-solid);
    border-color: var(--accent);
}

.edition-switcher-card.edition-layer-card {
    border-style: dashed;
}

.edition-switcher-card.edition-layer-card.active-layer {
    background: var(--accent-light, rgba(234, 88, 12, 0.08));
    border-color: var(--accent);
    border-style: solid;
}

.search-result-item.nissaya-search-item {
    border-left: 3px solid var(--accent);
}

.search-target-highlight {
    animation: targetFlash 2.5s ease-out;
}

@keyframes targetFlash {
    0% { background-color: rgba(234, 88, 12, 0.25); }
    100% { background-color: transparent; }
}

/* ============================================================
   v7.77 — Touch targets & interaction polish
   Comfortable tap areas (WCAG 2.5.5 Target Size) on touch layouts,
   plus consistent press feedback and hover affordance.
   ============================================================ */
@media (max-width: 768px) {
    .dropdown-item {
        min-height: 44px;
        padding: 12px;
    }
    .tab-btn { min-height: 44px; }
    .modal-tab-btn,
    .search-scope-btn { min-height: 42px; }
    .basket-btn {
        display: inline-flex;
        align-items: center;
        min-height: 38px;
        padding: 6px 12px;
    }
    .comp-tab { min-height: 40px; }
    .history-pill {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
    }
    .theme-btn {
        min-width: 40px;
        min-height: 40px;
    }
    .icon-btn-sm {
        min-width: 32px;
        min-height: 32px;
    }
    .edition-btn { min-height: 40px; }
    .toc-toolbar-btn {
        min-width: 36px;
        min-height: 36px;
    }
}

/* Subtle click/press feedback on compact controls */
.icon-btn:active,
.icon-btn-sm:active,
.tool-btn:active,
.nav-btn:active,
.tab-btn:active,
.basket-btn:active,
.edition-btn:active,
.theme-btn:active,
.comp-tab:active,
.history-pill:active {
    transform: scale(0.96);
}

/* Accent-tinted hover border so controls read as interactive (pointer only) */
@media (hover: hover) {
    .icon-btn:hover,
    .icon-btn-sm:hover,
    .tool-btn:hover {
        border-color: var(--accent);
    }
}
