:root{
  --bg: #ffffff;
  --text: #0a0a0a;
  --muted: #888888;
  --subtle: #bebebe;
  --panel: #fbfbfb;
  --line: #d7d7d7;
  --blue: #74b5ff;
  --red: #ff7474;
  --orange: #ffb974;
  --green: #5ecb5e;
  --yellow: #ffe539;
  --shadow: 0 10px 30px rgba(0,0,0,.07);
  --radius: 14px;
  --font-scale: 1;
  /* Semantic (light = dark UI ink on paper) */
  --app-bg: #f5f6f7;
  --border-strong: #0a0a0a;
  --line-strong: #bcbcbc;
  --body-muted: #364153;
  --list-muted: #4a5565;
  --card-tint: #f9fafb;
  --locked-tile-bg: #efefef;
  --btn-on-bg: #0a0a0a;
  --btn-on-fg: #ffffff;
  --btn-off-bg: #ffffff;
  --btn-off-fg: #0a0a0a;
  --bottom-nav-a: rgba(255,255,255,1);
  --bottom-nav-b: rgba(255,255,255,.78);
  --outline-focus: rgba(0,0,0,.25);
  --learn-grid: rgba(0,0,0,.045);
  --choice-frame: #6b6b6b;
  --pill-bg: #ffffff;
  --pill-border: #0a0a0a;
  --progress-track: #e5e7eb;
  --progress-fill: #0a0a0a;
  --algo-panel-bg: #f2f2f2;
  --algo-section-rule: #0a0a0a;
  --algo-item-divider: rgba(0,0,0,.12);
  --modal-bg: #ffffff;
  --modal-border: #0a0a0a;
  --scrollbar-thumb: rgba(0,0,0,.12);
  --lesson-tile-fg: #ffffff;
  --lesson-tile-muted-fg: rgba(10,10,10,.75);
  --lesson-tile-muted-border: rgba(10,10,10,.55);
  --lesson-tile-selected-border: rgba(10,10,10,.75);
  --active-card-inner-outline: rgba(10,10,10,.08);
  --review-hint: #878787;
  --ni-base: #e5e7eb;
  --ni-step-text: #364153;
  --certificate-accent: #db9d00;
  --settings-border: #d1d5dc;
  --hairline: #e5e7eb;
  --settings-knob: #99a1af;
  --tag-bg: #fff787;
  --yt-embed-bg: #0a0a0a;
  --ni-edge: rgba(10,10,10,.35);
  --ni-double-inset: rgba(255,255,255,.85);
  --active-hover-ring: rgba(255,255,255,.12);
}

html[data-theme="dark"]{
  color-scheme: dark;
  --bg: #121214;
  --text: #fafafa;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --panel: #18181b;
  --line: #3f3f46;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --app-bg: #09090b;
  --border-strong: #fafafa;
  --line-strong: #52525b;
  --body-muted: #d4d4d8;
  --list-muted: #c4c4cc;
  --card-tint: #1c1c1f;
  --locked-tile-bg: #27272a;
  --btn-on-bg: #fafafa;
  --btn-on-fg: #121214;
  --btn-off-bg: #18181b;
  --btn-off-fg: #fafafa;
  --bottom-nav-a: rgba(18,18,20,.98);
  --bottom-nav-b: rgba(18,18,20,.82);
  --outline-focus: rgba(250,250,250,.35);
  --learn-grid: rgba(255,255,255,.06);
  --choice-frame: #71717a;
  --pill-bg: #18181b;
  --pill-border: #fafafa;
  --progress-track: #27272a;
  --progress-fill: #fafafa;
  --algo-panel-bg: #1a1a1d;
  --algo-section-rule: #fafafa;
  --algo-item-divider: rgba(255,255,255,.12);
  --modal-bg: #18181b;
  --modal-border: #fafafa;
  --scrollbar-thumb: rgba(255,255,255,.18);
  --lesson-tile-fg: #ffffff;
  --lesson-tile-muted-fg: rgba(250,250,250,.78);
  --lesson-tile-muted-border: rgba(250,250,250,.45);
  --lesson-tile-selected-border: rgba(250,250,250,.72);
  --active-card-inner-outline: rgba(250,250,250,.12);
  --review-hint: #a1a1aa;
  --ni-base: #3f3f46;
  --ni-step-text: #d4d4d8;
  --settings-border: #3f3f46;
  --hairline: #2a2a2e;
  --settings-knob: #71717a;
  --tag-bg: #a16207;
  --yt-embed-bg: #09090b;
  --ni-edge: rgba(250,250,250,.3);
  --ni-double-inset: rgba(12,12,14,.88);
  --active-hover-ring: rgba(18,18,22,.35);
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
html{
  font-size: calc(16px * var(--font-scale, 1));
}
body{
  margin: 0;
  font-family: "Instrument Sans", Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--app-bg);
  color: var(--text);
}

.app-root{
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
}

.phone{
  width: min(390px, 100%);
  height: min(844px, 100dvh);
  max-height: 100dvh;
  background: var(--bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Single scroll surface for non–learn-home screens; learn home uses screen-root--learn (no vertical scroll). */
.screen-root{
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.screen-root--scroll{
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.screen-root--scroll::-webkit-scrollbar{
  width: 10px;
}

.screen-root--scroll::-webkit-scrollbar-thumb{
  background: var(--scrollbar-thumb);
  border-radius: 5px;
}

.screen-root--scroll::-webkit-scrollbar-track{
  background: transparent;
}

.screen-root--learn{
  overflow: visible;
}

.screen{
  padding: 22px;
}

/* Faster repeat taps on settings toggles (avoid 300ms delay / double-tap zoom on some browsers). */
.settings-screen .btn-small{
  touch-action: manipulation;
}

.h1{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0;
}

.h2{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0;
}

.muted{ color: var(--muted); }
.subtle{ color: var(--subtle); }

.center{
  text-align: center;
}

.row{ display: flex; gap: 14px; }
.col{ display: flex; flex-direction: column; gap: 14px; }
.spacer{ flex: 1; }

.card{
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.card-strong{
  border: 7px solid var(--choice-frame);
  border-radius: 0;
}

.btn{
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border: 6px solid #ffbcbc;
  background: var(--bg);
  padding: 16px 18px;
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  border-radius: 0;
  width: 100%;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.btn:active{ transform: translateY(1px); }

.btn:hover{
  background: var(--btn-on-bg);
  color: var(--btn-on-fg);
  border-color: var(--btn-on-bg);
  transform: scale(1.03);
}
.btn:focus-visible{
  outline: 4px solid var(--outline-focus);
  outline-offset: 3px;
}

.nav-btn{
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.nav-btn:hover{
  background: var(--btn-on-bg);
  color: var(--btn-on-fg);
  border-color: var(--btn-on-bg);
  transform: scale(1.03);
}
.nav-btn:focus-visible{
  outline: 4px solid var(--outline-focus);
  outline-offset: 3px;
}
.btn-blue{ border-color: rgba(116,181,255,.55); }
.btn-red{ border-color: rgba(255,116,116,.55); }
.btn-orange{ border-color: rgba(255,185,116,.55); }
.btn-gray{ border-color: rgba(196,196,196,.95); }

.btn-small{
  border-width: 5px;
  padding: 12px 14px;
  font-weight: 900;
}

.choice{
  flex: 1;
  padding: 18px 14px;
  background: var(--bg);
  border: 7px solid var(--choice-frame);
  border-radius: 0;
  min-height: 216px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.choice .big{ display: inline-block; transition: transform 180ms ease, color 180ms ease; }
.choice .kicker,
.choice .subtle{ transition: transform 180ms ease, color 180ms ease; }

.choice:hover{
  background: var(--btn-on-bg);
  border-color: var(--btn-on-bg);
  transform: scale(1.04);
}
.choice:hover .big{
  color: var(--btn-on-fg);
  transform: scale(1.14);
}
.choice:hover .kicker,
.choice:hover .subtle{
  color: var(--btn-on-fg);
  transform: scale(1.06);
}

.choice:focus-visible{
  outline: 4px solid var(--outline-focus);
  outline-offset: 3px;
}
.choice.selected{
  background: var(--btn-on-bg);
  border-color: var(--btn-on-bg);
  transform: scale(1.04);
  outline: none;
}
.choice.selected .big{
  color: var(--btn-on-fg);
  transform: scale(1.14);
}
.choice.selected .kicker,
.choice.selected .subtle{
  color: var(--btn-on-fg);
  transform: scale(1.06);
}
.choice .big{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 44px;
  line-height: 1;
  margin-top: 4px;
}

.grid-2x2{
  display: grid;
  grid-template-columns: repeat(2, 38px);
  grid-auto-rows: 38px;
  gap: 10px;
  margin-top: 8px;
}
.grid-3x3{
  display: grid;
  grid-template-columns: repeat(3, 24px);
  grid-auto-rows: 24px;
  gap: 7px;
  margin-top: 6px;
}
.sq{ width: 100%; height: 100%; }

.pill{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--pill-bg);
  border: 2px solid var(--pill-border);
  font-weight: 800;
}

.progress{
  height: 6px;
  background: var(--progress-track);
  position: relative;
  width: 100%;
}
.progress > div{
  height: 100%;
  width: 30%;
  background: var(--progress-fill);
}

.learn-page{
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.learn-shell{
  padding: 14px 16px 118px;
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen-root--learn .learn-shell{
  overflow: visible;
}

.screen-root--learn .learn-shell > *{
  flex-shrink: 0;
}

.screen-root--learn .learn-shell > .active-stage{
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
  margin-bottom: 4px;
  overflow: visible;
  padding: 20px 12px;
  align-content: center;
}

.screen-root--learn .active-stage{
  min-height: 0;
}

/* Square tap target; hover grows the inner cube only so it is not clipped. */
.screen-root--learn .active-card{
  width: 152px;
  height: 152px;
  min-height: 152px;
  max-height: 152px;
  aspect-ratio: 1;
  margin-top: 0;
  padding: 0;
  box-sizing: border-box;
}

.screen-root--learn .active-card .inner{
  width: 124px;
  height: 124px;
  aspect-ratio: 1;
  outline-width: 5px;
  box-sizing: border-box;
}

.screen-root--learn .active-card .code{
  font-size: 44px;
}

.screen-root--learn .active-card .title{
  font-size: 14px;
}

.screen-root--learn .active-card:hover{
  transform: none;
  background: var(--bg);
}

.screen-root--learn .active-card:hover .inner{
  background: var(--btn-on-bg) !important;
  border-color: var(--btn-on-bg);
  outline: 6px solid var(--active-hover-ring);
  transform: scale(1.09);
}

.screen-root--learn .active-card:hover .code,
.screen-root--learn .active-card:hover .title{
  color: var(--btn-on-fg) !important;
}

.screen-root--learn .active-card:hover .code{
  font-size: 48px;
  transform: scale(1.05);
}

.screen-root--learn .active-card:hover .title{
  font-size: 15px;
  transform: none;
}

/* Smaller lesson “timeline” strip on learn home */
.screen-root--learn #lessonCarousel{
  margin-top: 18px;
  gap: 10px;
  padding: 12px 2px 8px;
  overflow-y: visible;
}

.screen-root--learn #lessonCarousel .lesson-tile{
  width: 72px;
  height: 72px;
  border-width: 3px;
  font-size: 22px;
}

.screen-root--learn #lessonCarousel .lesson-tile:hover{
  transform: translateY(-2px) scale(1.06);
}

.screen-root--learn #lessonCarousel .lesson-tile.selected{
  transform: translateY(-3px) scale(1.08);
}

/* Compact info card */
.screen-root--learn .home-info-card{
  padding: 12px 14px;
  border-width: 5px;
}

.screen-root--learn .home-info-card .home-info-meta{
  font-size: 12px;
}

.screen-root--learn .home-info-card .home-info-title{
  font-size: 18px;
  margin-top: 6px;
}

.screen-root--learn .home-info-card .home-info-purpose{
  font-size: 0.95rem;
  line-height: 1.35;
  margin-top: 6px;
}

.screen-root--learn .home-info-card .home-info-tag{
  margin-top: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

/* Subtle grey squares background (Home) */
.learn-shell::before{
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--learn-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--learn-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .22;
  pointer-events: none;
}
.learn-shell > *{
  position: relative;
  z-index: 1;
}

.bottom-nav{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 14px 18px;
  background: linear-gradient(to top, var(--bottom-nav-a), var(--bottom-nav-b));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  pointer-events: none;
}

.nav-btn{
  border: 5px solid var(--border-strong);
  background: var(--bg);
  padding: 12px 10px;
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}

/* My Algorithms */
.algo-shell{
  padding: 22px 18px 160px;
}
.algo-title{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-size: 46px;
  margin: 8px 0 16px;
}
.algo-panel{
  background: var(--algo-panel-bg);
  padding: 18px 16px;
  border-radius: 0;
}
.algo-section{
  padding: 10px 0 16px;
}
.algo-section + .algo-section{
  border-top: 5px solid var(--algo-section-rule);
}
.algo-section-title{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 30px;
  letter-spacing: -0.02em;
  margin: 8px 0 10px;
}
.algo-item{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 0 14px;
}
.algo-item + .algo-item{
  border-top: 2px solid var(--algo-item-divider);
}
.algo-item-head{
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}
.algo-lesson-id{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.algo-item-name{
  font-family: "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--body-muted);
}
.algo-notation-cluster{
  border: 3px solid var(--border-strong);
  background: var(--bg);
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
}
.algo-notation-cluster .ni-seq{
  gap: 6px;
  row-gap: 8px;
}
.algo-notation-cluster .ni{
  box-shadow: 0 0 0 1px var(--ni-edge);
}
.algo-notation-cluster .ni.double{
  outline-width: 2px;
  outline-offset: 2px;
}
.algo-notation-cluster .ni.ni-d{
  box-shadow: 0 0 0 1px var(--ni-edge), 0 0 0 3px var(--text) inset;
}
.nav-btn.secondary{
  border-color: transparent;
  background: var(--locked-tile-bg);
}

.lesson-card{
  border: 7px solid var(--border-strong);
  padding: 18px;
  background: var(--bg);
  cursor: pointer;
  transition: transform 180ms ease;
}
.lesson-card:hover{
  transform: scale(1.02);
}
.tag{
  background: var(--tag-bg);
  color: var(--text);
  display: inline-block;
  padding: 6px 10px;
  font-weight: 800;
  margin-top: 10px;
}

.streak{
  position: absolute;
  top: 8px;
  right: 8px;
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
}
.streak .count{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 14px));
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 38px;
  color: var(--lesson-tile-fg);
  pointer-events: none;
}

/* Keep streak in the header row so it does not cover the title (learn home only). */
.screen-root--learn .learn-shell > .row{
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
}
.screen-root--learn .learn-shell > .row > div:first-child{
  min-width: 0;
}
.screen-root--learn .streak{
  position: relative;
  top: auto;
  right: auto;
  flex-shrink: 0;
}

.modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.25);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-backdrop.open{ display: flex; }
.modal{
  width: min(360px, 100%);
  background: var(--modal-bg);
  border: 6px solid var(--modal-border);
  padding: 16px;
}

.streak-modal-backdrop{
  z-index: 40;
  align-items: center;
  justify-content: center;
}

.streak-celebrate-modal{
  text-align: center;
  padding: 20px 18px 18px;
  max-width: 320px;
}

.streak-celebrate-lottie{
  width: 140px;
  height: 140px;
  margin: 0 auto 4px;
}

.streak-celebrate-count-block{
  margin-bottom: 10px;
}

.streak-celebrate-label{
  font-family: "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.streak-celebrate-count{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--lesson-tile-fg);
  margin-top: 4px;
}

@keyframes streakCountPulse{
  0%, 100%{ transform: scale(1); }
  50%{ transform: scale(1.07); }
}

.streak-celebrate-count--pulse{
  animation: streakCountPulse 0.55s ease-in-out 2;
  transform-origin: center center;
}

@media (prefers-reduced-motion: reduce){
  .streak-celebrate-count--pulse{
    animation: none;
  }
}

.streak-celebrate-title{
  font-size: 20px;
  margin-top: 4px;
}

.streak-celebrate-sub{
  margin-top: 10px;
  color: var(--body-muted);
  font-size: 15px;
  line-height: 1.35;
}

.streak-celebrate-actions{
  margin-top: 16px;
}

.streak-modal-animate.streak-modal-backdrop.open{
  animation: streakBackdropFade 320ms ease-out both;
}

.streak-modal-animate.streak-modal-backdrop.open .streak-celebrate-modal{
  animation: streakModalPop 520ms cubic-bezier(0.22, 1.28, 0.36, 1) both;
}

@keyframes streakBackdropFade{
  from{ opacity: 0; }
  to{ opacity: 1; }
}

@keyframes streakModalPop{
  from{
    opacity: 0;
    transform: scale(0.88) translateY(12px);
  }
  to{
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce){
  .streak-modal-animate.streak-modal-backdrop.open,
  .streak-modal-animate.streak-modal-backdrop.open .streak-celebrate-modal{
    animation: none;
  }
}

.tiny-top{
  height: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 0;
  width: 150px;
}
.tiny-top > div{ background: var(--progress-track); }
.tiny-top > div.active{ background: var(--progress-fill); }
.tiny-top > div.mid{ background: var(--settings-knob); }

.back-btn{
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.back-btn img{ width: 34px; height: 34px; }

.loading{
  min-height: min(844px, 100dvh);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.loading-inner{
  width: 100%;
  display: grid;
  place-items: center;
  gap: 18px;
}
.lottie{
  width: 220px;
  height: 220px;
}

.list{
  margin: 0;
  padding-left: 22px;
  color: var(--list-muted);
  font-size: 1.125rem;
  line-height: 1.45;
}
.para{
  color: var(--list-muted);
  font-size: 1.125rem;
  line-height: 1.45;
  margin: 0;
}

.kicker{
  font-weight: 700;
  letter-spacing: -0.01em;
}

.yt-wrap{
  position: relative;
  width: 100%;
  height: 240px;
  background: var(--yt-embed-bg);
  border-radius: 0;
  overflow: hidden;
}
.yt-embed{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 380px){
  .choice .big{ font-size: 40px; }
  .lesson-card{ padding: 14px; }
}

.carousel{
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 10px 6px 18px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.carousel::-webkit-scrollbar{ height: 10px; }
.carousel::-webkit-scrollbar-thumb{ background: var(--scrollbar-thumb); border-radius: 999px; }

.lesson-tile{
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: 86px;
  height: 86px;
  border: 5px solid rgba(0,0,0,.0);
  background: var(--locked-tile-bg);
  display: grid;
  place-items: center;
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  color: var(--lesson-tile-fg);
  user-select: none;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, border-color 180ms ease;
  position: relative;
}
.lesson-tile:hover{
  background: var(--btn-on-bg) !important;
  color: var(--btn-on-fg);
  border-color: var(--btn-on-bg);
  transform: translateY(-2px) scale(1.08);
  opacity: 1;
}
.lesson-tile.locked:hover{
  background: var(--bg) !important;
  color: var(--lesson-tile-muted-fg);
  border-color: var(--lesson-tile-muted-border);
  transform: none;
  opacity: .45;
  cursor: not-allowed;
}
.lesson-tile.locked{
  background: var(--bg);
  border-color: var(--lesson-tile-muted-border);
  color: var(--lesson-tile-muted-fg);
  opacity: .45;
}
.lesson-tile.completed{
  border-color: transparent;
  color: var(--lesson-tile-fg);
}
.lesson-tile.selected{
  border-color: var(--lesson-tile-selected-border);
  transform: translateY(-4px) scale(1.12);
  z-index: 2;
}

/* Selected (center) tile should look like hover state */
.lesson-tile.selected:not(.locked){
  background: var(--btn-on-bg) !important;
  color: var(--btn-on-fg);
  border-color: var(--btn-on-bg);
  opacity: 1;
}

.active-stage{
  display: grid;
  place-items: center;
  margin-top: 22px;
  margin-bottom: 34px;
  min-height: 280px;
  position: relative;
  z-index: 3;
}
.active-card{
  width: 272px;
  min-height: 252px;
  margin-top: 14px;
  border: none;
  background: var(--bg);
  display: grid;
  place-items: center;
  transition: transform 200ms ease, background-color 200ms ease;
  cursor: pointer;
  position: relative;
  z-index: 1;
  overflow: visible;
  pointer-events: auto;
}
.active-card:hover{
  transform: scale(1.08);
  background: var(--btn-on-bg);
}
.active-card:hover .inner{
  background: var(--btn-on-bg) !important;
  border-color: var(--btn-on-bg);
  outline: 8px solid var(--active-hover-ring);
  transform: scale(1.1);
}
.active-card:hover .code,
.active-card:hover .title{
  color: var(--btn-on-fg) !important;
}
.active-card:hover .code{
  font-size: 64px;
  transform: scale(1.12);
}
.active-card:hover .title{
  font-size: 20px;
  transform: scale(1.1);
}
.active-card:focus-visible{
  outline: 4px solid var(--outline-focus);
  outline-offset: 3px;
}
.active-card .inner{
  width: 160px;
  height: 160px;
  border: 2px solid var(--line);
  outline: 8px solid var(--active-card-inner-outline);
  display: grid;
  place-items: center;
  gap: 4px;
  transform: translateX(0);
  transition: transform 240ms ease, opacity 240ms ease, background-color 200ms ease, border-color 200ms ease, outline-color 200ms ease;
}
.active-card .code,
.active-card .title{
  transition: transform 200ms ease, color 200ms ease, font-size 200ms ease;
}

@keyframes bigSlideFromLeft{
  from{ transform: translateX(-28%); opacity: .0; }
  to{ transform: translateX(0); opacity: 1; }
}
@keyframes bigSlideFromRight{
  from{ transform: translateX(28%); opacity: .0; }
  to{ transform: translateX(0); opacity: 1; }
}
.active-card.slide-from-left .inner{ animation: bigSlideFromLeft 240ms ease both; }
.active-card.slide-from-right .inner{ animation: bigSlideFromRight 240ms ease both; }
.active-card .code{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 56px;
  line-height: .9;
}
.active-card .title{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.review-hint{
  text-align: center;
  color: var(--review-hint);
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 6px 0 0;
}

/* Notation icons (Memory Tools) */
.ni-seq{
  display: inline-flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.ni{
  --ni-color: var(--ni-base);
  width: 40px;
  height: 40px;
  background: var(--ni-color);
  display: grid;
  place-items: center;
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  color: var(--text);
  position: relative;
  border-radius: 0;
  line-height: 1;
}
.ni-label{
  display: inline-block;
  line-height: 1;
}
.ni-md{ width: 38px; height: 38px; font-size: 26px; }
.ni-sm{ width: 28px; height: 28px; font-size: 18px; }
.ni-xs{ width: 22px; height: 22px; font-size: 13px; }
.ni-lg{ width: 46px; height: 46px; font-size: 32px; }

.ni.ni-d{
  /* Updated Figma: D tile is white with black inset border */
  box-shadow: 0 0 0 5px var(--text) inset;
}

.ni.double{
  outline: 4px solid var(--ni-color);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--ni-double-inset) inset;
}

.ni.ni-d.double{
  /* Updated Figma: D2 uses a black double-outline */
  outline-color: var(--text);
  box-shadow: 0 0 0 5px var(--text) inset;
}
.ni.prime{
  /* Updated Figma: prime moves are diamond-shaped */
  transform: rotate(45deg);
}
.ni.prime .ni-label{
  transform: rotate(-45deg);
}

.ni-text{
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.ni-step{
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.ni-step-text{
  font-family: "Instrument Sans", Inter, system-ui, sans-serif;
  color: var(--ni-step-text);
}

/* —— Course complete certificate (Figma node 44:1855) —— */
.course-complete-screen{
  position: relative;
  min-height: min(820px, 100dvh);
  padding: 18px 16px 28px;
  overflow: hidden;
}
.course-complete-confetti{
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.course-confetti-piece{
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 1px;
  background: var(--c, #db9d00);
  opacity: 0.95;
  animation: courseConfettiFall var(--d, 2.8s) ease-in forwards;
}
@keyframes courseConfettiFall{
  0%{
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  100%{
    transform: translate3d(var(--x, 0), 110vh, 0) rotate(var(--r, 360deg));
    opacity: 0.85;
  }
}

.certificate-shell{
  position: relative;
  z-index: 1;
  max-width: 100%;
  margin: 0 auto;
}
.certificate-frame{
  position: relative;
  padding: 0 4px 8px;
}
.certificate-svg{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.certificate-stroke{
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: certificateStrokeDraw 1.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes certificateStrokeDraw{
  to{ stroke-dashoffset: 0; }
}

.certificate-inner{
  position: relative;
  z-index: 1;
  padding: 22px 18px 100px;
  min-height: 420px;
}
.certificate-title{
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(22px, 5.5vw, 30px);
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  margin: -14px auto 0;
  padding: 0 14px;
  max-width: 96%;
  background: var(--bg);
  position: relative;
  z-index: 2;
  opacity: 0;
  animation: certReveal 0.55s ease 0.15s forwards;
}
.certificate-script{
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: clamp(44px, 12vw, 64px);
  line-height: 1.05;
  text-align: center;
  color: var(--text);
  margin: 10px 0 18px;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  animation: certScriptIn 0.85s cubic-bezier(0.34, 1.2, 0.64, 1) 0.45s forwards;
}
@keyframes certScriptIn{
  to{
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.certificate-body{
  font-family: "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(16px, 4vw, 18px);
  line-height: 1.55;
  text-align: center;
  color: var(--text);
  margin: 0 auto;
  max-width: 36rem;
  opacity: 0;
  animation: certReveal 0.65s ease 0.75s forwards;
}
.certificate-body p{
  margin: 0 0 1em;
}
.certificate-body p:last-child{
  margin-bottom: 0;
}
.certificate-sparkle{
  display: inline-block;
  animation: certSparkle 2.5s ease-in-out infinite;
}
@keyframes certSparkle{
  0%, 100%{ filter: brightness(1); transform: scale(1); }
  50%{ filter: brightness(1.15); transform: scale(1.02); }
}
@keyframes certReveal{
  to{ opacity: 1; }
}

.certificate-actions{
  position: absolute;
  right: 12px;
  bottom: 18px;
  z-index: 3;
  opacity: 0;
  animation: certReveal 0.5s ease 1.15s forwards;
}
.certificate-home-btn{
  display: inline-block;
  margin: 0;
  padding: 14px 22px;
  background: var(--bg);
  border: 3px solid var(--certificate-accent);
  color: var(--text);
  font-family: "Nexa Heavy", "Nexa", "Instrument Sans", Inter, system-ui, sans-serif;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.certificate-home-btn:hover{
  background: var(--btn-on-bg);
  color: var(--btn-on-fg);
  border-color: var(--btn-on-bg);
  transform: translateY(-2px) scale(1.02);
}
.certificate-home-btn:active{
  transform: translateY(0) scale(0.99);
}

@media (prefers-reduced-motion: reduce){
  .course-confetti-piece{
    animation: none !important;
    opacity: 0 !important;
  }
  .certificate-stroke{
    animation: none !important;
    stroke-dashoffset: 0 !important;
  }
  .certificate-title,
  .certificate-script,
  .certificate-body,
  .certificate-actions{
    animation: none !important;
    opacity: 1 !important;
  }
  .certificate-script{
    transform: none !important;
  }
}
