/* ============================================================
   נלמד — Design System
   One source of truth. Palette + rules per DESIGN.md:
   70% professional / 30% playful, progress as a core material.
   ============================================================ */

:root {
  /* color */
  --ink: #101916;
  --ink-2: #1a2621;
  --paper: #f7f8f8;
  --card: #ffffff;
  --line: #dde4e1;
  --muted: #57645f;
  --emerald: #126b4b;
  --bright: #20a66a;
  --soft: #e4f3ec;
  --lime: #c9f05a;
  --lime-soft: #f3fadd;
  --coral: #ff6b5e;
  --red: #9b382f;
  --red-soft: #fbeae8;

  /* shape */
  --r-card: 20px;
  --r-ctrl: 12px;
  --r-pill: 999px;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(16, 25, 22, .05), 0 4px 14px rgba(16, 25, 22, .06);
  --shadow-2: 0 2px 4px rgba(16, 25, 22, .06), 0 14px 34px rgba(16, 25, 22, .12);

  /* motion */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: 160ms;
  --t-view: 280ms;

  /* layers */
  --z-nav: 20;
  --z-modal: 50;
  --z-toast: 70;

  /* layout */
  --topbar-h: 76px;
  --tabbar-h: 62px;
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Rubik", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
iframe { display: block; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; margin: 0; }
p { margin: 0; text-wrap: pretty; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

:focus-visible {
  outline: 3px solid rgba(32, 166, 106, .45);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--lime); color: var(--ink); }

/* ---------- icons ---------- */
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: inherit;
  line-height: 1;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 2px 6px rgba(16, 25, 22, .18);
  transition: transform var(--t-fast) var(--ease);
}
.brand:hover .brand-mark { transform: translateX(-2px); }

/* signature: momentum flow — staggered forward chevrons */
.flow {
  position: absolute;
  z-index: -1;
  display: flex;
  gap: 14px;
}
.flow i {
  width: 56px;
  height: 100px;
  clip-path: polygon(55% 0, 0 50%, 55% 100%, 100% 100%, 45% 50%, 100% 0);
  opacity: .25;
  animation: flow-step 3.6s var(--ease) infinite;
}
.flow i:nth-child(1) { background: var(--emerald); }
.flow i:nth-child(2) { background: var(--bright); animation-delay: .45s; }
.flow i:nth-child(3) { background: var(--lime); animation-delay: .9s; }
@keyframes flow-step {
  0%, 100% { opacity: .22; transform: none; }
  40% { opacity: .8; transform: translateX(-8px); }
  70% { opacity: .35; }
}

/* ---------- buttons ---------- */
.primary, .ghost, .back, .link, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: var(--r-ctrl);
  font-weight: 600;
  transition: background-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.primary {
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  font-weight: 700;
}
.primary:hover { background: var(--ink-2); box-shadow: 0 6px 16px rgba(16, 25, 22, .18); }
.primary:active { transform: scale(.97); box-shadow: none; }

.ghost, .back {
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
}
.ghost:hover, .back:hover { background: #e9efec; color: var(--ink); }
.ghost:active, .back:active { transform: scale(.97); }

.link {
  min-height: 44px;
  padding: 8px 2px;
  color: var(--emerald);
  font-weight: 700;
  border-radius: 8px;
}
.link:hover { color: var(--bright); }

/* forward-nudge on action icons */
.primary .ic, .link .ic { transition: transform var(--t-fast) var(--ease); }
.primary:hover .ic:last-child, .link:hover .ic:last-child { transform: translateX(-3px); }

.icon-btn {
  width: 44px;
  min-height: 44px;
  border-radius: var(--r-ctrl);
  color: var(--muted);
  background: transparent;
}
.icon-btn:hover { background: #e9efec; color: var(--ink); }

.wide { width: 100%; }

button:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none !important;
  box-shadow: none !important;
}

.danger { color: var(--red) !important; }

/* ---------- fields ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 8px; font-weight: 600; font-size: .95rem; }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 50px;
  border: 1.5px solid #c8d3ce;
  border-radius: var(--r-ctrl);
  background: #fff;
  padding: 12px 15px;
  outline: 0;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field textarea { resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible {
  outline: 0;
  border-color: var(--bright);
  box-shadow: 0 0 0 4px rgba(32, 166, 106, .14);
}
.field input[type="email"], .field input[type="url"] { direction: ltr; text-align: left; }
.field ::placeholder { color: #75817c; opacity: 1; }

.error { min-height: 24px; margin-top: 10px; color: var(--red); font-size: .88rem; font-weight: 500; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--emerald);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.meta { color: var(--muted); font-size: .88rem; line-height: 1.55; }

/* ---------- login ---------- */
.login {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr);
}

.login-art {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(32px, 6vw, 84px);
  background: var(--ink);
  color: #fff;
}
.login-art .flow { left: clamp(26px, 5vw, 68px); bottom: clamp(30px, 7vh, 72px); }
.login-art .flow i { width: 74px; height: 130px; }
.login-art .eyebrow { color: var(--lime); }

.hero-copy { max-width: 640px; margin-block: 6vh; }
.hero-copy h1 {
  margin: 0 0 24px;
  font-size: clamp(3.2rem, 6vw, 5.8rem);
  font-weight: 800;
  line-height: .97;
  letter-spacing: -.05em;
}
.hero-sub {
  max-width: 30rem;
  color: #c2cdc8;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.75;
}

.hero-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  max-width: 420px;
}
.hero-points li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #d4ddd9;
  font-size: .95rem;
  font-weight: 500;
}
.hero-points .ic { color: var(--lime); }

.login-panel {
  display: grid;
  place-items: center;
  padding: 44px 24px;
  background: #fff;
}
.authbox { width: min(420px, 100%); }
.authbox h2 {
  margin: 0 0 10px;
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.03em;
}
.sub { margin: 0 0 30px; color: var(--muted); line-height: 1.7; }
.auth-note { margin-top: 16px; color: var(--muted); font-size: .8rem; text-align: center; }
.demo {
  margin-top: 24px;
  padding: 12px 16px;
  border: 1.5px dashed #b9c6c0;
  border-radius: var(--r-ctrl);
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.6;
}

/* ---------- app shell / topbar ---------- */
.shell { min-height: 100svh; overflow-x: clip; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 clamp(20px, 4vw, 56px);
  background: rgba(247, 248, 248, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav { display: flex; align-items: center; gap: 6px; margin-inline-end: auto; }
.nav button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-weight: 600;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav button:hover { background: #e9efec; color: var(--ink); }
.nav button.active { background: var(--ink); color: #fff; }
.nav button.active .ic { color: var(--lime); }

.topbar-side { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--emerald);
  font-weight: 700;
  border: 1.5px solid #c4e2d4;
}

/* mobile bottom tab bar (hidden on desktop) */
.tabbar { display: none; }

/* ---------- page & views ---------- */
.page {
  width: min(1440px, 100%);
  margin: auto;
  padding: clamp(28px, 4vw, 52px) clamp(20px, 4vw, 56px) 88px;
}

/* view enter animation (retriggers on display change) */
#homeView:not(.hidden),
#learnView:not(.hidden),
#adminView:not(.hidden) {
  animation: view-in var(--t-view) var(--ease);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- welcome ---------- */
.welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 32px;
}
.welcome h1 {
  margin: 0 0 8px;
  font-size: clamp(2.1rem, 3.6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.045em;
}
.welcome-sub { color: var(--muted); }

.stat {
  min-width: 230px;
  padding: 16px 20px;
  border-radius: var(--r-card);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-1);
}
.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.stat strong { font-size: 1.55rem; font-weight: 800; color: var(--lime); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { color: #b9c5c0; font-size: .8rem; }
.stat-bar {
  display: block;
  height: 6px;
  border-radius: var(--r-pill);
  background: #33413b;
  overflow: hidden;
}
.stat-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--lime);
  transition: width 600ms var(--ease);
}

/* ---------- home: courses layout ---------- */
.courses {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

/* featured course stage */
.course-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  grid-column: 1;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
  padding: clamp(28px, 3.5vw, 46px);
  border-radius: var(--r-card);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-2);
}
.course-stage .flow { left: 34px; top: 38px; gap: 11px; }
.course-stage .flow i { width: 42px; height: 74px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .1);
  color: #e6edea;
  padding: 8px 14px;
  font-size: .76rem;
  font-weight: 600;
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); }

.course-stage h3 {
  max-width: 720px;
  margin: 20px 0 12px;
  font-size: clamp(2.3rem, 4vw, 4.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.045em;
}
.course-stage .meta { max-width: 560px; color: #b7c3be; font-size: .95rem; }

/* learning route — progress as design material */
.learning-route {
  display: flex;
  align-items: center;
  margin-top: 34px;
}
.route-node {
  z-index: 1;
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid #4c5a54;
  border-radius: 50%;
  background: var(--ink);
  color: #93a09a;
  font-size: .74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.route-node .ic { width: 16px; height: 16px; }
.route-node.done { border-color: var(--bright); background: var(--bright); color: #fff; }
.route-node.current {
  border-color: var(--coral);
  background: var(--coral);
  color: #fff;
  box-shadow: 0 0 0 6px rgba(255, 107, 94, .16);
  animation: pulse-current 2.6s ease-in-out infinite;
}
@keyframes pulse-current {
  0%, 100% { box-shadow: 0 0 0 5px rgba(255, 107, 94, .18); }
  50% { box-shadow: 0 0 0 11px rgba(255, 107, 94, .06); }
}
.route-line { height: 2px; flex: 1; min-width: 12px; background: #3c4a44; }
.route-line.done { background: var(--bright); }

.stage-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}
.stage-progress strong { display: block; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stage-progress span { color: #9caaa4; font-size: .84rem; }
.stage-cta { min-width: 230px; background: var(--lime); color: var(--ink); }
.stage-cta:hover { background: #d6f775; color: var(--ink); box-shadow: 0 8px 20px rgba(201, 240, 90, .25); }

/* sidebar: continue-from-here (real data) */
.nextup {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  padding: 22px;
  box-shadow: var(--shadow-1);
}
.nextup h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.nextup > p { color: var(--muted); font-size: .84rem; margin-bottom: 18px; }
.nextup-list { display: grid; gap: 10px; }
.nextup-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: start;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.nextup-item:hover { background: var(--soft); border-color: #bcdccd; }
.nextup-item:active { transform: scale(.98); }
.nextup-item.all-done { grid-template-columns: 40px minmax(0, 1fr); }
.nextup-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--soft);
  color: var(--emerald);
}
.nextup-icon .ic { width: 18px; height: 18px; }
.nextup-item strong {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nextup-item small {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nextup-item .ic:last-child { color: #a9b5b0; }
.nextup-done {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.nextup-done strong { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.nextup-done span { color: var(--muted); font-size: .78rem; }

/* course shelf */
.course-shelf {
  grid-column: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.course-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  text-align: start;
  display: flex;
  flex-direction: column;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: #cbd8d2; }

.cover {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  height: 128px;
  background: var(--emerald);
  display: grid;
  place-items: center;
  background-size: cover;
  background-position: center;
}
.cover::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 82px;
  height: 128px;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(201, 240, 90, .4);
  clip-path: polygon(55% 0, 0 50%, 55% 100%, 100% 100%, 45% 50%, 100% 0);
}
.cover.alt { background: var(--ink-2); }
.cover.alt::before { background: rgba(32, 166, 106, .5); }
.cover.warm { background: var(--bright); }
.cover.warm::before { background: rgba(255, 255, 255, .35); }
.cover .play-chip {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.cover .play-chip .ic { width: 20px; height: 20px; margin-left: 2px; }

.course-body { display: flex; flex-direction: column; flex: 1; padding: 20px 22px 22px; }
.course-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.course-body .meta { overflow-wrap: anywhere; }

.progress {
  height: 7px;
  overflow: hidden;
  margin: 18px 0 8px;
  border-radius: var(--r-pill);
  background: #e5ebe8;
}
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--bright); transition: width 400ms var(--ease); }

.course-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
}
.course-foot > span { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }

.empty {
  grid-column: 1 / -1;
  padding: 56px 24px;
  text-align: center;
  border: 1.5px dashed #bcc8c2;
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--muted);
  line-height: 1.8;
}
.empty.compact { padding: 22px; border-radius: 14px; }

/* ---------- learn view ---------- */
.learn {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100svh - var(--topbar-h));
  background: var(--card);
}

.lessons {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100svh - var(--topbar-h));
  overflow: auto;
  border-inline-end: 1px solid var(--line);
  background: var(--paper);
  padding: 24px 18px 32px;
}
.lessons h2 { margin: 4px 6px 6px; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.lessons > .meta { margin: 0 6px 20px; }
.lessons .back { margin-bottom: 10px; padding-inline: 8px; }

.lesson-list { display: grid; gap: 4px; }
.lesson {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  border-radius: 14px;
  padding: 9px 10px;
  text-align: start;
  color: var(--ink);
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.lesson:hover { background: #eaf0ed; }
.lesson.active { background: var(--card); box-shadow: var(--shadow-1); }
.lesson .num {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px solid #c7d2cd;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.lesson .num .ic { width: 15px; height: 15px; }
.lesson.done .num { border-color: var(--bright); background: var(--bright); color: #fff; }
.lesson.active:not(.done) .num { border-color: var(--coral); background: var(--coral); color: #fff; }
.lesson-titles { min-width: 0; }
.lesson-titles strong { display: block; font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-titles small { color: var(--muted); font-size: .74rem; }
.lesson > .ic { color: #a9b5b0; }

.player-area {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(24px, 3.5vw, 48px);
}
.mobile-back { display: none; }

.video {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-card);
  background: var(--ink);
  box-shadow: var(--shadow-2);
}
.video iframe { width: 100%; height: 100%; border: 0; }

.lesson-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 26px;
  margin: 28px 0;
}
.lesson-head .eyebrow { margin-bottom: 10px; }
.lesson-head h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -.035em;
}
.complete { white-space: nowrap; background: var(--emerald); }
.complete:hover { background: #0e5a3f; }
.complete.done { background: var(--soft); color: var(--emerald); }
.complete.done:hover { background: #d7ecdf; box-shadow: none; }

.notes {
  max-width: 72ch;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  color: #414e49;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.notes strong { display: block; margin-bottom: 6px; }

.nextbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

/* ---------- admin ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  padding: 24px;
  box-shadow: var(--shadow-1);
}
.panel h2 { margin: 0 0 18px; font-size: 1.25rem; font-weight: 800; }
.panel { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; min-width: 480px; }
.table th, .table td {
  text-align: start;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
}
.table th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.table tbody tr:last-child td { border-bottom: 0; }

.status {
  display: inline-flex;
  border-radius: var(--r-pill);
  background: var(--soft);
  color: var(--emerald);
  padding: 5px 11px;
  font-size: .74rem;
  font-weight: 700;
}
.status.draft { background: #eef1f0; color: var(--muted); }

.snapshot-stats { display: grid; gap: 12px; margin-bottom: 18px; }
.mini-stat {
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  padding: 16px 18px;
}
.mini-stat.bright { background: var(--emerald); }
.mini-stat small { display: block; color: #c3cec9; font-size: .8rem; }
.mini-stat strong { display: block; margin-top: 2px; font-size: 1.6rem; font-weight: 800; color: var(--lime); font-variant-numeric: tabular-nums; }

.publish-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 22px;
  color: var(--muted);
  cursor: pointer;
}
.publish-control input { width: 19px; height: 19px; accent-color: var(--emerald); }

.manage-lessons-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 6px;
}
.manage-lessons-head h3 { font-size: 1.02rem; }
.managed-lessons { border-top: 1px solid var(--line); margin-bottom: 22px; }
.managed-lesson {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}
.managed-lesson-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--emerald);
  font-size: .74rem;
  font-weight: 700;
}
.managed-lesson strong, .managed-lesson small { display: block; }
.managed-lesson strong { font-size: .92rem; font-weight: 600; }
.managed-lesson small { color: var(--muted); margin-top: 2px; font-size: .78rem; }

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 15, 13, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  width: min(560px, 100%);
  max-height: 90svh;
  overflow: auto;
  border-radius: var(--r-card);
  background: #fff;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .3);
  margin: 0;
}
.modal:not(.hidden) .modal-card { animation: modal-in var(--t-view) var(--ease); }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.modal-head h2 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-ctrl);
  background: #edf1ef;
  color: var(--ink);
  transition: background-color var(--t-fast) var(--ease);
}
.close:hover { background: #e0e7e3; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: var(--z-toast);
  bottom: 24px;
  inset-inline-start: 24px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: toast-in var(--t-view) var(--ease);
}
.toast[data-type="error"] { background: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   responsive — tablet
   ============================================================ */
@media (max-width: 1060px) {
  .courses { grid-template-columns: 1fr; }
  .nextup { grid-column: 1; grid-row: auto; }
  .nextup-list { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .nextup-done { margin-top: 18px; }
  .admin-grid { grid-template-columns: 1fr; }
  .learn { grid-template-columns: 1fr; display: flex; flex-direction: column; min-height: 0; }
  .player-area { order: 1; }
  .lessons {
    order: 2;
    position: static;
    height: auto;
    border-inline-end: 0;
    border-top: 1px solid var(--line);
    padding: 28px clamp(20px, 4vw, 48px) 40px;
  }
  .lessons .back { display: none; }
  .mobile-back { display: inline-flex; margin-bottom: 14px; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 46svh; }
  .hero-copy { margin-block: 24px; }
  .hero-points { display: none; }
}

/* ============================================================
   responsive — phone: app experience
   ============================================================ */
@media (max-width: 700px) {
  :root { --topbar-h: 60px; }

  body { font-size: 16px; }

  /* compact app header */
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar .nav { display: none; }
  .topbar .icon-btn[data-logout] { display: none; }
  .brand { font-size: 1.3rem; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .avatar { width: 36px; height: 36px; }

  /* bottom tab bar */
  .shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
  .tabbar {
    position: fixed;
    z-index: var(--z-nav);
    inset-inline: 0;
    bottom: 0;
    display: flex;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .92);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  .tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    border-radius: 14px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 600;
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
  }
  .tabbar button:active { background: var(--soft); }
  .tabbar button .ic { width: 23px; height: 23px; }
  .tabbar button.active { color: var(--emerald); }
  .tabbar button.active .ic { color: var(--emerald); }

  /* login */
  .login-art { min-height: 0; padding: 22px 20px 30px; gap: 26px; }
  .login-art .flow { left: 20px; bottom: 20px; gap: 10px; }
  .login-art .flow i { width: 40px; height: 70px; }
  .hero-copy { margin-block: 26px 0; }
  .hero-copy h1 { font-size: 2.7rem; margin-bottom: 14px; }
  .hero-sub { font-size: .98rem; line-height: 1.6; }
  .login-panel { place-items: start center; padding: 30px 20px max(30px, env(safe-area-inset-bottom)); }
  .authbox h2 { font-size: 1.7rem; }
  .sub { margin-bottom: 24px; }

  /* home */
  .page { padding: 22px 16px 56px; }
  .welcome { flex-direction: column; align-items: stretch; gap: 18px; margin-bottom: 24px; }
  .welcome h1 { font-size: 2rem; }
  .stat { width: 100%; min-width: 0; }
  .courses { gap: 16px; }

  .course-stage { min-height: 0; gap: 26px; padding: 24px 20px; }
  .course-stage h3 { font-size: 2rem; }
  .course-stage .flow { left: 18px; top: 22px; gap: 8px; }
  .course-stage .flow i { width: 30px; height: 54px; }
  .learning-route { margin-top: 26px; }
  .route-node { width: 34px; height: 34px; }
  .stage-bottom { flex-direction: column; align-items: stretch; gap: 16px; }
  .stage-cta { min-width: 0; width: 100%; }

  .nextup { padding: 18px 16px; }
  .nextup-list { grid-template-columns: 1fr; }
  .course-shelf { grid-template-columns: 1fr; gap: 14px; }
  .cover { height: 110px; }

  /* learn: edge-to-edge video, app-like reading column */
  .learn { min-height: 0; }
  .player-area { padding: 10px 0 8px; }
  .mobile-back { margin: 2px 16px 10px; }
  .video { border-radius: 0; box-shadow: none; }
  .lesson-head, .notes, .nextbar { margin-inline: 16px; }
  .lesson-head { flex-direction: column; gap: 6px; margin-block: 20px 22px; }
  .lesson-head h1 { font-size: 1.55rem; }
  .complete { width: 100%; margin-top: 14px; }
  .nextbar { margin-top: 30px; }
  .nextbar > * { flex: 1; min-width: 0; padding-inline: 10px; }
  .lessons { padding: 24px 16px 36px; }

  /* admin */
  .panel { padding: 18px 16px; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
    border: 0;
  }
  .table td:first-child { font-size: 1rem; padding-bottom: 8px; }
  .table td[data-th]::before { content: attr(data-th); color: var(--muted); font-size: .82rem; }
  .table td:last-child { padding-top: 10px; }
  .table td:last-child .link {
    width: 100%;
    justify-content: center;
    border: 1.5px solid var(--line);
    border-radius: var(--r-ctrl);
  }

  /* modals become bottom sheets */
  .modal { align-items: end; padding: 0; }
  .modal-card {
    width: 100%;
    max-height: min(92svh, 760px);
    border-radius: var(--r-card) var(--r-card) 0 0;
    padding: 14px 18px max(22px, env(safe-area-inset-bottom));
  }
  .modal-card::before {
    content: "";
    display: block;
    width: 44px;
    height: 5px;
    margin: 0 auto 16px;
    border-radius: var(--r-pill);
    background: #d3dcd7;
  }
  .modal:not(.hidden) .modal-card { animation: sheet-in var(--t-view) var(--ease); }

  /* toast above tab bar */
  .toast {
    inset-inline: 16px;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
    text-align: center;
  }
}
@keyframes sheet-in {
  from { transform: translateY(40%); }
  to { transform: none; }
}

/* no hover-lift on touch devices */
@media (hover: none) {
  .course-card:hover, .primary:hover { transform: none; box-shadow: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
