/* ============================================================
   Romeo & Juliet Study Guide — Stylesheet
   /var/www/html/library/rj/css/style.css
   ============================================================ */

:root {
    --cream: #FAF7F2; --cream-dark: #F0EBE3; --parchment: #F5F0E8;
    --ink: #1a1a1a; --ink-light: #4a4a4a; --ink-lighter: #7a7a7a;
    /* accent vars are set inline by PHP for theme switching */
    --gold: #B8860B; --gold-light: #D4A843;
    --border: rgba(0,0,0,0.08); --border-strong: rgba(0,0,0,0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
    --radius: 6px; --transition: 0.2s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-body); background: var(--cream); color: var(--ink); line-height: 1.65; -webkit-font-smoothing: antialiased; }

/* === TOPBAR === */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--ink); color: white; display: flex; align-items: center; padding: 0 1.25rem; height: 52px; gap: 1rem; }
.topbar-brand { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; opacity: 0.95; cursor: pointer; text-decoration: none; color: white; }
.topbar-brand:hover { opacity: 1; }
.topbar-search { flex: 1; max-width: 480px; position: relative; }
.topbar-search input { width: 100%; padding: 0.45rem 0.75rem 0.45rem 2.25rem; border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; background: rgba(255,255,255,0.08); color: white; font-family: var(--font-body); font-size: 0.88rem; transition: var(--transition); outline: none; }
.topbar-search input::placeholder { color: rgba(255,255,255,0.45); }
.topbar-search input:focus { background: rgba(255,255,255,0.95); color: var(--ink); border-color: transparent; }
.topbar-search input:focus::placeholder { color: var(--ink-lighter); }
.topbar-search-icon { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); opacity: 0.45; pointer-events: none; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.topbar-btn { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; padding: 0.35rem; border-radius: 4px; display: flex; transition: var(--transition); text-decoration: none; }
.topbar-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.menu-btn { display: none; }

/* === LAYOUT === */
.layout { display: flex; min-height: calc(100vh - 52px); }

/* === SIDEBAR === */
.sidebar { width: 200px; min-width: 200px; background: white; border-right: 1px solid var(--border); overflow-y: auto; padding: 1.25rem 0; transition: width 0.3s ease, min-width 0.3s ease; position: relative; flex-shrink: 0; }
.sidebar.collapsed { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right: none; }
.sidebar-toggle { flex-shrink: 0; align-self: flex-start; position: sticky; top: 60px; z-index: 91; width: 22px; height: 44px; background: white; border: 1px solid var(--border); border-left: none; border-radius: 0 6px 6px 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s ease; box-shadow: 2px 0 6px rgba(0,0,0,0.04); margin-left: -1px; }
.sidebar-toggle:hover { background: var(--parchment); }
.sidebar-toggle svg { width: 12px; height: 12px; stroke: var(--ink-lighter); transition: transform 0.3s ease; }
.sidebar-toggle.flipped svg { transform: rotate(180deg); }
.sb-label { font-family: var(--font-display); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-lighter); padding: 0 1rem; margin-bottom: 0.5rem; }
.sb-section { margin-bottom: 1.5rem; }
.sb-act { padding: 0.4rem 1rem; font-family: var(--font-display); font-weight: 600; font-size: 0.88rem; color: var(--accent); cursor: pointer; display: flex; align-items: center; gap: 0.4rem; transition: var(--transition); user-select: none; }
.sb-act:hover { background: var(--accent-faint); }
.sb-act .arrow { transition: transform 0.2s ease; display: inline-block; font-size: 0.7rem; }
.sb-act.open .arrow { transform: rotate(90deg); }
.sb-scenes { display: none; }
.sb-act.open + .sb-scenes { display: block; }
.sb-ch { display: block; padding: 0.3rem 1rem 0.3rem 2rem; font-size: 0.84rem; color: var(--ink-light); text-decoration: none; transition: var(--transition); border-left: 2px solid transparent; }
.sb-ch:hover { background: var(--parchment); color: var(--ink); }
.sb-ch.active { background: var(--accent-faint); color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.sb-divider { height: 1px; background: var(--border); margin: 1rem 1.25rem; }

/* === MAIN === */
.main { flex: 1; overflow-y: auto; padding: 2.5rem 3rem; max-width: 1100px; }

/* === HOME === */
.hero { text-align: center; padding: 3rem 0 2.5rem; border-bottom: 1px solid var(--border); margin-bottom: 2.5rem; }
.hero h1 { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; color: var(--accent); line-height: 1.15; margin-bottom: 0.6rem; }
.hero .subtitle { font-family: var(--font-display); font-size: 1.3rem; font-style: italic; color: var(--ink-light); }
.hero .byline { margin-top: 1rem; font-size: 0.85rem; color: var(--ink-lighter); }
.section-label { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--ink); margin: 2rem 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--ink); }
.act-header { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--accent); padding: 1rem 0 0.4rem; border-bottom: 1px solid var(--accent-glow); margin-top: 0.75rem; }
.toc-row { display: flex; align-items: center; padding: 0.65rem 0.75rem; cursor: pointer; border-radius: var(--radius); transition: var(--transition); gap: 0.75rem; text-decoration: none; color: var(--ink); }
.toc-row:hover { background: var(--accent-faint); }
.toc-num { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; color: var(--accent); min-width: 2.5rem; }
.toc-title { font-size: 0.95rem; }
.toc-lock { margin-left: auto; color: var(--ink-lighter); font-size: 0.8rem; display: flex; align-items: center; gap: 0.3rem; }
.toc-lock svg { width: 14px; height: 14px; }
.toc-row.locked { opacity: 0.65; }
.toc-row.locked:hover { opacity: 0.85; }
.toc-free-badge { margin-left: auto; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #2d8a4e; background: rgba(45,138,78,0.08); padding: 0.15rem 0.5rem; border-radius: 10px; }

/* === READER === */
.reader-header { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.breadcrumb { font-size: 0.82rem; color: var(--ink-lighter); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.35rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.reader-title { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
.reader-subtitle { font-family: var(--font-display); font-size: 1rem; font-style: italic; color: var(--accent); }
.reader-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }

/* === TABS === */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.75rem; }
.tab { padding: 0.6rem 1.25rem; font-family: var(--font-body); font-size: 0.88rem; font-weight: 500; color: var(--ink-lighter); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: var(--transition); }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-ai { position: relative; }
.ai-badge { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.15rem 0.45rem 0.15rem 0.3rem; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--gold)); color: white; margin-left: 0.4rem; vertical-align: middle; line-height: 1; }
.ai-badge svg { width: 10px; height: 10px; stroke: white; }

/* === CONTENT === */
.content { font-size: 1.08rem; line-height: 1.8; color: var(--ink); }
.content p { margin-bottom: 1.25rem; }
.content b { color: var(--accent); font-weight: 600; }
.summary-box { background: white; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 1.25rem 1.5rem; margin-bottom: 2rem; }
.summary-box h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--accent); margin-bottom: 0.5rem; }
.summary-box p { font-size: 0.95rem; line-height: 1.7; color: var(--ink-light); }
.quote-box { background: var(--parchment); border-left: 3px solid var(--gold); padding: 1.25rem 1.5rem; border-radius: 0 var(--radius) var(--radius) 0; font-family: var(--font-display); font-size: 1.05rem; font-style: italic; line-height: 1.7; color: var(--ink-light); }

/* === SIDE-BY-SIDE TRANSLATION === */
.text-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.text-col { padding: 1.5rem; }
.text-col-original { background: white; border-right: 1px solid var(--border); }
.text-col-modern { background: var(--parchment); }
.text-col-header { font-family: var(--font-display); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-lighter); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; }
.text-col-header svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.5; }
.speech-block { margin-bottom: 1rem; }
.speaker { font-weight: 700; color: var(--accent); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.04em; margin-bottom: 0.15rem; }
.stage-direction { font-style: italic; color: var(--ink-lighter); font-size: 0.95rem; margin: 0.4rem 0; }
.speech-text { font-size: 1.05rem; line-height: 1.5; color: var(--ink); }
.speech-text[style*="pre-line"] { margin: 0; /* pre-line: collapse \r\n\r\n into tighter gaps */ }
.text-col-modern .speech-text { color: var(--ink-light); }

/* Translation Controls */
.translate-controls { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.translate-controls-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.translate-controls-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 0.4rem; }
.translate-controls-title svg { width: 16px; height: 16px; stroke: var(--accent); }
.style-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.style-btn { padding: 0.3rem 0.75rem; font-size: 0.8rem; font-family: var(--font-body); border: 1px solid var(--border-strong); border-radius: 20px; background: white; color: var(--ink-light); cursor: pointer; transition: var(--transition); }
.style-btn:hover { border-color: var(--accent); color: var(--accent); }
.style-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.level-slider-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.level-label { font-size: 0.78rem; color: var(--ink-lighter); min-width: 80px; }
.level-slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: var(--border-strong); outline: none; }
.level-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.level-value { font-size: 0.78rem; color: var(--accent); font-weight: 600; min-width: 90px; text-align: right; }
.custom-prompt-row { display: flex; gap: 0.5rem; }
.custom-prompt-input { flex: 1; padding: 0.45rem 0.75rem; font-size: 0.85rem; font-family: var(--font-body); border: 1px solid var(--border); border-radius: var(--radius); outline: none; color: var(--ink); }
.custom-prompt-input:focus { border-color: var(--accent); }
.custom-prompt-input::placeholder { color: var(--ink-lighter); font-size: 0.8rem; }
.custom-prompt-submit { padding: 0.45rem 1rem; font-size: 0.82rem; font-family: var(--font-body); background: var(--accent); color: white; border: none; border-radius: var(--radius); cursor: pointer; transition: var(--transition); white-space: nowrap; }
.custom-prompt-submit:hover { background: var(--accent-light); }
.custom-prompt-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.translate-loading { text-align: center; padding: 2rem; color: var(--ink-lighter); font-style: italic; }

/* Mobile text toggle */
.text-toggle { display: none; margin-bottom: 1rem; }
.text-toggle-btn { flex: 1; padding: 0.5rem; font-family: var(--font-body); font-size: 0.85rem; border: 1px solid var(--border-strong); background: white; color: var(--ink-light); cursor: pointer; transition: var(--transition); text-align: center; }
.text-toggle-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.text-toggle-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.text-toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* === NAVIGATION === */
.chapter-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.nav-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem; background: white; border: 1px solid var(--border-strong); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.88rem; color: var(--ink); cursor: pointer; transition: var(--transition); text-decoration: none; }
.nav-btn:hover { background: var(--parchment); border-color: var(--accent); color: var(--accent); }

/* === TAGS === */
.devices { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.device-tag { font-size: 0.78rem; padding: 0.2rem 0.65rem; border-radius: 20px; background: var(--accent-faint); color: var(--accent); font-weight: 500; cursor: pointer; transition: var(--transition); text-decoration: none; }
.device-tag:hover { background: var(--accent-glow); }
.tag-pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; padding: 0.3rem 0.75rem; border-radius: 20px; cursor: pointer; transition: var(--transition); border: 1px solid transparent; }
.tag-pill .tag-count { font-size: 0.72rem; opacity: 0.6; background: rgba(0,0,0,0.06); padding: 0.1rem 0.35rem; border-radius: 10px; margin-left: 0.15rem; }
.tag-pill-themes { background: var(--accent-faint); color: var(--accent); }
.tag-pill-themes:hover { background: var(--accent-glow); border-color: var(--accent); }
.tag-pill-literary_devices { background: rgba(184,134,11,0.08); color: var(--gold); }
.tag-pill-literary_devices:hover { background: rgba(184,134,11,0.15); border-color: var(--gold); }
.tag-pill-characters { background: rgba(100,100,180,0.08); color: #555; }
.tag-pill-characters:hover { background: rgba(100,100,180,0.15); border-color: #888; }
.tag-pill-motifs { background: rgba(34,139,34,0.08); color: #2d7d2d; }
.tag-pill-motifs:hover { background: rgba(34,139,34,0.15); border-color: #2d7d2d; }

/* === TAG SEARCH PANEL === */
.tag-search-panel { display: none; margin-top: 1.5rem; background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tag-search-panel.open { display: block; animation: calloutFadeIn 0.3s ease-out; }
.tag-search-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.25rem; background: var(--parchment); border-bottom: 1px solid var(--border); }
.tag-search-panel-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.tag-search-ai-zone { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, rgba(26,58,92,0.03), rgba(184,134,11,0.03)); }
.tag-search-ai-prompt { display: flex; align-items: center; gap: 0.75rem; }
.tag-search-ai-icon { flex-shrink: 0; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--accent); border-radius: 50%; color: white; }
.tag-search-ai-text { flex: 1; }
.tag-search-ai-text .ai-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 0.15rem; display: flex; align-items: center; gap: 0.3rem; }
.tag-search-ai-text .ai-desc { font-size: 0.85rem; color: var(--ink-light); line-height: 1.4; }
.ai-analysis-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.15rem; background: var(--accent); color: white; border: none; border-radius: 20px; font-family: var(--font-body); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: var(--transition); }
.ai-analysis-btn:hover { background: var(--accent-light); }
.ai-analysis-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-result { padding: 1rem 0 0; }
.ai-result-analysis { font-size: 0.93rem; line-height: 1.7; color: var(--ink); margin-bottom: 1rem; }
.ai-evidence { margin-bottom: 0.75rem; }
.ai-evidence-quote { font-family: var(--font-display); font-style: italic; font-size: 0.95rem; color: var(--ink-light); padding: 0.5rem 0.75rem; background: var(--parchment); border-left: 2px solid var(--gold); border-radius: 0 4px 4px 0; margin-bottom: 0.25rem; }
.ai-evidence-explanation { font-size: 0.85rem; color: var(--ink-lighter); padding-left: 0.75rem; }
.ai-connection { font-size: 0.88rem; color: var(--ink-light); font-style: italic; padding-top: 0.5rem; border-top: 1px solid var(--border); margin-top: 0.75rem; }
.tag-search-panel-body { padding: 0; overflow-y: auto; max-height: 400px; }
.tag-search-section { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
.tag-search-section-title { font-family: var(--font-display); font-size: 0.82rem; font-weight: 600; color: var(--ink-lighter); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.tag-search-ch-link { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; font-size: 0.9rem; color: var(--ink); text-decoration: none; transition: var(--transition); }
.tag-search-ch-link:hover { color: var(--accent); }
.tag-search-ch-link .ch-badge { font-family: var(--font-display); font-weight: 600; color: var(--accent); min-width: 2rem; }
.tag-search-ch-link.current { font-weight: 600; color: var(--accent); }
.tag-search-snippet { padding: 0.5rem 0.75rem; margin: 0.35rem 0; background: var(--cream); border-radius: 4px; font-size: 0.85rem; line-height: 1.6; color: var(--ink-light); border-left: 2px solid var(--border); }
.tag-search-snippet mark { background: rgba(184,134,11,0.25); color: var(--ink); padding: 0.05em 0.15em; border-radius: 2px; }

/* === AI ASK BOX === */
.ai-ask-box { flex-shrink: 0; width: 300px; }
.ai-ask-collapsed { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 1rem; cursor: pointer; background: white; border: 1px solid var(--border); border-radius: 24px; font-family: var(--font-body); font-size: 0.85rem; color: var(--ink-lighter); transition: var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.ai-ask-collapsed:hover { border-color: var(--accent); color: var(--accent); }
.ai-ask-collapsed svg { stroke: var(--accent); flex-shrink: 0; }
.ai-ask-expanded { display: none; background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.ai-ask-box.open .ai-ask-collapsed { display: none; }
.ai-ask-box.open .ai-ask-expanded { display: block; animation: calloutFadeIn 0.3s ease-out; }
.ai-ask-header { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.85rem; background: linear-gradient(135deg, var(--accent), var(--accent-light)); color: white; }
.ai-ask-label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ai-ask-minimize { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1.2rem; cursor: pointer; padding: 0 0.3rem; line-height: 1; }
.ai-ask-minimize:hover { color: white; }
.ai-ask-hint { padding: 0.6rem 0.85rem 0.35rem; font-size: 0.78rem; color: var(--ink-lighter); line-height: 1.45; }
.ai-ask-input-row { display: flex; align-items: center; gap: 0; padding: 0.35rem 0.85rem 0.5rem; }
.ai-ask-input { flex: 1; padding: 0.5rem 0.7rem; font-family: var(--font-body); font-size: 0.85rem; border: 1px solid var(--border); border-right: none; border-radius: var(--radius) 0 0 var(--radius); outline: none; color: var(--ink); }
.ai-ask-input:focus { border-color: var(--accent); }
.ai-ask-input::placeholder { color: var(--ink-lighter); font-size: 0.8rem; }
.ai-ask-submit { padding: 0.5rem 0.7rem; background: var(--accent); color: white; border: 1px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; transition: var(--transition); display: flex; align-items: center; }
.ai-ask-submit:hover { background: var(--accent-light); }
.ai-ask-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-ask-suggestions { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0 0.85rem 0.65rem; }
.ai-ask-chip { padding: 0.25rem 0.6rem; font-size: 0.72rem; background: var(--parchment); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; color: var(--ink-light); transition: var(--transition); white-space: nowrap; }
.ai-ask-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); }
.ai-ask-result { max-height: 350px; overflow-y: auto; border-top: 1px solid var(--border); }
.ai-ask-result:empty { display: none; border-top: none; }
.ai-ask-answer { padding: 0.85rem; font-size: 0.88rem; line-height: 1.7; color: var(--ink); }
.ai-ask-answer p { margin: 0 0 0.6rem; }
.ai-ask-loading { padding: 1.25rem; text-align: center; color: var(--ink-lighter); font-size: 0.85rem; font-style: italic; }
.ai-ask-q { padding: 0.5rem 0.85rem; font-size: 0.8rem; background: var(--parchment); color: var(--ink-light); font-style: italic; border-bottom: 1px solid var(--border); }

/* === SEARCH MODAL === */
.search-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); justify-content: center; padding-top: 80px; }
.search-overlay.open { display: flex; }
.search-modal { background: white; width: 90%; max-width: 640px; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; max-height: 70vh; display: flex; flex-direction: column; }
.search-modal-header { display: flex; align-items: center; padding: 1rem 1.25rem; gap: 0.75rem; border-bottom: 1px solid var(--border); }
.search-modal-header input { flex: 1; border: none; font-family: var(--font-body); font-size: 1.05rem; outline: none; color: var(--ink); background: transparent; }
.search-modal-header input::placeholder { color: var(--ink-lighter); }
.search-close { background: none; border: none; cursor: pointer; color: var(--ink-lighter); padding: 0.25rem; font-size: 1.3rem; border-radius: 4px; line-height: 1; }
.search-close:hover { background: var(--parchment); color: var(--ink); }
.search-results { overflow-y: auto; flex: 1; }
.search-result { padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition); display: block; text-decoration: none; color: var(--ink); }
.search-result:hover { background: var(--accent-faint); }
.search-result-title { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.search-result-context { font-size: 0.88rem; color: var(--ink-light); line-height: 1.5; }
.search-result-context mark { background: rgba(184,134,11,0.2); color: var(--ink); padding: 0.05em 0.15em; border-radius: 2px; }
.search-count { padding: 0.5rem 1.25rem; font-size: 0.82rem; color: var(--ink-lighter); border-bottom: 1px solid var(--border); background: var(--parchment); }
.search-empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--ink-lighter); font-style: italic; font-family: var(--font-display); font-size: 1rem; }

/* === PAYWALL === */
.paywall-overlay { position: relative; margin-top: -2rem; padding: 3rem 2rem 2.5rem; background: linear-gradient(to bottom, rgba(250,247,242,0), var(--cream) 40%); text-align: center; }
.paywall-card { max-width: 520px; margin: 0 auto; background: white; border: 1px solid var(--border); border-radius: 12px; padding: 2rem 2rem 1.5rem; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.paywall-icon { margin-bottom: 1rem; }
.paywall-icon svg { width: 48px; height: 48px; stroke: var(--accent); stroke-width: 1.5; }
.paywall-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--ink); margin-bottom: 0.5rem; }
.paywall-desc { font-size: 0.93rem; color: var(--ink-light); line-height: 1.6; margin-bottom: 1.5rem; }
.paywall-price { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--accent); margin-bottom: 0.25rem; }
.paywall-price-note { font-size: 0.82rem; color: var(--ink-lighter); margin-bottom: 1.25rem; }
.paywall-buy-btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.75rem 2rem; background: var(--accent); color: white; border: none; border-radius: 8px; font-family: var(--font-body); font-size: 1rem; font-weight: 600; cursor: pointer; transition: var(--transition); text-decoration: none; }
.paywall-buy-btn:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.paywall-features { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin: 1.25rem 0 0; }
.paywall-feature { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--ink-light); }
.paywall-feature svg { width: 14px; height: 14px; stroke: #2d8a4e; flex-shrink: 0; }
.paywall-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--ink-lighter); font-size: 0.82rem; }
.paywall-divider::before, .paywall-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.paywall-code-form { display: flex; gap: 0.5rem; max-width: 320px; margin: 0 auto; }
.paywall-code-input { flex: 1; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.9rem; text-align: center; letter-spacing: 0.1em; color: var(--ink); }
.paywall-code-input:focus { border-color: var(--accent); outline: none; }
.paywall-code-submit { padding: 0.55rem 1rem; background: var(--ink); color: white; border: none; border-radius: var(--radius); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; }
.paywall-alt { margin-top: 1rem; font-size: 0.82rem; color: var(--ink-lighter); }
.paywall-alt a { color: var(--ink-light); text-decoration: underline; }

/* === THEME SWITCHER === */
.theme-switcher { display: flex; gap: 0.35rem; align-items: center; }
.theme-dot { width: 18px; height: 18px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: var(--transition); }
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: white; box-shadow: 0 0 0 2px rgba(255,255,255,0.3); }
.theme-dot-classic { background: #1a3a5c; }
.theme-dot-crimson { background: #8B1A1A; }
.theme-dot-emerald { background: #1a5c3a; }
.theme-dot-royal { background: #4a1a6b; }

/* Settings panel (dropdown below topbar, fixed positioning) */
.settings-panel { display: none; position: fixed; top: 52px; right: 0.75rem; z-index: 110; background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1rem 1.25rem; width: 280px; animation: calloutFadeIn 0.2s ease-out; }
.settings-panel.open { display: block; }
.settings-section { margin-bottom: 1rem; }
.settings-section:last-child { margin-bottom: 0; }
.settings-label { font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-lighter); margin-bottom: 0.5rem; }
.settings-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.settings-chip { padding: 0.25rem 0.6rem; font-size: 0.78rem; border: 1px solid var(--border-strong); border-radius: 14px; background: white; color: var(--ink-light); cursor: pointer; transition: var(--transition); }
.settings-chip:hover { border-color: var(--accent); color: var(--accent); }
.settings-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.settings-size-row { display: flex; align-items: center; gap: 0.5rem; }
.settings-size-row button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); background: white; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-light); transition: var(--transition); font-family: var(--font-display); }
.settings-size-row button:hover { border-color: var(--accent); color: var(--accent); }
.settings-size-row span { flex: 1; text-align: center; font-size: 0.82rem; color: var(--ink); font-weight: 500; }
.settings-divider { height: 1px; background: var(--border); margin: 0.75rem 0; }

/* Theme dots inside settings panel — need solid visibility on white bg */
.settings-panel .theme-dot { width: 24px; height: 24px; border: 2px solid rgba(0,0,0,0.1); }
.settings-panel .theme-dot:hover { border-color: rgba(0,0,0,0.3); transform: scale(1.15); }
.settings-panel .theme-dot.active { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(0,0,0,0.15); }

/* Font theme classes applied to body */
body.font-serif { --font-body: 'Cormorant Garamond', Georgia, serif; }
body.font-sans { --font-body: 'Source Sans 3', 'Segoe UI', sans-serif; }
body.font-modern { --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif; --font-display: system-ui, -apple-system, 'Segoe UI', sans-serif; }
body.font-mono { --font-body: 'Courier New', Courier, monospace; --font-display: Georgia, serif; }
body.font-dyslexic { --font-body: 'Comic Sans MS', 'OpenDyslexic', cursive, sans-serif; letter-spacing: 0.03em; word-spacing: 0.1em; }

/* Text size classes */
body.size-sm .speech-text, body.size-sm .content { font-size: 0.95rem; }
body.size-md .speech-text, body.size-md .content { font-size: 1.08rem; }
body.size-lg .speech-text, body.size-lg .content { font-size: 1.22rem; line-height: 1.75; }
body.size-xl .speech-text, body.size-xl .content { font-size: 1.38rem; line-height: 1.8; }

/* === ANIMATIONS === */
@keyframes calloutFadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* === MOBILE === */
@media (max-width: 768px) {
    .menu-btn { display: flex !important; }
    .sidebar { position: fixed; top: 52px; left: 0; bottom: 0; z-index: 90; transform: translateX(-100%); box-shadow: var(--shadow-lg); transition: transform 0.3s ease; width: 240px; min-width: 240px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { width: 240px; min-width: 240px; transform: translateX(-100%); }
    .sidebar-toggle { display: none !important; }
    .sidebar-overlay { display: none; position: fixed; inset: 0; top: 52px; background: rgba(0,0,0,0.3); z-index: 89; }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .main { padding: 1.5rem 1.25rem; }
    .hero h1 { font-size: 1.9rem; }
    .reader-title { font-size: 1.6rem; }
    .reader-header-row { flex-direction: column; gap: 0.75rem; }
    .ai-ask-box { width: 100%; }
    .text-columns { grid-template-columns: 1fr; }
    .text-col-original { border-right: none; border-bottom: 1px solid var(--border); }
    .text-toggle { display: flex; }
    .text-col.mobile-hidden { display: none; }
}