/* ==========================================================================
   Dashboard redesign — design system.
   Geometry measured from `System Design News Feed Dashboard.png` (1672×941).
   Loaded after course.css; the scene CSS stays in course.css.
   ========================================================================== */

@font-face {
  font-family: "Satoshi";
  src: url("/assets/fonts/satoshi-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Satoshi";
  src: url("/assets/fonts/satoshi-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Satoshi";
  src: url("/assets/fonts/satoshi-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Satoshi";
  src: url("/assets/fonts/satoshi-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Surfaces */
  --db-page: var(--d-fcf4e9);
  --db-panel: var(--d-fdf8f0);
  --db-card: var(--d-fdf6ec);
  --db-card-2: var(--d-fbf4e9);
  --db-card-border: var(--d-f0e5d3);
  --db-diagram: var(--d-fef8f0);
  --db-white: var(--d-fdf9f3);

  /* Ink */
  --db-ink: var(--d-17150f);
  --db-ink-2: var(--d-35302a);
  --db-muted: var(--d-7c7466);
  --db-muted-2: var(--d-9d9484);

  /* Greens */
  --db-green-tint: var(--d-d9ebb5);
  --db-green-tint-2: var(--d-e9f2d6);
  --db-green-soft: var(--d-b7d78b);
  --db-green: var(--d-45922f);
  --db-green-deep: var(--d-2f6e1e);
  --db-green-ink: var(--d-33531f);
  --db-green-wash: var(--d-eef3dc);

  /* Accents */
  --db-mint: var(--d-e4f0d3);
  --db-violet: var(--d-eaeaf5);
  --db-violet-ink: var(--d-5b4a8a);
  --db-cream: var(--d-fdf2df);
  --db-orange: var(--d-e8933f);
  --db-purple: var(--d-b9a6e0);

  --db-radius-card: 18px;
  --db-radius-tile: 14px;
  --db-shadow-card: 0 1px 2px rgba(90, 70, 30, 0.04), 0 8px 24px -16px rgba(90, 70, 30, 0.35);
  --db-font: "Satoshi", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Page shell ---------- */

html,
body {
  height: 100%;
}

body {
  background: var(--db-page);
  color: var(--db-ink);
  font-family: var(--db-font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.dash {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 300px minmax(0, 1fr) 200px;
  grid-template-areas:
    "top top top"
    "side main rail";
  padding: 0 14px 0 7px;
  background: var(--db-page);
}

.dash > *:not(.dash-bg) {
  position: relative;
  z-index: 1;
}

/* Auth views without the course sidebar: pricing keeps its billing rail,
   login drops both side columns. */
.dash.dash--no-side {
  grid-template-columns: minmax(0, 1fr) 200px;
  grid-template-areas:
    "top top"
    "main rail";
}

.dash.dash--solo {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "main";
}

/* The topbar hosts the language popup, which must paint above the main and
   rail columns; as an earlier z-index:1 sibling the whole bar (popup
   included) would otherwise sit under them. Same specificity as the generic
   rule above, later in the file, so it wins. */
.dash > .dash-top {
  z-index: 40;
}

/* The search dialog is a shell-level modal. The generic shell rule would
   flatten it into a grid cell (position: relative, z-index: 1), so restore
   its overlay box and stack it above the topbar (40) and the drawer
   (44/45). On non-desktop course.css keeps it position: fixed with a
   higher-specificity rule; only the z-index needs the lift there. */
.dash > .sx {
  position: absolute;
  z-index: 46;
}

.dash-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.dash-bg__waves {
  position: absolute;
  /* Fluid size and offsets keep the arc anchored to the top-right at any width. */
  top: -4.2vw;
  right: -6vw;
  width: clamp(200px, 40vw, 1050px);
  height: auto;
  transform: scaleX(-1);
  user-select: none;
}

.dash-bg__db {
  position: absolute;
  top: 136px;
  right: 244px;
  width: clamp(150px, 11.25vw, 188px);
  height: auto;
  user-select: none;
}

.dash-bg__circles {
  position: absolute;
  left: -54px;
  bottom: -72px;
  width: clamp(170px, 14vw, 240px);
  height: auto;
  user-select: none;
}

.dash__side {
  grid-area: side;
  margin: -2px 14px 13px 0;
  padding: 20px 10px 16px 24px;
  background: var(--db-panel);
  border: 1px solid var(--d-f2e7d5);
  border-radius: 18px;
  overflow: hidden;
}

.dash__main {
  grid-area: main;
  padding: 22px 30px 0 33px;
  min-width: 0;
  position: relative;
}

.dash__rail {
  grid-area: rail;
  padding: 87px 0 0;
  /* The learning path reaches under the rail's gutter, so the empty rail box
     must let clicks through; only the cards themselves capture pointer events. */
  pointer-events: none;
}

.dash__rail > * {
  pointer-events: auto;
}

.dash-rail__stack {
  display: block;
}

/* ---------- Topbar ---------- */

.dash-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 22px 0 28px;
  min-width: 0;
  /* The bar is a light page tint on the right, fading into the page colour.
     The tint block must reach the window's right edge: the shell's right
     gutter would otherwise show a page-coloured sliver past the bar. */
  margin-right: -14px;
  padding-right: 36px;
  background: linear-gradient(
    270deg,
    var(--d-fdf8f0) 0%,
    color-mix(in srgb, var(--d-fdf8f0) 96%, transparent) 18%,
    color-mix(in srgb, var(--d-fdf8f0) 60%, transparent) 42%,
    color-mix(in srgb, var(--d-fdf8f0) 0%, transparent) 70%
  );
}

.dash-top .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 70px;
  color: var(--db-ink);
  text-decoration: none;
  flex: none;
}

.dash-top .brand img.logo {
  flex: none;
  width: 26px;
  height: 26px;
}

.dash-top .brand .logo--dark {
  display: none;
}

[data-theme="dark"] .dash-top .brand .logo--light {
  display: none;
}

[data-theme="dark"] .dash-top .brand .logo--dark {
  display: inline-block;
}

.dash-top .brand__name {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.dash-top .brand__name b {
  font-weight: 900;
  background: var(--db-green-tint);
  border-radius: 6px;
  padding: 2px 7px 3px;
  margin-left: 1px;
}

.dash-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.dash-nav__item {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--db-ink);
  white-space: nowrap;
  background: none;
}

.dash-nav__item .i {
  color: var(--db-ink-2);
}

.dash-nav__item.is-active {
  background: var(--db-green-tint);
}

.dash-nav__item:not(.is-active):hover {
  background: color-mix(in srgb, var(--d-d9ebb5) 40%, transparent);
}

.dash-top__spacer {
  flex: 1;
  min-width: 12px;
}

.dash-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 206px;
  height: 31px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--db-white);
  border: 1px solid var(--db-card-border);
  color: var(--db-muted);
  font-size: 12.5px;
  font-weight: 500;
  flex: none;
}

.dash-search:hover {
  border-color: var(--db-muted-2);
}

.dash-search span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.dash-search .i {
  color: var(--db-ink-2);
  flex: none;
}

.dash-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 9px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--db-card-border);
  background: var(--db-white);
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}

.dash-lang .i {
  color: var(--db-ink-2);
}

.dash-iconbtn {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 999px;
  border: 1px solid var(--db-card-border);
  background: var(--db-white);
  color: var(--db-ink);
  flex: none;
}

.dash-avatar {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 999px;
  background: var(--d-34323f);
  color: var(--d-fff);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}

.dash-top > .dash-search,
.dash-top > .dash-iconbtn,
.dash-top > .dash-avatar,
.dash-top > div {
  margin-left: 10px;
}

/* ---------- Sidebar ---------- */

.dash-side__section-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.015em;
  padding: 0;
  margin: 0 0 14px;
  line-height: 1.2;
  position: relative;
  display: inline-block;
}

.dash-side__section-title::after {
  content: "";
  position: absolute;
  left: 0;
  right: -2px;
  bottom: -3px;
  height: 3px;
  border-radius: 3px;
  background: var(--d-eef2da);
}

.dash-side__section-title + .dash-toc,
.dash-progress + .dash-side__section-title {
  margin-top: 0;
}

.dash-progress + .dash-side__section-title {
  margin-top: 22px;
}

.dash-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--db-panel);
  border: 1px solid var(--db-card-border);
  border-radius: var(--db-radius-tile);
  padding: 9px 12px;
  box-shadow: var(--db-shadow-card);
  margin: 4px 0 0 -1px;
  height: 66px;
}

.dash-ring {
  position: relative;
  width: 54px;
  height: 54px;
  flex: none;
}

.dash-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dash-ring__track {
  stroke: var(--d-eae3d4);
}

.dash-ring__arc {
  stroke: var(--d-5b9a35);
  stroke-linecap: round;
}

.dash-ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.dash-progress__meta {
  min-width: 0;
  flex: 1;
}

.dash-progress__count {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
}

.dash-progress__count span {
  color: var(--db-ink-2);
  font-weight: 500;
}

.dash-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--d-fdfcf7);
  border: 1px solid var(--d-ece1cf);
  overflow: hidden;
}

.dash-progress .dash-bar {
  height: 7px;
}

.dash-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--d-4f9130);
}

/* Module list */

.dash-toc {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dash-toc > li {
  margin-bottom: 1px;
}

.dash-toc__row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  height: 37px;
  padding: 0 10px 0 4px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  color: var(--db-ink);
  text-align: left;
  background: none;
}

.dash-toc__row:hover {
  background: color-mix(in srgb, var(--d-d9ebb5) 35%, transparent);
}

.dash-toc__row.is-open {
  background: var(--d-e9f2d6);
  height: 39px;
  margin: 1px 0;
}

.dash-toc__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-toc__count {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--d-8a8172);
  letter-spacing: 0.01em;
}

.dash-toc__row > .i {
  color: var(--d-2b2721);
}

.dash-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 999px;
  background: var(--d-4f9130);
  color: var(--d-fff);
}

.dash-check--todo {
  background: transparent;
  border: 1.5px solid var(--d-cfc6b5);
  color: transparent;
}

.dash-check--play {
  background: var(--db-green-tint);
  color: var(--db-green-deep);
}

/* Partly complete module: a small green ring, no label inside. */
.dash-check--progress {
  position: relative;
  background: var(--db-green-tint-2);
  color: var(--db-green-ink);
}

.dash-check--progress svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dash-check--progress circle {
  fill: none;
  stroke-width: 2.6;
}

.dash-check__track {
  stroke: var(--d-d9ebb5);
}

.dash-check__arc {
  stroke: var(--d-4f9130);
  stroke-linecap: round;
}

/* Expanded lessons tree */

/* Opening/closing animation: interpolating the grid row height gives a smooth
   reveal without hard-coding a max-height that would break long lists. */
.dash-tree__clip {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms cubic-bezier(0.22, 0.72, 0.24, 1);
}

.dash-tree__clip.is-open {
  grid-template-rows: 1fr;
}

.dash-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.dash-tree > li {
  margin: 0;
}

.dash-tree__row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 31px;
  height: auto;
  padding: 3px 10px 3px 32px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--db-ink-2);
  position: relative;
  text-align: left;
  text-decoration: none;
}

/* Long lesson names wrap instead of clipping into the next row. */
.dash-tree__row > span:last-child {
  min-width: 0;
  overflow-wrap: break-word;
}

.dash-tree__row:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dash-tree__row.is-locked {
  color: var(--db-muted);
  cursor: pointer;
}

.dash-tree__row.is-locked:hover {
  background: var(--db-green-wash);
  color: var(--db-green-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dash-tree__row.is-locked:focus-visible {
  outline: 2px solid var(--db-green-deep);
  outline-offset: 2px;
}

.dash-tree__row.is-current {
  background: none;
  color: var(--d-24360f);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dash-tree__check {
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 999px;
  background: var(--d-4f9130);
  border: none;
  color: var(--d-fff);
}

.dash-tree__check.is-current {
  background: var(--d-5b9a35);
}

/* In-progress lessons show a green play circle; the check appears at 100%. */
.dash-tree__check.is-play {
  background: var(--d-4f9130);
  color: var(--d-fff);
}

.dash-tree__check.is-todo {
  background: transparent;
  border: 1.5px solid var(--d-cfc6b5);
}

.dash-tree__check.is-locked {
  background: var(--db-card-2);
  border: 1px solid var(--db-card-border);
  color: var(--db-muted-2);
}

/* Keep going card */

.dash-keep {
  margin: 9px 0 0 -4px;
  padding: 16px 16px 15px;
  background: var(--db-panel);
  border: 1px solid var(--db-card-border);
  border-radius: var(--db-radius-tile);
  box-shadow: var(--db-shadow-card);
}

.dash-keep__head {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}

.dash-keep__bulb {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--db-cream);
  color: var(--db-ink);
  overflow: hidden;
}

.dash-keep__bulb img {
  display: block;
  width: 26px;
  height: auto;
}

.dash-keep__title {
  font-size: 15px;
  font-weight: 900;
  margin-top: 1px;
}

.dash-keep__text {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--d-6f675a);
  line-height: 1.35;
  font-weight: 500;
}

.dash-keep .dash-bar {
  margin-top: 12px;
}

/* ---------- Main header ---------- */

.dash-header {
  position: relative;
}

.dash-crumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dash-crumb__left {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.dash-crumb__module {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--db-green-tint);
  color: var(--d-2f4a18);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.dash-crumb__lesson {
  font-size: 14px;
  font-weight: 500;
  color: var(--d-3a352c);
  white-space: nowrap;
}

.dash-title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -0.028em;
  line-height: 1.08;
  margin: 4px 0 6px;
  color: var(--d-0f0e0b);
}

.dash-subtitle {
  font-size: 15px;
  font-weight: 400;
  color: var(--d-4a4439);
  margin: 0;
  max-width: 700px;
  line-height: 1.4;
}

.dash-chip-row {
  display: flex;
  gap: 10px;
  flex: none;
}

.dash-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--db-ink);
  white-space: nowrap;
}

.dash-chip .i {
  flex: none;
}

.dash-chip--cream {
  background: var(--d-fdf2df);
  border-color: var(--d-e9d3ac);
}

.dash-chip--mint {
  background: var(--d-e6f0d6);
  border-color: var(--d-c6d9a5);
}

.dash-chip--mint .i {
  color: var(--d-3c6b23);
}

.dash-chip--violet {
  background: var(--d-e9e8f4);
  border-color: var(--d-cdc9e2);
}

.dash-chip--violet .i {
  color: var(--d-4b4560);
}

/* Stat cards */

.dash-stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 9px;
  margin-top: 14px;
  position: relative;
}

.dash-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  background: var(--db-card);
  border: 1px solid var(--db-card-border);
  border-radius: 10px;
  box-shadow: var(--db-shadow-card);
  padding: 4px 9px;
  min-height: 40px;
  transition:
    background 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.dash-stat > div {
  min-width: 0;
}

.dash-stat__icon {
  flex: none;
  color: var(--db-ink);
  display: grid;
  place-items: center;
}

.dash-stat__icon--orange {
  color: var(--d-e8933f);
}

.dash-stat__value {
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.35s ease;
}

/* Values carry a health level from the lesson metrics: tint each card so the
   row reads at a glance as the step changes. */
.dash-stat[data-level="good"] {
  background: var(--d-f2f8e6);
  border-color: var(--d-c9dfa3);
}

.dash-stat[data-level="good"] .dash-stat__value,
.dash-stat[data-level="good"] .dash-stat__icon {
  color: var(--d-35681c);
}

.dash-stat[data-level="warn"] {
  background: var(--d-fdf6e3);
  border-color: var(--d-ecd49a);
}

.dash-stat[data-level="warn"] .dash-stat__value,
.dash-stat[data-level="warn"] .dash-stat__icon {
  color: var(--d-8a5a0b);
}

.dash-stat[data-level="bad"] {
  background: var(--d-fcefe9);
  border-color: var(--d-eec1b1);
}

.dash-stat[data-level="bad"] .dash-stat__value,
.dash-stat[data-level="bad"] .dash-stat__icon {
  color: var(--d-a33522);
}

.dash-stat[data-level="none"] .dash-stat__value {
  color: var(--db-ink);
}

.dash-stat__label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--d-7c7466);
  margin-top: 1px;
  white-space: nowrap;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep the stat row clear of the database illustration on wide screens. */
@media (min-width: 1400px) {
  .dash-stats {
    max-width: calc(100% - 300px);
  }
}

/* ---------- Diagram card ---------- */

.dash-stage-card {
  position: relative;
  margin-top: 23px;
  background: var(--db-diagram);
  border: 1px solid var(--d-f0e5d2);
  border-radius: var(--db-radius-card);
  box-shadow: var(--db-shadow-card);
  overflow: hidden;
  height: 407px;
}

/* Expanded mode parks the learning path in the rail and lets the diagram
   absorb the freed height (the stage refits itself on resize). */

:root[data-layout="stack"] .dash-stage-card.is-full {
  height: min(70vh, 620px);
}

:root.has-full[data-layout="stack"] body {
  overflow: auto;
}

/* On desktop and tablet the card already fills the free height, so expanding
   frees the learning path's row instead: the path folds away and the diagram
   absorbs the room (the stage refits itself on resize). */
:root[data-layout="desktop"] .dash-path,
:root[data-layout="tablet"] .dash-path {
  interpolate-size: allow-keywords;
  transition:
    height 0.24s cubic-bezier(0.2, 0.7, 0.2, 1),
    margin-top 0.24s cubic-bezier(0.2, 0.7, 0.2, 1),
    padding 0.24s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.18s ease;
}

:root.has-full[data-layout="desktop"] .dash-path,
:root.has-full[data-layout="tablet"] .dash-path {
  height: 0;
  margin-top: 0;
  padding-block: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

.dash-stage-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 22px 23px 0;
}

.dash-tabs {
  display: flex;
  gap: 8px;
}

.dash-tab {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--d-37322a);
  background: transparent;
}

.dash-tab.is-active {
  background: var(--db-green-tint);
  color: var(--d-2f4a18);
}

.dash-tab:not(.is-active):hover {
  background: color-mix(in srgb, var(--d-d9ebb5) 45%, transparent);
}

.dash-stage-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dash-expand,
.dash-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--d-fdfaf4);
  border: 1px solid var(--db-card-border);
  font-size: 12px;
  font-weight: 700;
  color: var(--db-ink);
  white-space: nowrap;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.dash-tool:hover {
  background: var(--d-fff);
}

.dash-tool.is-on {
  background: var(--db-green-tint);
  border-color: var(--d-bdd69b);
  color: var(--d-2f4a18);
}

.dash-tool--expand {
  background: var(--d-f4f7e5);
  border-color: var(--d-d6e2b8);
}

/* The graph fills the whole card: no reserved header/footer bands, the tools
   row and the legend strip simply overlay the canvas (both keep z-index 2). */
.dash-stage-body {
  position: absolute;
  inset: 0;
  perspective: 1600px;
}

.dash-stage-body .stage__canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* course.css reserves HUD space around the canvas on non-desktop layouts with
   a higher-specificity rule; the dashboard has its own header, so the canvas
   fills the card on every layout. */
:root:not([data-layout="desktop"]) .dash-stage-body .stage__canvas {
  inset: 0;
}

/* The scene SVG normally paints outside its viewBox for glow effects. In the
   dashboard the stage must stay inside the card in every mode, expanded
   included, so the SVG is clipped to its own box. */
.dash-stage-card .stage-svg {
  overflow: hidden;
}

/* The card guide flips the stage like a card, keeping the diagram mounted so
   the renderer never loses its measured size. The outgoing face is also made
   `visibility: hidden` after the rotation - backface-visibility alone is not
   enough in every browser and can leak mirrored content. */
.dash-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.dash-flip__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition:
    transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1),
    visibility 0s linear 0.55s;
}

.dash-flip__diagram {
  transform: rotateY(0deg);
  visibility: visible;
  /* The face being revealed must become visible immediately. */
  transition:
    transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1),
    visibility 0s;
}

.dash-flip__guide {
  transform: rotateY(180deg);
  visibility: hidden;
  background: var(--db-diagram);
}

.dash-stage-body.is-guide .dash-flip__diagram {
  transform: rotateY(180deg);
  visibility: hidden;
}

.dash-stage-body.is-guide .dash-flip__guide {
  transform: rotateY(0deg);
  visibility: visible;
  transition:
    transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1),
    visibility 0s;
}

.dash-cardguide {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 30px 26px;
  scrollbar-width: thin;
}

.dash-cardguide__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.dash-cardguide .guide__title {
  font-size: clamp(20px, 2vw, 30px);
  margin: 4px 0 10px;
}

.dash-cardguide .guide__body p {
  font-size: 14px;
  line-height: 1.6;
}

.dash-cardguide .callout {
  margin-top: 12px;
}

.dash-cardguide .changes {
  margin-top: 14px;
}

/* Packet indicators (request, response, handshake, …) below the diagram. */
.dash-flip__diagram .stage__legend {
  inset-inline-start: 18px;
  inset-inline-end: 18px;
  bottom: 7px;
  max-width: none;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 15px;
  padding: 2px 2px 4px;
  scrollbar-width: none;
  pointer-events: none;
}

.dash-flip__diagram .stage__legend::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* course.css paints the legend when the stage is zoomed; the dashboard keeps
   the indicator strip clean at every zoom level. */
.dash-stage-body .stage__canvas.is-zoomed ~ .stage__legend {
  background: none;
  border-radius: 0;
  margin-inline-start: 0;
  padding: 2px 2px 4px;
  inset-inline-end: 18px;
}

/* Packet counter shown in the diagram's bottom-right corner while expanded. */
.dash-stage-count {
  position: absolute;
  right: 18px;
  bottom: 10px;
  z-index: 2;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--d-8a8171);
  pointer-events: none;
  white-space: nowrap;
}

/* Keep the indicator strip clear of the step counter in expanded mode. */
:root.has-full .dash-flip__diagram .stage__legend {
  inset-inline-end: 120px;
}

/* Phones and tablets need to scroll the indicator strip to see every token. */
:root:not([data-layout="desktop"]) .dash-flip__diagram .stage__legend {
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
}


/* ---------- Learning path ---------- */

.dash-path {
  position: relative;
  margin-top: 18px;
  margin-inline-start: auto;
  width: 100%;
  background: var(--db-card-2);
  border: 1px solid var(--db-card-border);
  border-radius: var(--db-radius-card);
  box-shadow: var(--db-shadow-card);
  padding: 14px 34px 14px 30px;
  height: 126px;
  overflow: clip;
  overflow-clip-margin: 20px;
  transition:
    width 0.4s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.18s ease,
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.dash-path__head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  max-height: 40px;
  overflow: hidden;
  transition:
    max-height 0.34s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.22s ease,
    transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.dash-path__head .i {
  color: var(--db-ink);
}

.dash-path__row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.dash-path__track {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  justify-content: space-between;
  padding: 3px 2px 0;
  transition:
    flex-grow 0.4s cubic-bezier(0.2, 0.7, 0.2, 1),
    flex-basis 0.4s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.24s ease,
    transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.dash-path__line {
  position: absolute;
  top: 17px;
  left: 13px;
  right: 13px;
  height: 2px;
  background: var(--d-ded5c1);
}

.dash-step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: 1 1 0;
  min-width: 0;
  background: none;
  border: 0;
  padding: 2px 2px 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: center;
  cursor: pointer;
  border-radius: 10px;
  transition:
    background 0.18s ease,
    transform 0.18s ease;
}

.dash-step:focus-visible {
  outline: 2px solid var(--d-7f9f4a);
  outline-offset: 2px;
}

.dash-step__dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--d-fbf5ea);
  border: 1.6px solid var(--d-d9cfba);
  color: var(--d-6f6759);
  font-size: 12px;
  font-weight: 700;
}

.dash-step.is-done .dash-step__dot {
  background: var(--d-cfe4a5);
  border-color: var(--d-b9d387);
  color: var(--d-2f5417);
}

.dash-step.is-current .dash-step__dot {
  background: var(--d-cfe4a5);
  border: 2px solid var(--d-2f5417);
  color: var(--d-1f3a0e);
  font-weight: 900;
}

.dash-step__label {
  max-width: 100%;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--d-6f6759);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-step.is-current .dash-step__label {
  color: var(--d-1b1914);
  font-weight: 700;
}

.dash-next-btn {
  position: static;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 126px;
  height: 46px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--d-e9edc4);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--db-ink);
  white-space: nowrap;
}

.dash-next-btn:hover {
  background: var(--d-e0e6b4);
}

.dash-next-btn--subscribe {
  background: var(--db-green-ink);
  color: #fff;
  box-shadow: 0 3px 8px rgba(34, 52, 23, 0.18);
}

.dash-next-btn--subscribe:hover {
  background: var(--db-green-deep);
}

/* ---------- Right rail ---------- */

.dash-rail__card {
  background: var(--db-panel);
  border: 1px solid var(--db-card-border);
  border-radius: 18px;
  box-shadow: var(--db-shadow-card);
  padding: 14px 14px 13px;
  margin-bottom: 12px;
}

.dash-rail__title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.015em;
  margin: 0 0 11px;
}

.dash-info__rows {
  display: grid;
  gap: 13px;
}

.dash-info__row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.dash-info__row .i {
  flex: none;
  margin-top: 2px;
  color: var(--db-ink);
}

.dash-info__value {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.dash-info__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--d-7c7466);
  margin-top: 1px;
}

.dash-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  margin-top: 15px;
  border-radius: 12px;
  background: var(--d-c6df9f);
  font-size: 15px;
  font-weight: 700;
  color: var(--d-14130f);
}

.dash-start:hover {
  background: var(--d-b9d78d);
}

.dash-learn {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 11px;
}

.dash-learn li {
  font-size: 12px;
  font-weight: 500;
  color: var(--d-35302a);
  line-height: 1.3;
}

.dash-learn__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: -3px -6px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.dash-learn__item:hover {
  background: var(--d-f7f0e1);
}

.dash-learn__item:focus-visible {
  outline: 2px solid var(--d-9dbd6a);
  outline-offset: 1px;
}

.dash-learn__item.is-hit span {
  color: var(--d-3d5c24);
}

.dash-learn__item.is-current span {
  font-weight: 700;
  color: var(--d-223d10);
}

.dash-learn .dash-check {
  width: 19px;
  height: 19px;
  margin-top: 0;
  border-radius: 6px;
}

.dash-next-lesson {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 11px;
  border: 1px solid var(--db-card-border);
  background: var(--d-fdfaf4);
  text-align: left;
  width: 100%;
  color: var(--db-ink);
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.dash-next-lesson:hover {
  border-color: var(--db-green-soft);
  transform: translateY(-1px);
}

.dash-next-lesson:focus-visible {
  outline: 2px solid var(--db-green-deep);
  outline-offset: 2px;
}

.dash-next-lesson__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--d-fdf2df);
  color: var(--db-ink);
}

.dash-next-lesson__icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

/* The candle lights up on hover and stays lit once the lesson is completed. */
.dash-next-lesson__icon {
  position: relative;
}

.dash-next-lesson .candle--lit {
  display: none;
}

.dash-next-lesson:hover .candle--off,
.dash-next-lesson--done .candle--off {
  display: none;
}

.dash-next-lesson:hover .candle--lit,
.dash-next-lesson--done .candle--lit {
  display: block;
}

.dash-next-lesson__name {
  flex: 1;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--db-ink);
}

.dash-next-lesson .i {
  color: var(--db-ink);
  flex: none;
}

.dash-next-lesson--subscribe {
  background: var(--db-green-wash);
}

.dash-next-lesson--subscribe .dash-next-lesson__icon {
  background: var(--db-green-tint);
  color: var(--db-green-ink);
}

/* Previous/next step card shown under the Next Lesson card in expanded mode
   (the learning path's row is folded away while the diagram is expanded).
   It names the current step; the next button reuses the learning path's green
   .dash-next-btn style and stays the wider of the pair; previous is a matching
   arrow-only button. */
/* Fixed card height: the title reserves two lines, the track is one row of
   dots and the buttons a fixed 44px row, so the card can never spill past
   the rail (or overlap the content below it). */
.dash-stepnav {
  height: 160px;
}

.dash-stepnav__title {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--db-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Reserve both lines so a longer step title can never grow the card. */
  height: 2.6em;
}

.dash-stepnav__row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}

/* A three-step slice of the learning path (previous · current · next) inside
   the expanded-mode card. Reuses the path's track/step visuals so it reads as
   the same component, just compact and without a horizontal scroller. */
.dash-stepnav__track {
  margin: 0 0 13px;
  padding: 3px 0 0;
}

.dash-stepnav__track .dash-step {
  padding-left: 0;
  padding-right: 0;
}

/* Dots only: the step's short label is redundant with the card title and
   the arrows below, and hiding it keeps the card compact. */
.dash-stepnav__track .dash-step__label {
  display: none;
}

.dash-stepnav__prev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--db-card-border);
  background: var(--d-fdfaf4);
  color: var(--db-ink);
  transition: background 0.18s ease;
}

.dash-stepnav__prev:hover:not(:disabled) {
  background: var(--d-fff);
}

.dash-stepnav__prev:disabled,
.dash-stepnav .dash-next-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Fit the path's green button into the compact rail card without changing
   its look: same green background, radius and arrow as in collapsed mode. */
.dash-stepnav .dash-next-btn {
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  gap: 8px;
  font-size: 13px;
}

/* ==========================================================================
   Responsive shell
   The 1672×941 canvas is the desktop target. Below it we mirror the original
   course layout: compact desktop, two-column tablet, and a stacked phone
   layout with the course contents in an off-canvas drawer.
   ========================================================================== */

.dash-menu {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--db-card-border);
  background: var(--db-white);
  color: var(--db-ink);
  flex: none;
  margin-right: 10px;
}

.dash-drawer-backdrop {
  display: none;
}

/* --- compact desktop: keep three columns, tighten the chrome --- */
@media (min-width: 1200px) and (max-width: 1499px) {
  :root:not([data-design-fit]) .dash-top {
    padding: 0 18px 0 22px;
  }

  :root:not([data-design-fit]) .dash-top .brand {
    margin-right: 26px;
  }

  :root:not([data-design-fit]) .dash-nav {
    gap: 4px;
  }

  :root:not([data-design-fit]) .dash-nav__item {
    padding: 0 11px;
    font-size: 12px;
  }

  :root:not([data-design-fit]) .dash-search {
    width: 190px;
  }

  :root:not([data-design-fit]) .dash__main {
    padding: 20px 22px 0 24px;
  }

  :root:not([data-design-fit]) .dash__rail {
    padding-top: 78px;
  }

  :root:not([data-design-fit]) .dash-stats {
    gap: 7px;
  }

  :root:not([data-design-fit]) .dash-stat {
    padding: 4px 8px;
    gap: 6px;
  }

  :root:not([data-design-fit]) .dash-stat__value {
    font-size: 12px;
  }

  :root:not([data-design-fit]) .dash-stat__label {
    font-size: 10px;
  }

  /* Main's right padding is narrower here, so the path reach is 8px shorter. */
  :root:not([data-design-fit])[data-layout="desktop"] .dash-path {
    width: calc(100% + 222px);
  }

  :root:not([data-design-fit]) .dash-next-btn {
    height: 42px;
    padding: 0 16px;
  }
}

/* The database art is a wide-screen flourish; below 1400 the stats use the room. */
@media (max-width: 1399px) {
  .dash-bg__db {
    display: none;
  }
}

/* Desktop never scrolls the document; each pane scrolls on its own. */
@media (min-width: 1200px) {
  .dash {
    height: 100vh;
    overflow: hidden;
  }

  /* Main content is a single page: the diagram absorbs the free height. */
  :root[data-layout="desktop"] .dash__main {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  :root[data-layout="desktop"] .dash-header,
  :root[data-layout="desktop"] .dash-path {
    flex: none;
  }

  :root[data-layout="desktop"] .dash-stage-card {
    flex: 1 1 0;
    height: auto;
    min-height: 240px;
  }

  /* The learning path reaches across the right gutter and ends under the
     Next Lesson card, like the mockup. */
  :root[data-layout="desktop"] .dash-path {
    width: calc(100% + 230px);
  }

  .dash__side,
  .dash__main,
  .dash__rail {
    min-height: 0;
  }

  .dash__side,
  .dash__main,
  .dash__rail {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .dash__side::-webkit-scrollbar,
  .dash__main::-webkit-scrollbar,
  .dash__rail::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }
}

/* --- tablet: main + rail, contents become a drawer --- */
:root[data-layout="tablet"] .dash {
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "top top"
    "main rail";
  height: 100vh;
  overflow: hidden;
}

:root[data-layout="tablet"] .dash.dash--solo {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "main";
}

:root[data-layout="tablet"] .dash__main {
  display: flex;
  flex-direction: column;
  padding: 18px 20px 0 22px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

:root[data-layout="tablet"] .dash-header,
:root[data-layout="tablet"] .dash-path {
  flex: none;
}

:root[data-layout="tablet"] .dash-stage-card {
  flex: 1 1 0;
  height: auto;
  /* The diagram renderer needs enough room to fit; below ~280px it stays blank. */
  min-height: 280px;
  scroll-margin-top: 14px;
}

:root[data-layout="tablet"] .dash-stage-card.is-full {
  scroll-margin-top: 14px;
}

:root[data-layout="tablet"] .dash__rail {
  padding: 22px 14px 0 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

:root[data-layout="tablet"] .dash__main::-webkit-scrollbar,
:root[data-layout="tablet"] .dash__rail::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

:root[data-layout="tablet"] .dash-rail__stack {
  display: grid;
  gap: 14px;
}

:root[data-layout="tablet"] .dash-stats {
  gap: 8px;
}

:root[data-layout="tablet"] .dash-stat {
  padding: 5px 9px;
  gap: 7px;
}

:root[data-layout="tablet"] .dash-stat__value {
  font-size: 13px;
}

:root[data-layout="tablet"] .dash-stat__label {
  font-size: 11px;
}



:root[data-layout="tablet"] .dash-path {
  height: auto;
  padding: 12px 18px 14px;
}

:root[data-layout="tablet"] .dash-path__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

:root[data-layout="tablet"] .dash-path__track:not(.dash-stepnav__track) {
  overflow-x: auto;
  justify-content: flex-start;
  gap: 10px;
  padding-bottom: 4px;
  /* The row turns into a column on tablet, so `flex: 1 1 0` would resolve
     its basis against the height and collapse the track to zero — clipping
     the dots and hiding the connector line. Size it to its content instead. */
  flex: none;
  min-height: 54px;
}

:root[data-layout="tablet"] .dash-next-btn {
  position: static;
  width: 100%;
  height: 44px;
}

/* --- non-desktop chrome: menu button, no inline nav, compact search --- */
:root:not([data-layout="desktop"]) .dash-top {
  /* Tablet keeps the shell's 14px right gutter; stack reclaims 12px (below). */
  padding: 0 30px 0 16px;
  gap: 8px;
}

:root:not([data-layout="desktop"]) .dash-top .brand {
  margin-right: auto;
  flex: 0 1 auto;
  min-width: 0;
}

:root:not([data-layout="desktop"]) .dash-nav {
  display: none;
}

:root:not([data-layout="desktop"]) .dash-bg__db {
  display: none;
}

:root:not([data-layout="desktop"]) .dash-top {
  background:
    linear-gradient(270deg, var(--d-fdf8f0) 0%, color-mix(in srgb, var(--d-fdf8f0) 70%, transparent) 45%, color-mix(in srgb, var(--d-fdf8f0) 0%, transparent) 100%),
    var(--db-page);
}

:root:not([data-layout="desktop"]) .dash-search {
  width: 42px;
  padding: 0;
  justify-content: center;
}

:root:not([data-layout="desktop"]) .dash-search span {
  display: none;
}

:root:not([data-layout="desktop"]) .dash-menu {
  display: grid;
}

.dash-langwrap {
  position: relative;
}

@media (max-width: 560px) {
  .dash-langwrap {
    display: none;
  }

  /* Stack-only widths; header.dash-top outspecifies the stack sticky rule. */
  :root[data-layout="stack"] header.dash-top {
    padding: 0 24px 0 12px;
    gap: 6px;
  }

  :root:not([data-layout="desktop"]) .dash-top .brand__name {
    font-size: 17px;
  }
}

@media (max-width: 430px) {
  :root:not([data-layout="desktop"]) .dash-search {
    display: none;
  }

  :root[data-layout="stack"] header.dash-top {
    padding: 0 22px 0 10px;
    gap: 4px;
  }

  :root:not([data-layout="desktop"]) .dash-top > .dash-iconbtn,
  :root:not([data-layout="desktop"]) .dash-top > .dash-avatar {
    margin-left: 6px;
  }

  :root:not([data-layout="desktop"]) .dash-top .brand {
    gap: 7px;
    min-width: 0;
  }

  :root:not([data-layout="desktop"]) .dash-top .brand__name {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* --- off-canvas course contents --- */
:root:not([data-layout="desktop"]) .dash__side {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 45;
  width: min(340px, 88vw);
  margin: 0;
  padding: 18px 12px calc(16px + env(safe-area-inset-bottom)) 18px;
  border: 0;
  border-inline-end: 1.5px solid var(--db-ink);
  border-radius: 0;
  background: var(--db-page);
  box-shadow: 0 0 60px -18px rgba(60, 40, 20, 0.55);
  visibility: hidden;
  transform: translateX(-105%);
  overflow-y: auto;
  overscroll-behavior: contain;
}

:root[dir="rtl"]:not([data-layout="desktop"]) .dash__side {
  transform: translateX(105%);
}

:root.is-drawer .dash__side {
  visibility: visible;
  transform: none;
}

:root:not([data-layout="desktop"]) .dash-drawer-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(30, 24, 12, 0.38);
  opacity: 0;
  pointer-events: none;
}

:root.is-drawer .dash-drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* --- phone: single stacked column --- */
:root[data-layout="stack"] body {
  overflow: auto;
}

:root[data-layout="stack"] .dash {
  display: block;
  height: auto;
  min-height: 100dvh;
  padding: 0 12px calc(28px + env(safe-area-inset-bottom));
  overflow: visible;
}

:root[data-layout="stack"] .dash-top {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 52px;
  /* The stack shell's right gutter is 12px, not 14px. */
  margin-right: -12px;
  padding-right: 28px;
  background:
    linear-gradient(270deg, var(--d-fdf8f0) 0%, color-mix(in srgb, var(--d-fdf8f0) 70%, transparent) 55%, color-mix(in srgb, var(--d-fdf8f0) 0%, transparent) 100%),
    var(--db-page);
}

:root[data-layout="stack"] .dash__main {
  padding: 14px 2px 0;
}

:root[data-layout="stack"] .dash__rail {
  padding: 16px 0 0;
}

:root[data-layout="stack"] .dash-rail__stack {
  display: grid;
  gap: 14px;
}

:root[data-layout="stack"] .dash-title {
  font-size: clamp(28px, 8vw, 40px);
}

:root[data-layout="stack"] .dash-subtitle {
  max-width: none;
}

:root[data-layout="stack"] .dash-crumb {
  flex-wrap: wrap;
  gap: 8px;
}

:root[data-layout="stack"] .dash-chip-row {
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

:root[data-layout="stack"] .dash-crumb__left {
  flex-wrap: wrap;
  gap: 8px;
}

:root[data-layout="stack"] .dash-stats {
  /* Keep every stat on a single row on phones too: wrapping used to leave an
     empty cell whenever the lesson had an odd number of metrics. */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}

:root[data-layout="stack"] .dash-stat {
  padding: 6px 8px;
  gap: 5px;
  min-height: 38px;
}

:root[data-layout="stack"] .dash-stat__value {
  font-size: 12px;
}

:root[data-layout="stack"] .dash-stat__label {
  font-size: 10px;
}

/* Phones: drop the stat icons so the single row keeps room for the values
   and labels instead of ellipsizing every cell. */
@media (max-width: 560px) {
  :root[data-layout="stack"] .dash-stat {
    padding: 5px 6px;
    gap: 4px;
  }

  :root[data-layout="stack"] .dash-stat__icon {
    display: none;
  }

  :root[data-layout="stack"] .dash-stat__value {
    font-size: 11px;
  }

  :root[data-layout="stack"] .dash-stat__label {
    font-size: 9.5px;
  }
}



:root[data-layout="stack"] .dash-stage-card {
  height: clamp(300px, 74vw, 407px);
  scroll-margin-top: 64px;
  transition: height 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-layout="stack"] .dash-stage-card.is-full {
  scroll-margin-top: 64px;
}

:root[data-layout="stack"] .dash-stage-head {
  padding: 16px 16px 0;
}

:root[data-layout="stack"] .dash-tabs {
  gap: 4px;
}

:root[data-layout="stack"] .dash-tab {
  padding: 0 12px;
  font-size: 12.5px;
}

:root[data-layout="stack"] .dash-expand span,
:root[data-layout="stack"] .dash-tool span,
:root:not([data-layout="desktop"]) .dash-tool span {
  display: none;
}

:root:not([data-layout="desktop"]) .dash-tool,
:root:not([data-layout="desktop"]) .dash-expand {
  width: 28px;
  padding: 0;
  justify-content: center;
}

:root[data-layout="stack"] .dash-stage-tools {
  gap: 6px;
  flex-wrap: nowrap;
}

:root[data-layout="stack"] .dash-stage-body {
  inset: 0;
}

:root[data-layout="stack"] .dash-path {
  height: auto;
  padding: 12px 14px 14px;
}

:root[data-layout="stack"] .dash-path__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

:root[data-layout="stack"] .dash-path__track:not(.dash-stepnav__track) {
  overflow-x: auto;
  justify-content: flex-start;
  gap: 8px;
  padding-bottom: 4px;
  scrollbar-width: none;
  /* Same column-row collapse as tablet: keep the track at content height. */
  flex: none;
  min-height: 54px;
}

:root[data-layout="stack"] .dash-path__track::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

:root[data-layout="stack"] .dash-next-btn {
  position: static;
  width: 100%;
  height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  .dash-tree__clip {
    transition: none;
  }
}

/* Dashboard colour tokens (light values mirror the original design). */
:root {
  --d-0f0e0b: #0f0e0b;
  --d-14130f: #14130f;
  --d-17150f: #17150f;
  --d-1b1914: #1b1914;
  --d-1f3a0e: #1f3a0e;
  --d-223d10: #223d10;
  --d-24360f: #24360f;
  --d-2b2721: #2b2721;
  --d-2f4a18: #2f4a18;
  --d-2f5417: #2f5417;
  --d-2f6e1e: #2f6e1e;
  --d-33531f: #33531f;
  --d-34323f: #34323f;
  --d-35302a: #35302a;
  --d-35681c: #35681c;
  --d-37322a: #37322a;
  --d-3a352c: #3a352c;
  --d-3b362e: #3b362e;
  --d-3c6b23: #3c6b23;
  --d-3d5c24: #3d5c24;
  --d-45922f: #45922f;
  --d-4a4439: #4a4439;
  --d-4b4560: #4b4560;
  --d-4f9130: #4f9130;
  --d-5b4a8a: #5b4a8a;
  --d-5b9a35: #5b9a35;
  --d-6f6759: #6f6759;
  --d-6f675a: #6f675a;
  --d-7c7466: #7c7466;
  --d-7f9f4a: #7f9f4a;
  --d-8a5a0b: #8a5a0b;
  --d-8a8171: #8a8171;
  --d-8a8172: #8a8172;
  --d-9d9484: #9d9484;
  --d-9dbd6a: #9dbd6a;
  --d-a33522: #a33522;
  --d-b7d78b: #b7d78b;
  --d-b9a6e0: #b9a6e0;
  --d-b9d387: #b9d387;
  --d-b9d78d: #b9d78d;
  --d-bdd69b: #bdd69b;
  --d-c6d9a5: #c6d9a5;
  --d-c6df9f: #c6df9f;
  --d-c9dfa3: #c9dfa3;
  --d-cdc9e2: #cdc9e2;
  --d-cfc6b5: #cfc6b5;
  --d-cfe4a5: #cfe4a5;
  --d-d6e2b8: #d6e2b8;
  --d-d9cfba: #d9cfba;
  --d-d9ebb5: #d9ebb5;
  --d-ded5c1: #ded5c1;
  --d-e0e6b4: #e0e6b4;
  --d-e3dac8: #e3dac8;
  --d-e3e8c9: #e3e8c9;
  --d-e4f0d3: #e4f0d3;
  --d-e6f0d6: #e6f0d6;
  --d-e8933f: #e8933f;
  --d-e9d3ac: #e9d3ac;
  --d-e9e8f4: #e9e8f4;
  --d-e9edc4: #e9edc4;
  --d-e9f2d6: #e9f2d6;
  --d-eae3d4: #eae3d4;
  --d-eaeaf5: #eaeaf5;
  --d-eaf2cf: #eaf2cf;
  --d-ecd49a: #ecd49a;
  --d-ece1cf: #ece1cf;
  --d-eec1b1: #eec1b1;
  --d-eef2da: #eef2da;
  --d-eef3dc: #eef3dc;
  --d-f0e5d2: #f0e5d2;
  --d-f0e5d3: #f0e5d3;
  --d-f2e7d5: #f2e7d5;
  --d-f2f8e6: #f2f8e6;
  --d-f4f7e5: #f4f7e5;
  --d-f7f0e1: #f7f0e1;
  --d-fbf4e9: #fbf4e9;
  --d-fbf5ea: #fbf5ea;
  --d-fcefe9: #fcefe9;
  --d-fcf4e9: #fcf4e9;
  --d-fdf2df: #fdf2df;
  --d-fdf6e3: #fdf6e3;
  --d-fdf6ec: #fdf6ec;
  --d-fdf8f0: #fdf8f0;
  --d-fdf9f3: #fdf9f3;
  --d-fdfaf4: #fdfaf4;
  --d-fdfcf7: #fdfcf7;
  --d-fef8f0: #fef8f0;
  --d-fff: #ffffff;
}
/* ---------- Dark theme ----------
   Palette mirrors course.css [data-theme="dark"]: dark paper surfaces,
   light ink, muted greens. Every --d-* token flips here. */
[data-theme="dark"] {
  --d-0f0e0b: #f5ecdc;
  --d-14130f: #efe6d6;
  --d-17150f: #efe6d6;
  --d-1b1914: #f5ecdc;
  --d-1f3a0e: #e6f2d6;
  --d-223d10: #d9ebb5;
  --d-24360f: #d9ebb5;
  --d-2b2721: #efe6d6;
  --d-2f4a18: #cde6ba;
  --d-2f5417: #cde6ba;
  --d-2f6e1e: #8fce6a;
  --d-33531f: #cde6ba;
  --d-34323f: #3a352c;
  --d-35302a: #ddd3c2;
  --d-35681c: #bde1b7;
  --d-37322a: #ddd3c2;
  --d-3a352c: #c9bfae;
  --d-3b362e: #ddd3c2;
  --d-3c6b23: #bde1b7;
  --d-3d5c24: #cde6ba;
  --d-45922f: #6fae4a;
  --d-4a4439: #c9bfae;
  --d-4b4560: #cfc4e2;
  --d-4f9130: #6fae4a;
  --d-5b4a8a: #cfc4e2;
  --d-5b9a35: #6fae4a;
  --d-6f6759: #a3998b;
  --d-6f675a: #a3998b;
  --d-7c7466: #a3998b;
  --d-7f9f4a: #8fce6a;
  --d-8a5a0b: #ebd5ad;
  --d-8a8171: #a3998b;
  --d-8a8172: #a3998b;
  --d-9d9484: #8d7f6c;
  --d-9dbd6a: #8fce6a;
  --d-a33522: #ebb2ad;
  --d-b7d78b: #4c5c35;
  --d-b9a6e0: #6b5b8f;
  --d-b9d387: #4a5a33;
  --d-b9d78d: #4a5a33;
  --d-bdd69b: #4a5a33;
  --d-c6d9a5: #3f4c2b;
  --d-c6df9f: #3f4c2b;
  --d-c9dfa3: #3f4c2b;
  --d-cdc9e2: #4a4156;
  --d-cfc6b5: #4f473d;
  --d-cfe4a5: #3f4c2b;
  --d-d6e2b8: #4a5a33;
  --d-d9cfba: #4f473d;
  --d-d9ebb5: #3f4c2b;
  --d-ded5c1: #4f473d;
  --d-e0e6b4: #4a5a33;
  --d-e3dac8: #3a352c;
  --d-e3e8c9: #342f28;
  --d-e4f0d3: #2f3d2a;
  --d-e6f0d6: #2f3d2a;
  --d-e8933f: #d98a3d;
  --d-e9d3ac: #4f473d;
  --d-e9e8f4: #332b40;
  --d-e9edc4: #3f4c2b;
  --d-e9f2d6: #37432a;
  --d-eae3d4: #3a352c;
  --d-eaeaf5: #332b40;
  --d-eaf2cf: #31402a;
  --d-ecd49a: #6b5a2a;
  --d-ece1cf: #3a352c;
  --d-eec1b1: #5c3830;
  --d-eef2da: #4a5a33;
  --d-eef3dc: #31402a;
  --d-f0e5d2: #342f28;
  --d-f0e5d3: #342f28;
  --d-f2e7d5: #342f28;
  --d-f2f8e6: #2b3520;
  --d-f4f7e5: #31402a;
  --d-f7f0e1: #2e2a24;
  --d-fbf4e9: #24201c;
  --d-fbf5ea: #2b2721;
  --d-fcefe9: #3a2723;
  --d-fcf4e9: #211e1a;
  --d-fdf2df: #3a342a;
  --d-fdf6e3: #3a3222;
  --d-fdf6ec: #26231e;
  --d-fdf8f0: #25211c;
  --d-fdf9f3: #2b2721;
  --d-fdfaf4: #2b2721;
  --d-fdfcf7: #2e2a24;
  --d-fef8f0: #28241f;
  --d-fff: #35302a;

  --db-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px -16px rgba(0, 0, 0, 0.6);
  --db-shadow: 0 1.5px 0 rgba(0, 0, 0, 0.5);
}
