.theme-picker {
  position: relative;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-color);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle[aria-expanded="true"] {
  color: var(--link-hover-color);
  background: var(--bg-subtle);
  border-color: var(--accent-color);
}

.theme-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.theme-popover {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 10rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.theme-popover[hidden] {
  display: none;
}

.theme-popover fieldset {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-option {
  position: relative;
}

.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.theme-option label {
  display: block;
  padding: 0.4rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.3;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.theme-option label:hover {
  background: var(--bg-subtle);
  border-color: var(--border-color);
}

.theme-option input:checked + label {
  background: var(--bg-subtle);
  border-color: var(--accent-color);
  color: var(--link-hover-color);
  font-weight: 600;
}

.theme-option input:focus-visible + label {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.theme-option input {
  accent-color: var(--accent-color);
  cursor: pointer;
}
