/* Colours follow the client's screens: near-black background, purple actions, teal for audio, Adept orange for highlights. */
:root {
  --bg: #0E0D14;
  --card: #1A1924;
  --field: #22212E;
  --purple: #7C3AED;
  --purple-deep: #5B21B6;
  --teal: #2DD4BF;
  --orange: #E8884A;
  --blue: #93C5FD;
  --muted: rgba(255, 255, 255, 0.6);
  --line: rgba(255, 255, 255, 0.12);
  --gradient: linear-gradient(90deg, var(--purple), var(--purple-deep));
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --tabbar: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: #fff; }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.45; cursor: default; }
img { display: block; max-width: 100%; }
svg { width: 22px; height: 22px; flex: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* Splash (screen 1) */
#splash {
  position: fixed; inset: 0; z-index: 100; background: #16121F;
  display: grid; place-items: center; transition: opacity .4s ease;
}
#splash img { width: 220px; }
#splash.gone { opacity: 0; pointer-events: none; }

/* Page and navigation bar */
#view { min-height: 100vh; padding-bottom: calc(var(--tabbar) + var(--bottom) + 24px); }
#view.no-tabs { padding-bottom: calc(var(--bottom) + 24px); }
.page { animation: slide-in .25s ease-out; }
.page.root { animation: fade-in .2s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.navbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--top) + 6px) 8px 6px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px;
  background: rgba(14, 13, 20, 0.82);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--line);
}
.navbar .title { font-weight: 600; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.navbar .left { justify-self: start; }
.navbar .right { justify-self: end; display: flex; gap: 14px; align-items: center; padding-right: 8px; }
.back { color: var(--purple); display: flex; align-items: center; gap: 2px; font-size: 17px; padding: 6px 4px; }
.back svg { width: 22px; height: 22px; }
.link { color: var(--purple); font-weight: 600; }

.large-title { padding: calc(var(--top) + 14px) 18px 6px; font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 18px; }
.wrap.narrow { max-width: 520px; }
.stack > * + * { margin-top: 18px; }
.stack.tight > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.tiny { font-size: 13px; }
.caps { font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.center { text-align: center; }
.h2 { font-size: 22px; font-weight: 700; }
.h3 { font-size: 20px; font-weight: 700; }
.headline { font-weight: 600; }

/* Tab bar (5 tabs like the client's screens) */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + var(--bottom)); padding-bottom: var(--bottom);
  background: rgba(18, 17, 26, 0.88);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--line);
}
#tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: rgba(255,255,255,.55); }
#tabbar a svg { width: 25px; height: 25px; }
#tabbar a.on { color: var(--purple); }

/* Building blocks */
.card { background: var(--card); border-radius: 20px; padding: 16px; }
.outline { border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.btn {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  padding: 16px; border-radius: 999px; background: var(--gradient); color: #fff; font-weight: 600;
}
.btn.secondary { background: var(--field); width: auto; padding: 14px 28px; margin-left: auto; margin-right: auto; }
.btn.teal { background: var(--teal); color: #052; }
.btn:active, .press:active { opacity: .8; }
.btn svg { width: 20px; height: 20px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; color: var(--purple); background: rgba(124,58,237,.18); }
.chip.teal { color: var(--teal); background: rgba(45,212,191,.18); }
.chip.blue { color: var(--blue); background: rgba(147,197,253,.18); }
.chip.orange { color: var(--orange); background: rgba(232,136,74,.18); }
.kind { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--purple); display: flex; gap: 5px; align-items: center; }
.kind.audio { color: var(--teal); }
.kind svg { width: 14px; height: 14px; }

.segmented { display: flex; background: var(--field); border-radius: 10px; padding: 2px; }
.segmented button { flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,.75); }
.segmented button.on { background: #45434f; color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }

.art {
  position: relative; overflow: hidden; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 30px; background-size: cover; background-position: center;
}
.bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--purple); border-radius: 4px; }
.bar.teal > i { background: var(--teal); }

.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; }
.icon-btn svg { width: 22px; height: 22px; }
.bookmark.on { color: var(--purple); }
.bookmark.on svg { fill: currentColor; }

.avatar {
  display: grid; place-items: center; border-radius: 50%; font-weight: 700; flex: none;
  background: linear-gradient(135deg, var(--orange), var(--purple)); border: 2px solid var(--purple);
}

.title-row { display: flex; gap: 14px; padding: 10px 0; align-items: flex-start; }
.title-row .art { width: 76px; height: 76px; }
.title-row .body { flex: 1; min-width: 0; }
.title-row .body .headline { margin-top: 2px; }
.title-row .sub { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-row .bookmark { margin-top: 18px; }
.divider { height: 0.5px; background: var(--line); }

.hscroll { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -18px; padding: 0 18px 4px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: none; }

.empty { text-align: center; padding: 40px 10px; }
.empty .circle { width: 80px; height: 80px; border-radius: 50%; background: var(--card); color: var(--purple); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .circle svg { width: 32px; height: 32px; }
.empty .btn { margin-top: 16px; }

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.input { display: flex; align-items: center; gap: 12px; background: var(--field); border-radius: 16px; padding: 0 16px; }
.input svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.input input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 16px 0; font-size: 17px; }
textarea.answer {
  width: 100%; min-height: 110px; resize: vertical; background: var(--bg); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px; outline: 0; font-size: 17px;
}
textarea.answer:focus, .input:focus-within { box-shadow: 0 0 0 2px var(--purple); }
.note { font-size: 14px; color: var(--teal); }

/* For You */
.hello { display: flex; align-items: center; gap: 14px; padding: calc(var(--top) + 14px) 0 0; }
.hello h1 { font-size: 28px; flex: 1; }
.motd { padding: 18px; border-radius: 20px; background: linear-gradient(135deg, rgba(124,58,237,.25), var(--card)); }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.featured {
  flex: 0 0 100%; scroll-snap-align: center; position: relative; height: 420px; border-radius: 24px; overflow: hidden;
  display: block; background-size: cover; background-position: center;
}
.featured .shade { position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0,0,0,.85)); }
.featured .emoji { position: absolute; inset: 0; display: grid; place-items: center; font-size: 90px; }
.featured .chip { position: absolute; top: 18px; left: 18px; }
.featured .bm { position: absolute; top: 14px; right: 14px; background: rgba(0,0,0,.5); border-radius: 50%; width: 44px; height: 44px; display: grid; place-items: center; }
.featured .info { position: absolute; left: 22px; right: 90px; bottom: 22px; }
.featured .info .h2 { font-size: 24px; }
.featured .go { position: absolute; right: 20px; bottom: 20px; width: 56px; height: 56px; border-radius: 50%; background: var(--purple); display: grid; place-items: center; }
.featured .go svg { width: 24px; height: 24px; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.dots i { width: 7px; height: 7px; border-radius: 4px; background: rgba(255,255,255,.3); transition: width .2s; }
.dots i.on { width: 22px; background: var(--purple); }
.continue { width: 290px; display: flex; align-items: center; gap: 12px; padding: 12px; }
.continue .art { width: 64px; height: 64px; border-radius: 10px; }
.reco { width: 200px; }
.reco .art { width: 200px; height: 220px; border-radius: 18px; place-items: start; padding: 12px; }
.reco .art .mins { position: absolute; left: 12px; bottom: 12px; font-size: 15px; font-weight: 600; }
.reco .art .big { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; }

/* Explore */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px; }
.tile { position: relative; }
.tile .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; margin-bottom: 12px; }
.tile .check { position: absolute; top: 12px; right: 12px; color: var(--purple); }
.search { display: flex; align-items: center; gap: 8px; background: var(--field); border-radius: 12px; padding: 0 12px; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; background: none; border: 0; outline: 0; padding: 11px 0; font-size: 17px; }

/* Magazine and reading */
.cover { height: 230px; background-size: cover; background-position: center; }
.num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: var(--purple); background: rgba(124,58,237,.18); flex: none; }
.hero { height: 240px; background-size: cover; background-position: center; display: grid; place-items: center; font-size: 80px; }
.reading p.para { font-size: 19px; line-height: 1.6; }
.vocab { color: var(--orange); font-weight: 700; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.anchor { text-decoration: underline; text-decoration-color: var(--blue); text-underline-offset: 3px; }
.explore-note { display: flex; gap: 10px; padding: 12px; border-radius: 12px; font-size: 15px; color: var(--blue); background: rgba(30,58,95,.6); }
.explore-note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.mode-bar { position: sticky; top: calc(var(--top) + 57px); z-index: 5; background: var(--bg); padding: 8px 18px; }

.pager { display: flex; flex-direction: column; height: calc(100vh - var(--top) - 160px - var(--tabbar) - var(--bottom)); height: calc(100dvh - var(--top) - 160px - var(--tabbar) - var(--bottom)); min-height: 360px; }
.pager .viewport { flex: 1; overflow: auto; background: #2a2933; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.pager .viewport img { background: #fff; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; flex-wrap: wrap; }
.tool { background: var(--field); border-radius: 10px; padding: 8px 14px; font-weight: 600; color: var(--purple); }
.tool.teal { background: var(--teal); color: #04342c; }

.player { text-align: center; padding-top: 24px; }
.player .art { width: 240px; height: 240px; border-radius: 24px; margin: 0 auto 18px; font-size: 90px; }
.player .controls { display: flex; justify-content: center; align-items: center; gap: 36px; margin: 22px 0; }
.round { width: 52px; height: 52px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
.round svg { width: 22px; height: 22px; }
.round.big { width: 72px; height: 72px; background: var(--purple); }
.round.big svg { width: 30px; height: 30px; fill: currentColor; }
.times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 6px; }

/* Pulse */
.steps { display: flex; }
.steps > div { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.steps b { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); font-size: 17px; color: #fff; }
.steps .on b { background: var(--purple); }
.steps .cur { color: var(--purple); }
.other { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }

/* Lists (profile, settings) */
.list-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; }
.list-row .ico { width: 44px; height: 44px; border-radius: 50%; background: var(--card); display: grid; place-items: center; flex: none; }
.list-row .ico svg { width: 20px; height: 20px; }
.list-row .chev { color: var(--muted); width: 18px; height: 18px; }
.group { background: var(--card); border-radius: 14px; padding: 4px 16px; }
.group .list-row + .list-row { border-top: 0.5px solid var(--line); }
.group .list-row .ico { background: var(--field); width: 36px; height: 36px; }
.group-label { font-size: 13px; color: var(--muted); text-transform: uppercase; margin: 22px 0 8px 16px; }
.stats { display: flex; text-align: center; }
.stats > div { flex: 1; }
.stats > div + div { border-left: 0.5px solid var(--line); }
.stats b { display: block; font-size: 22px; }
.danger { color: #F87171; }

/* Teacher */
.banner { background: rgba(232,136,74,.15); color: var(--orange); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpis .card b { display: block; font-size: 26px; }
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.class { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
table.class th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; padding: 8px 6px; border-bottom: 0.5px solid var(--line); }
table.class td { padding: 12px 6px; border-bottom: 0.5px solid var(--line); }
table.class tr.me td { background: rgba(124,58,237,.12); }
.score { font-weight: 600; }
.score.hi { color: var(--teal); }
.score.mid { color: #FBBF24; }
.score.lo { color: #F87171; }

/* Scanner */
.scanner { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 60vh; width: 100%; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid var(--teal); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Sheets and dialogs */
#overlay:empty { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; animation: fade-in .2s; }
.sheet { width: 100%; max-width: 560px; background: #1f1e29; border-radius: 22px 22px 0 0; padding: 24px 24px calc(24px + var(--bottom)); animation: up .25s ease-out; }
.backdrop.center { align-items: center; padding: 24px; }
.backdrop.center .sheet { border-radius: 22px; text-align: center; padding: 26px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: -12px auto 14px; }

/* Wider screens (iPad, Chromebook) */
@media (min-width: 760px) {
  .featured { flex-basis: 70%; height: 440px; }
  .large-title { max-width: 720px; margin: 0 auto; padding-left: 18px; }
}

/* Labels sitting on top of pictures need a dark backing to stay readable */
.featured .chip, .reco .art .chip { background: rgba(14, 13, 20, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.featured .chip { color: #C4B5FD; }
.reco .art .chip { color: #fff; }
.reco .art .chip.teal { color: var(--teal); }
