:root {
  --cl-pine: #0e4638;
  --cl-pine-700: #125845;
  --cl-ink: #1c1917;
  --cl-muted: #78716c;
  --cl-line: rgba(28, 25, 23, 0.12);
  --cl-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  /* Neutral paper (never white) so a sub-pixel sliver at the frame edge blends. */
  background: #f5f4ef;
}

body {
  margin: 0;
  background: #f5f4ef;
  color: var(--cl-ink);
  font-family: var(--cl-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Full-viewport demo surface. Each iteration keeps a persistent, viewport-sized
   iframe that is shown/hidden — never reloaded — so switching preserves the
   demo's own state (scroll, forms, navigation). Hidden frames stay laid out
   (visibility, not display) so their internal viewport never changes size. */
.cl-frames {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  /* Neutral paper fallback behind the frames (never white). */
  background: #f5f4ef;
  overflow: hidden;
}

.cl-frame {
  position: absolute;
  inset: 0;
  /* 1px wider than the viewport so sub-pixel rounding at the right edge can
     never reveal the page behind it. */
  width: calc(100% + 1px);
  height: 100%;
  border: 0;
  /* Overridden per-iteration (showcase.js) with that iteration's paper colour. */
  background: transparent;
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.cl-frame[data-active="true"] {
  visibility: visible;
  pointer-events: auto;
}

/* ---------- floating switcher ---------- */

.cl-pill {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: var(--cl-font);
}

.cl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: var(--cl-pine);
  color: #f5f6f3;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(5, 32, 25, 0.28), 0 2px 6px rgba(5, 32, 25, 0.18);
  transition: transform 0.16s ease, background 0.16s ease;
}

.cl-toggle:hover {
  background: var(--cl-pine-700);
}

.cl-toggle:active {
  transform: translateY(1px);
}

.cl-toggle__mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #ffffff;
}

.cl-toggle__mark svg {
  width: 17px;
  height: 17px;
}

.cl-toggle__count {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #c9dcd3;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 3px 7px;
}

/* Fixed label width so the pill never changes size between iterations
   (prevents the fixed pill's own content from registering a layout shift). */
.cl-toggle__label {
  flex: 0 0 auto;
  width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

.cl-toggle__chev {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: #c9dcd3;
  transition: transform 0.2s ease;
}

.cl-toggle__chev svg {
  width: 15px;
  height: 15px;
}

.cl-pill[data-expanded="true"] .cl-toggle__chev {
  transform: rotate(180deg);
}

/* ---------- panel ---------- */

.cl-panel {
  width: min(300px, calc(100vw - 32px));
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--cl-line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(5, 32, 25, 0.22), 0 4px 14px rgba(5, 32, 25, 0.1);
  transform-origin: bottom right;
  animation: cl-pop 0.16s ease;
}

@keyframes cl-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cl-panel__title {
  margin: 2px 6px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cl-muted);
}

.cl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cl-item {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.cl-item__btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--cl-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.13s ease;
}

.cl-item__btn:hover {
  background: #f5f5f4;
}

.cl-item__btn[aria-current="true"] {
  background: #eef6f2;
}

.cl-item__idx {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f5f5f4;
  color: #57534e;
  font-size: 11px;
  font-weight: 700;
}

.cl-item__btn[aria-current="true"] .cl-item__idx {
  background: var(--cl-pine);
  color: #ffffff;
}

.cl-item__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cl-item__label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}

.cl-item__meta {
  font-size: 11.5px;
  color: var(--cl-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl-item__badge {
  flex: none;
  align-self: center;
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid #f0e0ad;
  border-radius: 999px;
  background: #fdf3d8;
  color: #8a6d1f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cl-item__ext {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  border-radius: 10px;
  color: #a8a29e;
  text-decoration: none;
}

.cl-item__ext:hover {
  background: #f5f5f4;
  color: var(--cl-pine);
}

.cl-item__ext svg {
  width: 14px;
  height: 14px;
}

.cl-panel__foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--cl-line);
}

.cl-ghost {
  border: 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--cl-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cl-ghost:hover {
  background: #f5f5f4;
  color: var(--cl-ink);
}

/* ---------- zen restore handle ---------- */

.cl-restore {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(14, 70, 56, 0.3);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.cl-restore:hover {
  background: rgba(14, 70, 56, 0.65);
  transform: scale(1.15);
}

/* ---------- focus, motion, noscript ---------- */

.cl-toggle:focus-visible,
.cl-item__btn:focus-visible,
.cl-item__ext:focus-visible,
.cl-ghost:focus-visible,
.cl-restore:focus-visible {
  outline: 2px solid var(--cl-pine-700);
  outline-offset: 2px;
}

.cl-noscript {
  position: fixed;
  inset: 16px auto auto 16px;
  z-index: 10;
  margin: 0;
  padding: 12px 16px;
  list-style: none;
  background: #ffffff;
  border: 1px solid var(--cl-line);
  border-radius: 12px;
  font-family: var(--cl-font);
  font-size: 14px;
  line-height: 1.7;
}

.cl-noscript a {
  color: var(--cl-pine-700);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
