:root {
  --primary: #1e3a8a;
  --primary-deep: #142654;
  --primary-light: #3b82f6;
  --gold: #d4af37;
  --gold-soft: #eadca7;
  --bg-color: #f5f2ec;
  --text-dark: #263247;
  --card-bg: #fffdfa;
  --muted: #6b7280;
  --border: #e5e7eb;
  --poem-size: 1.28rem;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Noto Sans Ethiopic', 'Playfair Display', serif;
  background: var(--bg-color); color: var(--text-dark); line-height: 1.65;
  min-height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* --- HEADER --- */
.site-header {
  background-color: #1e3a8a;
  background-image: linear-gradient(125deg, #1e3a8a 0%, #142654 100%);
  color: white; padding: 1.1rem clamp(1rem, 3vw, 2.4rem);
  border-bottom: 4px solid #d4af37; 
  box-shadow: 0 5px 18px rgba(15,23,42,.12); 
  z-index: 5;
}
.header-content { display:flex; align-items:center; justify-content:space-between; gap:1.2rem; max-width:1500px; margin:auto; }
.header-text h1 { font-size:clamp(1.4rem,2.4vw,2.05rem); line-height:1.35; margin-bottom:.3rem; text-shadow:0 2px 4px rgba(0,0,0,.2); }
.subtitle { color:var(--gold-soft); font-size:clamp(.82rem,1.2vw,.98rem); letter-spacing:.02em; }
.header-actions { display: flex; align-items: center; gap: 0.8rem; }

.theme-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white; font-size: 1.2rem; padding: 0.5rem; border-radius: 50%;
  cursor: pointer; width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease;
}

.brand-logo { object-fit:contain; border:2px solid var(--gold); background:#fff; border-radius:13px; padding:3px; box-shadow:0 4px 12px rgba(0,0,0,.15); }
.header-logo { width:82px; height:82px; flex-shrink:0; }

/* --- MAIN LAYOUT --- */
.layout-grid { display:grid; grid-template-columns:300px minmax(0,1fr) 220px; flex:1; min-height:0; overflow:hidden; }
.sidebar { background:#fff; border-right:1px solid var(--border); min-width:0; overflow-y:auto; overscroll-behavior:contain; }
.sidebar-top { text-align:center; padding:1.2rem 1rem .9rem; border-bottom:1px solid #f1f3f6; }
.sidebar-heading { color:var(--primary); font-weight:700; margin-top:.55rem; font-size:.95rem; }
.search-wrap { margin:.85rem .85rem .65rem; display:flex; align-items:center; gap:.55rem; background:#f7f8fb; border:1px solid #e5eaf2; border-radius:10px; padding:.5rem .65rem; color:#718096; }
.search-wrap:focus-within { border-color:var(--primary-light); box-shadow:0 0 0 3px rgba(59,130,246,.1); }
.search-wrap input { min-width:0; width:100%; border:0; outline:0; background:transparent; color:var(--text-dark); font-size:.92rem; }
#poem-list { list-style:none; padding:.25rem .55rem .8rem; text-align: center; }
#poem-list li { margin:.2rem 0; }
#poem-list a { display:block; text-decoration:none; color:var(--primary); font-weight:600; font-size:1rem; line-height:1.55; padding:.8rem .85rem; border-radius:9px; border-left:3px solid transparent; transition:background .18s,color .18s,border-color .18s; }
#poem-list a:hover { background:#f4f6fb; }
#poem-list a.active { background:#eaf0ff; border-left-color:var(--gold); color:var(--primary-deep); }
.no-results { color:var(--muted); text-align:center; padding:1rem; font-size:.9rem; }

.content-area { min-width:0; overflow-y:auto; overscroll-behavior:contain; padding:clamp(1rem,2.5vw,2.2rem); display:flex; flex-direction:column; }
.welcome-card { margin:auto; max-width:760px; width:100%; text-align:center; color:var(--primary); position:relative; isolation:isolate; padding:clamp(1.5rem,4vw,3.2rem); }
.watermark-logo { position:absolute; inset:50% auto auto 50%; transform:translate(-50%,-50%); width:min(380px,80vw); aspect-ratio:1; background:url('images/logo.png') center/contain no-repeat; opacity:.1; pointer-events:none; z-index:-1; }
.cross-icon { color:var(--gold); font-size:3.3rem; margin-bottom:.55rem; }
.welcome-card h2 { font-size:clamp(1.5rem,2.3vw,2rem); margin-bottom:.5rem; }
.welcome-card p { color:#6b7280; font-size:1.12rem; }
.welcome-hint { display:block; margin-top:1.2rem; color:#64748b; font-size:.95rem; }

#detail-view { width:100%; max-width:1000px; margin:0 auto; }
.detail-topbar { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin:0 auto .85rem; max-width:900px; }
.back-btn { border:1px solid #cbd5e1; background:#fff; color:var(--primary); border-radius:999px; padding:.55rem .9rem; font-weight:700; cursor:pointer; transition:.2s; }
.back-btn:hover { background:#eef3ff; border-color:var(--primary-light); }
.reading-tools { display:flex; gap:.35rem; align-items: center; }
.reading-tools button { min-width:38px; border:1px solid #d7dce5; border-radius:8px; background:#fff; color:var(--primary); font-weight:700; padding:.4rem .55rem; cursor:pointer; }
.reading-tools button:hover { background:#edf2ff; }

.poem-card { position:relative; isolation:isolate; background-color:var(--card-bg); background-size:cover!important; background-position:center!important; background-repeat:no-repeat!important; border:1px solid #e8e1cc; border-top:5px solid var(--gold); border-radius:16px; box-shadow:0 12px 32px rgba(15,23,42,.07); width:100%; max-width:900px; margin:0 auto; padding:2.35rem clamp(1.4rem,4vw,3.2rem) 2.4rem; }
#poem-title { color:var(--primary); text-align:center; font-size:clamp(1.45rem,2.2vw,2rem); line-height:1.45; margin:.35rem 0 .55rem; }
#poem-author { text-align:center; color:#6b7280; font-style:italic; margin-bottom:1.25rem; font-size:.95rem; }
.divider { height:2px; background:linear-gradient(90deg,transparent,var(--gold),transparent); margin:1.2rem 0 1.6rem; }
#poem-body { white-space:pre-wrap; text-align:center; font-size:var(--poem-size); font-weight:500; color:#172033; line-height:2.05; max-width:720px; margin:0 auto; overflow-wrap:anywhere; }
.poem-navigation { display:flex; align-items:center; justify-content:space-between; gap:.8rem; border-top:1px dashed #cbd5e1; margin-top:2.5rem; padding-top:1.2rem; }
.nav-btn { border:0; background:var(--primary); color:#fff; padding:.75rem 1rem; border-radius:9px; cursor:pointer; font-weight:700; font-size:.95rem; transition:transform .18s,background .18s,color .18s; }
.nav-btn:hover:not(:disabled) { background:var(--gold); color:var(--primary-deep); transform:translateY(-1px); }
.nav-btn:disabled { background:#d7deeb; color:#8591a5; cursor:not-allowed; }
.poem-count { color:#6b7280; font-size:.85rem; white-space:nowrap; }

.right-panel { background:#fafbfd; border-left:1px solid var(--border); padding:1.2rem; overflow-y:auto; }
.info-card { background:#fff; border:1px solid #e9edf3; border-radius:13px; padding:1.1rem; margin-bottom:1rem; box-shadow:0 3px 12px rgba(15,23,42,.025); }
.info-icon { color:var(--gold); font-size:1.6rem; margin-bottom:.4rem; }
.info-card h3 { color:var(--primary); font-size:1rem; margin-bottom:.7rem; }
.info-card p { font-size:.92rem; color:#526174; }
.audio-title { font-weight:700; margin-bottom:.4rem; }
.coming-soon { display:inline-block; background:#f6f3e8; color:#82703b; border-radius:7px; padding:.4rem .55rem; font-size:.78rem; line-height:1.5; }
.offline-card { border-left:3px solid #6ca38c; }
.load-error { margin:auto; max-width:600px; background:#fff5f5; color:#9b2c2c; border:1px solid #fecaca; border-radius:12px; padding:1.1rem; text-align:center; }
button:focus-visible, a:focus-visible, input:focus-visible { outline:3px solid rgba(59,130,246,.45); outline-offset:2px; }
[hidden] { display:none!important; }

/* --- DARK MODE --- */
body.dark-mode {
  --bg-color: #0f172a;
  --text-dark: #f8fafc;
  --card-bg: #1e293b;
  --border: #334155;
  --muted: #cbd5e1;
}

body.dark-mode .site-header {
  background-color: #d4af37;
  background-image: linear-gradient(125deg, #d4af37 0%, #fbbf24 100%);
  border-bottom: 4px solid #1e3a8a;
  box-shadow: 0 5px 18px rgba(0,0,0,.3);
}
body.dark-mode .header-text h1, 
body.dark-mode .subtitle { 
  color: #1e3a8a; 
  text-shadow: none; 
}
body.dark-mode .theme-btn {
  background: rgba(30, 58, 138, 0.1);
  border-color: rgba(30, 58, 138, 0.3);
  color: #1e3a8a;
}

body.dark-mode .sidebar { background: #1e293b; border-right-color: #334155; }
body.dark-mode .sidebar-top { border-bottom-color: #334155; }
body.dark-mode .sidebar-heading { color: #fbbf24; }
body.dark-mode .search-wrap { background: #0f172a; border-color: #334155; color: #94a3b8; }
body.dark-mode .search-wrap input { color: #f8fafc; }
body.dark-mode #poem-list a { color: #cbd5e1; }
body.dark-mode #poem-list a:hover { background: #334155; }
body.dark-mode #poem-list a.active { background: #1e3a8a; color: #fff; border-left-color: #fbbf24; }

body.dark-mode .welcome-card { color: #cbd5e1; }
body.dark-mode .welcome-card p { color: #94a3b8; }
body.dark-mode .watermark-logo { opacity: 0.05; }

body.dark-mode .poem-card { border-color: #334155; border-top-color: #fbbf24; }
body.dark-mode #poem-title { color: #fbbf24; }
body.dark-mode #poem-author { color: #94a3b8; }
body.dark-mode #poem-body { color: #ffffff; font-weight: 600; }

body.dark-mode .back-btn, body.dark-mode .reading-tools button { background: #1e293b; border-color: #475569; color: #93c5fd; }
body.dark-mode .back-btn:hover, body.dark-mode .reading-tools button:hover { background: #334155; }
body.dark-mode .nav-btn { background: #fbbf24; color: #1e3a8a; }
body.dark-mode .nav-btn:hover:not(:disabled) { background: #d4af37; }
body.dark-mode .nav-btn:disabled { background: #334155; color: #64748b; }

body.dark-mode .right-panel { background: #0f172a; border-left-color: #334155; }
body.dark-mode .info-card { background: #1e293b; border-color: #334155; }
body.dark-mode .info-card h3 { color: #fbbf24; }
body.dark-mode .info-card p { color: #94a3b8; }

/* --- PROJECTOR MODE --- */
.projector-container {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: #000000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  color: white;
  padding: 2rem;
}

.projector-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 1rem; border-bottom: 2px solid #333;
}

.projector-title h2 { font-size: clamp(1.8rem, 3.5vw, 3rem); color: #fbbf24; margin-bottom: 0.5rem; }
.projector-title p { font-size: clamp(1rem, 2vw, 1.4rem); color: #aaa; font-style: italic; }

.projector-controls { display: flex; gap: 0.8rem; align-items: center; }

.proj-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3);
  color: white; padding: 0.6rem 1rem; border-radius: 8px; font-size: 1.1rem; cursor: pointer; transition: 0.2s;
}
.proj-btn:hover { background: rgba(255,255,255,0.25); }
.proj-btn.active { background: #fbbf24; color: black; font-weight: bold; }
.close-btn { background: rgba(220, 38, 38, 0.3); border-color: #dc2626; }

.projector-body { 
  flex: 1; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  overflow-y: auto; 
  padding: 2rem 0; 
}

.projector-text { 
  font-size: clamp(1.8rem, 4vw, 3.5rem); 
  line-height: 2; 
  text-align: center; 
  white-space: pre-wrap; 
  font-weight: 600; 
  color: #ffffff; 
  padding: 1rem; 
  max-width: 95%; 
  margin: 0 auto;
}

/* --- RESPONSIVE --- */
@media (max-width:1100px) { .layout-grid { grid-template-columns:245px minmax(0,1fr); } .right-panel { display:none; } }
@media (max-width:700px) {
  body { height:100dvh; }
  .site-header { padding:.7rem .85rem; }
  .header-content { gap:.65rem; }
  .header-text h1 { font-size:1.25rem; }
  .subtitle { font-size:.75rem; letter-spacing:0; }
  .header-logo { width:56px; height:56px; border-radius:10px; }
  .layout-grid { display:flex; flex-direction:column; overflow:hidden; }
  .sidebar { flex:1; display:flex; flex-direction:column; min-height:0; border-right:0; }
  body.reading-mode .sidebar { display:none; }
  body.reading-mode .content-area { display:flex; }
  .sidebar-top { padding:.7rem .7rem .55rem; display:flex; align-items:center; justify-content:center; gap:.7rem; }
  .sidebar-heading { margin:0; font-size:.9rem; }
  .search-wrap { margin:.65rem .75rem .35rem; }
  #poem-list { overflow-y:auto; padding:.25rem .55rem .6rem; }
  #poem-list a { padding:.7rem .8rem; font-size:.97rem; }
  .content-area { display:none; padding:.65rem; }
  body.reading-mode .content-area { flex:1; min-height:0; }
  #detail-view { padding:.2rem 0; }
  .detail-topbar { margin-bottom:.6rem; }
  .back-btn { font-size:.85rem; padding:.48rem .7rem; }
  .reading-tools button { min-width:35px; padding:.35rem .45rem; }
  .poem-card { border-radius:13px; padding:2rem 1rem 1.35rem; border-top-width:4px; box-shadow:0 5px 18px rgba(15,23,42,.05); }
  .card-logo-container { top:-22px; left:12px; }
  .card-logo { width:52px; height:52px; border-radius:9px; }
  #poem-title { margin-top:.45rem; font-size:1.38rem; }
  #poem-author { font-size:.85rem; margin-bottom:.9rem; }
  .divider { margin:1rem 0 1.1rem; }
  #poem-body { font-size:var(--poem-size); line-height:1.95; padding:0 .1rem; }
  .poem-navigation { gap:.45rem; margin-top:1.6rem; padding-top:.9rem; flex-wrap:wrap; }
  .nav-btn { flex:1 1 40%; padding:.7rem .35rem; font-size:.78rem; min-height:44px; }
  .poem-count { order:3; width:100%; text-align:center; }
  
  /* Projector Mobile */
  .projector-header { flex-direction: column; gap: 1rem; }
  .projector-controls { width: 100%; justify-content: space-between; }
  .projector-text { font-size: clamp(1.4rem, 6vw, 2.5rem); }
}
@media (max-width:380px) {
  .header-text h1 { font-size:1.08rem; }
  .subtitle { font-size:.68rem; }
  .header-logo { width:48px; height:48px; }
  .nav-btn { font-size:.72rem; }
  #poem-title { font-size:1.1rem; }
}