/* ==========================================================================
   Irizar ieBus AI – podstawy, tło, ekrany, bliźniak
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Bazowy rozmiar rośnie z ekranem: 16 px na laptopie, ~20 px na ekranie 1920 px, max 22 px */
  font-size: clamp(16px, 0.55vw + 9px, 22px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--abyss);
  color: var(--polar);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv05';
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-kiosk {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

body.is-kiosk textarea,
body.is-kiosk input {
  user-select: text;
  -webkit-user-select: text;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--ion);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--ion);
  color: var(--on-ion);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--t-med) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
  box-shadow: var(--focus-ring);
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 16px;
  border-radius: var(--r-control);
  background: var(--glass-strong);
  color: var(--polar);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Tło: zorza, perspektywiczna podłoga, ziarno
   -------------------------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 70% -10%, rgba(var(--nebula-rgb), 0.16), transparent 60%),
    radial-gradient(90% 70% at 10% 110%, rgba(var(--ion-rgb), 0.1), transparent 55%),
    var(--abyss);
}

.backdrop__aurora {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.backdrop__aurora--a {
  top: -35vmax;
  right: -20vmax;
  background: radial-gradient(circle, rgba(var(--nebula-rgb), 0.55), transparent 65%);
  animation: aurora-a 38s var(--ease-in-out) infinite alternate;
}

.backdrop__aurora--b {
  bottom: -40vmax;
  left: -25vmax;
  background: radial-gradient(circle, rgba(var(--ion-rgb), 0.4), transparent 65%);
  animation: aurora-b 46s var(--ease-in-out) infinite alternate;
}

.backdrop__aurora--c {
  top: 20%;
  left: 35%;
  width: 45vmax;
  height: 45vmax;
  opacity: 0.22;
  background: radial-gradient(circle, rgba(180, 120, 255, 0.45), transparent 65%);
  animation: aurora-c 54s var(--ease-in-out) infinite alternate;
}

@keyframes aurora-a {
  to { transform: translate3d(-18vmax, 14vmax, 0) scale(1.15); }
}

@keyframes aurora-b {
  to { transform: translate3d(20vmax, -10vmax, 0) scale(1.1); }
}

@keyframes aurora-c {
  to { transform: translate3d(-12vmax, 10vmax, 0) scale(0.85); }
}

/* Siatka podłogi w perspektywie – nawiązanie do hali wystawowej */
.backdrop__floor {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: -10%;
  height: 60%;
  background-image:
    linear-gradient(rgba(var(--ion-rgb), 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--ion-rgb), 0.13) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(600px) rotateX(62deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent 75%);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent 75%);
  animation: floor-drift 14s linear infinite;
}

@keyframes floor-drift {
  to { background-position: 0 64px, 0 0; }
}

.backdrop__grain {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.backdrop__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* --------------------------------------------------------------------------
   Marka (tekstowa – bez odwzorowania logotypów)
   -------------------------------------------------------------------------- */

.brand-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-1);
  letter-spacing: 0.02em;
  color: var(--polar);
}

.brand-by {
  font-size: var(--step--1);
  color: var(--mist);
}

/* Olbrzymie, obrysowane „ie” – typografia jako scenografia */
.giant-type {
  position: absolute;
  z-index: 0;
  font-family: var(--font-display);
  font-weight: 200;
  font-size: var(--giant);
  line-height: 0.8;
  letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(var(--ion-rgb), 0.13);
  mask-image: linear-gradient(180deg, #000 20%, transparent 85%);
  -webkit-mask-image: linear-gradient(180deg, #000 20%, transparent 85%);
  user-select: none;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Przyciski
   -------------------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: var(--step-0);
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), background-color var(--t-med);
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  color: var(--on-ion);
  background: linear-gradient(100deg, var(--frost) 0%, var(--ion) 45%, var(--nebula) 130%);
  box-shadow: 0 10px 40px -8px rgba(var(--ion-rgb), 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn--primary:hover {
  box-shadow: 0 14px 50px -6px rgba(var(--ion-rgb), 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn--ghost {
  color: var(--polar);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn--ghost:hover {
  background: rgba(var(--ion-rgb), 0.08);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn--xl {
  min-height: 64px;
  padding: 0 40px;
  font-size: var(--step-1);
}

.btn--sm {
  min-height: 40px;
  padding: 0 16px;
  font-size: var(--step--1);
}

.btn__pulse {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(var(--ion-rgb), 0.55);
  animation: pulse-ring 2.6s var(--ease-out) infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(var(--ion-rgb), 0.5); }
  70%, 100% { box-shadow: 0 0 0 22px rgba(var(--ion-rgb), 0); }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--mist);
  font-size: var(--step--1);
  font-weight: 600;
  transition: color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}

.icon-btn:hover {
  color: var(--polar);
  background: rgba(var(--ion-rgb), 0.08);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.icon-btn[aria-pressed='true'] {
  color: var(--ion);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.icon-slot {
  display: inline-flex;
}

/* --------------------------------------------------------------------------
   Ekran powitalny / ekran oczekiwania
   -------------------------------------------------------------------------- */

.welcome {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  padding: var(--gutter);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  cursor: pointer;
  transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out), filter var(--t-slow);
}

.welcome.is-leaving {
  opacity: 0;
  transform: scale(1.04);
  filter: blur(8px);
  pointer-events: none;
}

.welcome__brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.welcome__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: clamp(16px, 4vh, 64px) 0 clamp(8px, 2vh, 24px);
}

.welcome__stage .giant-type {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -62%);
}

.twin--hero {
  /* Szerokość ograniczona także wysokością ekranu, żeby tekst i przycisk zawsze się mieściły */
  width: min(92vw, 1400px, calc((100dvh - 580px) * 3.24));
  min-width: min(92vw, 520px);
}

.welcome__copy {
  display: grid;
  justify-items: center;
  gap: clamp(14px, 2vh, 24px);
  text-align: center;
  padding-bottom: clamp(8px, 3vh, 40px);
}

.welcome__title {
  max-width: 18ch;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: min(var(--step-5), 5rem, 9vh);
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
  background: linear-gradient(180deg, #ffffff 30%, #b9d7ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome__lead {
  max-width: 46ch;
  color: var(--mist);
  font-size: var(--step-1);
  line-height: 1.5;
  text-wrap: pretty;
}

.welcome__hint {
  color: var(--dim);
  font-size: var(--step--1);
}

/* Orkiestrowane wejście: hologram rysuje się, potem pojawia się tekst */
.welcome__copy > * {
  animation: rise-in 900ms var(--ease-out) both;
}

.welcome__title { animation-delay: 1500ms; }
.welcome__lead { animation-delay: 1700ms; }
.welcome .btn { animation-delay: 1900ms; }
.welcome__hint { animation-delay: 2300ms; }

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(6px);
  }
}

/* --------------------------------------------------------------------------
   Hologram cyfrowego bliźniaka
   -------------------------------------------------------------------------- */

.twin {
  position: relative;
  z-index: 1;
  aspect-ratio: 928 / 282;
}

/* ieBus z akrylowego szkła – rysunek wektorowy */
.iebus {
  position: absolute;
  inset: 0;
  animation: float 7s var(--ease-in-out) infinite alternate;
}

.iebus__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ib-panes rect, .ib-panes path { stroke: rgba(207, 227, 255, 0.6); stroke-width: 1; }
.ib-pillar { fill: none; stroke: rgba(207, 227, 255, 0.22); stroke-width: 1; }
.ib-glint { stroke: rgba(255, 255, 255, 0.16); }
.ib-door-frame { fill: rgba(10, 16, 30, 0.85); stroke: rgba(207, 227, 255, 0.75); stroke-width: 1.2; }
.ib-door-leaf { fill: rgba(90, 162, 255, 0.1); stroke: rgba(207, 227, 255, 0.5); stroke-width: 1; }
.ib-door-rail { fill: none; stroke: rgba(207, 227, 255, 0.35); stroke-width: 1; }
.ib-btn { fill: rgba(207, 227, 255, 0.25); stroke: rgba(207, 227, 255, 0.8); stroke-width: 1; }
.ib-fine { fill: none; stroke: rgba(207, 227, 255, 0.3); stroke-width: 1; }
.ib-fastener rect { fill: rgba(207, 227, 255, 0.45); }
.ib-arch { fill: none; stroke: rgba(207, 227, 255, 0.55); stroke-width: 1.3; }
.ib-lamp { fill: rgba(234, 246, 255, 0.18); stroke: #eaf6ff; stroke-width: 1.4; filter: drop-shadow(0 0 4px rgba(var(--ion-rgb), 0.9)); }
.ib-lamp--rear { fill: rgba(255, 92, 116, 0.35); stroke: #ff8a9a; filter: drop-shadow(0 0 4px rgba(255, 92, 116, 0.8)); }
.ib-marker { fill: #ffcf70; filter: drop-shadow(0 0 3px #ffcf70); }
.ib-reflector rect { fill: rgba(255, 207, 112, 0.6); }
.ib-flap { fill: rgba(56, 211, 159, 0.15); stroke: var(--nebula); stroke-width: 1.2; filter: drop-shadow(0 0 3px rgba(var(--nebula-rgb), 0.9)); }
.ib-lamp, .ib-flap, .ib-marker { animation: none; }
.ib-outline { fill: none; stroke-width: 2.2; stroke-linejoin: round; filter: drop-shadow(0 0 5px rgba(var(--ion-rgb), 0.75)); }
.ib-energy { fill: none; stroke-width: 3.2; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(var(--nebula-rgb), 0.9)); }
.ib-tyre { fill: #070b16; stroke-width: 2; }
.ib-tread { fill: none; stroke: rgba(207, 227, 255, 0.18); stroke-width: 1; }
.ib-rim { fill: rgba(90, 162, 255, 0.12); stroke: rgba(207, 227, 255, 0.65); stroke-width: 1.2; }
.ib-rim-in { fill: none; stroke: rgba(207, 227, 255, 0.35); stroke-width: 1; }
.ib-bolts circle { fill: rgba(207, 227, 255, 0.7); }
.ib-hub { fill: rgba(207, 227, 255, 0.9); }
.iebus__svg * { vector-effect: non-scaling-stroke; }
/* Obrys rysowany animacją: długość kreski liczona w jednostkach rysunku */
.iebus__svg .ib-outline { vector-effect: none; stroke-width: 1.6; }

.iebus__shadow {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -12%;
  height: 16%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--ion-rgb), 0.35), rgba(var(--nebula-rgb), 0.12) 60%, transparent);
  filter: blur(6px);
  animation: shadow 7s var(--ease-in-out) infinite alternate;
}

@keyframes float {
  to { transform: translateY(-6px); }
}

@keyframes shadow {
  to { transform: scaleX(0.94); opacity: 0.75; }
}


/* Wejście: obrys rysuje się linią, potem pojawia się szkło */
.twin.is-drawing .ib-outline {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.6s var(--ease-out) forwards;
}

.twin.is-drawing .ib-body,
.twin.is-drawing .ib-band,
.twin.is-drawing .ib-panes,
.twin.is-drawing .ib-door,
.twin.is-drawing .ib-fine,
.twin.is-drawing .ib-pillar,
.twin.is-drawing .ib-arch,
.twin.is-drawing .ib-fastener,
.twin.is-drawing .ib-reflector,
.twin.is-drawing .ib-wheel,
.twin.is-drawing .iebus__shadow {
  animation: fade-in 900ms var(--ease-out) 900ms both;
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { from { opacity: 0; } }

[data-state='thinking'] .ib-rim { animation: spin 1.6s linear infinite; transform-box: fill-box; transform-origin: center; stroke-dasharray: 6 4; }
[data-state='speaking'] .ib-outline { animation: breathe 1.4s var(--ease-in-out) infinite; }

@keyframes breathe {
  50% { filter: drop-shadow(0 0 10px rgba(var(--nebula-rgb), 1)); }
}

[data-state='offline'] .iebus {
  filter: grayscale(0.9);
  opacity: 0.55;
}

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

/* Przegub autobusu 18 m */
.ib-joint-body { fill: rgba(5, 9, 18, 0.9); stroke: rgba(207, 227, 255, 0.5); stroke-width: 1; }
.ib-joint-ribs { fill: none; stroke: rgba(207, 227, 255, 0.22); stroke-width: 1; }

/* Suwak wariantów */
.variant {
  display: grid;
  gap: 6px;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: var(--glass);
  box-shadow: var(--inner-edge);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.variant__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.variant__label { color: var(--mist); font-size: var(--step--1); }
.variant__value { font-family: var(--font-display); font-weight: 600; font-size: var(--step-0); color: var(--polar); }
.variant__note { margin: 0; color: var(--dim); font-size: var(--step--2); }
.variant__scale { display: flex; justify-content: space-between; color: var(--dim); font-size: var(--step--2); padding: 0 2px; }
.variant__scale span:nth-child(2) { margin-left: -6%; }

.variant__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.variant__range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ion), var(--nebula));
  opacity: 0.85;
}

.variant__range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ion), var(--nebula));
}

.variant__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--polar);
  box-shadow: 0 0 0 4px rgba(var(--ion-rgb), 0.35), 0 0 14px rgba(var(--ion-rgb), 0.8);
}

.variant__range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--polar);
  box-shadow: 0 0 0 4px rgba(var(--ion-rgb), 0.35), 0 0 14px rgba(var(--ion-rgb), 0.8);
}

.variant__range:focus-visible { outline: none; }
.variant__range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.variant__range:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }

/* Punkty zainteresowania na hologramie */
.hotspot {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.hotspot__core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--frost);
  box-shadow: 0 0 0 4px rgba(var(--ion-rgb), 0.25), 0 0 18px 4px rgba(var(--ion-rgb), 0.7);
  transition: transform var(--t-med) var(--ease-out);
}

.hotspot::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(var(--ion-rgb), 0.6);
  animation: hotspot-ping 3s var(--ease-out) infinite;
}

.hotspot__tag {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 4px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--polar);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast), translate var(--t-med) var(--ease-out);
}

.hotspot:hover .hotspot__core,
.hotspot.is-lit .hotspot__core {
  transform: scale(1.35);
}

.hotspot:hover .hotspot__tag,
.hotspot.is-lit .hotspot__tag {
  opacity: 1;
  translate: -50% 0;
}

@keyframes hotspot-ping {
  0% { transform: scale(0.6); opacity: 1; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

.twin.is-drawing .hotspot {
  animation: fade-in 600ms var(--ease-out) both;
  animation-delay: 1800ms;
}

/* --------------------------------------------------------------------------
   Aplikacja: pasek górny + scena + konsola
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.app.is-entering {
  animation: app-in 900ms var(--ease-out) both;
}

@keyframes app-in {
  from { opacity: 0; transform: scale(0.985); filter: blur(10px); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--gutter);
  padding-top: max(14px, env(safe-area-inset-top));
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 14px;
  min-height: 44px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--mist);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
}

.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dim);
}

.status[data-status='online'] .status__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(99, 242, 191, 0.18), 0 0 12px rgba(99, 242, 191, 0.8);
}

.status[data-status='connecting'] .status__dot,
.status[data-status='reconnecting'] .status__dot {
  background: var(--warn);
  animation: blink 1s steps(2, jump-none) infinite;
}

.status[data-status='offline'] .status__dot {
  background: var(--danger);
}

@keyframes blink {
  50% { opacity: 0.25; }
}

.experience {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr);
  gap: var(--gutter);
  min-height: 0;
  padding: 0 var(--gutter) var(--gutter);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
}

/* Scena z bliźniakiem – pełni rolę panelu bocznego */
.stage {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 0;
  isolation: isolate;
}


.stage__twin-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  height: 100%;
  container-type: size;
}

.twin--stage {
  width: min(100cqw, 100cqh * 3.29);
}

.stage__explore {
  display: grid;
  gap: 14px;
  padding-bottom: 8px;
}

.stage__prompt {
  color: var(--mist);
  font-size: var(--step--1);
}

.hotspot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--polar);
  font-size: var(--step--1);
  font-weight: 600;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease-out);
}

.legend-chip:hover {
  background: rgba(var(--ion-rgb), 0.1);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.legend-chip:active {
  transform: scale(0.97);
}

.legend-chip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.legend-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ion);
  box-shadow: 0 0 10px var(--ion);
}

/* --------------------------------------------------------------------------
   Dialog kiosku
   -------------------------------------------------------------------------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(1, 4, 12, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in var(--t-med) var(--ease-out);
}

.dialog__panel {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: min(460px, 100%);
  padding: 36px 32px 32px;
  border-radius: var(--r-shell);
  background: var(--glass-strong);
  box-shadow: var(--shadow-deep), var(--inner-edge), 0 0 80px rgba(var(--ion-rgb), 0.12);
  text-align: center;
  animation: rise-in 500ms var(--ease-out);
}

.dialog__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-3);
  letter-spacing: -0.02em;
}

.dialog__text {
  color: var(--mist);
}

.dialog__text strong {
  color: var(--ion);
  font-variant-numeric: tabular-nums;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Oznaczenie AI (AI Act, art. 50 – gość wie, że rozmawia z systemem AI)
   -------------------------------------------------------------------------- */

.ai-badge {
  display: inline-flex;
  align-items: center;
  align-self: center;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px rgba(var(--ion-rgb), 0.55);
  background: rgba(var(--ion-rgb), 0.1);
  color: var(--ion);
  font-family: var(--font-text);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.08em;
  vertical-align: middle;
  cursor: default;
}

.console__name .ai-badge {
  margin-left: 8px;
  transform: translateY(-2px);
}

/* Znaczek na awatarze odpowiedzi – widoczny także na telefonie, gdzie nagłówek konsoli jest ukryty. */
.avatar__ai {
  position: absolute;
  right: -5px;
  bottom: -3px;
  z-index: 1;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--ion);
  color: var(--abyss);
  font-family: var(--font-text);
  font-size: 9px;
  font-weight: 800;
  line-height: 13px;
  letter-spacing: 0.04em;
}

.avatar__ai::before {
  content: 'AI';
}

:root[lang='es'] .avatar__ai::before {
  content: 'IA';
}

.avatar--xl .avatar__ai {
  display: none;
}

@media (max-width: 480px) {
  .topbar .ai-badge {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Przełącznik języka
   -------------------------------------------------------------------------- */

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--line);
}

.lang-switch__btn {
  min-width: 40px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}

.lang-switch__btn:hover {
  color: var(--polar);
}

.lang-switch__btn[aria-pressed='true'] {
  color: var(--abyss, #02060e);
  background: var(--ion);
  box-shadow: 0 0 18px rgba(var(--ion-rgb), 0.35);
}

.lang-switch__btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.welcome__brand .lang-switch {
  margin-left: auto;
  align-self: center;
}

@media (max-width: 600px) {
  .topbar .brand-word {
    white-space: nowrap;
  }

  .topbar__actions {
    gap: 6px;
  }
}

/* Wąski telefon: nazwa „Irizar ieBus” jest dłuższa niż w i8 – mniejsza nazwa i przyciski, bez kapsułki stanu
   (o braku połączenia informuje komunikat w rozmowie). */
@media (max-width: 480px) {
  .topbar .brand-word {
    font-size: 1.05rem;
  }

  .topbar .status {
    display: none;
  }

  .topbar .icon-btn {
    min-height: 40px;
    padding: 0 11px;
  }

  .topbar .lang-switch__btn {
    min-width: 30px;
    min-height: 32px;
    padding: 0 5px;
  }

  .lang-switch__btn {
    min-width: 34px;
    min-height: 34px;
    padding: 0 7px;
  }
}

/* --------------------------------------------------------------------------
   Prywatność i pliki cookies
   -------------------------------------------------------------------------- */

.legal-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.legal-link:hover {
  color: var(--ion);
}

.legal-link:focus-visible {
  outline: 2px solid var(--ion);
  outline-offset: 2px;
  border-radius: 2px;
}

.welcome__legal {
  justify-self: inherit;
  color: var(--dim);
  font-size: var(--step--1);
  animation-delay: 2300ms;
}

.privacy {
  width: min(560px, calc(100% - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-shell);
  background: var(--glass-strong);
  color: inherit;
  box-shadow: var(--shadow-deep), var(--inner-edge), 0 0 80px rgba(var(--ion-rgb), 0.12);
}

.privacy[open] {
  animation: rise-in 400ms var(--ease-out);
}

.privacy::backdrop {
  background: rgba(1, 4, 12, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.privacy__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  max-height: inherit;
  padding: 28px 28px 24px;
}

.privacy__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-2);
  letter-spacing: -0.02em;
}

.privacy__body {
  overflow-y: auto;
  padding-right: 6px;
  color: var(--mist);
  font-size: var(--step--1);
  line-height: 1.55;
}

.privacy__body:focus-visible {
  outline: 2px solid var(--ion);
  outline-offset: 4px;
  border-radius: 4px;
}

.privacy__body h3 {
  margin: 16px 0 4px;
  color: var(--polar);
  font-size: var(--step-0);
  font-weight: 600;
}

.privacy__body h3:first-child {
  margin-top: 0;
}

.privacy__body p + p {
  margin-top: 12px;
}

.privacy__body a {
  color: var(--ion);
  text-underline-offset: 2px;
}

.privacy__actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .privacy__panel {
    padding: 22px 18px 18px;
  }
}

/* --------------------------------------------------------------------------
   Responsywność
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  .experience {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 1.1fr);
  }

  .icon-btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .icon-btn {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .app {
    height: auto;
    min-height: 100dvh;
  }

  .experience {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    height: calc(100dvh - 72px);
  }

  .stage {
    grid-template-rows: auto auto;
    gap: 6px;
  }

  .stage__twin-wrap {
    height: auto;
    padding: 0 6%;
    container-type: normal;
  }

  .twin--stage {
    width: 100%;
  }


  .stage__prompt {
    display: none;
  }

  .hotspot-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 85%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  }

  .hotspot-legend::-webkit-scrollbar {
    display: none;
  }

  .legend-chip {
    white-space: nowrap;
  }

  .hotspot__tag {
    display: none;
  }

  .hotspot {
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
  }

  .hotspot__core {
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 3px rgba(var(--ion-rgb), 0.2), 0 0 8px 2px rgba(var(--ion-rgb), 0.6);
  }

  .hotspot::before {
    inset: 10px;
  }

  /* Po rozpoczęciu rozmowy scena się chowa – ekran należy do rozmowy */
  .has-conversation .stage {
    display: none;
  }

  .has-conversation .experience {
    grid-template-rows: minmax(0, 1fr);
  }

  .brand-by {
    display: none;
  }

  .status {
    padding: 0 12px;
  }
}

@media (max-width: 600px) {
  .welcome__brand .brand-by {
    display: inline;
  }

  .welcome__stage {
    padding-top: 12vh;
  }

  .twin--hero {
    width: 100%;
    min-width: 0;
  }

  .welcome__stage .giant-type {
    font-size: 15rem;
  }

  .welcome__lead {
    font-size: var(--step-0);
  }

  .btn--xl {
    width: 100%;
    min-height: 58px;
  }

  .topbar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .experience {
    height: calc(100dvh - 64px);
  }

  /* Hologram jako niski pasek – ekran należy do rozmowy */
  .stage__twin-wrap {
    padding: 0;
  }

  .twin--stage {
    width: 100%;
  }

  .legend-chip {
    min-height: 40px;
    padding: 0 14px 0 12px;
  }

  #status-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .status {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
}

/* Telefon w poziomie: za mało wysokości na scenę – zostaje sama rozmowa */
@media (max-width: 900px) and (max-height: 520px) {
  .stage {
    display: none;
  }

  .experience {
    grid-template-rows: minmax(0, 1fr);
  }

  /* Ekran powitalny w dwóch kolumnach: hologram | tekst */
  .welcome {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 24px;
  }

  .welcome__brand {
    grid-column: 1 / -1;
  }

  .welcome__stage {
    padding: 0;
    align-self: center;
  }

  .twin--hero {
    width: 100%;
    min-width: 0;
  }

  .welcome__stage .giant-type,
  .welcome__hint {
    display: none;
  }

  .welcome__copy {
    align-self: center;
    justify-items: start;
    text-align: left;
    gap: 10px;
    padding: 0;
  }

  .welcome__title {
    font-size: 2rem;
  }

  .welcome__lead {
    font-size: var(--step--1);
  }

  .btn--xl {
    width: auto;
    min-height: 50px;
    padding: 0 28px;
    font-size: var(--step-0);
  }
}

/* Ekrany targowe w orientacji pionowej (totem) */
@media (min-width: 901px) and (orientation: portrait) {
  .experience {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }
}

/* --------------------------------------------------------------------------
   Ograniczony ruch
   -------------------------------------------------------------------------- */

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

  .backdrop__aurora,
  .hotspot::before,
  .btn__pulse {
    animation: none !important;
  }

}

/* Brak backdrop-filter – mocniejsze tło paneli */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .legend-chip,
  .dialog {
    background: var(--glass-strong);
  }
}

@media (forced-colors: active) {
  .btn,
  .icon-btn,
  .legend-chip {
    border: 1px solid ButtonText;
  }
}
