.demo-chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--chrome-h);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding:
    max(0.45rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    0.45rem
    max(0.75rem, env(safe-area-inset-left, 0px));
  isolation: isolate;
  background: rgba(255, 255, 255, 0.38);
  border-bottom: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow:
    0 1px 0 rgba(47, 70, 99, 0.05),
    0 10px 28px rgba(45, 74, 99, 0.06);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  backdrop-filter: blur(18px) saturate(1.35);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .demo-chrome {
    background: rgba(255, 255, 255, 0.86);
  }
}

.demo-chrome__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  letter-spacing: -0.02em;
  color: var(--by-indigo-deep);
}

.demo-chrome__brand .brand-logo {
  height: 36px;
  width: 36px;
  max-width: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.demo-chrome__brand-text {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.35rem;
  min-width: 0;
  line-height: 1.2;
}

.demo-chrome__brand-name {
  white-space: nowrap;
}

.demo-chrome__brand-th {
  color: var(--by-indigo);
  font-weight: 500;
  white-space: nowrap;
}

.demo-chrome__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.demo-chrome__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(47, 70, 99, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  color: var(--by-indigo-deep);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.22s var(--ease-out),
    border-color 0.22s var(--ease-out),
    transform 0.22s var(--ease-out);
}

.demo-chrome__icon-btn:hover {
  background: var(--by-indigo-soft);
  border-color: rgba(61, 90, 128, 0.22);
}

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

.demo-chrome__icon-btn[aria-expanded="true"] {
  background: var(--by-indigo-soft);
  border-color: rgba(61, 90, 128, 0.28);
}

.demo-chrome__icon-btn--close {
  font-size: 1.1rem;
}

.demo-chrome__backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(42, 51, 64, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.22s var(--ease-out);
}

.demo-chrome__backdrop.is-open {
  opacity: 1;
}

.demo-chrome__backdrop[hidden] {
  display: none !important;
}

.demo-chrome__panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  /* Prefer % over 100vw to avoid horizontal overflow / “narrow desktop” zoom feel */
  width: min(100%, 22rem);
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  padding:
    max(0.65rem, env(safe-area-inset-top, 0px))
    max(0.85rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    0.85rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 250, 0.97));
  border-left: 1px solid var(--by-line-soft);
  box-shadow: -12px 0 40px rgba(45, 74, 99, 0.14);
  transform: translateX(104%);
  transition: transform 0.28s var(--ease-out);
  overflow: hidden;
}

.demo-chrome__panel.is-open {
  transform: translateX(0);
}

.demo-chrome__panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--by-line-soft);
}

.demo-chrome__panel-titles {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.demo-chrome__panel-kicker {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.demo-chrome__panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 650;
  color: var(--by-indigo-deep);
  line-height: 1.25;
}

.demo-chrome__panel-body {
  display: grid;
  gap: 0.95rem;
  padding-top: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.role-hint {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.55;
}

.demo-chrome__lanes {
  display: grid;
  gap: 0.45rem;
}

.demo-chrome__nav-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: var(--tap-min);
  margin: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--by-line-soft);
  border-radius: 14px;
  background: var(--by-surface);
  color: var(--by-indigo-deep);
  font: inherit;
  font-size: 1.12rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.22s var(--ease-out),
    border-color 0.22s var(--ease-out),
    box-shadow 0.22s var(--ease-out);
}

.demo-chrome__nav-btn:hover {
  background: var(--by-indigo-wash);
}

.demo-chrome__nav-btn.is-active {
  background: linear-gradient(160deg, var(--by-indigo-soft), rgba(232, 240, 233, 0.75));
  border-color: rgba(61, 90, 128, 0.28);
  box-shadow: var(--by-shadow-sm);
}

.demo-chrome__back {
  width: 100%;
  justify-content: flex-start;
  font-size: 1.08rem;
}

.demo-chrome__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.25rem;
}

.chrome-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.05rem;
  color: var(--by-ink-muted);
  min-width: 0;
}

.chrome-field--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.chrome-field--stack > span {
  font-weight: 600;
  color: var(--by-indigo-deep);
}

.chrome-field select {
  width: 100%;
  border: 1px solid var(--by-line);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  min-height: var(--tap-min);
  background: var(--by-surface-glass);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--by-indigo-deep);
}

body.demo-chrome-lock {
  overflow: hidden;
}

.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;
}

/* Full-bleed drawer on phones */
@media (max-width: 768px) {
  .demo-chrome {
    padding:
      max(0.28rem, env(safe-area-inset-top, 0px))
      0.6rem
      0.28rem
      0.6rem;
    gap: 0.4rem;
  }

  .demo-chrome__brand {
    font-size: clamp(1.05rem, 4.2vw, 1.2rem);
  }

  .demo-chrome__brand .brand-logo {
    height: 32px;
    width: 32px;
    max-width: 32px;
  }

  .demo-chrome__brand-text {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    line-height: 1.15;
  }

  .demo-chrome__brand-th {
    font-size: 0.92em;
  }

  .demo-chrome__panel {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    border-left: none;
  }

  .demo-chrome__panel-title {
    font-size: 1.55rem;
  }

  .demo-chrome__nav-btn {
    font-size: 1.18rem;
    padding: 0.85rem 1.05rem;
  }

  .chrome-field,
  .chrome-field select,
  .role-hint {
    font-size: 1.12rem;
  }

  .demo-chrome__back {
    font-size: 1.12rem;
  }
}

@media (max-width: 640px) {
  .demo-chrome__brand {
    font-size: 1.08rem;
  }

  .demo-chrome__panel-title {
    font-size: 1.6rem;
  }
}
