/* B.Ed Study Hub — soft neumorphism, mobile-first, light by default */
:root,
:root[data-theme="light"] {
  --bg: #e4e9f0;
  --text: #2c3440;
  --muted: #687384;
  --accent: #5865e8;
  --accent-ink: #ffffff;
  --err: #c2414b;
  --line: rgba(120, 135, 160, 0.28);
  --light: rgba(255, 255, 255, 0.9);
  --dark: rgba(163, 177, 198, 0.7);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #252a32;
  --text: #e3e7ee;
  --muted: #9aa3b2;
  --accent: #8c98ff;
  --accent-ink: #14161b;
  --err: #ff8a92;
  --line: rgba(160, 170, 190, 0.18);
  --light: rgba(56, 63, 74, 0.9);
  --dark: rgba(12, 14, 18, 0.8);
  color-scheme: dark;
}
:root {
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
  --raise: 8px 8px 18px var(--dark), -8px -8px 18px var(--light);
  --raise-sm: 4px 4px 10px var(--dark), -4px -4px 10px var(--light);
  --press: inset 4px 4px 10px var(--dark), inset -4px -4px 10px var(--light);
  --press-sm: inset 2px 2px 6px var(--dark), inset -2px -2px 6px var(--light);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font: 400 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  transition: background-color .25s, color .25s;
}
h1, h2, h3, h4 { font-family: Fraunces, Georgia, serif; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); }
h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }

.card { background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--raise); padding: 20px 18px; }
.card.inset { box-shadow: var(--press); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; border: 0; border-radius: var(--r-md);
  background: var(--bg); color: var(--text);
  font: 600 0.95rem Inter, system-ui, sans-serif;
  box-shadow: var(--raise-sm); cursor: pointer;
  transition: box-shadow .15s, transform .15s; -webkit-tap-highlight-color: transparent;
}
.btn:active { box-shadow: var(--press-sm); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .theme-btn:focus-visible, .seg button:focus-visible, summary:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.icon-btn, .theme-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 14px; background: var(--bg); color: var(--text);
  box-shadow: var(--raise-sm); cursor: pointer;
  font: 600 0.9rem Inter, system-ui, sans-serif; -webkit-tap-highlight-color: transparent;
}
.icon-btn:active, .theme-btn:active { box-shadow: var(--press-sm); }

/* Theme toggle: shows the icon of the mode you'll switch to */
.theme-btn { color: var(--accent); }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- Lock screen ---------- */
.corner { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 10; }
.lock-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 72px 16px 24px; }
.lock { width: 100%; max-width: 420px; text-align: center; padding: 34px 22px 28px; }
.badge-ring { width: 72px; height: 72px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); box-shadow: var(--press); }
.lock h1 { font-size: 1.7rem; margin-bottom: 6px; }
.slots { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 26px 0 10px; cursor: text; }
.slots input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px; color: transparent; caret-color: transparent; background: transparent; }
.slot { aspect-ratio: 3 / 4; border-radius: var(--r-sm); box-shadow: var(--press-sm); display: grid; place-items: center; }
.slot.filled::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--text); }
.slot.active { box-shadow: var(--press-sm), 0 0 0 2px var(--accent); }
.msg { min-height: 1.6em; font-size: 0.9rem; margin-bottom: 14px; }
.msg.err { color: var(--err); }

/* ---------- Top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.02rem; margin-right: auto; }
.logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-family: Fraunces, serif; font-weight: 700; color: var(--accent); box-shadow: var(--raise-sm); }
.top-actions { display: flex; gap: 12px; margin-left: auto; }
.top-title { min-width: 0; flex: 1; line-height: 1.3; }
.tt-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wrap { max-width: 960px; margin: 0 auto; padding: 8px 16px 40px; }

/* ---------- Segmented toggle ---------- */
.seg {
  --i: 0;
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  padding: 6px; margin: 8px 0 24px; border-radius: 18px; box-shadow: var(--press);
}
.seg-thumb {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc(50% - 6px);
  border-radius: 13px; background: var(--bg); box-shadow: var(--raise-sm);
  transform: translateX(calc(var(--i) * 100%)); transition: transform .25s ease;
}
.seg button {
  position: relative; z-index: 1; min-height: 46px; border: 0; background: none;
  font: 600 0.95rem Inter, system-ui, sans-serif; color: var(--muted); cursor: pointer;
  border-radius: 13px; -webkit-tap-highlight-color: transparent;
}
.seg button[aria-selected="true"] { color: var(--accent); }

/* ---------- Assignment (expandable) ---------- */
.assignment { padding: 0; margin-bottom: 20px; }
.assignment summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px;
  padding: 20px 18px; border-radius: var(--r-lg); -webkit-tap-highlight-color: transparent;
}
.assignment summary::-webkit-details-marker { display: none; }
.a-title { flex: 1; min-width: 0; display: grid; gap: 4px; }
.a-name { font-family: Fraunces, serif; font-weight: 700; font-size: 1.35rem; line-height: 1.2; }
.chev { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--muted); box-shadow: var(--raise-sm); transition: transform .2s; }
.assignment[open] .chev { transform: rotate(180deg); box-shadow: var(--press-sm); }
.a-sum { padding: 0 18px; }
.sets { display: grid; gap: 14px; padding: 18px 14px 18px; }
.set { border-radius: var(--r-md); box-shadow: var(--press); padding: 16px; }
.set-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.set-name { font-family: Fraunces, serif; font-weight: 700; font-size: 1.1rem; }
.tag { font-size: 0.78rem; font-weight: 600; color: var(--accent); padding: 3px 10px; border-radius: 999px; box-shadow: var(--raise-sm); }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }

.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.tile { padding: 18px; }
.tile h3 { font-size: 1.02rem; margin-bottom: 4px; }

/* ---------- Reader ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.read-wrap { max-width: 760px; }
.set-switch { display: flex; gap: 10px; margin: 6px 0 16px; overflow-x: auto; padding: 6px 4px 10px; }
.chip { flex: none; padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; color: var(--text); box-shadow: var(--raise-sm); }
.chip.on { color: var(--accent); box-shadow: var(--press-sm); }
.read-tools { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.toc { flex: 1; padding: 0; border-radius: var(--r-md); }
.toc summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ul { margin: 0; padding: 0 16px 14px; list-style: none; display: grid; gap: 4px; font-size: 0.93rem; }
.toc li a { display: block; padding: 6px 0; border-bottom: 1px solid var(--line); }
.toc li:last-child a { border-bottom: 0; }
.toc a { color: var(--text); }
.size-ctl { display: flex; gap: 10px; }

.doc { --fs: 1; padding: 26px 20px 32px; font-size: calc(1rem * var(--fs)); line-height: 1.75; }
.doc h1 { font-size: 1.7em; margin-bottom: 6px; }
.doc .doc-meta { margin-bottom: 8px; }
.doc h2 { font-size: 1.35em; margin: 1.9em 0 0.6em; padding-top: 0.6em; border-top: 1px solid var(--line); scroll-margin-top: 84px; }
.doc h3, .doc h4 { font-size: 1.1em; margin: 1.5em 0 0.4em; color: var(--accent); }
.doc p { margin: 0 0 0.9em; }
.doc ol, .doc ul { margin: 0 0 1em; padding-left: 1.4em; }
.doc li { margin-bottom: 0.5em; }
.doc li::marker { color: var(--accent); font-weight: 600; }
.doc strong { font-weight: 600; }
.tbl { overflow-x: auto; margin: 0.4em 0 1.2em; border-radius: var(--r-sm); box-shadow: var(--press-sm); }
.tbl table { width: 100%; border-collapse: collapse; font-size: 0.88em; line-height: 1.5; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 10px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .tbl table { font-size: 0.8em; }
  .tbl th, .tbl td { padding: 8px 7px; }
}
.tbl th { font-weight: 600; color: var(--accent); }
.tbl tr:last-child td { border-bottom: 0; }

.fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  display: inline-flex; align-items: center; gap: 6px; height: 50px; padding: 0 20px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
  box-shadow: var(--raise);
}
.to-top { position: fixed; left: 16px; bottom: calc(21px + env(safe-area-inset-bottom)); z-index: 25; }
.reader .foot { padding-bottom: 90px; }

.foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 10px 16px 28px; }
.foot a { color: var(--muted); text-decoration: underline; }

@media (min-width: 640px) {
  .card { padding: 26px; }
  .doc { padding: 40px 44px 48px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .sets { padding: 20px 22px 24px; }
  .seg { max-width: 420px; }
}
@media (min-width: 900px) {
  .sets { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .top { padding: 16px 28px; }
}
@media (max-width: 360px) {
  .slots { gap: 5px; }
  .brand span:last-child { font-size: 0.92rem; }
}
@media print {
  .top, .progress, .set-switch, .read-tools, .fab, .to-top, .foot { display: none !important; }
  body { background: #fff; color: #000; }
  .doc { box-shadow: none; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
