/* Top bar */
.player-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }
.player-bar .logo { font-size: 24px; }
.player-bar .logo-mark { width: 30px; height: 30px; }
.bar-divider { width: 1px; height: 28px; background: var(--hair); }
.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.back:hover { color: var(--ink); }
.bar-progress { margin-left: auto; display: flex; align-items: center; gap: 10px; font: 500 13px var(--f-mono); white-space: nowrap; }
@media (max-width: 1200px) { .back, .bar-divider { display: none; } .bar-progress .bar { width: 100px; } }
.bar-progress .bar { width: 160px; }

/* Layout */
.player { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.player.side-closed { grid-template-columns: 0 minmax(0, 1fr); }
.player.side-closed .curriculum { visibility: hidden; }

/* Curriculum sidebar */
.curriculum {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--hair);
  background: var(--bg);
}
.side-head { padding: 22px 20px 18px; border-bottom: 1px solid var(--hair); }
.side-title { margin: 0 0 14px; font: 800 28px/1 var(--f-display); font-stretch: 78%; letter-spacing: -0.02em; }
.side-pct { margin: 10px 0 0; font: 500 12px var(--f-mono); color: var(--muted); }
.side-section { display: flex; align-items: center; gap: 10px; padding: 18px 20px 8px; font-weight: 700; font-size: 14px; }
.side-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 20px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.side-row:hover { background: var(--soft); }
.side-row.active { background: var(--sec, var(--mint)); font-weight: 700; }
.side-row .label { flex: 1; min-width: 0; }
.side-row .mins { font: 500 11px var(--f-mono); color: var(--muted); }

/* Lecture area */
.lecture { padding: 36px 48px 64px; max-width: 1000px; width: 100%; min-width: 0; }
.lec-head {
  border-radius: var(--r-panel);
  background: var(--sec, var(--mint));
  padding: 28px 32px 30px;
  margin-bottom: 28px;
}
.lec-head p { margin: 0 0 10px; font-weight: 600; font-size: 14px; }
.lecture h1 { margin: 0; font-size: 60px; line-height: 0.92; overflow-wrap: break-word; }

.reading { max-width: 36em; font: 20px/1.65 var(--f-read); }
.reading p { margin: 0 0 18px; }
.reading ul, .reading ol { margin: 0 0 18px; padding-left: 24px; }
.reading li { margin-bottom: 8px; }
.reading code, .reading kbd { font-size: 0.8em; }
.ref-table { border-collapse: collapse; margin: 6px 0 22px; font: 16px var(--f-ui); }
.ref-table th, .ref-table td { border-bottom: 1px solid var(--hair); padding: 8px 22px 8px 0; text-align: left; }
.ref-table th { border-bottom: 2px solid var(--ink); font-weight: 700; }

.task { margin: 0 0 20px; font-size: 18px; max-width: 760px; }

/* Practice window: Google Sheets chrome inside a brand card */
.gs-window {
  border: 2px solid var(--ink);
  border-radius: var(--r-card);
  overflow: hidden;
  background: #fff;
  font-family: Arial, sans-serif;
}
.gs-titlebar { display: flex; align-items: center; gap: 12px; padding: 10px 14px 4px; }
.gs-doc-icon { width: 22px; height: 28px; flex: none; border-radius: 3px; background: #188038; position: relative; }
.gs-doc-icon::after { content: ""; position: absolute; inset: 9px 5px 6px; border: 2px solid #fff; border-radius: 1px; }
.gs-titles { min-width: 0; }
.gs-docname { display: flex; align-items: center; gap: 8px; font: 18px "Plus Jakarta Sans", Arial, sans-serif; color: #1f1f1f; }
.gs-docname span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-star { color: #444746; display: inline-flex; }
.gs-menus { display: flex; gap: 2px; margin-left: -6px; font-size: 14px; color: #1f1f1f; }
.gs-menus span { padding: 1px 6px; border-radius: 4px; }
.gs-saved { margin-left: auto; font: 500 12px var(--f-mono); color: var(--muted); }

.gs-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 4px 10px 6px;
  padding: 4px 8px;
  border-radius: 20px;
  background: #edf2fa;
  color: #444746;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
}
.tb { display: inline-grid; place-items: center; width: 26px; height: 24px; }
.tb svg { width: 18px; height: 18px; }
.tb-text { padding: 2px 6px; }
.tb-text.b { font-weight: 700; }
.tb-text.i { font-style: italic; font-family: Georgia, serif; }
.tb-text.s { text-decoration: line-through; }
.tb-text.u { text-decoration: underline 3px; text-underline-offset: 2px; }
.tb-num { border: 1px solid #747775; border-radius: 4px; padding: 0 8px; }
.tb-caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: #444746; margin: 4px 6px 0 -2px; }
.tb-sep { width: 1px; height: 18px; background: #c7c7c7; margin: 0 6px; }

.gs-grid { position: relative; border-top: 1px solid #c7c7c7; }
.sheet { height: 320px; }
.sheet-loading { position: absolute; inset: 0; display: grid; place-items: center; background: #fff; color: var(--muted); font-family: var(--f-ui); }

.gs-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 10px;
  background: #f9fbfd;
  border-top: 1px solid #c7c7c7;
  color: #444746;
}
.gs-tab-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; font-size: 20px; }
.gs-tab { margin-left: 6px; padding: 5px 18px; border-radius: 6px; background: #e1e9f7; color: #0b57d0; font-size: 13px; font-weight: 700; }

/* Feedback: tinted strips, no side bars */
.feedback { margin-top: 18px; padding: 13px 18px; border-radius: var(--r-node); background: var(--soft); }
.feedback.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.feedback.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.feedback.info { background: var(--hint-soft); }
.practice-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.explain { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--hair); font: 19px/1.6 var(--f-read); max-width: 40em; }
.explain b { font-family: var(--f-ui); font-size: 16px; }

/* Exam */
.exam { max-width: 640px; padding: 28px 30px; border: 2px solid var(--ink); border-radius: var(--r-card); font: 19px/1.6 var(--f-read); }
.exam p { margin: 0 0 12px; }
.exam-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 0; }
.exam .meter { display: flex; align-items: center; gap: 12px; margin-top: 18px; font: 500 13px var(--f-mono); }
.exam .meter .bar { flex: 1; }

.lec-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--hair); }


/* Task + syntax card */
.task-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 20px; }
.task-row .task { margin: 0 0 12px; }
.task-row:has(.fn-card:not([hidden])) { grid-template-columns: minmax(0, 1fr) 280px; }
.fn-card { border: 2px solid var(--ink); border-radius: var(--r-node); padding: 14px 16px; background: #fff; }
.fn-sig { margin: 0 0 6px; font: 600 15px var(--f-mono); }
.fn-sig .arg { color: #0b57d0; }
.fn-sig .arg.opt { color: var(--muted); }
.fn-does { margin: 0; font-size: 13px; color: var(--muted); }

.attempts { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.attempts .dot { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid #b9bdbb; }
.attempts .dot.miss { background: var(--bad-soft); border-color: var(--bad); }
.attempts .dot.ok { background: var(--ok); border-color: var(--ok); }
.att-label { margin-left: 6px; font: 500 12px var(--f-mono); color: var(--muted); }

/* Points */
.xp { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font: 500 13px var(--f-mono); padding: 6px 12px; border-radius: 999px; background: var(--soft); }
.xp b { font-weight: 600; }
.xp-sep { width: 1px; height: 14px; background: var(--hair); margin: 0 4px; }
.pts { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--ok); color: #fff; font: 600 12px var(--f-mono); }
.auto-hint { display: inline-block; margin-top: 6px; color: var(--ink); font-weight: 400; }

.feedback-row { display: flex; gap: 12px; align-items: stretch; margin-top: 18px; }
.feedback-row .feedback { margin-top: 0; flex: 1; }
.next-ex { align-self: center; }

/* Celebration: cells burst out of the grid */
.burst { position: absolute; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 5; }
.burst span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid #111;
  animation: burst 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) scale(1); opacity: 0; }
}

@media (max-width: 900px) {
  .player, .player.side-closed { grid-template-columns: minmax(0, 1fr); }
  .curriculum {
    position: fixed;
    top: 64px;
    left: 0;
    width: min(340px, 88vw);
    z-index: 15;
    border-right: 2px solid var(--ink);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .player.side-open .curriculum { transform: none; }
  .player.side-closed .curriculum { visibility: visible; }
  .bar-progress, #completeBtn, .bar-divider, .back { display: none; }
  .lecture { padding: 18px 16px 48px; }
  .lec-head { padding: 22px 20px; border-radius: var(--r-card); }
  .lecture h1 { font-size: 40px; }
  .gs-menus, .gs-saved { display: none; }
  .task-row { grid-template-columns: 1fr; gap: 12px; }
  .feedback-row { flex-direction: column; }
  .next-ex { align-self: stretch; }
  .xp { display: none; }
  .reading { font-size: 19px; }
  .lec-nav { flex-wrap: wrap; }
  .lec-nav .btn { white-space: normal; }
  .lec-nav .primary { flex: 1; }
}

/* Animated explainers (explain.js) */
/* No card around the explainer: the mini sheet is the frame. */
.exp {
  margin: 8px 0 28px;
  font-family: var(--f-ui);
  max-width: 560px;
}
.exp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.exp-title { margin: 0; font: 800 22px/1 var(--f-display); font-stretch: 78%; letter-spacing: -0.02em; white-space: nowrap; }
.exp-bars { flex: 1; display: flex; gap: 4px; }
.exp-bars i { flex: 1; height: 4px; border-radius: 2px; background: var(--hair); overflow: hidden; }
.exp-bars b { display: block; height: 100%; width: 0; background: #188038; }
.exp-bars i.done b { width: 100%; }
.exp-bars i.run b { animation: exp-fill var(--d) linear forwards; }
@keyframes exp-fill { from { width: 0; } to { width: 100%; } }

.exp-sheet { border: 1px solid #c7c7c7; border-radius: 12px; overflow: hidden; font: 13px Arial, sans-serif; background: #fff; }
.exp-fx { display: flex; align-items: center; height: 30px; border-bottom: 1px solid #c7c7c7; background: #fff; }
.exp-name { width: 52px; padding: 0 10px; border-right: 1px solid #c7c7c7; color: #444746; line-height: 30px; }
.exp-fxi { padding: 0 8px; color: #5f6368; font-style: italic; font-family: Georgia, serif; }
.exp-in { font: 13px var(--f-mono); color: #1f1f1f; white-space: nowrap; overflow: hidden; }
.exp-in[data-fx]::after { content: ""; display: inline-block; width: 1px; height: 14px; margin-left: 1px; vertical-align: -2px; background: #1f1f1f; animation: exp-caret 1s steps(1) infinite; }
@keyframes exp-caret { 50% { opacity: 0; } }

.exp-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.exp-grid th { height: 22px; background: #f8f9fa; color: #5f6368; font-weight: 400; font-size: 11px; border: 1px solid #e2e3e3; transition: background 0.3s ease, color 0.3s ease; }
.exp-grid tr th:first-child { width: 32px; }
.exp-grid th.on { background: #d3e3fd; color: #0b57d0; font-weight: 700; }
.exp-grid td {
  position: relative;
  height: 26px;
  padding: 0 6px;
  border: 1px solid #e2e3e3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.35s ease, color 0.35s ease;
}
.exp-grid td.num { text-align: right; }
.exp-grid td.hd { font-weight: 700; }
.exp-grid td.hl { background: #e8f0fe; }
.exp-grid td.good { background: #ceead6; }
.exp-grid td.bad { background: #fce8e6; color: #c5221f; }
.exp-grid td.blue { color: #0000ff; }
.exp-grid td.ref { background: color-mix(in srgb, var(--ref) 12%, #fff); box-shadow: inset 0 0 0 1.5px var(--ref); }
.exp-grid td.active { box-shadow: inset 0 0 0 2px #1a73e8; }
.exp-grid td.active::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 6px; height: 6px; background: #1a73e8; border: 1px solid #fff; }
.exp-grid td.pop { animation: exp-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes exp-pop { 0% { transform: scale(0.85); opacity: 0.2; } 100% { transform: scale(1); opacity: 1; } }

.exp-say { margin: 12px 2px 6px; min-height: 2.9em; font: 500 16px/1.45 var(--f-ui); color: var(--ink); }
.exp-ctrl { display: flex; gap: 6px; }
.exp-btn {
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-size: 16px; line-height: 1;
  cursor: pointer;
}
.exp-btn:hover { background: #e6f4ea; color: #0d652d; }
.exp-play { background: #188038; color: #fff; font-size: 12px; }
.exp-play:hover { background: #0d652d; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .exp-bars i.run b { animation: none; width: 100%; }
  .exp-grid td.pop { animation: none; }
  .exp-grid td, .exp-grid th { transition: none; }
}

/* Levels 2-3 in the sidebar, and the paywall view */
.side-level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 16px 20px 6px;
  border-top: 1px solid var(--hair);
  font: 800 20px/1.1 var(--f-display);
  font-stretch: 78%;
  letter-spacing: -0.01em;
}
.side-level .type-icon { width: 16px; height: 16px; color: var(--muted); }
.side-unlock { margin-left: auto; font: 600 12px var(--f-ui); color: #0d652d; text-decoration: none; padding: 3px 10px; border-radius: 999px; background: #e6f4ea; }
.side-unlock:hover { background: #ceead6; }
.side-section.paid { font-weight: 600; color: var(--muted); padding-top: 10px; }
.side-row.locked { color: var(--muted); }
.side-row.locked .type-icon { width: 16px; height: 16px; margin: 0 2px; }

.pw-card { max-width: 720px; padding: 26px 28px; border-radius: var(--r-card); background: #fff; box-shadow: var(--lift); font-size: 17px; }
.pw-lead { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; color: #0d652d; }
.pw-lead .type-icon { color: #0d652d; }
.pw-card h3 { margin: 22px 0 8px; font-size: 26px; }
.pw-outline { list-style: none; margin: 0; padding: 0; }
.pw-outline li { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; padding: 10px 0; border-top: 1px solid var(--hair); font-size: 15px; }
.pw-outline li span { color: var(--muted); }
.pw-buy { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding: 18px 20px; border-radius: var(--r-node); background: #e6f4ea; }
.pw-price { font: 800 44px/1 var(--f-display); font-stretch: 75%; margin-right: 10px; }
.pw-once { color: #0d652d; font-size: 14px; }
.pw-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 900px) {
  .pw-card { padding: 20px; }
  .pw-outline li { grid-template-columns: 1fr; gap: 2px; }
}

/* Project step checklist */
.steps { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); }
.steps .st-n {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  border: 2px solid #c4c7c5;
  font: 600 12px var(--f-mono);
  color: var(--muted);
  background: #fff;
}
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.now .st-n { border-color: #188038; color: #0d652d; background: #e6f4ea; }
.steps li.done { color: var(--ink); }
.steps li.done .st-n { border-color: #188038; background: #188038; color: #fff; }

/* Final exams (exam.js) */
.exam.running { max-width: none; padding: 0; border: 0; font: inherit; }
.ex-facts { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 16px 0 4px; padding: 0; font: 500 14px var(--f-ui); }
.ex-facts li { padding: 5px 12px; border-radius: 999px; background: var(--soft); }
.ex-prev { margin-top: 14px !important; font: 600 15px var(--f-ui); color: var(--muted); }
.ex-prev.ok { color: var(--ok); }
.ex-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; font: 500 13px var(--f-mono); white-space: nowrap; }
.ex-top .bar { flex: 1; min-width: 60px; }
.ex-quit { padding: 6px 10px; }
.ex-q { margin: 0 0 18px; max-width: 760px; font: 500 20px/1.5 var(--f-ui); }
.ex-note { margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.ex-opts { display: grid; gap: 10px; max-width: 720px; }
.ex-opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--hair); border-radius: var(--r-node);
  background: #fff; color: var(--ink);
  font: 16px/1.4 var(--f-ui); text-align: left; cursor: pointer;
}
.ex-opt:hover:not(:disabled) { border-color: var(--ink); }
.ex-opt[aria-checked="true"] { border-color: var(--ink); background: var(--soft); }
.ex-opt:disabled { cursor: default; }
.ex-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.ex-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ex-key { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1.5px solid currentColor; font: 600 13px var(--f-mono); }
.ex-fb { margin-top: 18px; max-width: 760px; }
.ex-result { padding: 26px 28px; border-radius: var(--r-card); background: var(--soft); }
.ex-result.ok { background: var(--ok-soft); }
.ex-score { margin: 0 !important; font: 800 72px/1 var(--f-display); font-stretch: 75%; }
.ex-verdict { margin: 8px 0 6px !important; font: 700 22px var(--f-ui); }
.ex-result.ok .ex-verdict { color: var(--ok); }

/* Phones: instructions above a full-width grid that scrolls in its own frame,
   and the grading buttons pinned where a thumb can reach them. */
@media (max-width: 900px) {
  .task-row, .task-row:has(.fn-card:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
  .task { font-size: 17px; }
  .fn-card { padding: 10px 14px; }
  .gs-window { max-width: 100%; isolation: isolate; }
  .gs-grid { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .gs-toolbar { display: none; }
  .gs-titlebar { padding-bottom: 8px; }
  .gs-docname { font-size: 16px; }
  .practice-actions {
    position: sticky; bottom: 0; z-index: 12;
    display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px;
    margin: 12px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--hair);
  }
  .practice-actions .btn { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  #checkBtn { background: var(--ink); color: #fff; }
  .ex-q { font-size: 18px; }
  .ex-top { flex-wrap: wrap; }
  .ex-opt { padding: 10px 12px; font-size: 15px; }
  .exam { padding: 20px 18px; }
  .exam.running { padding: 0; }
}
