:root {
  --head-control-height: 2.75rem;
  --head-picker-width: 7rem;
  --head-menu-height: 15rem;
  --head-gap: 0.75rem;
  --head-padding: 0.75rem;
  --head-option-padding: 0.625rem;
  --head-font-size: 0.75rem;
  --head-icon-size: 0.75rem;
  --head-menu-surface: #172019;
  --head-control-surface: #202a22;
  --head-control-accent: var(--lime-bright);
  --head-selected-surface: #243023;
  --head-selected-ink: #14200f;
}

html[data-theme="brand"] {
  --head-menu-surface: #211e22;
  --head-control-surface: #29262a;
  --head-control-accent: var(--gold);
  --head-selected-surface: #3a2b25;
  --head-selected-ink: var(--obsidian);
}

/* Keep the copy icon's overlap colour in sync with its button surface. */
html[data-theme="brand"] :is(.copy-mini, #copy-head-command) {
  --copy-icon-bg: var(--head-control-surface);
  --mc-top: var(--mc-action-light);
  --mc-left: var(--ember-bright);
  --mc-right: var(--mc-action-dark);
  --mc-bottom: var(--mc-action-dark);
  background: var(--head-control-surface);
  color: var(--gold);
  border-color: var(--ember);
}

html[data-theme="brand"] :is(.copy-mini, #copy-head-command):is(:hover, :focus-visible, :active) {
  --copy-icon-bg: var(--ember-bright);
  background: var(--ember-bright);
  color: var(--obsidian);
  border-color: var(--gold);
}

html[data-theme="brand"] body #copy-head-command:is(:hover, :focus-visible, :active) {
  background: var(--ember-bright);
}

.head-command-panel {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--head-gap);
}

.head-command-panel .head-command-controls {
  display: grid;
  grid-template-columns: var(--head-picker-width) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--head-gap);
  min-width: 0;
}

.head-command-controls #head-command,
.head-command-controls #copy-head-command {
  height: var(--head-control-height);
}

.head-command-controls #head-command {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: center;
  font: 500 var(--head-font-size)/1.5 var(--pixel);
  max-inline-size: 100%;
  min-inline-size: 0;
  padding: 0 var(--head-padding);
  white-space: nowrap;
  overflow: hidden;
}

#head-command-value {
  flex: 0 0 auto;
  white-space: nowrap;
}

.head-command-controls #copy-head-command {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
}

.head-version-picker {
  position: relative;
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

.head-command-panel .head-version-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--head-gap);
  width: 100%;
  height: var(--head-control-height);
  padding: 0 var(--head-padding);
  background: var(--head-control-surface);
  color: var(--head-control-accent);
  font: 700 var(--head-font-size)/1 var(--pixel);
  border: var(--mc-pixel-small) solid var(--line);
  box-shadow: var(--mc-recessed);
}

.head-command-panel .head-version-trigger:is(:hover, [aria-expanded="true"]) {
  background-color: var(--head-selected-surface);
  border-color: var(--head-control-accent);
}

.head-version-chevron {
  width: var(--head-icon-size);
  height: var(--head-icon-size);
  flex: 0 0 auto;
}

.head-version-trigger[aria-expanded="true"] .head-version-chevron {
  transform: rotate(180deg);
}

.head-version-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + var(--mc-pixel));
  left: 0;
  width: 100%;
  max-height: min(var(--head-menu-height), var(--head-menu-available-height, var(--head-menu-height)));
  overflow-y: auto;
  padding: var(--mc-pixel);
  background: var(--head-menu-surface);
  color: var(--ink);
  border: var(--mc-pixel-small) solid var(--line);
  scrollbar-color: var(--head-control-accent) var(--head-menu-surface);
  scrollbar-width: thin;
}

.head-version-picker[data-placement="top"] .head-version-menu {
  top: auto;
  bottom: calc(100% + var(--mc-pixel));
}

.head-command-panel .head-version-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: var(--head-control-height);
  padding: 0 var(--head-option-padding);
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 var(--head-font-size)/1 var(--pixel);
}

.head-command-panel .head-version-option:is(:hover, :focus-visible) {
  background: var(--head-selected-surface);
  color: var(--head-control-accent);
  outline-offset: calc(-1 * var(--mc-pixel-small));
}

.head-command-panel .head-version-option[aria-selected="true"] {
  background: var(--head-control-accent);
  color: var(--head-selected-ink);
}

.head-version-option[aria-selected="true"]::after {
  content: '';
  width: var(--mc-pixel);
  height: var(--mc-pixel);
  background: currentColor;
}

/* Desktop controls share one row: version, command, copy. */
@media (min-width: 38.8125rem) {
  .head-command-panel .head-command-controls {
    grid-template-columns: var(--head-picker-width) minmax(0, 1fr) auto;
  }

  .head-command-controls #head-command {
    grid-column: 2;
    grid-row: 1;
  }

  .head-command-controls #copy-head-command {
    grid-column: 3;
    grid-row: 1;
  }
}

