/* MedLMS: one stylesheet for the student site and the admin panel. */
:root {
  --primary: #0e6e66;
  --primary-ink: color-mix(in srgb, var(--primary) 82%, #000);
  --primary-soft: color-mix(in srgb, var(--primary) 10%, #fff);
  --ink: #14253a;
  --ink-2: #3a4a5e;
  --muted: #5f6e7e;
  --line: #e2e7ec;
  --line-2: #cbd3db;
  --canvas: #f4f6f8;
  --paper: #ffffff;
  --coin: #b7791f;
  --coin-soft: #fdf3e1;
  --ok: #1e7f4a;
  --ok-soft: #e5f4eb;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #e8f0fb;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(20, 37, 58, 0.06), 0 4px 16px rgba(20, 37, 58, 0.05);
  --top-h: 64px;
  --tab-h: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
img {
  max-width: 100%;
  height: auto;
}
a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--primary-ink);
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
  font-weight: 800;
}
h2 {
  font-size: 1.35rem;
  font-weight: 700;
}
h3 {
  font-size: 1.08rem;
  font-weight: 700;
}
p {
  margin: 0 0 1em;
}
small,
.small {
  font-size: 0.875rem;
}
.muted {
  color: var(--muted);
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  z-index: 100;
}
.skip:focus {
  left: 8px;
}
.icon {
  flex: none;
  vertical-align: middle;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  font: 600 0.95rem/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-ink);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn-ghost:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink-2);
}
.btn-coin {
  background: var(--ink);
  color: #fff;
}
.btn-coin:hover {
  background: #000;
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #8f1b12;
  color: #fff;
}
.btn-link {
  background: none;
  border: 0;
  color: var(--primary);
  padding: 0;
  min-height: 0;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.875rem;
  border-radius: 8px;
}
.btn-block {
  width: 100%;
}
.btn[disabled],
.btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--canvas);
}

/* ---------- Forms ---------- */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}
.field label,
.label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.field .hint {
  font-size: 0.84rem;
  color: var(--muted);
}
.input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="url"],
.field input[type="search"],
.field input[type="color"],
.field select,
.field textarea,
select.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}
.field input[type="color"] {
  padding: 4px;
  width: 64px;
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
}
.form-grid {
  display: grid;
  gap: 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}
.input-prefix {
  display: flex;
  align-items: stretch;
}
.input-prefix span {
  display: grid;
  place-items: center;
  padding: 0 12px;
  background: var(--canvas);
  border: 1px solid var(--line-2);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  color: var(--muted);
  font-weight: 600;
}
.input-prefix input {
  border-radius: 0 10px 10px 0 !important;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--top-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-logo {
  max-height: 36px;
  width: auto;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font: 800 0.95rem/1 var(--font-display);
  letter-spacing: -0.02em;
}
.brand-name {
  font: 800 1.15rem/1 var(--font-display);
  letter-spacing: -0.02em;
}
.topnav {
  display: flex;
  gap: 4px;
}
.topnav a {
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.95rem;
}
.topnav a:hover {
  background: var(--canvas);
  color: var(--ink);
}
.topnav a.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  background: var(--coin-soft);
  color: #7a4f0e;
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  border: 1px solid #f2ddb5;
}
.wallet-chip:hover {
  color: #5c3a08;
  border-color: var(--coin);
}
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.avatar::-webkit-details-marker {
  display: none;
}
.menu {
  position: relative;
}
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(20, 37, 58, 0.14);
  padding: 6px;
  z-index: 40;
}
.menu-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  display: grid;
}
.menu-head span {
  color: var(--muted);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-panel a,
.menu-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.menu-panel a:hover,
.menu-panel button:hover {
  background: var(--canvas);
}
.menu-panel form {
  margin: 0;
}

/* ---------- Page ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  min-height: calc(100vh - var(--top-h) - 120px);
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head p {
  margin: 0;
  color: var(--muted);
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--primary);
}
.crumbs span[aria-hidden] {
  color: var(--line-2);
}
.section {
  margin-top: 36px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
}
.narrow {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
}
.panel + .panel {
  margin-top: 16px;
}
.split > .panel + .panel,
.split > .table-wrap + .panel {
  margin-top: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2,
.panel-head h3 {
  margin: 0;
}

/* ---------- Flash ---------- */
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  margin-bottom: 16px;
  border: 1px solid;
  font-size: 0.95rem;
}
.flash-success {
  background: var(--ok-soft);
  border-color: #b7e0c7;
  color: #11532f;
}
.flash-error {
  background: var(--danger-soft);
  border-color: #f5c2bc;
  color: #7a1a11;
}
.flash-info {
  background: var(--info-soft);
  border-color: #c6d8f2;
  color: #1c3c6b;
}
.flash-close {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 2px;
  opacity: 0.7;
}

/* ---------- Landing ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 48px;
  align-items: center;
  padding: 24px 0 8px;
}
.hero h1 {
  font-size: clamp(2.2rem, 1.4rem + 3.4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  max-width: 14ch;
}
.hero-lead {
  font-size: 1.12rem;
  color: var(--ink-2);
  max-width: 46ch;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.hero-facts {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.95rem;
}
.hero-facts strong {
  display: block;
  font: 800 1.5rem/1.1 var(--font-display);
  color: var(--ink);
}
.periodic {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.periodic .el {
  aspect-ratio: 1;
  border-radius: 10px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: hsl(var(--h) 55% 95%);
  border: 1px solid hsl(var(--h) 40% 84%);
  color: hsl(var(--h) 45% 24%);
  text-decoration: none;
  min-width: 0;
}
.periodic .el b {
  font: 800 clamp(1rem, 0.6rem + 1.4vw, 1.6rem)/1 var(--font-display);
  letter-spacing: -0.03em;
}
.periodic .el i {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 600;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}
.periodic .el:hover {
  border-color: hsl(var(--h) 45% 50%);
}
.periodic .el.is-blank {
  background: transparent;
  border: 1px dashed var(--line);
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  counter-reset: step;
}
.step {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.step::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 700 0.9rem/1 var(--font-display);
  margin-bottom: 12px;
}
.step h3 {
  margin-bottom: 4px;
}
.step p {
  margin: 0;
  color: var(--muted);
}

/* ---------- Subject tiles (signature) ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 168px;
  padding: 14px;
  border-radius: 14px;
  text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  overflow: hidden;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.tile:hover {
  border-color: hsl(var(--h) 45% 50%);
  color: var(--ink);
  transform: translateY(-1px);
}
.tile-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tile-code {
  margin-top: auto;
  font: 800 2.6rem/1 var(--font-display);
  letter-spacing: -0.04em;
  color: hsl(var(--h) 50% 30%);
}
.tile-name {
  margin-top: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: hsl(var(--h) 55% 55%);
}
.tile-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--primary);
}
.tile-badge {
  font-weight: 700;
  color: var(--ok);
}

.program-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.program-tabs a {
  padding: 10px 14px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.program-tabs a.is-active {
  color: var(--ink);
  border-color: var(--ink);
}

.searchbar {
  position: relative;
  max-width: 520px;
  width: 100%;
}
.searchbar .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.searchbar input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px 10px 40px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  background: var(--paper);
}
.searchbar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ---------- Subject page ---------- */
.subject-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.subject-code {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 16px;
  background: hsl(var(--h) 55% 94%);
  border: 1px solid hsl(var(--h) 40% 82%);
  color: hsl(var(--h) 50% 28%);
  font: 800 2.2rem/1 var(--font-display);
  letter-spacing: -0.04em;
}
.subject-hero h1 {
  margin-bottom: 4px;
}
.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--canvas);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}
.bundle {
  min-width: 240px;
  padding: 16px;
  border-radius: var(--r);
  background: var(--coin-soft);
  border: 1px solid #f2ddb5;
}
.bundle strong {
  display: block;
  font: 800 1.5rem/1.1 var(--font-display);
}
.bundle p {
  margin: 4px 0 12px;
  font-size: 0.88rem;
  color: #6b4a14;
}
.price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.lesson-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.lesson-list li:first-child .lesson-row {
  border-top: 0;
}
.lesson-row:hover {
  background: #fafbfc;
  color: var(--ink);
}
.lesson-state {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--canvas);
  color: var(--muted);
}
.lesson-state.is-open {
  background: var(--primary-soft);
  color: var(--primary);
}
.lesson-state.is-done {
  background: var(--ok);
  color: #fff;
}
.lesson-code {
  font: 700 0.82rem/1 var(--font-display);
  color: var(--muted);
  letter-spacing: 0.01em;
}
.lesson-title {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}
.media-dots {
  display: inline-flex;
  gap: 4px;
}
.media-dots .icon {
  color: var(--line-2);
}
.media-dots .on {
  color: var(--ink-2);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--canvas);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.tag-coin {
  background: var(--coin-soft);
  color: #7a4f0e;
}
.tag-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.tag-info {
  background: var(--info-soft);
  color: #1c3c6b;
}

/* ---------- Lesson player ---------- */
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}
.player-head {
  margin-bottom: 14px;
}
.player-head h1 {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem);
  font-weight: 700;
  line-height: 1.3;
}
.media-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.media-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
  font: 600 0.95rem/1 var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}
.media-tabs button[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.frame {
  position: relative;
  width: 100%;
  background: #0d1620;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
}
.frame-video {
  aspect-ratio: 16 / 9;
}
.frame-doc {
  height: min(78vh, 900px);
  background: var(--paper);
}
.frame iframe,
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.frame-fallback {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  padding: 32px;
  min-height: 240px;
  background: var(--paper);
  color: var(--ink-2);
}
.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.player-nav {
  display: flex;
  gap: 8px;
}
.side-list {
  position: sticky;
  top: calc(var(--top-h) + 16px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.side-list-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.side-list-head strong {
  display: block;
}
.side-list ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - var(--top-h) - 140px);
  overflow-y: auto;
}
.side-list a {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}
.side-list a:hover {
  background: var(--canvas);
}
.side-list a.is-current {
  background: var(--primary-soft);
  color: var(--ink);
  font-weight: 600;
}
.side-list a .icon {
  margin-top: 2px;
  color: var(--muted);
}
.side-list a.is-done .icon {
  color: var(--ok);
}
.side-list span.t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.locked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}
.locked-preview {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
}
.includes {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.includes li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink-2);
}
.includes li.off {
  color: var(--line-2);
  text-decoration: line-through;
}
.buy-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.buy-card .amount {
  font: 800 2rem/1 var(--font-display);
  letter-spacing: -0.02em;
}
.buy-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  color: var(--muted);
}
.buy-row b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Dashboard & wallet ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.wallet-card {
  position: relative;
  border-radius: var(--r-lg);
  padding: 22px;
  color: #fff;
  background: var(--ink);
  overflow: hidden;
}
.wallet-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 22px solid rgba(227, 162, 59, 0.35);
}
.wallet-card .label {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}
.wallet-card .balance {
  font: 800 2.6rem/1.05 var(--font-display);
  letter-spacing: -0.03em;
  margin: 6px 0 18px;
  font-variant-numeric: tabular-nums;
}
.wallet-card .btn-primary {
  background: #e3a23b;
  color: var(--ink);
}
.wallet-card .btn-primary:hover {
  background: #f0b552;
  color: var(--ink);
}
.continue-list {
  display: grid;
  gap: 10px;
}
.continue {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
}
.continue:hover {
  border-color: var(--line-2);
  color: var(--ink);
}
.continue .mini-code {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: hsl(var(--h) 55% 94%);
  color: hsl(var(--h) 50% 28%);
  font: 800 1.2rem/1 var(--font-display);
}
.continue .t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 500;
  line-height: 1.35;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
}
.stat strong {
  display: block;
  font: 800 1.5rem/1.1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.stat span {
  color: var(--muted);
  font-size: 0.86rem;
}
.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.preset {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  font: 700 1rem/1 var(--font-body);
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.preset:hover,
.preset.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.txn-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.txn {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.txn:first-child {
  border-top: 0;
}
.txn-ic {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--canvas);
  color: var(--ink-2);
}
.txn-ic.credit {
  background: var(--ok-soft);
  color: var(--ok);
}
.txn-amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.txn-amt.credit {
  color: var(--ok);
}
.txn .d {
  font-weight: 500;
}
.txn .m {
  color: var(--muted);
  font-size: 0.84rem;
}

/* ---------- Auth ---------- */
.auth-wrap {
  display: grid;
  place-items: center;
  padding: 16px 0 40px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
}
.auth-card h1 {
  font-size: 1.7rem;
}
.auth-alt {
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Empty, pager, tables ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--ink-2);
}
.empty-state .icon {
  color: var(--muted);
}
.empty-state p {
  color: var(--muted);
  max-width: 48ch;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  align-items: center;
}
.pager-item {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.9rem;
}
.pager-item.is-current {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.pager-gap {
  color: var(--muted);
}
.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
  white-space: nowrap;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table .clip {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table .actions {
  white-space: nowrap;
  text-align: right;
}
.table .actions form {
  display: inline;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-cell .avatar {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
  cursor: default;
}
.user-cell small {
  display: block;
  color: var(--muted);
}

/* ---------- Footer & tabbar ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 28px 20px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
}
.footer-inner p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 52ch;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: flex-start;
}
.footer-links a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.92rem;
}
.footer-links a:hover {
  color: var(--primary);
}
.footer-copy {
  max-width: 1200px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.tabbar {
  display: none;
}
.prose {
  max-width: 72ch;
}
.prose p,
.prose li {
  color: var(--ink-2);
}

/* ---------- Admin ---------- */
body.admin {
  background: var(--canvas);
}
.admin-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: #c9d3de;
}
.sidebar .brand {
  color: #fff;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  height: 64px;
}
.sidebar-close {
  display: none;
  color: #fff;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
  display: grid;
  align-content: start;
  gap: 2px;
}
.sidebar-heading {
  padding: 16px 10px 6px;
  font-size: 0.78rem;
  color: #8494a7;
  font-weight: 600;
}
.sidebar-nav a,
.sidebar-foot a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #c9d3de;
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
}
.sidebar-nav a:hover,
.sidebar-foot a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar-nav a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 3px 0 0 #e3a23b;
}
.sidebar-foot {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.admin-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-open {
  display: none;
}
.admin-content {
  padding: 24px;
  max-width: 1280px;
}
.sidebar-scrim {
  display: none;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stats .stat strong {
  font-size: 1.7rem;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.toolbar .input {
  width: auto;
  min-width: 200px;
  min-height: 40px;
  padding: 8px 12px;
}
.toolbar select.input {
  min-width: 150px;
}
.bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 6px;
  height: 180px;
  padding-top: 10px;
}
.bar {
  position: relative;
  background: var(--primary);
  border-radius: 6px 6px 2px 2px;
  min-height: 2px;
}
.bar span {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.bar:hover::after {
  content: attr(data-v);
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
}
.bars-wrap {
  padding-bottom: 26px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tabs a {
  padding: 10px 14px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a.is-active {
  color: var(--ink);
  border-color: var(--ink);
}
.perm-group {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--paper);
}
.perm-group legend {
  font-weight: 700;
  padding: 0 6px;
  font-family: var(--font-display);
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px 16px;
}
.perm-grid small {
  display: block;
  color: var(--muted);
}
.kv {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 0.9rem;
}
.kv dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.code-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}
.logo-preview {
  max-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}
.status-dot.on {
  background: var(--ok);
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .player-layout {
    grid-template-columns: 1fr;
  }
  .side-list {
    position: static;
  }
  .side-list ol {
    max-height: 420px;
  }
  .split,
  .dash-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.sidebar-open .sidebar {
    transform: none;
  }
  body.sidebar-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 37, 58, 0.45);
    z-index: 45;
  }
  .sidebar-open,
  .sidebar-close {
    display: inline-grid;
  }
  .admin-content {
    padding: 16px;
  }
  .admin-top {
    padding: 0 12px;
  }
  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .locked {
    grid-template-columns: 1fr;
  }
  .subject-hero {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .subject-hero .bundle {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  body.is-auth {
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  }
  .topnav {
    display: none;
  }
  .topbar-inner {
    padding: 0 14px;
    gap: 12px;
  }
  .page {
    padding: 18px 14px 32px;
  }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(10px);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: var(--tab-h);
    text-decoration: none;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
  }
  .tabbar a.is-active {
    color: var(--primary);
  }
  .is-auth .site-footer {
    display: none;
  }
  .steps {
    grid-template-columns: 1fr;
  }
  .stat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .stat {
    padding: 12px;
  }
  .stat strong {
    font-size: 1.25rem;
  }
  .presets {
    grid-template-columns: repeat(2, 1fr);
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .tile {
    min-height: 150px;
  }
  .tile-code {
    font-size: 2.2rem;
  }
  .lesson-row {
    grid-template-columns: 30px minmax(0, 1fr);
    padding: 12px 14px;
  }
  .lesson-row .lesson-meta {
    grid-column: 2;
  }
  .lesson-state {
    width: 30px;
    height: 30px;
  }
  .panel {
    padding: 16px;
    border-radius: var(--r);
  }
  .subject-code {
    width: 60px;
    height: 60px;
    font-size: 1.6rem;
    border-radius: 12px;
  }
  .frame-doc {
    height: 70vh;
  }
  .wallet-card .balance {
    font-size: 2.2rem;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .kv dd {
    margin-bottom: 10px;
  }
  .periodic {
    gap: 4px;
  }
  .periodic .el {
    border-radius: 7px;
    padding: 4px 5px;
  }
  .periodic .el i {
    display: none;
  }
  .table th,
  .table td {
    padding: 10px;
  }
  .auth-card {
    padding: 20px;
  }
  .hide-sm {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Home carousel ---------- */
.carousel {
  position: relative;
  margin: 0 0 22px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--primary-soft);
  box-shadow: var(--shadow);
}
.carousel-track {
  display: flex;
  align-items: center;
  transition: transform 0.5s ease;
  will-change: transform;
}
.carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
}
.carousel-slide a,
.carousel-slide img {
  display: block;
  width: 100%;
}
.carousel-slide img {
  /* Show the whole image, never crop. Height follows the image's own ratio. */
  height: auto;
  object-fit: contain;
}
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}
.carousel-arrow:hover {
  background: #fff;
}
.carousel-arrow:active {
  transform: translateY(-50%) scale(0.94);
}
.carousel-prev {
  left: 12px;
}
.carousel-next {
  right: 12px;
}
.carousel-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.carousel-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition:
    background 0.15s ease,
    width 0.15s ease;
}
.carousel-dot.is-active {
  width: 22px;
  border-radius: 5px;
  background: #fff;
}
@media (max-width: 720px) {
  .carousel {
    margin-bottom: 16px;
    border-radius: var(--r);
  }
  .carousel-arrow {
    width: 34px;
    height: 34px;
  }
  .carousel-prev {
    left: 8px;
  }
  .carousel-next {
    right: 8px;
  }
}

/* ---------- Admin: carousel slide manager ---------- */
.slide-admin-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}
.slide-admin-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--canvas);
}
.slide-admin-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--line);
}
.slide-admin-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.slide-admin-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.slide-order {
  max-width: 110px;
}
.slide-order span {
  display: block;
}
.slide-remove {
  color: var(--danger);
}
@media (max-width: 720px) {
  .slide-admin-row {
    grid-template-columns: 1fr;
  }
  .slide-admin-thumb {
    max-width: 220px;
  }
}

/* ---------- Home dedication ---------- */
.dedication {
  margin: 0 0 26px;
  padding: 26px 30px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.dedication h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 14px;
}
.dedication p {
  max-width: 760px;
  margin: 0 auto 12px;
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.7;
}
.dedication p:last-child {
  margin-bottom: 0;
}
.dedication strong {
  color: var(--ink);
  font-weight: 600;
}
@media (max-width: 720px) {
  .dedication {
    padding: 20px 18px;
    border-radius: var(--r);
    margin-bottom: 18px;
  }
  .dedication p {
    font-size: 0.98rem;
  }
}
