/* App-specific tokens (Bible App) */
:root{
  --panel-w:310px;
  /* Back-compat aliases */
  --gold:var(--accent);
  --gold-light:var(--accent-light);
}

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

body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh; display: flex; overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ── Left Panel ── */
#panel {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--panel-w);
  background: var(--surface);
  border-right: 1px solid var(--border); z-index: 50;
  display: flex; flex-direction: column;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}
#panel.hidden { transform: translateX(calc(-1 * var(--panel-w))); }

#panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
#panel-header h2 {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.ph-close {
  font-family: var(--font-ui); font-size: 11px; font-weight: 500; color: var(--muted);
  background: none; border: 1px solid var(--border); padding: 4px 8px; border-radius: 4px;
  cursor: pointer; transition: all .2s;
}
.ph-close:hover { color: var(--text); background: var(--active); }

#panel-body {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 24px;
}
#panel-body::-webkit-scrollbar { width: 6px; }
#panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.p-section { display: flex; flex-direction: column; gap: 8px; }
.p-label {
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.p-divider { height: 1px; background: var(--border); margin: 4px 0; }

label.f { display: block; font-size: 11px; font-weight: 500; color: var(--muted);
  margin-bottom: 4px; margin-top: 12px; text-transform: uppercase; }
label.f:first-of-type { margin-top: 0; }

select, input[type="number"], input[type="text"], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font-ui); font-size: 14px;
  padding: 8px 10px; border-radius: 4px; outline: none; appearance: none; transition: border-color .2s;
}
select:focus, input:focus, textarea:focus { border-color: var(--gold); }
optgroup { color: var(--muted); font-weight: 600; font-size: 12px; }
option { color: var(--text); background: var(--bg); }
.row2 { display: flex; gap: 10px; } .row2>div { flex: 1; }

.btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  padding: 8px 12px; border: none; border-radius: 4px; cursor: pointer; transition: all .2s; width: 100%;
}
.btn-primary {
  background: var(--gold); color: #fff; font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--active); }
.nav-row { display: flex; gap: 8px; }
.nav-row .btn { flex: 1; }

/* Keyword search */
#keyword-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
#keyword-results::-webkit-scrollbar { width: 6px; }
#keyword-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.result-item { background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 10px 12px; cursor: pointer; transition: all .2s; }
.result-item:hover { border-color: var(--gold); background: var(--active); }
.result-ref { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--gold); margin-bottom: 4px; }
.result-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.result-text mark { background: rgba(35, 131, 226, 0.2); color: var(--gold); border-radius: 2px; padding: 0 2px; }
.search-count { font-size: 12px; color: var(--muted); margin-top: 6px; }
.no-results { color: var(--muted); font-size: 13px; padding: 6px 0; }
.fetching { color: var(--muted); font-size: 13px; padding: 6px 0; }
#cache-status { font-size: 11px; color: var(--muted); margin-top: 6px; display: none; }

/* Search Modal List Scrolling */
#search-modal-list::-webkit-scrollbar { width: 6px; }
#search-modal-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Display settings */
.s-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--border); border-radius: 2px; outline: none; cursor: pointer; }
.s-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--gold); cursor: pointer; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-val { font-size: 12px; color: var(--muted); min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: all .15s; }
.swatch:hover, .swatch.active { border-color: var(--gold); transform: scale(1.1); }
.color-custom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.color-custom input[type="color"] { width: 30px; height: 24px; border: 1px solid var(--border); background: none; cursor: pointer; border-radius: 4px; padding: 1px; }
.color-custom span { font-size: 12px; color: var(--muted); }
.s-btn { font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  padding: 8px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 4px; cursor: pointer; transition: all .2s; width: 100%; text-align: center; }
.s-btn:hover { background: var(--active); }
.s-btn.active { background: rgba(35, 131, 226, 0.1); color: var(--gold); border-color: var(--gold); }

/* Feature request */
.fr-open-btn {
  display: block; text-align: center; font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  color: var(--text); border: 1px solid var(--border); padding: 8px 12px; border-radius: 4px;
  cursor: pointer; transition: all .2s; background: var(--surface); width: 100%;
}
.fr-open-btn:hover { background: var(--active); }

/* Recent verses */
.recent-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: hidden; margin-top: 6px; }
.recent-list:hover { overflow-y: auto; }
.recent-list::-webkit-scrollbar { width: 6px; }
.recent-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.recent-item { background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 10px 12px; cursor: pointer; transition: all .2s; position: relative; }
.recent-item:hover { border-color: var(--gold); background: var(--active); }
.recent-item.active { border-left: 3px solid var(--gold); }
.ri-ref { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--gold); margin-bottom: 4px; }
.ri-preview { font-size: 13px; line-height: 1.4; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-time { font-size: 10px; color: var(--muted); margin-top: 4px; }
.recent-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }

/* Font style buttons & Filter Tabs */
.font-style-btns { display: flex; gap: 6px; margin-top: 6px; }
.font-style-btn { flex: 1; padding: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 4px; cursor: pointer; transition: all .2s; font-size: 13px; text-align: center; }
.font-style-btn:hover { background: var(--active); }
.font-style-btn.active { background: rgba(35, 131, 226, 0.1); color: var(--gold); border-color: var(--gold); }

/* ── Toggle Tab ── */
#panel-tab {
  position: fixed; top: 50%; left: 0; transform: translateY(-50%);
  z-index: 60; background: var(--surface); border: 1px solid var(--border);
  border-left: none; color: var(--text); cursor: pointer;
  padding: 12px 6px; border-radius: 0 4px 4px 0; transition: all .3s;
  writing-mode: vertical-rl; font-family: var(--font-ui); font-size: 11px;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em;
}
#panel-tab:hover { background: var(--active); }
#panel.hidden ~ #panel-tab { left: 0; }
#panel:not(.hidden) ~ #panel-tab { left: var(--panel-w); }

/* ── Main Stage ── */
#main {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  position: relative; z-index: 1; margin-left: var(--panel-w);
  transition: margin-left var(--transition); 
  min-height: 100vh; 
  overflow-y: hidden; /* Forces no scrolling for the stage */
}
#main.expanded { margin-left: 0; }

.stage-content { 
  width: 100%; 
  max-width: 1400px; 
  padding: 12vh 4% 160px; /* Safe padding from footer and edges */
  text-align: center; position: relative; z-index: 1; 
}

/* Top-left verse info */
#verse-info{
  position: relative; width: 100%; text-align: center;
  pointer-events: none; margin: 0 0 16px 0;
}
#verse-info-ref{
  font-family: var(--font-ui); font-size: 32px; font-weight: 700;
  color: var(--text); display: block; line-height: 1.3; letter-spacing: -0.02em;
}
#verse-info-badge { 
  display: inline-block; font-size: 12px; font-weight: 500; color: var(--muted);
  background: var(--active); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 4px; margin-top: 8px;
}

/* Bottom-left broadcast indicator */
#statusbar {
  position: fixed; bottom: 70px; left: 20px;
  display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 500; color: var(--muted);
  font-family: var(--font-ui); z-index: 25; transition: opacity .3s, margin-left var(--transition);
  margin-left: var(--panel-w); text-transform: uppercase; letter-spacing: 0.05em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.dot.live { background: #5ddb8a; box-shadow: none; animation: none; }

/* Footer nav bar */
#footer-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border);
  transition: padding var(--transition);
}

#footer-nav select, #footer-nav input[type="number"], #footer-nav input[type="text"] {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font-ui); font-size: 13px;
  padding: 6px 10px; border-radius: 4px; outline: none; appearance: none; cursor: pointer;
}
#footer-nav select:focus, #footer-nav input:focus { border-color: var(--gold); }
#fn-version { min-width: 200px; width: auto; }

#footer-nav option, #footer-nav optgroup { background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; }

.fn-label { font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 4px; }
.fn-group { display: flex; flex-direction: column; }
.fn-narrow { width: 56px !important; max-width: 56px !important; min-width: 0 !important; text-align: center; }
.fn-sep { width: 1px; height: 32px; background: var(--border); margin: auto 4px 0; flex-shrink: 0; align-self: flex-end; }
.fn-btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  padding: 7px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 4px; cursor: pointer; transition: all .2s; white-space: nowrap; align-self: flex-end;
}
.fn-btn:hover { background: var(--active); }
.fn-btn.primary {
  background: var(--gold); color: #fff; font-weight: 600; border: none;
}
.fn-btn.primary:hover { opacity: 0.9; }

/* Recent Verses drop-up */
.fn-dropup { position: relative; align-self: flex-end; }
.fn-dropup-menu {
  display: none; position: absolute; bottom: calc(100% + 10px); right: -160px;
  width: 320px; max-height: 80vh; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  flex-direction: column; overflow: hidden; z-index: 100;
}
.fn-dropup-menu.open { display: flex; }
.fn-dropup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.fn-dropup-title { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--text); }
.fn-dropup-clear { font-family: var(--font-ui); font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; }
.fn-dropup-clear:hover { color: var(--text); }
.fn-dropup-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.fn-dropup-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .15s; }
.fn-dropup-item:hover { background: var(--active); }
.fn-dropup-item.active { border-left: 3px solid var(--gold); padding-left: calc(16px - 3px); }
.fn-ri-ref { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--gold); margin-bottom: 4px; }
.fn-ri-preview { font-size: 13px; line-height: 1.4; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fn-ri-time { font-size: 10px; color: var(--muted); margin-top: 4px; }
.fn-dropup-empty { padding: 16px; font-size: 13px; color: var(--muted); }

.waiting { display: flex; flex-direction: column; align-items: center; gap: 16px; animation: fadeIn .8s ease; }
.waiting .icon { font-size: 32px; opacity: .5; margin-bottom: 8px; color: var(--muted); }
.waiting h2 { font-family: var(--font-ui); font-size: 20px; font-weight: 600; color: var(--text); }
.waiting p { color: var(--muted); font-size: 14px; }

/* The Verse Container */
.verse-display { 
  display: none; flex-direction: column; align-items: center; 
  width: 100%; 
  animation: verseIn .4s ease forwards; 
}
@keyframes verseIn { from{opacity:0;transform:translateY(10px);} to{opacity:1;transform:translateY(0);} }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

#verse-text {
  font-family: 'EB Garamond', Georgia, serif; line-height: 1.6; font-weight: 400;
  color: var(--text); 
  width: 100%; 
  margin: 0 auto;
  transition: color .2s, font-style .15s, font-weight .15s;
}
#verse-display.transitioning{opacity:0;transition:opacity .1s ease;}
#verse-display.verse-visible{opacity:1;transition:opacity .1s ease;}
.verse-reference { display: none; }

/* Fullscreen */
body.fullscreen #panel, body.fullscreen #panel-tab, body.fullscreen #statusbar, body.fullscreen #verse-info, body.fullscreen #footer-nav { display: none !important; opacity: 0; pointer-events: none; }
body.fullscreen #main { margin-left: 0; }
#exit-fs { display: none; position: fixed; top: 16px; right: 16px; z-index: 200;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 4px; cursor: pointer; transition: all .2s; }
#exit-fs:hover { background: var(--active); }
body.fullscreen #exit-fs { display: block; }

/* Modal overlays */
.fr-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 400; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.fr-modal { background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 24px; width: 90%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.fr-modal-title { font-family: var(--font-ui); font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.fr-modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
textarea.fr-textarea { width: 100%; min-height: 100px; display: block; margin-top: 8px; }
.fr-error { font-size: 12px; color: #eb5757; margin-top: 8px; display: none; }
.fr-btns { display: flex; gap: 10px; margin-top: 20px; }
.fr-btns .btn { margin-top: 0; }
.fr-success { display: none; text-align: center; padding: 16px 0; }
.fr-success-icon { font-size: 32px; margin-bottom: 12px; }
.fr-success-title { font-family: var(--font-ui); font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.fr-success-msg { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Papyrus Notes Button */
#papyrus-btn {
  position: fixed; top: 16px; right: 16px; z-index: 150;
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 4px; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
#papyrus-btn:hover { background: var(--active); }
body.fullscreen #papyrus-btn { opacity: 0; pointer-events: none; }

#signout-btn {
  position: fixed; top: 16px; right: 110px; z-index: 150;
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 4px; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
#signout-btn:hover { color: #e03e3e; border-color: #e03e3e; background: rgba(224,62,62,0.06); }
body.fullscreen #signout-btn { opacity: 0; pointer-events: none; }

/* Verse Hover Popup */
#verse-popup { position: fixed; z-index: 300; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; transform: translateX(-6px); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 4px; padding: 12px 16px; max-width: 280px; width: 280px; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
#popup-ref { font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--gold); margin-bottom: 6px; }
#popup-text { font-size: 13px; line-height: 1.5; color: var(--text); }
#popup-ver { font-size: 10px; color: var(--muted); margin-top: 6px; }

/* MEDIA CENTER PEEK OVERLAY */
#media-peek { 
  display: none; 
  position: fixed; 
  inset: 0; 
  background: rgba(0, 0, 0, 0.7); /* Reduced from 0.95 to 0.7 */
  z-index: 2000; 
  align-items: center; 
  justify-content: center; 
  backdrop-filter: blur(5px);    /* Reduced from 15px to 5px for better visibility */
  transition: background 0.3s ease;
}
#media-content { max-width: 90%; max-height: 85%; position: relative; }


/* Interlinear */
.interlinear-verse {
  display: inline;
}
.interlinear-word {
  display: inline;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 .08em;
  transition: background .15s ease, box-shadow .15s ease;
}
#verse-popup.interlinear-hover {
  pointer-events: auto;
  max-width: 360px;
  width: 360px;
}
#verse-popup.interlinear-hover #popup-ref {
  margin-bottom: 4px;
}
#verse-popup.interlinear-hover #popup-text {
  font-size: 22px;
  line-height: 1.25;
  font-family: 'Noto Serif', 'Times New Roman', serif;
  margin-bottom: 8px;
}
#verse-popup.interlinear-hover #popup-ver {
  margin-top: 0;
}
.popup-original-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  pointer-events: auto;
}
.popup-original-link:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.lexicon-modal {
  max-width: 720px;
}
#lexicon-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text);
}
.lexicon-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lexicon-original {
  font-size: 32px;
  line-height: 1.2;
  font-family: 'Noto Serif', 'Times New Roman', serif;
}
.lexicon-translit {
  font-size: 32px;
  line-height: 1.2;
  font-family: 'Noto Serif', 'Times New Roman', serif;
  color: var(--text);
  font-style: normal;
}
.lexicon-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lexicon-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.lexicon-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.lexicon-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.lexicon-section ul {
  margin: 0;
  padding-left: 18px;
}
.lexicon-empty {
  color: var(--muted);
}
