/* Student app: phone first. */
.topbar { background: var(--hero); color: #fff; padding: .75rem 1rem; padding-top: calc(.75rem + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 12px rgba(5, 5, 26, .25); }
.topbar .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar nav { display: flex; gap: .15rem; }
.topbar nav a { color: #d6d6ff; text-decoration: none; padding: .45rem .75rem; border-radius: 9px; font-weight: 600; font-size: .9rem; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 6rem; }
.parent-banner { background: var(--accent); color: var(--night); text-align: center; padding: .4rem; font-weight: 700; font-size: .85rem; }

.welcome { background: var(--hero); color: #fff; border-radius: 18px; padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; position: relative; overflow: hidden; }
.welcome h1 { margin: 0; font-size: 1.6rem; }
.welcome .initials { width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent); color: var(--night); font-family: var(--display); font-weight: 700; font-size: 1.6rem; letter-spacing: .02em; border: 3px solid rgba(255, 255, 255, .85); }
.welcome .muted { color: #c9cafc; }
.welcome::after { content: "√x  π  ∑  ƒ(x)"; position: absolute; right: .8rem; bottom: .4rem; font-size: 1.6rem; opacity: .1; letter-spacing: .3em; pointer-events: none; }
.next { display: flex; align-items: center; gap: .7rem; }
.next .date { background: var(--brand); color: #fff; border-radius: 12px; padding: .35rem .6rem; text-align: center; font-family: var(--display); line-height: 1.05; min-width: 54px; }
.next .date b { display: block; font-size: 1.4rem; }
.next .date small { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.big-score { font-family: var(--display); font-size: 3.4rem; font-weight: 700; line-height: 1; color: var(--brand); }

/* bottom tab bar (phones) */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .topbar nav { display: none; }
  .topbar .brand .name { font-size: .98rem; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); z-index: 70; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(20, 18, 58, .06); }
  .bottom-nav a { flex: 1; text-align: center; padding: .5rem 0 .45rem; text-decoration: none; color: #8a88a8; font-size: .66rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: .15rem; min-width: 0; }
  .bottom-nav a svg { width: 23px; height: 23px; }
  .bottom-nav a.on { color: var(--brand); }
  .bottom-nav a.on svg { stroke-width: 2.4; }
  .wrap { padding: 1rem .85rem calc(5.6rem + env(safe-area-inset-bottom)); }
}

/* exam */
.exam-bar { position: sticky; top: 0; z-index: 60; background: #fff; border-bottom: 1px solid var(--line); padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); box-shadow: var(--shadow); }
.exam-bar .inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.exam-bar .title { min-width: 0; }
.exam-bar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.3rem; padding: .2rem .65rem; border-radius: 9px; background: var(--brand-2); color: var(--brand); }
.timer.low { background: var(--bad-bg); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.view-switch { display: none; }
.exam-layout { max-width: 1400px; margin: 0 auto; padding: 1rem; display: grid; grid-template-columns: 1fr 390px; gap: 1rem; align-items: start; }
.exam-layout.no-paper { grid-template-columns: minmax(0, 760px); justify-content: center; }
.paper { background: #e6e5f0; border-radius: var(--radius); padding: .5rem; max-height: calc(100vh - 90px); overflow-y: auto; position: sticky; top: 72px; }
.paper canvas { width: 100%; display: block; margin-bottom: .5rem; background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.sheet { max-height: calc(100vh - 90px); overflow-y: auto; position: sticky; top: 72px; }
.exam-layout.no-paper .sheet { max-height: none; position: static; }
.q { padding: .9rem 0; border-bottom: 1px solid var(--line); scroll-margin-top: 130px; }
.q:last-child { border-bottom: 0; }
.q-num { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--brand); margin-right: .4rem; }
.q-text { white-space: pre-wrap; margin: .3rem 0 .6rem; }
.q img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-bottom: .6rem; }
.bubbles { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; }
.bubble { width: 50px; height: 50px; border-radius: 50%; border: 2px solid #c6c3e6; background: #fff; color: var(--ink-2); font-weight: 800; font-size: 1.05rem; padding: 0; }
.bubble.on { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(59, 48, 217, .35); }
.choice-list { display: flex; flex-direction: column; gap: .45rem; }
.choice { display: flex; gap: .7rem; align-items: flex-start; justify-content: flex-start; padding: .7rem .8rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 500; text-align: left; white-space: normal; min-height: 48px; }
.choice b { color: var(--brand); min-width: 1.2rem; }
.choice.on { border-color: var(--brand); background: var(--brand-2); }
.grid-input { max-width: 180px; font-size: 1.2rem !important; font-weight: 700; letter-spacing: .05em; }
.q-dots { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.q-dots a { width: 32px; height: 32px; border-radius: 8px; background: #efeef8; color: var(--ink-2); font-size: .8rem; font-weight: 700; display: grid; place-items: center; text-decoration: none; }
.q-dots a.done { background: var(--brand); color: #fff; }
.save-state { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { font-weight: 800; font-size: 1.1rem; }
.mark.ok { color: var(--ok); }
.mark.bad { color: var(--bad); }

@media (max-width: 900px) {
  /* On phones the paper and the answer sheet each get the full screen: switch with the two tabs. */
  .view-switch { display: flex; gap: .3rem; background: #efeef8; border-radius: 11px; padding: .22rem; margin-top: .55rem; }
  .view-switch button { flex: 1; background: transparent; color: var(--ink-2); border: 0; min-height: 36px; font-size: .9rem; }
  .view-switch button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
  .exam-layout { grid-template-columns: 1fr; padding: .7rem .6rem 6rem; }
  .paper, .sheet { position: static; max-height: none; }
  .paper { padding: .35rem; }
  .exam-layout.show-answers .paper { display: none; }
  .exam-layout.show-paper .sheet { display: none; }
  .exam-layout.no-paper .sheet { display: block; }
  .sheet.card { padding: .9rem; }
  .q-dots a { width: 36px; height: 36px; }
}

/* recordings */
.player { position: relative; border-radius: 14px; overflow: hidden; background: #000; }
.player video { width: 100%; max-height: 75vh; display: block; }
.watermark { position: absolute; pointer-events: none; color: rgba(255, 255, 255, .28); font-weight: 700; font-size: .85rem; transition: top 2s, left 2s; text-shadow: 0 0 2px rgba(0, 0, 0, .4); white-space: nowrap; }
.video-card { display: flex; flex-direction: column; gap: .5rem; }
.video-thumb { aspect-ratio: 16 / 9; border-radius: 12px; background: var(--hero); display: grid; place-items: center; color: #fff; font-size: 2.2rem; }
.video-thumb.locked { background: linear-gradient(135deg, #8b89a8, #59577a); }

/* books */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.book { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: .7rem; display: flex; flex-direction: column; gap: .45rem; }
.book img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; display: block; }
.book .t { font-family: var(--display); font-weight: 600; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .02em; line-height: 1.15; }
.book .s { font-size: .8rem; color: var(--muted); }
.book .p { font-weight: 800; color: var(--brand); }
.book .btn, .book button { margin-top: auto; }
@media (max-width: 640px) {
  .book-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .book { padding: .55rem; border-radius: 14px; }
  .book .t { font-size: .95rem; }
  .book .d { display: none; }
}

/* side menu (drawer) */
.menu-btn { background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 10px; flex: none; }
.menu-btn svg { width: 22px; height: 22px; }
#drawerShade { position: fixed; inset: 0; background: rgba(5, 5, 26, .5); z-index: 900; opacity: 0; pointer-events: none; transition: opacity .2s; }
#drawerShade.on { opacity: 1; pointer-events: auto; }
#drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(330px, 86vw); z-index: 950; background: linear-gradient(165deg, #1b2fc8 0%, #2453e6 55%, #2f7bf0 100%);
  color: #fff; transform: translateX(-105%); transition: transform .25s ease; display: flex; flex-direction: column; padding: calc(1rem + env(safe-area-inset-top)) .8rem 1rem;
  border-radius: 0 22px 22px 0; box-shadow: 0 0 60px rgba(0, 0, 0, .35); overflow-y: auto; }
#drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: .7rem; padding: .3rem .4rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, .18); margin-bottom: .7rem; }
.drawer-head b { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-head small { opacity: .8; font-size: .78rem; }
.drawer-x { margin-left: auto; background: transparent; border: 2px solid rgba(255, 255, 255, .8); color: #fff; width: 34px; height: 34px; min-height: 34px; padding: 0; border-radius: 9px; flex: none; }
#drawer nav { display: flex; flex-direction: column; gap: .2rem; }
#drawer nav a { display: flex; align-items: center; gap: .85rem; color: #fff; text-decoration: none; font-weight: 600; font-size: 1.02rem; padding: .78rem .9rem; border-radius: 14px; }
#drawer nav a svg { width: 22px; height: 22px; flex: none; opacity: .95; }
#drawer nav a:hover { background: rgba(255, 255, 255, .1); }
#drawer nav a.on { background: rgba(255, 255, 255, .22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
#drawer hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .18); margin: .5rem .4rem; width: auto; }

/* exam & practice tools */
.tools-bar { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .55rem; }
.tool { background: #fff; color: var(--ink-2); border: 1px solid var(--line); min-height: 36px; padding: .35rem .7rem; font-size: .85rem; border-radius: 9px; }
.tool.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.calc-box { position: fixed; right: 1rem; bottom: 1rem; width: min(440px, 94vw); height: min(520px, 70vh); background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .3); z-index: 1200; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.calc-head { display: flex; justify-content: space-between; align-items: center; padding: .4rem .5rem .4rem .8rem; background: var(--night); color: #fff; }
.calc-head button { color: #fff; }
.calc-el { flex: 1; min-height: 0; }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.ref-grid > div { background: #f6f6fc; border-radius: 10px; padding: .6rem .7rem; font-size: .92rem; }
.ref-grid b { display: block; color: var(--brand); margin-bottom: .2rem; font-size: .82rem; }
.struck { opacity: .45; text-decoration: line-through; text-decoration-thickness: 2px; }
.bubble.struck { background: repeating-linear-gradient(135deg, #fff 0 6px, #eee 6px 8px); }
.bubble.right, .choice.right { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-bg); }
.flag-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); min-height: 30px; padding: .15rem .55rem; font-size: .78rem; border-radius: 8px; margin-left: .4rem; }
.flag-btn.on { background: #fff4dc; border-color: var(--accent); color: var(--warn); }
.q-dots a.flag { box-shadow: inset 0 -3px 0 var(--accent); }
.q-dots a.cur { outline: 2px solid var(--brand); outline-offset: 1px; }
.q-dots a.ok { background: var(--ok); color: #fff; }
.q-dots a.bad { background: var(--bad); color: #fff; }
.timer.hidden-time { color: transparent; text-shadow: none; position: relative; }
.timer.hidden-time::after { content: '⏱ show'; color: var(--brand); position: absolute; inset: 0; display: grid; place-items: center; font-size: .8rem; }
.paper-page { background: #e6e5f0; border-radius: 10px; padding: .3rem; margin-top: .6rem; }
.paper-page canvas { width: 100%; display: block; background: #fff; border-radius: 4px; }

/* practice */
.topic-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.topic-ic { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-2); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; flex: none; }
.level-seg button { flex: 1; }

/* leaderboard */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: .6rem; margin: .8rem 0 .2rem; }
.pod { flex: 1; max-width: 120px; background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 6px 6px; text-align: center; padding: .7rem .4rem; box-shadow: var(--shadow); }
.pod.p1 { padding-top: 1.4rem; border-color: var(--accent); }
.pod.me { box-shadow: 0 0 0 2px var(--brand); }
.pod .medal { font-size: 1.8rem; }
.pod b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod span { color: var(--muted); font-size: .85rem; }
.lb-rank { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-2); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.me-row { background: #f6f5ff; margin: 0 -.6rem; padding-left: .6rem; padding-right: .6rem; border-radius: 10px; }

@media (max-width: 640px) {
  .calc-box { right: 0; left: 0; bottom: 0; width: 100%; height: 62vh; border-radius: 16px 16px 0 0; }
}

/* why my answer is wrong */
.why { margin-top: .55rem; }
.why-wrong { background: var(--bad-bg); border-radius: 10px; padding: .6rem .75rem; font-size: .9rem; }
.why-wrong b { color: var(--bad); display: block; margin-bottom: .15rem; }
.why-wrong div { white-space: pre-wrap; }
.how { margin-top: .45rem; background: var(--ok-bg); border-radius: 10px; padding: .55rem .75rem; font-size: .9rem; }
.how summary { cursor: pointer; font-weight: 700; color: var(--ok); }
.how div { white-space: pre-wrap; margin-top: .35rem; }

.checkin-result { text-align: center; padding: 2.5rem 1rem; }
.checkin-result .icon { font-size: 4rem; }
