# Theme Toggle Top-Bar Relocation Implementation Plan > **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Move the light/dark toggle from floating right-side UI into top-bar controls (left of settings), with consistent visibility and behavior across all user-facing views. **Architecture:** Introduce one reusable controls partial (`topbar-controls.php`) that owns toggle/settings markup, then reuse it from each page header. Keep theme state logic centralized in `theme.php` while removing floating positioning and binding behavior to the top-bar toggle IDs. Update all templates in `views/*.php` to ensure complete coverage and consistent top-bar placement. **Tech Stack:** PHP 8+, server-rendered views, Tailwind CDN utilities, Bootstrap Icons, cookie-based theme persistence. --- ## File Structure and Responsibilities - Create: `views/partials/topbar-controls.php` - Single responsibility: render top-bar controls (theme toggle always, settings link optionally). - Modify: `views/partials/theme.php` - Single responsibility: theme token CSS + initialization + toggle behavior script. - Remove floating button markup/CSS; keep runtime toggle logic. - Modify: `views/index.php` - Use shared top-bar controls in existing header with settings visible. - Modify: `views/vehicle.php` - Use shared top-bar controls in existing header with settings visible. - Modify: `views/settings.php` - Use shared top-bar controls in existing header with settings hidden. - Modify: `views/login.php` - Add slim top header + controls; preserve centered login card in main content area. - Modify: `views/setup.php` - Add slim top header + controls; preserve centered setup card in main content area. - Modify: `views/export.php` - Add theme partial includes and slim top header + controls, preserving export content. ## Chunk 1: Shared Controls + Theme Engine Refactor ### Task 1: Add reusable top-bar controls partial **Files:** - Create: `views/partials/topbar-controls.php` - [ ] **Step 1: Write `topbar-controls.php` with explicit include API defaults** ```php
Settings
``` - [ ] **Step 2: Run syntax check for new partial** Run: `php -l views/partials/topbar-controls.php` Expected: `No syntax errors detected in views/partials/topbar-controls.php` - [ ] **Step 3: Commit partial addition** ```bash git add views/partials/topbar-controls.php git commit -m "feat: add reusable top-bar controls partial" ``` ### Task 2: Refactor `theme.php` to stop rendering floating toggle **Files:** - Modify: `views/partials/theme.php` - [ ] **Step 1: Remove floating toggle CSS rules and keep focus-visible styling** Replace floating positioning block with only focus-visible rule: ```css #themeToggle:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; } ``` - [ ] **Step 2: Remove body-section button markup and keep JS behavior block** Delete the button HTML + `