@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700;800&family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&display=swap');

:root {
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --border: #e2e8f0; --summary-bg: #eff6ff; --summary-accent: #2563eb;
  --topbar: rgba(15,23,42,0.96); --sidebar: #131c31;
}
body.theme-sepia { --bg: #f5ebd6; --card: #fdf8ee; --text: #3b2a1e; --muted: #7c6250; --border: #e6d5b8; --summary-bg: #f3e5cb; --summary-accent: #b45309; }
body.theme-dark { --bg: #080d1a; --card: #111a2e; --text: #e2e8f0; --muted: #94a3b8; --border: #23304c; --summary-bg: #17233b; --summary-accent: #38bdf8; }

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.theme-dark { background-image: radial-gradient(circle at 18% 15%, rgba(37,99,235,0.16), transparent 40%), radial-gradient(circle at 82% 80%, rgba(124,58,237,0.14), transparent 40%); }

.topbar { background: var(--topbar); color: #f8fafc; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-bottom: 1px solid #1e293b; }
.brand { font-weight: 800; font-size: 16px; background: linear-gradient(90deg, #38bdf8, #a78bfa, #f472b6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.beta-tag { font-size: 10px; background: linear-gradient(135deg,#2563eb,#7c3aed); color: #fff; padding: 2px 7px; border-radius: 6px; font-weight: 800; }
.xp-pill { background: rgba(250,204,21,0.15); color: #fde047; border: 1px solid rgba(250,204,21,0.35); padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-right: auto; }
.prog-wrap { height: 3px; background: #1e293b; width: 100%; }
.prog-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #38bdf8, #10b981); transition: width .35s; }

.btn { border: none; border-radius: 9px; padding: 7px 11px; font-weight: 700; font-size: 12px; cursor: pointer; background: #26334d; color: #f8fafc; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; transition: transform .1s; }
.btn:active { transform: scale(0.96); }
.btn.blue { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.btn.green { background: linear-gradient(135deg, #059669, #047857); }
.btn.purple { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.btn.amber { background: linear-gradient(135deg, #d97706, #b45309); }
.btn.ghost { background: rgba(148,163,184,0.16); color: var(--text); }
.btn.active-pill { outline: 2px solid #38bdf8; background: #1e40af; color: #fff; }

/* Rich Home Hero Launchpad (Replaces blank ugly screen!) */
.hero-wrap { flex: 1; overflow-y: auto; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.hero-card { width: 100%; max-width: 860px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: 0 18px 40px rgba(0,0,0,0.18); }
.hero-title { font-size: clamp(22px, 3vw, 30px); font-weight: 800; margin: 0 0 8px; line-height: 1.2; }
.hero-grad { background: linear-gradient(90deg, #38bdf8, #818cf8, #f472b6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; margin: 18px 0; }
.feat-tile { background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.feat-tile b { display: block; font-size: 13px; margin: 4px 0; }
.feat-tile span { font-size: 12px; color: var(--muted); line-height: 1.4; display: block; }
.hero-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 600px) { .hero-inputs { grid-template-columns: 1fr; } }
.hero-inputs input, .hero-inputs select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: inherit; font-weight: 600; }

/* Workspace & Split Screen */
.workspace { flex: 1; display: none; min-height: 0; position: relative; }
.workspace.active { display: flex; }
.sidebar { width: 265px; background: var(--sidebar); color: #f8fafc; border-right: 1px solid #23304c; overflow-y: auto; padding: 12px; display: none; }
.sidebar.open { display: block; }
.idx-search { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid #475569; background: #090d16; color: #fff; font-size: 12px; margin: 8px 0; }
.ch-title { font-weight: 700; font-size: 13px; color: #93c5fd; margin-top: 10px; cursor: pointer; padding: 6px; border-radius: 6px; }
.sub-item { font-size: 12px; color: #cbd5e1; padding: 6px 8px 6px 12px; cursor: pointer; border-left: 2px solid #475569; margin: 2px 0; display: flex; justify-content: space-between; }
.sub-item.active-sub { background: rgba(56,189,248,0.16); border-left-color: #38bdf8; color: #fff; font-weight: 600; }

.split { flex: 1; display: flex; flex-direction: row; min-height: 0; }
.left-pane { flex: 1; background: #070b14; display: flex; flex-direction: column; border-right: 2px solid #23304c; min-width: 0; min-height: 0; }
.right-pane { flex: 1.08; overflow-y: auto; padding: 14px; min-width: 0; min-height: 0; }
.split.mode-book .right-pane { display: none; }
.split.mode-study .left-pane { display: none; }
@media (max-width: 820px) {
  .split { flex-direction: column; }
  .left-pane { flex: none; height: 37vh; border-right: none; border-bottom: 2px solid #23304c; }
  .split.mode-book .left-pane { height: 100%; }
  .sidebar { position: absolute; z-index: 60; top: 0; bottom: 0; left: 0; width: 82%; max-width: 300px; }
}

.pdf-toolbar { background: #131c31; color: #e2e8f0; padding: 6px 10px; display: flex; align-items: center; gap: 5px; font-size: 12px; }
.page-inp { width: 44px; padding: 3px; border-radius: 6px; border: 1px solid #475569; background: #090d16; color: #fff; text-align: center; font-weight: 700; }
.pdf-scroll { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 12px; }
canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); background: #fff; }

.assist-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 9px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.ink-dots { display: inline-flex; gap: 5px; align-items: center; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); }
.dot { width: 15px; height: 15px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.dot.sel { border-color: var(--text); transform: scale(1.18); }
.exam-sel { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12px; font-weight: 700; }

.module-dock { background: #0f172a; border-top: 1px solid #23304c; display: none; justify-content: space-around; padding: 6px 4px; }
.module-dock.active { display: flex; }
.mod-btn { flex: 1; max-width: 150px; background: transparent; border: none; color: #94a3b8; font-size: 11px; font-weight: 700; padding: 5px 4px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mod-btn.active { color: #38bdf8; background: rgba(56,189,248,0.14); }
.mod-btn span.ico { font-size: 16px; }

.para-row, .q-card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,0.05); }
.para-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }
@media (max-width: 620px) { .para-grid { grid-template-columns: 1fr; } }
.para-text { font-family: 'Source Serif 4', Georgia, serif; font-size: 15.5px; line-height: 1.7; }
.summary-box { background: var(--summary-bg); border-left: 4px solid var(--summary-accent); padding: 11px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.para-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }

mark { padding: 1px 4px; border-radius: 4px; font-weight: 600; color: #0f172a; }
mark.hl-auto, mark.hl-yellow { background: #fef08a; } mark.hl-pink { background: #fbcfe8; } mark.hl-green { background: #bbf7d0; } mark.hl-blue { background: #bae6fd; }
.hide-hl mark.hl-auto { background: transparent; color: inherit; font-weight: inherit; }
body.cloze-mode mark { background: #334155 !important; color: transparent !important; cursor: pointer; border-bottom: 2px dotted #38bdf8; }
body.cloze-mode mark.revealed { background: #bbf7d0 !important; color: #0f172a !important; }

.trigger-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.trig-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(239,68,68,0.12); color: #dc2626; border: 1px solid rgba(239,68,68,0.3); }
body.theme-dark .trig-pill { color: #fca5a5; }
.q-badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; margin-bottom: 7px; }
.q-badge.neet { background: #dbeafe; color: #1e40af; } .q-badge.ini { background: #ede9fe; color: #5b21b6; } .q-badge.fill { background: #fef3c7; color: #92400e; }
.opt-btn { width: 100%; text-align: left; padding: 10px 12px; margin: 5px 0; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13.5px; cursor: pointer; }
.opt-btn.correct { background: #dcfce7 !important; border-color: #16a34a !important; color: #14532d !important; font-weight: 700; }
.opt-btn.wrong { background: #fee2e2 !important; border-color: #dc2626 !important; color: #7f1d1d !important; }
.exp-box { display: none; margin-top: 9px; padding: 10px; border-radius: 9px; background: var(--summary-bg); border-left: 4px solid var(--summary-accent); font-size: 13px; }
.exp-box.open { display: block; }
.blank-pill { display: inline-block; min-width: 86px; padding: 2px 10px; border-radius: 6px; background: #1e293b; color: #fde047; font-weight: 700; text-align: center; cursor: pointer; }
.blank-pill.shown { background: #dcfce7; color: #14532d; }
.mem-img-box { margin-top: 8px; background: rgba(250,204,21,0.1); border: 1px solid rgba(234,179,8,0.45); padding: 10px; border-radius: 10px; }
.mem-img-box img { width: 100%; max-width: 380px; border-radius: 8px; display: block; margin-top: 6px; }

.skeleton { height: 110px; border-radius: 12px; margin-bottom: 12px; background: linear-gradient(90deg, var(--border) 25%, rgba(148,163,184,0.22) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.toast { position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%) translateY(80px); background: #0f172a; color: #f8fafc; border: 1px solid #38bdf8; padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 200; opacity: 0; transition: all .25s; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.modal-bg { position: fixed; inset: 0; background: rgba(9,13,22,0.84); backdrop-filter: blur(5px); z-index: 100; display: none; justify-content: center; align-items: center; padding: 12px; }
.modal-bg.open { display: flex; }
.modal { background: var(--card); color: var(--text); width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; border-radius: 18px; padding: 20px; border: 1px solid var(--border); }
.modal input, .modal textarea, .modal select, .q-card input, .q-card textarea { width: 100%; padding: 9px; margin: 5px 0 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; }

/* Upload Loading Tab & Draw Area Snip Overlay */
.upload-prog-box { display: none; margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--summary-bg); border: 1px solid var(--summary-accent); }
.upload-prog-box.active { display: block; }
.up-bar-bg { width: 100%; height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.up-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #38bdf8, #10b981); transition: width .2s; }
.up-err { display: none; margin-top: 10px; padding: 10px; border-radius: 8px; background: rgba(239,68,68,0.16); color: #f87171; border: 1px solid #ef4444; font-size: 13px; }
.up-err.active { display: block; }
.canvas-stage { position: relative; display: inline-block; }
#snipCanvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; display: none; background: transparent; box-shadow: none; }
#snipCanvas.active { display: block; }
.snip-preview { display: flex; gap: 10px; align-items: center; background: rgba(56,189,248,0.1); border: 1px solid #38bdf8; border-radius: 10px; padding: 8px; margin-bottom: 10px; font-size: 12px; }
.snip-preview img { max-height: 70px; border-radius: 6px; border: 1px solid var(--border); }

/* First-Time Interactive Tutorial Tour */
.tour-spot { outline: 3px solid #38bdf8 !important; outline-offset: 3px; border-radius: 10px; box-shadow: 0 0 0 6px rgba(56,189,248,0.28), 0 0 26px rgba(56,189,248,0.8) !important; animation: tourPulse 1.3s infinite; }
@keyframes tourPulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(56,189,248,0.3), 0 0 18px #38bdf8; } 50% { box-shadow: 0 0 0 8px rgba(56,189,248,0.18), 0 0 30px #38bdf8; } }
.tour-card { position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%); width: calc(100% - 24px); max-width: 440px; background: var(--card); color: var(--text); border: 2px solid #38bdf8; border-radius: 16px; padding: 15px 16px; z-index: 250; box-shadow: 0 16px 40px rgba(0,0,0,0.55); display: none; }
.tour-card.open { display: block; animation: tourPop .2s ease-out; }
@keyframes tourPop { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.tour-dots { display: flex; gap: 5px; margin: 10px 0; }
.tour-dot { height: 6px; flex: 1; border-radius: 999px; background: var(--border); }
.tour-dot.on { background: linear-gradient(90deg, #38bdf8, #818cf8); }

/* Visual Mnemonic Hints Box */
.hints-box { margin-top: 8px; padding: 10px; border-radius: 9px; background: var(--card); border: 1px solid var(--border); font-size: 12.5px; line-height: 1.5; }
.hint-item { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.hint-item:last-child { border-bottom: none; }
.hint-sym { font-weight: 800; color: #38bdf8; }
body:not(.theme-dark) .hint-sym { color: #1d4ed8; }

/* Fix button clipping & dock wrapping on tablets/phones */
.mod-btn { white-space: nowrap; }
.art-stack { display: flex; flex-direction: column; gap: 8px; }
.art-stack select, .art-stack input { width: 100%; min-width: 0; margin: 0; }
