:root {
  --bg: #09090b;
  --surface: #121216;
  --surface-2: #1a1a21;
  --text: #f8fafc;
  --muted: #a1a1aa;
  --primary: #eab308;
  --primary-strong: #ca8a04;
  --primary-soft: rgba(234, 179, 8, 0.14);
  --border: rgba(234, 179, 8, 0.24);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --glow: 0 0 15px rgba(234, 179, 8, 0.3);
}

body.light-mode {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --primary: #d97706;
  --primary-strong: #b45309;
  --primary-soft: rgba(217, 119, 6, 0.12);
  --border: rgba(217, 119, 6, 0.28);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --glow: 0 0 15px rgba(217, 119, 6, 0.15);
}

body.girly-mode {
  --bg: #fdf2f8;
  --surface: #fff1f2;
  --surface-2: #fce7f3;
  --text: #831843;
  --muted: #be185d;
  --primary: #ec4899;
  --primary-strong: #db2777;
  --primary-soft: rgba(236, 72, 153, 0.12);
  --border: rgba(236, 72, 153, 0.25);
  --shadow: 0 12px 32px rgba(236, 72, 153, 0.1);
  --glow: 0 0 20px rgba(236, 72, 153, 0.3);
}

body.blood-mode {
  --bg: #0c0202;
  --surface: #1a0505;
  --surface-2: #2d0a0a;
  --text: #fda4af;
  --muted: #f43f5e;
  --primary: #e11d48;
  --primary-strong: #be123c;
  --primary-soft: rgba(225, 29, 72, 0.15);
  --border: rgba(225, 29, 72, 0.3);
  --shadow: 0 12px 32px rgba(225, 29, 72, 0.2);
  --glow: 0 0 25px rgba(225, 29, 72, 0.4);
}

body.anime-mode {
  --bg: #1e1b4b;
  --surface: #312e81;
  --surface-2: #3730a3;
  --text: #e0e7ff;
  --muted: #818cf8;
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.15);
  --border: 2px solid #6366f1;
  --shadow: 8px 8px 0px #000;
  --glow: 0 0 20px rgba(99, 102, 241, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: "Cairo", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell {
  max-width: 540px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 14.5px;
  color: var(--primary);
}

/* Theme Chooser (Dropdown with Smooth Transitions) */
.theme-selector {
  position: relative;
}

.theme-btn {
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  width: 140px;
  box-shadow: var(--shadow);
}
.theme-dropdown.open { display: flex; animation: slideIn 0.2s ease; }

.theme-opt {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12.5px;
  text-align: right;
  cursor: pointer;
  width: 100%;
}
.theme-opt:hover, .theme-opt.active {
  background: var(--primary-soft);
  color: var(--primary);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home Section */
.view-panel {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  gap: 12px;
}
.view-panel.active { display: flex; }

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Animated Portrait Frame */
.prof-avatar-wrap {
  width: 148px !important;
  height: 148px !important;
  margin: 0 auto 14px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: #000000 !important;
  border: 3px solid var(--gold, #eab308) !important;
  box-shadow: 0 0 28px rgba(234, 179, 8, 0.30) !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: var(--glow); }
  100% { transform: scale(1.03); box-shadow: 0 0 25px var(--primary); }
}

.prof-avatar {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  transform: scale(1.25) translate(19%, 11%) !important;
}

.prof-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.prof-subtitle {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--primary);
}

.series-pill {
  background: var(--primary-soft);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 900;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.social-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
}

.social-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease;
}
.social-btn:active { transform: scale(0.93); }
.social-btn svg { width: 22px; height: 22px; fill: #fff; }
.soc-yt { background: #FF0000; }
.soc-fb { background: #1877F2; }
.soc-ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.soc-tg { background: #26A5E4; }

/* Action Buttons & Sounds */
.primary-cta {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 15px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #000;
  box-shadow: var(--glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s;
}
.primary-cta:active { transform: scale(0.97); }

.full-pdf-cta {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 13px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s;
}
.full-pdf-cta:active { transform: scale(0.98); }

/* Topics View */
.topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.back-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.search-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.topics-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lesson-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lesson-info {
  min-width: 0;
  flex: 1;
}

.lesson-badge {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 900;
  color: var(--primary);
}

.lesson-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-yt, .btn-pdf {
  border: none;
  border-radius: 12px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-yt { background: #dc2626; color: #fff; }
.btn-pdf { background: var(--primary-soft); border: 1.5px solid var(--border); color: var(--text); }

/* Footer */
.app-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 14px;
  text-align: center;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}

.rights-line {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text);
}

.dev-line {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.dev-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 900;
}

/* Advanced Modal Options */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  position: relative;
}

.modal-box.viewer-mode {
  max-width: 760px;
  height: 86dvh;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.pdf-frame {
  width: 100%;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  margin-top: 12px;
}

.btn-mute {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
}

/* === MULTI-THEME BACKGROUNDS === */
body {
  background: linear-gradient(rgba(9, 9, 11, 0.55), rgba(9, 9, 11, 0.72)),
              url("https://i.ibb.co/Q7cHRHr6/file-00000000a6c08210b0f036feacded412.png") center/cover no-repeat fixed !important;
  --surface: rgba(18, 18, 22, 0.76);
  --surface-2: rgba(26, 26, 33, 0.82);
}

body.light-mode {
  background: linear-gradient(rgba(255, 255, 255, 0.45), rgba(248, 250, 252, 0.65)),
              url("https://i.ibb.co/XZ9C6cqS/file-0000000010748210bdf38db1f6b90454.png") center/cover no-repeat fixed !important;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(241, 245, 249, 0.84);
}

body.girly-mode {
  background: linear-gradient(rgba(253, 242, 248, 0.35), rgba(252, 231, 243, 0.55)),
              url("https://i.ibb.co/WvhML5tm/file-0000000035688210a1cb374a8901eb01.png") center/cover no-repeat fixed !important;
  --surface: rgba(255, 241, 242, 0.78);
  --surface-2: rgba(252, 231, 243, 0.84);
}

body.blood-mode {
  background: linear-gradient(rgba(12, 2, 2, 0.52), rgba(20, 4, 4, 0.72)),
              url("https://i.ibb.co/RkC2Dn3Q/file-00000000dcf48210be7185c06bfb4535.png") center/cover no-repeat fixed !important;
  --surface: rgba(26, 5, 5, 0.78);
  --surface-2: rgba(45, 10, 10, 0.84);
}

body.anime-mode {
  background: linear-gradient(rgba(15, 12, 41, 0.50), rgba(30, 27, 75, 0.70)),
              url("https://i.ibb.co/qLbPMLfk/file-0000000072008243878ed52fe77353b0.png") center/cover no-repeat fixed !important;
  --surface: rgba(49, 46, 129, 0.76);
  --surface-2: rgba(55, 48, 163, 0.82);
}

.topbar,
.hero-card,
.lesson-card,
.app-footer,
.theme-dropdown,
.modal-box,
.back-btn,
.search-input {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}



/* === 5 THEMES DROPDOWN === */
.theme-selector { position: relative; }
.theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 9999;
  width: 145px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.theme-dropdown.open { display: flex; }
.theme-opt {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12.5px;
  text-align: right;
  cursor: pointer;
  width: 100%;
}
.theme-opt:hover, .theme-opt.active {
  background: var(--gold-soft, rgba(234,179,8,0.16));
  color: var(--gold, #eab308);
}
body.girly-mode { --text: #831843; --muted: #be185d; --gold: #ec4899; --border: rgba(236,72,153,0.35); }
body.blood-mode { --text: #fda4af; --muted: #f43f5e; --gold: #e11d48; --border: rgba(225,29,72,0.4); }
body.anime-mode { --text: #e0e7ff; --muted: #a5b4fc; --gold: #818cf8; --border: rgba(99,102,241,0.45); }

/* === FIX DROPDOWN Z-INDEX & AVATAR RING === */
.topbar {
  position: relative !important;
  z-index: 1000 !important;
}
.prof-avatar-wrap {
  width: 148px !important;
  height: 148px !important;
  margin: 0 auto 14px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: #000000 !important;
  border: 3px solid var(--gold, #eab308) !important;
  box-shadow: 0 0 28px rgba(234, 179, 8, 0.30) !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* === PRO AVATAR CENTER & SVG ICONS === */
.prof-avatar-wrap {
  width: 148px !important;
  height: 148px !important;
  margin: 0 auto 14px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: #000000 !important;
  border: 3px solid var(--gold, #eab308) !important;
  box-shadow: 0 0 28px rgba(234, 179, 8, 0.30) !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.prof-avatar {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  transform: scale(1.25) translate(19%, 11%) !important;
}
.pro-ico {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-opt {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

/* === HERO POSTER BANNER === */
.hero-poster-wrap {
  width: 100%;
  max-width: 240px;
  margin: 14px auto 18px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--gold, #eab308);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  background: #000;
}
.hero-poster-img {
  width: 100%;
  height: auto;
  display: block;
}


/* === POSTER AS HERO CARD BACKGROUND === */
.hero-card, .card, main > section:first-of-type {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(180deg, rgba(10, 12, 20, 0.58) 0%, rgba(10, 12, 20, 0.78) 55%, rgba(10, 12, 20, 0.88) 100%), url('assets/poster.png?v=16') !important;
  background-size: cover !important;
  background-position: center !important;
}
body.light-mode .hero-card, body.light-mode .card, body.light-mode main > section:first-of-type {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.68) 0%, rgba(255, 255, 255, 0.84) 60%, rgba(255, 255, 255, 0.92) 100%), url('assets/poster.png?v=16') !important;
}
body.girly-mode .hero-card, body.girly-mode .card, body.girly-mode main > section:first-of-type {
  background-image: linear-gradient(180deg, rgba(255, 240, 247, 0.68) 0%, rgba(255, 232, 243, 0.85) 60%, rgba(255, 224, 239, 0.92) 100%), url('assets/poster.png?v=16') !important;
}
.hero-card h1, .hero-card p, .card h1, .card p {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
body.light-mode .hero-card h1, body.girly-mode .hero-card h1,
body.light-mode .card h1, body.girly-mode .card h1 {
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.85);
}


/* === PRO YOUTUBE MODAL & ONEDRIVE PDF MENU === */
.yt-btn-pro {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #ff1e1e, #c80000) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 800;
  cursor: pointer;
}
.pdf-btn-pro {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 800;
  cursor: pointer;
}
.compta-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 13, 0.82);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10000;
}
.compta-modal-backdrop.open {
  display: flex;
}
.compta-modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface, #121624);
  color: var(--text, #f8fafc);
  border: 1px solid var(--border, rgba(234, 179, 8, 0.35));
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  position: relative;
  animation: modalPop 0.2s ease-out;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.compta-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.compta-modal-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}
.compta-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text, #f8fafc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.yt-thumb-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #090b10;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
  position: relative;
}
.yt-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.yt-watch-cta {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #ff1e1e, #b91c1c);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.35);
}
.pdf-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.pdf-choice-btn {
  width: 100%;
  padding: 13px 15px;
  border-radius: 15px;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #f8fafc);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: right;
  transition: transform 0.15s ease, background 0.15s ease;
}
.pdf-choice-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}
.pdf-choice-left {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}
.pdf-preview-frame {
  width: 100%;
  height: 68vh;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  background: #ffffff;
  display: none;
  margin-top: 12px;
}
.pdf-preview-frame.open {
  display: block;
}
