.home-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  image-rendering: pixelated;
}

.panel-home {
  --home-control-size: 32px;
  --home-control-gap: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.home-toolbar {
  position: absolute;
  left: calc(var(--home-control-size) + var(--home-control-gap));
  bottom: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--home-control-gap) 0;
  max-width: calc(100% - 52px - var(--home-control-size) - var(--home-control-gap));
  padding: 6px 8px;
  border: 1px solid var(--hair);
  background: var(--panel);
}

.home-toolbar[hidden] {
  display: none;
}

.home-toolbar-toggle {
  position: absolute;
  left: 0;
  /* The toggle always sits at the panel edge; the toolbar follows after one
     control width plus the fixed gap. */
  bottom: 15px;
  z-index: 2;
}

.ht-group {
  display: flex;
  align-items: center;
  gap: var(--home-control-gap);
}

.ht-group + .ht-group {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--hair);
}

.ht-btn,
.home-toolbar-toggle {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--home-control-size);
  height: var(--home-control-size);
  min-width: var(--home-control-size);
  min-height: var(--home-control-size);
  max-width: var(--home-control-size);
  max-height: var(--home-control-size);
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line-b) 55%, transparent);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 1;
  cursor: pointer;
}

.ht-btn:hover,
.home-toolbar-toggle:hover {
  border-color: var(--line-b);
}

.ht-btn.is-active {
  opacity: 1;
  color: var(--line-c);
  outline: 2px solid var(--line-a);
  outline-offset: 2px;
}

.ht-btn:disabled {
  opacity: 1;
  border-color: var(--hair);
  cursor: default;
}

.ht-btn:focus-visible,
.home-toolbar-toggle:focus-visible {
  outline: 2px solid var(--line-a);
  outline-offset: 2px;
}

/* Hide the inactive toggle glyph only; the visible one keeps its own display
   (inline for the text fallback, grid for the pixel icon). */
.home-toolbar-toggle:not([aria-expanded="true"]) .ht-toggle-open,
.home-toolbar-toggle[aria-expanded="true"] .ht-toggle-closed {
  display: none;
}

@media (max-width: 760px) {
  .home-toolbar {
    right: 52px;
    bottom: 4px;
    max-width: none;
    padding: 4px 6px;
  }

  .home-toolbar-toggle {
    /* toolbar bottom (4px) + border (1px) + padding (4px) */
    bottom: 9px;
  }

  .ht-group + .ht-group {
    margin-left: 6px;
    padding-left: 6px;
  }
}
