:root {
  --preview-bar-height: 60px;
  --preview-frame: min(1320px, 100%);
  --preview-gutter: clamp(16px, 3.2vw, 48px);
}
.global-bar {
  height: var(--preview-bar-height);
  padding-inline: var(--preview-gutter);
  gap: clamp(12px, 2vw, 28px);
  background: color-mix(in srgb, var(--theme-top, var(--bar)) 86%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--theme-rail) 32%, var(--line));
  backdrop-filter: saturate(1.35) blur(18px);
}
.global-bar > .global-brand {
  min-height: 36px;
  margin-inline-start: -6px;
  padding-inline: 6px;
  border-radius: 9px;
  font-weight: 650;
  letter-spacing: -.025em;
}
:root[data-palette] .global-bar > .global-brand:is(:hover,:focus-visible) {
  background: color-mix(in srgb, var(--theme-selected) 84%, var(--theme-ring));
  color: var(--theme-selected-text);
}
:root[data-palette] .global-bar > .global-brand:focus-visible { outline-offset: 1px; }
.global-brand img { display: block; width: 28px; height: 28px; object-fit: contain; }
.global-bar .settings-button { flex: none; width: 40px; height: 40px; padding: 0; }
.global-bar .merged-tool {
  display: grid;
  grid-template-columns: minmax(0, 136px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.global-bar .merged-tool > .component-name {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 16px;
  line-height: 1;
  font-weight: 620;
  white-space: nowrap;
}
:root[data-palette] .global-bar .merged-tool > button.component-name:hover:not(:disabled) {
  background: color-mix(in srgb, var(--theme-selected) 84%, var(--theme-ring));
  color: var(--theme-selected-text);
}
.global-bar .merged-tool > button.component-name:focus-visible {
  outline: 2px solid var(--theme-ring);
  outline-offset: 1px;
}
.global-bar .component-controls { height: 40px; align-items: center; }
.global-bar .component-controls > button {
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  line-height: 1.15;
}
@media (min-width: 901px) {
  .global-bar .component-controls > button[data-action="menu"] { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .global-bar { background: var(--theme-top, var(--bar)); backdrop-filter: none; }
}
#workspace { height: calc(var(--workspace-viewport-height, 100dvh) - var(--preview-bar-height)); }

:root[data-palette] .preview-home {
  background: var(--group, var(--bg));
  color: var(--label);
  padding: clamp(10px, 1.5vw, 22px) var(--preview-gutter) 10px;
}
:root[data-palette] .preview-home .hero-editorial {
  width: var(--preview-frame);
  padding: 0;
  isolation: isolate;
  border-radius: clamp(20px, 2.5vw, 32px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 70%, transparent);
}
:root[data-palette] .preview-home .hero-stage {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  max-width: none;
  border: 0;
  overflow: hidden;
}
.preview-home .hero-artwork {
  position: absolute;
  inset-inline: 0;
  top: 0;
  aspect-ratio: 2 / 1;
}
.preview-home .hero-stage .hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center;
}
.preview-home .hero-image { animation: none; transform: none; }
.preview-home .hero-effects {
  position: absolute;
  pointer-events: none;
}
.preview-home .hero-motion-toggle:not([hidden]) {
  position: absolute;
  z-index: 2;
  inset: auto 12px 12px auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #ffffff35;
  border-radius: 50%;
  background: #181921b8;
  color: #fff;
  cursor: pointer;
}
.preview-home .hero-motion-toggle:hover { background: #181921ed; }
.hero-motion-toggle::before {
  content: '';
  width: 9px;
  height: 12px;
  border-inline: 2px solid currentColor;
}
.hero-motion-toggle[data-paused]::before {
  width: 0;
  height: 0;
  border: 0;
  border-block: 6px solid transparent;
  border-inline-start: 9px solid currentColor;
  margin-inline-start: 2px;
}
@media (max-width: 760px) {
  :root { --preview-bar-height: 56px; --preview-gutter: 12px; }
  .global-bar { gap: 8px; }
  .global-bar .merged-tool { grid-template-columns: minmax(0, 112px) auto; gap: 3px; }
  .global-bar .merged-tool > .component-name { font-size: 14px; padding-inline: 6px; }
  .global-bar .component-controls > button { padding-inline: 6px; }

}
@media (max-width: 350px) {
  .global-bar .merged-tool > .component-name { font-size: 13px; padding-inline: 4px; }
  .global-bar .component-controls > button { padding-inline: 4px; }
}

.settings-section .settings-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 0 14px;
}
.settings-group > summary {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-inline: -14px;
  padding-inline: 14px;
  border-radius: 13px;
}
.settings-group > summary::-webkit-details-marker { display: none; }
.settings-group > summary::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  flex: none;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--secondary);
}
.settings-group > summary::after { transform: rotate(-45deg); margin-right: 2px; }
.settings-group[open] > summary::after { transform: translateY(-2px) rotate(45deg); }
.settings-group > summary:is(:hover,:focus-visible) { background: var(--fill); }

#home .site-filing {
  justify-content: center;
  padding: 12px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--secondary);
}
.site-filing a {
  padding: 8px 12px;
  border-radius: 8px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-filing a:is(:hover, :focus-visible) { color: var(--label); }
.settings-group > summary:focus-visible { outline-offset: -3px; }
.settings-group > :last-child { margin-bottom: 14px; }
.settings-group:not([open]) > summary { margin-bottom: 0; }
#settings:has(#connectionStatus:not(:empty)) #connectionStatus { margin-block: 8px 12px; }

/* Crop the static image and its animation as one composition on short desktops. */
@media (min-width: 1050px) {
  :root[data-palette] .preview-home .hero-stage {
    max-height: max(min(397px, (100vw - var(--preview-gutter) * 2) / 3.33), calc(100svh - 380px));
  }
  .preview-home .hero-artwork {
    top: var(--hero-crop-anchor, 48%);
    transform: translateY(calc(-1 * var(--hero-crop-anchor, 48%)));
  }
  :root[data-palette="chiikawa"] .preview-home { --hero-crop-anchor: 70%; }
  :root[data-palette="afterglow"] .preview-home { --hero-crop-anchor: 84%; }
  :root[data-palette="fox"] .preview-home { --hero-crop-anchor: 58%; }
  :root[data-palette="sheep"] .preview-home { --hero-crop-anchor: 82%; }
  :root[data-palette="tiga"] .preview-home { --hero-crop-anchor: 46%; }
}
/* Keep the settings actions within reach on short mobile screens. */
@media (max-width: 480px) and (max-height: 680px) {
  #settings .palette-sample { height: 34px; margin-bottom: 2px; }
  #settings .palette-options { gap: 7px; }
  #settings .palette-options button { padding-block: 5px 6px; }
}
@media (pointer: coarse) {
  .global-bar .settings-button { width: 44px; height: 44px; }
  .global-bar .merged-tool > .component-name,
  .global-bar .component-controls > button { min-height: 44px; }
  .global-bar .component-controls { height: 44px; }
}

/* The wide artwork is composed for short desktops. Original artwork and its
   matching animated WebP remain paired at taller and narrower sizes. */
.preview-home .hero-artwork:has(.hero-image[data-hero-wide]) {
  inset: 0;
  aspect-ratio: auto;
  transform: none;
}
.preview-home .hero-stage .hero-image[data-hero-wide] {
  object-fit: cover;
  object-position: center var(--wide-art-position, 54%);
}
:root[data-palette="chiikawa"] .preview-home { --wide-art-position: 60%; }
:root[data-palette="sheep"] .preview-home { --wide-art-position: 60%; }

@media (prefers-reduced-motion: no-preference) {
  .hero-editorial[data-wide-playing] .hero-artwork::after {
    content: '';
    position: absolute;
    inset: -8%;
    pointer-events: none;
    background: radial-gradient(ellipse at var(--wide-light-origin, 42% 54%),
      var(--wide-light, #d8e2ff5c), transparent 47%);
    mix-blend-mode: screen;
    animation: wide-hero-light 8s ease-in-out infinite alternate;
  }
  :root[data-palette="afterglow"] .hero-editorial {
    --wide-light-origin: 65% 65%;
    --wide-light: #f8944266;
  }
  :root[data-palette="fox"] .hero-editorial,
  :root[data-palette="sheep"] .hero-editorial,
  :root[data-palette="chiikawa"] .hero-editorial {
    --wide-light-origin: 68% 24%;
    --wide-light: #ffe6a261;
  }
  :root[data-palette="tiga"] .hero-editorial {
    --wide-light-origin: 61% 45%;
    --wide-light: #92dfff5c;
  }
  @keyframes wide-hero-light {
    from { opacity: .23; transform: translate3d(-2%, 1%, 0); }
    to { opacity: .8; transform: translate3d(3%, -1%, 0); }
  }
}

@media (prefers-reduced-motion: no-preference) {
  :root[data-palette="tiga"] .hero-editorial[data-wide-playing] .hero-artwork::before {
    content: '';
    position: absolute;
    z-index: 1;
    inset: -36px;
    pointer-events: none;
    opacity: .17;
    background-image:
      radial-gradient(ellipse 1px 11px at 14px 16px, #b6d9f7, transparent),
      radial-gradient(ellipse 1px 8px at 53px 32px, #8cc8ed, transparent);
    background-size: 70px 48px, 89px 48px;
    animation: wide-hero-rain 560ms linear infinite;
  }
  @keyframes wide-hero-rain {
    from { transform: skewX(-8deg) translateY(-24px); }
    to { transform: skewX(-8deg) translateY(24px); }
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-editorial[data-crayon-playing] .hero-artwork::before,
  .hero-editorial[data-crayon-playing] .hero-artwork::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .hero-editorial[data-crayon-playing] .hero-artwork::before {
    background:
      radial-gradient(ellipse 9% 4% at 10% 81%, #fff5c87a, transparent 80%),
      radial-gradient(ellipse 4% 10% at var(--crayon-block-glint, 66% 64%), #ffdc6270, transparent 82%);
    mix-blend-mode: screen;
    animation: crayon-glints 6s ease-in-out infinite;
  }
  .hero-editorial[data-crayon-playing] .hero-artwork::after {
    background: radial-gradient(ellipse 26% 40% at 88% 1%, #62532645, transparent);
    mix-blend-mode: multiply;
    animation: crayon-tree-shadow 7s ease-in-out infinite alternate;
  }
  .hero-editorial[data-crayon-playing]:not(:has([data-hero-wide])) {
    --crayon-block-glint: 58% 78%;
  }
  @keyframes crayon-glints {
    0%, 62%, 100% { opacity: .16; }
    78% { opacity: .82; }
  }
  @keyframes crayon-tree-shadow {
    from { opacity: .26; transform: translateX(-.7%); }
    to { opacity: .54; transform: translateX(.5%); }
  }
}
