/* ==========================================================================
   MediMeet — Isometric journey (How it works)
   Light + dark themes · boxless stage · scroll-synced
   ========================================================================== */

.journey {
  --journey-progress: 16.667%;
  position: relative;
}

.journey .section-head {
  margin-bottom: clamp(1.4rem, 2.6vw, 2rem);
}

/* ---------- Floor key ---------- */

.floor-key {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: clamp(1.2rem, 2.4vw, 1.8rem);
}

.floor-key-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.95rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--shape-lg);
  background: var(--tone-soft, var(--surface-container-low));
}

.floor-key-num {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border-radius: 50%;
  background: var(--tone);
  color: var(--on-tone, #ffffff);
  font-family: var(--font-head);
  font-size: 0.7rem;
  font-weight: 700;
}

.floor-key-item h3 {
  font-size: 0.9rem;
}

.floor-key-item p {
  margin-top: 0.18rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--on-surface-variant);
}

/* ---------- Journey layout ---------- */

.journey-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(330px, 0.84fr);
  align-items: start;
  gap: clamp(1.3rem, 3vw, 2.6rem);
}

/* ---------- Sticky isometric stage ---------- */

.journey-stage {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  z-index: 4;
  overflow: hidden;
  /* The stage stays boxless. The surface color is an invisible mask only. */
  background: var(--surface);
}

.stage-bar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0 0.5rem;
}

.stage-bar .mini-mark {
  width: auto;
  height: 1.3rem;
  flex: none;
}

.stage-bar .stage-title {
  font-family: var(--font-head);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--on-surface);
}

.stage-live {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  margin-left: auto;
  padding: 0.18rem 0.5rem;
  border: 0;
  border-radius: var(--shape-full);
  background: var(--primary-container);
  font-family: var(--font-body);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--on-primary-container);
}

.stage-live i {
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: none;
}

.stage-count {
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-full);
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface-variant);
}

.stage-canvas {
  position: relative;
  aspect-ratio: 1000 / 700;
  background: var(--surface);
}

.stage-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(193, 201, 192, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(193, 201, 192, 0.3) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 74% 70% at 50% 52%, #000 20%, transparent 78%);
  mask-image: radial-gradient(ellipse 74% 70% at 50% 52%, #000 20%, transparent 78%);
  pointer-events: none;
}

.iso-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.iso-scene text {
  font-family: var(--font-head);
}

/* Stage overlays */

.stage-hud {
  position: absolute;
  z-index: 5;
  top: 0.4rem;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 60%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-lg);
  background: var(--surface-container-lowest);
  box-shadow: var(--shadow-1);
}

.hud-num {
  font-family: var(--font-head);
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--primary);
}

.hud-kicker {
  display: block;
  font-family: var(--font-body);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.hud-title {
  display: block;
  margin-top: 0.08rem;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--on-surface);
}

.stage-event {
  position: absolute;
  z-index: 5;
  left: 0;
  bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 66%;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-full);
  background: var(--surface-container-high);
  font-size: 0.66rem;
  line-height: 1.3;
  color: var(--on-surface);
}

.stage-event i {
  width: 0.34rem;
  height: 0.34rem;
  flex: none;
  border-radius: 50%;
  background: var(--clinic);
}

.stage-ai {
  position: absolute;
  z-index: 5;
  top: 0.4rem;
  right: 0;
  width: min(222px, 38%);
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: var(--shape-lg);
  background: var(--tertiary-container);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease-enter), transform 0.3s var(--ease-enter);
}

.journey[data-active="3"] .stage-ai {
  opacity: 1;
  transform: none;
}

.stage-ai .ai-tag {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-body);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-tertiary-container);
}

.stage-ai p {
  margin-top: 0.3rem;
  font-size: 0.66rem;
  line-height: 1.45;
  color: var(--on-tertiary-container);
}

.stage-ai .ai-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.stage-ai .ai-actions span {
  padding: 0.18rem 0.5rem;
  border-radius: var(--shape-full);
  font-size: 0.55rem;
  font-weight: 600;
}

.stage-ai .ai-actions span:first-child {
  background: var(--primary);
  color: var(--on-primary);
}

.stage-ai .ai-actions span:last-child {
  border: 1px solid var(--tertiary);
  color: var(--tertiary);
}

.stage-progress {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: 26px;
  padding: 0;
  margin-top: 0.2rem;
}

.stage-progress-label {
  font-family: var(--font-body);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--on-surface-muted);
  white-space: nowrap;
}

.stage-progress-track {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: var(--shape-full);
  background: var(--surface-container-highest);
  overflow: hidden;
}

.stage-progress-fill {
  display: block;
  width: var(--journey-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.4s var(--ease-emphasized);
}

/* ---------- Isometric scene ---------- */

.iso-platform .platform-top {
  fill: #f5f2eb;
}

.iso-platform .platform-face--left {
  fill: #e3e0d7;
}

.iso-platform .platform-face--right {
  fill: #d6d3c8;
}

.iso-platform .platform-outline {
  fill: none;
  stroke: var(--outline-variant);
  stroke-width: 1.2;
}

.iso-platform .platform-rim {
  fill: none;
  stroke: rgba(27, 28, 24, 0.08);
  stroke-width: 1;
}

.floor-grid line {
  stroke: rgba(193, 201, 192, 0.3);
  stroke-width: 1;
}

/* The ambient field, floor shadow and spotlights keep their SVG radial
   gradients (updated for the light scene) instead of flat overrides. */
.scene-ambient {
  animation: scene-breathe 9s ease-in-out infinite;
}

.scene-shadow {
  fill: url(#floorShadow);
}

.iso-spot {
  opacity: 0;
  transition: opacity 0.5s var(--ease-emphasized);
  pointer-events: none;
}

.iso-spot.is-active {
  opacity: 1;
}

.iso-zone {
  transition: opacity 0.45s var(--ease-emphasized);
}

.iso-zone:not(.is-lit):not(.zone-ai) {
  opacity: 0.58;
}

.iso-room {
  --room-top-fill: #eef0e8;
  --room-wall-left: #dddfd5;
  --room-wall-right: #cbcec3;
  --room-ink: var(--on-surface-variant);
  --room-line: rgba(27, 28, 24, 0.12);
}

.room--dept {
  --room-top-fill: var(--primary-container);
  --room-wall-left: #7fdcc0;
  --room-wall-right: #66c9ac;
  --room-ink: var(--primary);
}

.room--clinic {
  --room-top-fill: var(--clinic-container);
  --room-wall-left: #7edce6;
  --room-wall-right: #69c8d3;
  --room-ink: var(--clinic);
}

.room--visit,
.room--waiting {
  --room-top-fill: var(--tertiary-container);
  --room-wall-left: #cbbeec;
  --room-wall-right: #b6a7dc;
  --room-ink: var(--tertiary);
}

.room--record {
  --room-top-fill: var(--records-container);
  --room-wall-left: #f3c0d8;
  --room-wall-right: #e3a6c4;
  --room-ink: var(--records);
}

.room-shadow {
  fill: rgba(27, 28, 24, 0.1);
}

.room-glow {
  display: none;
}

.iso-room .room-top {
  fill: var(--room-top-fill);
  stroke: rgba(27, 28, 24, 0.16);
  stroke-width: 1;
  transition: stroke 0.3s, filter 0.3s;
}

.iso-room .room-wall--left {
  fill: var(--room-wall-left);
  stroke: rgba(27, 28, 24, 0.1);
  stroke-width: 1;
}

.iso-room .room-wall--right {
  fill: var(--room-wall-right);
  stroke: rgba(27, 28, 24, 0.1);
  stroke-width: 1;
}

.iso-room .room-line {
  fill: none;
  stroke: var(--room-line);
  stroke-width: 1;
}

.iso-room .room-desk {
  fill: rgba(255, 255, 255, 0.55);
  stroke: rgba(27, 28, 24, 0.12);
  stroke-width: 0.6;
}

.iso-room .room-desk-side {
  fill: rgba(255, 255, 255, 0.3);
  stroke: rgba(27, 28, 24, 0.08);
  stroke-width: 0.6;
}

.iso-room .room-label {
  fill: var(--on-surface);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--surface-container-lowest);
  stroke-width: 3px;
}

.iso-room .room-status {
  fill: var(--room-ink);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-anchor: middle;
  text-transform: uppercase;
}

.iso-room.is-active .room-top {
  stroke: var(--room-ink);
  stroke-width: 2;
  filter: drop-shadow(0 5px 8px rgba(27, 28, 24, 0.18));
}

.iso-room.is-active .room-line {
  stroke: rgba(27, 28, 24, 0.22);
}

.iso-zone.is-lit .zone-label {
  fill: var(--on-surface-variant);
}

.zone-label {
  fill: var(--on-surface-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-anchor: middle;
}

.zone-label--tone {
  fill: var(--primary);
  opacity: 0.72;
}

.zone-label--visit {
  fill: var(--tertiary);
  opacity: 0.78;
}

/* People + live markers */

.person {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: iso-bob 4.2s ease-in-out infinite;
}

.person:nth-of-type(2n) { animation-delay: -1.4s; }
.person:nth-of-type(3n) { animation-delay: -2.8s; }

.person .person-head {
  fill: var(--on-surface-variant);
}

.person .person-body {
  fill: var(--primary);
}

.person--patient .person-head { fill: var(--on-surface-variant); }
.person--patient .person-body { fill: var(--tertiary); }

.live-tag {
  fill: var(--surface-container-lowest);
  stroke: var(--records);
  stroke-width: 1;
}

.live-tag-text {
  fill: var(--records);
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-anchor: middle;
}

/* Route */

.route-base {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 3 8;
  opacity: 0.3;
}

.route-segment {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 4 9;
  opacity: 0.4;
  transition: stroke 0.35s, opacity 0.35s;
  animation: route-flow 3.2s linear infinite;
}

.route-segment.is-done {
  opacity: 0.7;
}

.route-segment.is-current {
  opacity: 1;
  stroke-width: 2.8;
  stroke-dasharray: 7 8;
  animation-duration: 1.4s;
}

.route-node .node-ring {
  fill: var(--surface-container-lowest);
  stroke: var(--primary);
  stroke-width: 1.4;
  transition: stroke 0.3s, fill 0.3s;
}

.route-node .node-core {
  fill: var(--primary);
  transition: fill 0.3s;
}

.route-node text {
  fill: var(--on-surface);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.route-node .node-halo {
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.5;
  opacity: 0;
}

.route-node.is-active .node-ring {
  fill: var(--primary);
  stroke: var(--primary);
}

.route-node.is-active .node-core {
  fill: var(--primary);
}

.route-node.is-active text {
  fill: var(--on-primary);
}

.route-node.is-active .node-halo {
  opacity: 0.45;
  animation: node-pulse 2s ease-out infinite;
}

.request-line {
  fill: none;
  stroke: var(--records);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 4 6;
  opacity: 0;
  transition: opacity 0.4s;
}

.journey[data-active="5"] .request-line {
  opacity: 0.9;
  animation: route-flow 1.8s linear infinite;
}

/* AI hub */

.ai-hub .ai-base {
  fill: var(--primary-container);
  stroke: var(--primary);
  stroke-width: 1;
}

.ai-hub .ai-ring {
  fill: none;
  stroke: var(--tertiary);
  stroke-width: 1.2;
  stroke-dasharray: 3 7;
  opacity: 0.6;
  transform-box: fill-box;
  transform-origin: center;
  animation: iso-spin 18s linear infinite;
}

.ai-hub .ai-ring--outer {
  stroke: var(--clinic);
  opacity: 0.45;
  animation-direction: reverse;
  animation-duration: 24s;
}

.ai-hub .ai-core {
  fill: var(--primary);
  stroke: none;
  filter: drop-shadow(0 3px 5px rgba(0, 97, 78, 0.25));
}

.ai-hub .ai-spark {
  fill: var(--on-primary);
}

.ai-hub .ai-label {
  fill: var(--tertiary);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-anchor: middle;
}

.ai-hub .ai-pulse {
  fill: var(--primary);
  opacity: 0.14;
  animation: ai-breathe 3.2s ease-in-out infinite;
}

/* ---------- Journey steps ---------- */

.journey-steps {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0 0 16vh;
}

.journey-steps::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 12vh;
  left: 1.45rem;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--outline-variant) 8%, var(--outline-variant) 88%, transparent);
}

.journey-step {
  position: relative;
  min-height: 152px;
  padding: 1.15rem 1.15rem 1.1rem 3.75rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-lg);
  background: var(--surface-container-low);
  transition:
    transform 0.35s var(--ease-emphasized),
    border-color 0.35s,
    background-color 0.35s,
    box-shadow 0.35s;
}

.journey-step.is-past {
  background: var(--surface-container);
}

.journey-step.is-active {
  border-color: var(--primary);
  background: var(--primary-container);
  box-shadow: inset 0 0 0 1px var(--primary), var(--shadow-2);
  transform: translateX(-2px);
}

.journey-step::after {
  content: "";
  position: absolute;
  top: 2.15rem;
  right: 100%;
  width: 40px;
  height: 1px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.journey-step.is-active::after {
  opacity: 1;
}

.journey-step-num {
  position: absolute;
  top: 1.05rem;
  left: 0.45rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--outline-variant);
  border-radius: 50%;
  background: var(--surface-container-highest);
  font-family: var(--font-head);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface-variant);
  transition: color 0.3s, background-color 0.3s, border-color 0.3s;
}

.journey-step.is-active .journey-step-num {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.journey-step-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.journey-step-icon {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border: 0;
  border-radius: var(--shape-sm);
  background: var(--tone-container);
  color: var(--on-tone-container);
}

.journey-step-icon svg {
  width: 1rem;
  height: 1rem;
}

.journey-step-kicker {
  font-family: var(--font-body);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.journey-step h3 {
  margin-top: 0.6rem;
  font-size: 1.02rem;
  line-height: 1.25;
}

.journey-step > p {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  line-height: 1.58;
  color: var(--on-surface-variant);
}

.journey-step.is-active > p {
  color: var(--on-primary-container);
}

.journey-step.is-active .journey-step-kicker {
  color: var(--on-primary-container);
}

.journey-step-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--outline-variant);
}

.journey-step.is-active .journey-step-meta {
  border-top-color: color-mix(in srgb, var(--on-primary-container) 28%, transparent);
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-full);
  background: var(--surface-container-lowest);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--on-surface-variant);
}

.role-chip svg {
  width: 0.72rem;
  height: 0.72rem;
  color: var(--on-surface-muted);
}

.scene-link {
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-muted);
}

.scene-link b {
  color: var(--on-surface);
  font-weight: 700;
}

.journey-step.is-active .scene-link {
  color: var(--on-primary-container);
}

.journey-step.is-active .scene-link b {
  color: var(--primary);
}

/* Compact AI fallback inside step 3 */

.journey-step-ai {
  display: none;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.8rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--shape-md);
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
}

.journey-step-ai .ai-tag {
  display: block;
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.journey-step-ai p {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1.45;
}

.journey-step-ai .ai-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.journey-step-ai .ai-actions span {
  padding: 0.2rem 0.55rem;
  border-radius: var(--shape-full);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 0.6rem;
  font-weight: 600;
}

.journey-step-ai .ai-actions span:last-child {
  background: transparent;
  border: 1px solid var(--tertiary);
  color: var(--tertiary);
}

/* ---------- Access + AI ---------- */

.journey-access {
  margin-top: clamp(1.2rem, 2.4vw, 1.8rem);
  overflow: hidden;
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-lg);
  background: var(--outline-variant);
}

.journey-access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  background: var(--surface-container-low);
}

.journey-access-head h3 {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--on-surface);
}

.journey-access-head span {
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--on-surface-muted);
}

.journey-access-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
}

.access-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  background: var(--surface-container-lowest);
}

.access-item .icon-tile {
  width: 2rem;
  height: 2rem;
  border-radius: var(--shape-sm);
}

.access-item .icon-tile svg {
  width: 1rem;
  height: 1rem;
}

.access-item h4 {
  font-family: var(--font-head);
  font-size: 0.9rem;
  color: var(--on-surface);
}

.access-item p {
  margin-top: 0.18rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--on-surface-variant);
}

.journey-ai {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  align-items: center;
  gap: clamp(1.4rem, 3vw, 2.6rem);
  margin-top: 1rem;
  padding: clamp(1.3rem, 2.8vw, 1.9rem);
  border: 0;
  border-radius: var(--shape-xl);
  background: var(--tertiary-container);
}

.journey-ai::before {
  content: none;
}

.journey-ai h3 {
  margin-top: 0.35rem;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  color: var(--on-tertiary-container);
}

.journey-ai .lead {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--on-tertiary-container);
}

.journey-ai .eyebrow {
  color: var(--tertiary);
}

.journey-ai .link-arrow {
  margin-top: 1rem;
  color: var(--primary);
}

.journey-ai .suggestion-card {
  position: relative;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .journey-layout {
    grid-template-columns: minmax(0, 1fr) minmax(310px, 0.8fr);
    gap: 1.3rem;
  }

  .floor-key-item p {
    font-size: 0.72rem;
  }
}

@media (max-width: 860px) {
  .journey-layout {
    grid-template-columns: 1fr;
  }

  .journey-stage {
    top: calc(var(--header-h) + 8px);
    width: 100%;
    max-width: 680px;
    margin-inline: auto;
  }

  .stage-canvas {
    aspect-ratio: 1000 / 620;
  }

  .journey-steps {
    width: 100%;
    max-width: 680px;
    margin-inline: auto;
    padding-top: 1.4rem;
    padding-bottom: 10vh;
  }

  .journey-step {
    min-height: 0;
  }

  .journey-step::after {
    display: none;
  }

  .journey-access-grid {
    grid-template-columns: 1fr;
  }

  .floor-key {
    grid-template-columns: 1fr;
  }

  .journey-ai {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .floor-key {
    grid-template-columns: 1fr;
  }

  .journey-stage {
    max-width: none;
  }

  .stage-bar {
    padding: 0 0 0.4rem;
  }

  .stage-canvas {
    aspect-ratio: 1 / 0.78;
  }

  .stage-hud {
    top: 0.3rem;
    left: 0;
    max-width: 68%;
    padding: 0.4rem 0.5rem;
    gap: 0.45rem;
  }

  .hud-num {
    font-size: 1.15rem;
  }

  .hud-kicker {
    font-size: 0.44rem;
  }

  .hud-title {
    font-size: 0.66rem;
  }

  .stage-event {
    left: 0;
    bottom: 0.3rem;
    max-width: calc(100% - 1.1rem);
    padding: 0.32rem 0.5rem;
    font-size: 0.58rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-ai {
    display: none;
  }

  .journey-step-ai {
    display: flex;
  }

  .stage-progress {
    height: 28px;
  }

  .journey-step {
    padding: 1rem 0.95rem 1rem 3.35rem;
  }

  .journey-step-num {
    left: 0.35rem;
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.62rem;
  }

  .journey-steps::before {
    left: 1.25rem;
  }

  .journey-step h3 {
    font-size: 0.96rem;
  }

  .journey-step > p {
    font-size: 0.875rem;
  }

  .journey-ai {
    padding: 1.2rem;
  }

  .journey-ai .suggestion-card {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .stage-bar .stage-title {
    display: none;
  }

  .stage-canvas {
    aspect-ratio: 1 / 0.86;
  }

  .stage-progress-label {
    display: none;
  }

  .journey-steps {
    gap: 0.65rem;
  }

  .journey-access-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }
}

/* ---------- Motion ---------- */

@keyframes iso-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5px); }
}

@keyframes route-flow {
  to { stroke-dashoffset: -30; }
}

@keyframes node-pulse {
  0% { transform: scale(0.8); opacity: 0.9; }
  70%, 100% { transform: scale(1.55); opacity: 0; }
}

@keyframes iso-spin {
  to { transform: rotate(360deg); }
}

@keyframes ai-breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 0.75; transform: scale(1.06); }
}

@keyframes scene-breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .person,
  .route-segment.is-current,
  .request-line,
  .ai-hub .ai-ring,
  .ai-hub .ai-pulse,
  .scene-ambient,
  .route-node.is-active .node-halo {
    animation: none;
  }

  .iso-zone,
  .iso-spot,
  .iso-room .room-top,
  .route-segment,
  .stage-progress-fill,
  .journey-step {
    transition: none;
  }
}

/* ---------- Dark scene ----------
   The isometric floor is a light architectural model, so its platform, room
   walls and shadows are re-tuned for the dark scheme while the route and
   status colours keep using the shared role tokens. */
html[data-theme="dark"] .iso-platform .platform-top {
  fill: #0b1422;
}

html[data-theme="dark"] .iso-platform .platform-face--left {
  fill: #091120;
}

html[data-theme="dark"] .iso-platform .platform-face--right {
  fill: #070e1a;
}

html[data-theme="dark"] .iso-platform .platform-rim {
  stroke: rgba(238, 244, 251, 0.06);
}

html[data-theme="dark"] .floor-grid line {
  stroke: rgba(148, 178, 214, 0.14);
}

html[data-theme="dark"] .iso-room {
  --room-top-fill: #131f31;
  --room-wall-left: #1a2a42;
  --room-wall-right: #15243a;
  --room-ink: var(--on-surface-variant);
  --room-line: rgba(238, 244, 251, 0.12);
}

html[data-theme="dark"] .room--dept {
  --room-top-fill: #0e3b33;
  --room-wall-left: #145244;
  --room-wall-right: #0f443a;
}

html[data-theme="dark"] .room--clinic {
  --room-top-fill: #0a3a41;
  --room-wall-left: #0e515b;
  --room-wall-right: #0b444d;
}

html[data-theme="dark"] .room--visit,
html[data-theme="dark"] .room--waiting {
  --room-top-fill: #211a38;
  --room-wall-left: #3a2f5e;
  --room-wall-right: #2f2650;
}

html[data-theme="dark"] .room--record {
  --room-top-fill: #331426;
  --room-wall-left: #53213c;
  --room-wall-right: #441a31;
}

html[data-theme="dark"] .room-shadow {
  fill: rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .iso-room .room-top {
  stroke: rgba(238, 244, 251, 0.14);
}

html[data-theme="dark"] .iso-room .room-wall--left,
html[data-theme="dark"] .iso-room .room-wall--right {
  stroke: rgba(238, 244, 251, 0.08);
}

html[data-theme="dark"] .iso-room .room-desk {
  fill: rgba(238, 244, 251, 0.08);
  stroke: rgba(238, 244, 251, 0.12);
}

html[data-theme="dark"] .iso-room .room-desk-side {
  fill: rgba(238, 244, 251, 0.04);
  stroke: rgba(238, 244, 251, 0.08);
}

html[data-theme="dark"] .iso-room.is-active .room-top {
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.55));
}

html[data-theme="dark"] .iso-room.is-active .room-line {
  stroke: rgba(238, 244, 251, 0.22);
}

html[data-theme="dark"] .ai-hub .ai-core {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

/* SVG gradients declared in how-it-works.html. */
html[data-theme="dark"] #ambientGlow stop {
  stop-color: var(--primary-container);
}

html[data-theme="dark"] #ambientGlow stop:first-child {
  stop-opacity: 0.5;
}

html[data-theme="dark"] #ambientGlow stop:nth-child(2) {
  stop-opacity: 0.26;
}

html[data-theme="dark"] #floorShadow stop {
  stop-color: #000000;
}

html[data-theme="dark"] #floorShadow stop:first-child {
  stop-opacity: 0.55;
}

html[data-theme="dark"] #floorShadow stop:nth-child(2) {
  stop-opacity: 0.28;
}

html[data-theme="dark"] #spotGlow stop,
html[data-theme="dark"] #spotGlowLime stop {
  stop-color: var(--primary);
}

html[data-theme="dark"] #spotGlowPurple stop {
  stop-color: var(--tertiary);
}

html[data-theme="dark"] #spotGlowPink stop {
  stop-color: var(--records);
}

html[data-theme="dark"] #spotGlow stop:first-child,
html[data-theme="dark"] #spotGlowLime stop:first-child,
html[data-theme="dark"] #spotGlowPurple stop:first-child,
html[data-theme="dark"] #spotGlowPink stop:first-child {
  stop-opacity: 0.22;
}
