/* Keep each instruction, its control and the tour action in the same view. */
.topbar .learning-library {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.topbar .learning-library:hover { color: var(--gold); }
@media (max-width: 1000px) {
  .topbar .top-context { display: none; }
}
@media (max-width: 480px) {
  .topbar > .text-link { display: none; }
  .topbar .learning-library { margin-left: auto; font-size: 11px; }
}

body.tour-active {
  --tour-header: 58px;
  --tour-footer: 78px;
  --tour-sidebar: 192px;
  --tour-progress: 0px;
  overflow: hidden;
}

.tour-active .topbar {
  height: var(--tour-header);
  padding: 0 26px;
  gap: 25px;
}
.tour-active .brand > span { font-size: 25px; }
.tour-active .brand svg { width: 26px; }
.tour-active .tour {
  grid-template-columns: var(--tour-sidebar) minmax(0, 1fr);
  height: calc(100dvh - var(--tour-header));
  min-height: 0;
  max-width: none;
}
.tour-active .sidebar {
  min-height: 0;
  padding: 22px 12px calc(var(--tour-footer) + 15px);
  overflow: auto;
}
.tour-active .sidebar-head { padding: 0 9px 13px; }
.tour-active .sidebar-head h2 { font-size: 23px; margin: 12px 0 6px; }
.tour-active .sidebar-head p { font-size: 11px; }
.tour-active .chapter { margin: 14px 9px 5px; font-size: 9px; }
.tour-active .step-nav { padding: 8px 7px; gap: 8px; font-size: 11px; }
.tour-active .sidebar-bottom { padding: 20px 8px 0; }
.tour-active .workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  width: 100%;
  max-width: none;
  height: calc(100dvh - var(--tour-header) - var(--tour-progress) - var(--tour-footer));
  min-height: 0;
  margin: 0;
  padding: 16px 24px 18px;
}
.tour-active .mode-row { min-height: 29px; gap: 14px; }
.tour-active .mode-control button { font-size: 10px; padding: 5px 11px; }
.tour-active #mode-note { font-size: 10px; }
.tour-active .step-heading {
  margin: 1px 0 2px;
  gap: 18px;
  align-items: flex-start;
}
.tour-active .step-heading h1 {
  font-size: clamp(26px, 2.35vw, 36px);
  margin: 7px 0 7px;
  line-height: 1.1;
}
.tour-active .step-heading p { max-width: 930px; font-size: 12px; line-height: 1.45; }
.tour-active .step-heading .eyebrow { font-size: 9px; }
.tour-active .step-count { padding-top: 1px; font-size: 11px; }
.tour-active .stage-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-color: #424d62;
  box-shadow: 0 9px 28px #0002;
}
.tour-active .stage-toolbar { flex: 0 0 30px; height: 30px; padding: 0 11px; }
.tour-active .stage-toolbar .icon-button { min-height: 26px; min-width: 26px; }
.tour-active .stage-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  flex: 1 1 auto;
  gap: 2px;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  background: #111927;
  isolation: isolate;
}
.tour-active .capture-panel {
  display: grid;
  align-items: center;
  justify-items: center;
  min-width: 0;
  min-height: 0;
  padding: 11px;
  container-type: size;
}
.tour-active #screen.screen {
  width: min(100%, calc(100cqh * var(--ratio, 1.8)));
  max-width: 100%;
  max-height: none;
  height: auto;
  aspect-ratio: var(--ratio, 1.8);
  margin: 0;
  overflow: visible;
  border-radius: 3px;
  outline: 1px solid #3e4a5b;
  box-shadow: 0 4px 18px #0003;
  line-height: 0;
}
.tour-active #screen-image { display: block; width: 100%; height: auto; border-radius: 3px; }
.tour-active .hotspot { z-index: 2; box-shadow: 0 0 0 4px #060b133d; }
.tour-active .hotspot-number { font-size: 10px; }
.tour-active .coach-rail {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0 0 0 14px;
  z-index: 4;
}
.tour-active .caption-card {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 16px 16px 14px;
  border-color: #9a873d;
  background: #1b2535;
  border-radius: 9px;
  box-shadow: 0 7px 25px #0003;
}
.tour-active .caption-heading { gap: 10px; margin: 0 0 13px; }
.tour-active .caption-symbol {
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  font-size: 13px;
  font-weight: 750;
}
.tour-active .caption-heading h2 { font-size: 17px; line-height: 1.2; margin: 3px 0 0; }
.tour-active .caption-heading .eyebrow { font-size: 8px; letter-spacing: .12em; }
.tour-active .caption-steps { gap: 10px; }
.tour-active .caption-steps li { gap: 9px; font-size: 12px; line-height: 1.48; }
.tour-active .caption-steps li::before {
  width: 18px;
  height: 18px;
  font-size: 9px;
  margin-top: 0;
}
.tour-active .caption-check { display: block; padding-top: 11px; margin-top: 12px; }
.tour-active .caption-check > span { display: block; font-size: 8px; margin-bottom: 5px; }
.tour-active .caption-check p { font-size: 12px; line-height: 1.4; }
.tour-active #coach-connector {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.tour-active #coach-connector path,
.tour-active #coach-connector polyline,
.tour-active #coach-connector line {
  stroke: var(--gold);
  stroke-width: 1.5;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.tour-active #coach-connector circle { fill: var(--gold); }
.tour-active .stage-instruction { display: none; }
.tour-active .success-bar { display: none; }
.tour-active .step-footer {
  position: fixed;
  bottom: 0;
  left: var(--tour-sidebar);
  right: 0;
  z-index: 10;
  height: var(--tour-footer);
  min-height: var(--tour-footer);
  margin: 0;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #465167;
  background: #172131;
  box-shadow: 0 -6px 22px #0003;
  gap: 20px;
}
.tour-active #back { font-size: 12px; padding: 11px 0; white-space: nowrap; }
.tour-active .navigation-status { flex: 1 1 auto; min-width: 0; }
.tour-active #nav-status { display: block; font-size: 12px; line-height: 1.35; color: #f0f2f6; font-weight: 650; }
.tour-active #takeaway { display: block; margin-top: 4px; font-size: 10px; line-height: 1.35; color: var(--muted); }
.tour-active #next { flex: 0 0 auto; min-width: 190px; font-size: 13px; padding: 13px 20px; }
.tour-active .completion-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
}
.tour-active .completion-actions .primary,
.tour-active .completion-actions .secondary { font-size: 12px; padding: 11px 14px; }
.tour-active .completion-actions p {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.tour-active .toast { bottom: calc(var(--tour-footer) + 12px); max-width: calc(100vw - 28px); }

/* The review may scroll; its submit control stays at the bottom of the panel. */
.action-dialog { padding-bottom: 0; max-height: min(90dvh, 850px); }
.action-dialog .dialog-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: #182131;
  margin: 24px -27px 0;
  padding: 16px 27px 19px;
  box-shadow: 0 -8px 18px #182131e6;
}

@media (min-width: 1550px) {
  .tour-active .stage-layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .tour-active .caption-card { padding: 19px; }
  .tour-active .caption-steps li { font-size: 13px; }
}

@media (max-width: 1150px) and (min-width: 1001px) {
  body.tour-active { --tour-sidebar: 174px; }
  .tour-active .workspace { padding-left: 18px; padding-right: 18px; }
  .tour-active .stage-layout { grid-template-columns: minmax(0, 1fr) 278px; padding: 9px; }
  .tour-active .caption-card { padding: 14px; }
  .tour-active .caption-steps { gap: 8px; }
}

@media (max-width: 1000px) {
  body.tour-active { --tour-sidebar: 0px; --tour-progress: 48px; --tour-header: 56px; }
  .tour-active .tour { display: block; }
  .tour-active .topbar { padding: 0 18px; gap: 18px; }
  .tour-active .sidebar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    height: var(--tour-progress);
    padding: 6px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }
  .tour-active .sidebar-head,
  .tour-active .chapter,
  .tour-active .sidebar-bottom .progress-track,
  .tour-active .sidebar-bottom .progress-label { display: none; }
  .tour-active #steps-nav { display: flex; flex: 1; align-items: center; gap: 5px; min-width: 0; overflow: auto; padding: 1px; }
  .tour-active .step-nav { flex-shrink: 0; width: auto; min-width: 31px; margin: 0; padding: 4px; gap: 7px; }
  .tour-active .step-nav span:last-child { display: none; }
  .tour-active .step-nav.current span:last-child { display: block; font-size: 10px; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tour-active .step-dot { width: 22px; height: 22px; }
  .tour-active .sidebar-bottom { display: block; flex: 0 0 auto; margin: 0; padding: 0; }
  .tour-active .sidebar-bottom .text-button { font-size: 10px; padding: 5px 0; white-space: nowrap; }
  .tour-active .workspace { padding: 12px 18px 14px; gap: 10px; }
  .tour-active .step-heading h1 { font-size: 28px; margin: 5px 0; }
  .tour-active .step-heading p { display: none; }
  .tour-active .step-footer { padding-left: 18px; padding-right: 18px; gap: 16px; }
}

@media (max-width: 900px) {
  .tour-active .stage-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(105px, 1fr) auto;
    gap: 8px;
    padding: 10px 12px 12px;
  }
  .tour-active .capture-panel { padding: 7px 10px; }
  .tour-active .coach-rail { padding: 0; }
  .tour-active .caption-card { margin-top: 0 !important; padding: 12px 15px; }
  .tour-active .caption-heading { margin-bottom: 10px; }
  .tour-active .caption-heading h2 { font-size: 16px; }
  .tour-active .caption-symbol { width: 26px; height: 26px; flex-basis: 26px; }
  .tour-active .caption-steps { gap: 7px; }
  .tour-active .caption-steps li { font-size: 12px; line-height: 1.4; }
  .tour-active .caption-check { display: flex; align-items: baseline; gap: 9px; padding-top: 9px; margin-top: 9px; }
  .tour-active .caption-check > span { flex: 0 0 auto; margin: 0; }
  .tour-active .caption-check p { font-size: 12px; line-height: 1.35; }
  .tour-active .caption-card::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    width: 12px;
    height: 12px;
    background: #1b2535;
    border-top: 1px solid #9a873d;
    border-left: 1px solid #9a873d;
    transform: translateX(-50%) rotate(45deg);
  }
  .tour-active #coach-connector { z-index: 1; }
  .tour-active .stage-layout[data-anchored="false"] .caption-card::before { display: none; }
}

@media (max-width: 760px) {
  .action-dialog .dialog-footer { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 600px) {
  body.tour-active { --tour-footer: calc(91px + env(safe-area-inset-bottom, 0px)); --tour-progress: 44px; }
  .tour-active .topbar { padding: 0 14px; gap: 14px; }
  .tour-active .brand { gap: 7px; }
  .tour-active .brand > span { font-size: 23px; }
  .tour-active .brand svg { width: 24px; }
  .tour-active .top-context { gap: 0; }
  .tour-active .top-context > span:last-child { display: none; }
  .tour-active .text-link { font-size: 11px; }
  .tour-active .text-link span { margin-left: 4px; }
  .tour-active .sidebar { padding: 5px 10px; gap: 8px; }
  .tour-active .sidebar-bottom { display: none; }
  .tour-active #steps-nav { gap: 3px; }
  .tour-active .step-nav { padding: 3px; min-width: 29px; gap: 5px; }
  .tour-active .step-nav.current span:last-child { max-width: 101px; font-size: 9px; }
  .tour-active .step-dot { width: 21px; height: 21px; font-size: 9px; }
  .tour-active .workspace { padding: 10px 12px 12px; gap: 9px; }
  .tour-active .mode-row { min-height: 28px; gap: 8px; }
  .tour-active .mode-control { flex-shrink: 0; }
  .tour-active .mode-control button { padding: 5px 8px; font-size: 9px; }
  .tour-active #mode-note { font-size: 9px; line-height: 1.3; max-width: 118px; text-align: right; }
  .tour-active .step-heading { margin: 0; gap: 7px; }
  .tour-active .step-heading h1 { font-size: clamp(22px, 6vw, 27px); line-height: 1.08; margin: 5px 0 2px; }
  .tour-active .step-heading .eyebrow { font-size: 8px; letter-spacing: .12em; }
  .tour-active .step-count { font-size: 9px; padding-top: 1px; }
  .tour-active .stage-toolbar { flex-basis: 27px; height: 27px; padding: 0 9px; }
  .tour-active #screen-label { font-size: 8px; margin-left: 6px; }
  .tour-active .window-dot { width: 4px; height: 4px; }
  .tour-active .stage-layout { padding: 7px 9px 9px; gap: 7px; }
  .tour-active .capture-panel { padding: 7px; }
  .tour-active .caption-card { padding: 11px 12px; border-radius: 7px; }
  .tour-active .caption-heading { gap: 8px; margin-bottom: 8px; }
  .tour-active .caption-heading h2 { font-size: 15px; }
  .tour-active .caption-heading .eyebrow { font-size: 7px; }
  .tour-active .caption-steps { gap: 6px; }
  .tour-active .caption-steps li { gap: 7px; font-size: 12px; line-height: 1.35; }
  .tour-active .caption-steps li::before { width: 17px; height: 17px; font-size: 9px; }
  .tour-active .caption-check { padding-top: 8px; margin-top: 8px; }
  .tour-active .caption-check p { font-size: 12px; line-height: 1.3; }
  .tour-active .hotspot { min-width: 22px; min-height: 20px; border-width: 1.5px; }
  .tour-active .hotspot-number { width: 19px; height: 19px; left: -9px; top: -9px; font-size: 8px; }
  .tour-active .step-footer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    gap: 6px 14px;
    padding: 9px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .tour-active #back { grid-column: 1; grid-row: 2; font-size: 12px; padding: 8px 0; }
  .tour-active .navigation-status { grid-column: 1 / -1; grid-row: 1; }
  .tour-active #nav-status { font-size: 11px; text-align: center; }
  .tour-active #takeaway { display: none; }
  .tour-active #next { grid-column: 2; grid-row: 2; width: 100%; min-width: 0; font-size: 12px; padding: 10px 12px; }
  .tour-active .completion-actions { grid-column: 2; grid-row: 2; gap: 6px; }
  .tour-active .completion-actions .primary,
  .tour-active .completion-actions .secondary { flex: 1; font-size: 10px; padding: 10px 8px; gap: 4px; }
  .tour-active .toast { padding: 10px 13px; font-size: 11px; text-align: center; }
  .action-dialog .dialog-footer { margin-left: -20px; margin-right: -20px; padding: 14px 20px 17px; gap: 10px; }
  .action-dialog .dialog-footer > .primary { white-space: normal; font-size: 12px; line-height: 1.35; max-width: 65%; }
}

/* A landscape phone or enlarged text may need more space than one viewport. */
@media (max-height: 650px) {
  body.tour-active { overflow: auto; }
  .tour-active .tour { height: auto; min-height: calc(100dvh - var(--tour-header)); padding-bottom: var(--tour-footer); }
  .tour-active .workspace { height: auto; min-height: calc(100dvh - var(--tour-header) - var(--tour-progress) - var(--tour-footer)); }
  .tour-active .stage-shell { min-height: 430px; }
  .tour-active .capture-panel { min-height: 160px; }
  .tour-active .step-heading p { display: none; }
  .tour-active .sidebar { max-height: calc(100dvh - var(--tour-header)); }
}

@media (prefers-reduced-motion: reduce) {
  .tour-active *, .tour-active *::before, .tour-active *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
