/* dream.prepnus.com/qr — scan-for-solutions. PrepNus design tokens, light (default) + dark. */
:root {
  --bg: #FFFFFF; --surface: #FAFAFA; --surface-2: #F1F3F5; --border: #E4E7EB;
  --title: #1A1A1A; --text: #1A1A1A; --muted: #5B6570; --dim: #8A929C;
  --accent: #F5B800; --accent-ink: #1A1A1A; --sky: #0EA5E9; --ok: #17A34A; --err: #DC2626;
  --shadow: 0 1px 2px rgba(16,25,35,.06), 0 8px 24px rgba(16,25,35,.06);
  --shadow-sm: 0 1px 2px rgba(16,25,35,.08);
  --radius: 16px;
  /* Reader text prefs (overridden at runtime by the settings editor). */
  --sol-font: 'Plus Jakarta Sans', 'Anek Bangla', system-ui, sans-serif;
  --sol-size: 16px;
  --sol-align: justify;
}
:root[data-theme="dark"] {
  --bg: #0F1923; --surface: #1A2733; --surface-2: #13202b; --border: #2A3A47;
  --title: #F5B800; --text: #E8E8E8; --muted: #9FB0BD; --dim: #6C7E8C;
  --accent: #F5B800; --accent-ink: #0F1923; --sky: #38BDF8; --ok: #22C55E; --err: #EF4444;
  --shadow: 0 10px 34px rgba(0,0,0,.45); --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
.qr-page {
  font-family: 'Plus Jakarta Sans', 'Anek Bangla', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; transition: background .2s, color .2s;
}
[lang="bn"], .qr-solbody { font-family: 'Anek Bangla', 'Plus Jakarta Sans', sans-serif; }

/* ── Responsive top app bar ── */
.qr-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); min-height: 54px;
}
.qr-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--title); font-weight: 800; flex-shrink: 0; font-size: 15px; }
.qr-brand img { border-radius: 6px; }
.qr-top-title { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: clamp(13px, 3.6vw, 16px); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qr-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 17px; line-height: 1; transition: background .12s, border-color .12s;
}
.qr-iconbtn:active { background: var(--surface-2); }
.qr-rescan { border: 1.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 0 12px; height: 38px; font-weight: 700; font-size: 13px; cursor: pointer; }
@media (max-width: 380px) { .qr-brand span { display: none; } }

.qr-main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 14px 96px; }

/* ── Scanner ── */
.qr-scan { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 8px; }
.qr-reader { width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: 18px; overflow: hidden; border: 2px solid var(--border); background: #000; box-shadow: var(--shadow); }
.qr-reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.qr-scan-hint { color: var(--muted); font-size: 14px; text-align: center; line-height: 1.6; max-width: 340px; }
.qr-file-btn { display: inline-block; color: var(--sky); font-weight: 700; font-size: 14px; cursor: pointer; border: 1.5px dashed color-mix(in srgb, var(--sky) 45%, var(--border)); border-radius: 10px; padding: 10px 16px; }

/* Browse my books */
.qr-browse { width: 100%; max-width: 420px; }
.qr-browse-btn { width: 100%; background: var(--surface); color: var(--text); border: 1.5px solid var(--border); border-radius: 12px; padding: 13px 16px; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: var(--shadow-sm); }
.qr-browse-btn:active { background: var(--surface-2); }
.qr-browse-panel { margin-top: 12px; }
.qr-search { width: 100%; background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 14px; font-size: 14px; margin-bottom: 10px; font-family: inherit; }
.qr-search::placeholder { color: var(--dim); }
.qr-book-list { display: flex; flex-direction: column; gap: 8px; }
.qr-book-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; color: var(--text); box-shadow: var(--shadow-sm); }
.qr-book-item .bt { font-weight: 700; font-size: 14px; }
.qr-book-item .bk { flex-shrink: 0; font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--sky); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 8px; border-radius: 6px; }
.qr-browse-empty { color: var(--dim); font-size: 13px; text-align: center; padding: 16px 0; }

.qr-toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 40; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; max-width: 90vw; text-align: center; box-shadow: var(--shadow); }

/* ── Loading ── */
.qr-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 70px 0; color: var(--muted); font-weight: 600; }
.qr-spinner { width: 34px; height: 34px; border: 3px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: qr-spin .8s linear infinite; }
@keyframes qr-spin { to { transform: rotate(360deg); } }

/* ── Book index (chapter list) ── */
.qr-book-head { margin-bottom: 18px; }
.qr-kind { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--accent-ink); background: var(--accent); padding: 3px 9px; border-radius: 6px; }
.qr-book-head h1 { font-size: clamp(20px, 5.5vw, 26px); font-weight: 800; margin: 10px 0 6px; color: var(--title); line-height: 1.3; }
.qr-hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
.qr-chapters { display: flex; flex-direction: column; gap: 10px; }
.qr-ch { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; width: 100%; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 15px 16px; cursor: pointer; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, transform .05s; }
.qr-ch:active { transform: scale(.995); }
.qr-ch[data-scanned="1"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.qr-ch-title { font-weight: 700; font-size: 15px; }
.qr-ch-count { flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--sky); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 10px; border-radius: 20px; }

/* ── Solutions (one question per view) ── */
.qr-solset-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.qr-back { width: 34px; height: 34px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); color: var(--text); border: 1.5px solid var(--border); border-radius: 10px; font-size: 20px; font-weight: 700; cursor: pointer; }
.qr-solset-head h2 { font-size: clamp(15px, 4.4vw, 19px); font-weight: 800; color: var(--title); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qr-q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm); }
.qr-q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.qr-serial { font-weight: 800; font-size: 13px; color: var(--accent-ink); background: var(--accent); padding: 4px 11px; border-radius: 8px; }
.qr-answer { font-weight: 800; font-size: 13px; color: var(--ok); }
.qr-stem { font-size: 14px; color: var(--muted); font-style: italic; margin-bottom: 8px; }
.qr-opts { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; }
.qr-opts li { font-size: 13px; color: var(--dim); }
.qr-opts b { color: var(--muted); }

/* Circled EN/BN solution selectors */
.qr-solnav { display: flex; flex-direction: column; gap: 10px; margin: 16px 2px 12px; }
.qr-solnav-row { display: flex; align-items: center; gap: 12px; }
.qr-lang-tag { flex-shrink: 0; width: 30px; font-size: 12px; font-weight: 800; letter-spacing: .5px; color: var(--muted); }
.qr-lang-en { color: var(--sky); }
.qr-lang-bn { color: var(--accent); }
:root:not([data-theme="dark"]) .qr-lang-bn { color: #B8860B; }
.qr-circles { display: flex; flex-wrap: wrap; gap: 8px; }
.qr-circle { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: transform .05s; }
.qr-circle:active { transform: scale(.94); }
.qr-circle.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 45%, transparent); }

/* Framed solution card (double frame: outer border + inner accent hairline). */
.qr-solbodies { position: relative; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 18px 17px; box-shadow: var(--shadow-sm); }
.qr-solbodies::before { content: ''; position: absolute; inset: 5px; border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent); border-radius: 10px; pointer-events: none; }
.qr-solbody { font-family: var(--sol-font); font-size: var(--sol-size); line-height: 1.85; color: var(--text); text-align: var(--sol-align); }
.qr-solbody p { margin: 0 0 12px; }
.qr-solbody ul, .qr-solbody ol { margin: 0 0 12px 22px; }
.qr-solbody li { margin: 0 0 5px; }
.qr-solbody table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.qr-solbody th, .qr-solbody td { border: 1px solid var(--border); padding: 7px 10px; font-size: 14px; }
.qr-solbody b, .qr-solbody strong { color: var(--title); }
.qr-solbody .katex { font-size: 1.05em; }
.qr-solbody .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.qr-nosol { color: var(--dim); font-style: italic; font-size: 14px; padding: 10px 0; }
.qr-img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); margin: 8px 0; cursor: zoom-in; display: block; }

.qr-empty { color: var(--dim); text-align: center; padding: 30px 0; font-size: 14px; }

/* Copy protection — solution content is view-only (anti-piracy). */
.qr-view, .qr-view * {
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.qr-img { -webkit-user-drag: none; user-drag: none; }

/* ── Reader settings editor (font / size / alignment) ── */
.qr-settings { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.4); }
.qr-settings-card { width: 100%; max-width: 480px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.25); padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 520px) { .qr-settings { align-items: center; } .qr-settings-card { border-radius: 20px; } }
.qr-settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.qr-settings-head span { font-weight: 800; font-size: 16px; color: var(--title); }
.qr-settings-close { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer; }
.qr-set-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.qr-set-row > label { flex-shrink: 0; width: 52px; font-size: 13px; font-weight: 700; color: var(--muted); }
.qr-seg { display: flex; flex: 1; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.qr-seg button { flex: 1; border: none; background: transparent; color: var(--text); font-weight: 700; font-size: 13px; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-family: inherit; }
.qr-seg button.active { background: var(--accent); color: var(--accent-ink); }
.qr-seg button[data-size="sm"] { font-size: 12px; }
.qr-seg button[data-size="lg"] { font-size: 15px; }
.qr-seg button[data-size="xl"] { font-size: 17px; }

/* ── Fixed bottom nav bar (prev / question dropdown / next) ── */
.qr-bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.qr-navbtn { flex-shrink: 0; height: 42px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-weight: 800; font-size: 14px; cursor: pointer; }
.qr-navbtn:disabled { opacity: .4; cursor: default; }
.qr-navbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.qr-qselect { flex: 1; min-width: 0; position: relative; }
.qr-qselect select { width: 100%; height: 42px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px; padding: 0 34px 0 14px; -webkit-appearance: none; appearance: none; cursor: pointer; font-family: inherit; text-align: center; }
.qr-qselect::after { content: '▾'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 13px; }

/* ── Locked / error ── */
.qr-locked { text-align: center; padding: 44px 20px; max-width: 420px; margin: 0 auto; }
.qr-lock-badge { width: 64px; height: 64px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 30px; margin: 0 auto 18px; }
.qr-locked h2 { font-size: 19px; font-weight: 800; color: var(--title); margin-bottom: 10px; line-height: 1.35; }
.qr-locked p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.qr-cta { display: inline-block; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 800; padding: 12px 22px; border-radius: 12px; }

/* ── Lightbox ── */
.qr-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: none; align-items: center; justify-content: center; padding: 24px; }
.qr-lightbox.show { display: flex; }
.qr-lightbox img { max-width: 100%; max-height: 90vh; border-radius: 10px; }
.qr-lb-close { position: absolute; top: 16px; right: 18px; background: rgba(255,255,255,.14); color: #fff; border: none; width: 42px; height: 42px; border-radius: 50%; font-size: 18px; cursor: pointer; }
