/* ═══════════════════════════════════════════════════════════════════════════
   Surface-Driven Design System
   Hierarchy via background contrast, spacing, and type — not outlines.
   Themes: light (default) · dark
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Geometry — concentric: outer = inner + padding */
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Motion — Emil design-eng budgets; strong custom curves */
  --duration: 160ms;
  --duration-press: 140ms;
  --duration-toast: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --transition: var(--duration) var(--ease);

  /* Touch — 44px min hit (better-ui) */
  --target-min: 44px;

  /* Type scale (better-typography) */
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  --text-xs: 0.75rem; /* 12px floor */
  --text-sm: 0.875rem; /* 14px UI */
  --text-base: 1rem; /* 16px body */
  --text-md: 1.125rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-body: 1.55;
  --tracking-tight: -0.025em;
  --tracking-label: 0.06em;

  /* Brand — OKLCH, constant hue ~264° (better-colors) */
  --primary: oklch(0.55 0.2 264);
  --primary-hover: oklch(0.48 0.19 264);
  --primary-foreground: oklch(0.99 0 0);
  --info: oklch(0.55 0.2 264);

  --success: oklch(0.62 0.14 165);
  --warning: oklch(0.7 0.15 55);
  --destructive: oklch(0.58 0.21 25);

  /* Legacy aliases */
  --bg: var(--background);
  --text: var(--foreground);
  --muted: var(--muted-foreground);
  --accent: var(--primary);
  --danger: var(--destructive);
  --radius: var(--radius-lg);
  --radius-sm-legacy: var(--radius-sm);
}

/* ── Light theme (default) — high L gap for AA contrast ───────────────────── */

:root,
[data-theme="light"] {
  color-scheme: light;

  --background: oklch(1 0 0);
  --foreground: oklch(0.21 0.006 286);

  --surface-raised: oklch(1 0 0);
  --surface-default: oklch(0.967 0.001 286);
  --surface-recessed: oklch(0.94 0.002 286);
  --surface-hover: oklch(0.92 0.002 286);

  --muted-foreground: oklch(0.48 0.014 286);
  --subtle-foreground: oklch(0.62 0.01 286);

  --primary-soft: oklch(0.55 0.2 264 / 0.12);
  --primary-soft-strong: oklch(0.55 0.2 264 / 0.18);

  --divider: oklch(0.9 0.004 286);

  --success-soft: oklch(0.62 0.14 165 / 0.12);
  --warning-soft: oklch(0.7 0.15 55 / 0.12);
  --destructive-soft: oklch(0.58 0.21 25 / 0.12);
  --info-soft: oklch(0.55 0.2 264 / 0.12);

  --shadow-float:
    0 12px 40px oklch(0 0 0 / 0.1),
    0 2px 8px oklch(0 0 0 / 0.04);
  --shadow-chip: 0 4px 14px oklch(0 0 0 / 0.08);
  --shadow-soft: 0 1px 2px oklch(0 0 0 / 0.06), 0 4px 12px oklch(0 0 0 / 0.04);
  --image-shadow: drop-shadow(0 18px 24px oklch(0 0 0 / 0.12));
  --image-outline: oklch(0 0 0 / 0.1);
  --inset-edge: inset 0 0 0 1px oklch(0 0 0 / 0.06);
  --selection-bg: oklch(0.55 0.2 264 / 0.22);
  --selection-fg: oklch(0.18 0.02 264);
}

/* ── Dark theme — reverse L mapping, same hues ────────────────────────────── */

[data-theme="dark"] {
  color-scheme: dark;

  --background: oklch(0.16 0.008 286);
  --foreground: oklch(0.97 0.002 286);

  --surface-raised: oklch(0.22 0.008 286);
  --surface-default: oklch(0.16 0.008 286);
  --surface-recessed: oklch(0.19 0.008 286);
  --surface-hover: oklch(0.28 0.01 286);

  --muted-foreground: oklch(0.72 0.014 286);
  --subtle-foreground: oklch(0.55 0.012 286);

  --primary: oklch(0.68 0.16 264);
  --primary-hover: oklch(0.74 0.14 264);
  --primary-foreground: oklch(0.99 0 0);
  --primary-soft: oklch(0.68 0.16 264 / 0.16);
  --primary-soft-strong: oklch(0.68 0.16 264 / 0.24);

  --divider: oklch(0.3 0.01 286);

  --success: oklch(0.72 0.14 165);
  --warning: oklch(0.78 0.14 70);
  --destructive: oklch(0.7 0.16 25);
  --info: oklch(0.68 0.16 264);

  --success-soft: oklch(0.72 0.14 165 / 0.14);
  --warning-soft: oklch(0.78 0.14 70 / 0.14);
  --destructive-soft: oklch(0.7 0.16 25 / 0.14);
  --info-soft: oklch(0.68 0.16 264 / 0.14);

  --shadow-float:
    0 16px 48px oklch(0 0 0 / 0.45),
    0 2px 8px oklch(0 0 0 / 0.3);
  --shadow-chip: 0 4px 16px oklch(0 0 0 / 0.35);
  --shadow-soft: 0 1px 2px oklch(0 0 0 / 0.35), 0 8px 24px oklch(0 0 0 / 0.25);
  --image-shadow: drop-shadow(0 18px 28px oklch(0 0 0 / 0.5));
  --image-outline: oklch(1 0 0 / 0.1);
  --inset-edge: inset 0 0 0 1px oklch(1 0 0 / 0.08);
  --selection-bg: oklch(0.68 0.16 264 / 0.35);
  --selection-fg: oklch(0.99 0 0);
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 400;
  font-synthesis: none;
  font-optical-sizing: auto;
  line-height: var(--leading-body);
  color: var(--foreground);
  background: var(--surface-default);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

p,
.hint,
.about-lead,
.about-copy {
  text-wrap: pretty;
  line-height: var(--leading-body);
}

/* Quiet page wash — surface contrast, no decorative multi-accent glow */
.bg-layer {
  position: fixed;
  inset: 0;
  background: var(--surface-default);
  z-index: 0;
}

.bg-layer::after {
  display: none;
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 8px 20px 16px;
  gap: 14px;
}

/* Focus ring — primary accent only */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Top chrome: flat header + underline tabs ─────────────────────────────── */

.top-chrome {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

/* Title bar — flat, no raised surface */
.titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 2px 10px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.titlebar-left,
.titlebar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.titlebar-right {
  justify-content: flex-end;
}

.titlebar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Brand mark — assets/nibble.svg */
.brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 7px;
  display: block;
  object-fit: contain;
  box-shadow: var(--shadow-soft);
}

.brand-logo.about-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.title-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--foreground);
  white-space: nowrap;
  text-wrap: balance;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15em;
  height: 1.15em;
  padding: 0 5px;
  margin-left: 3px;
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  vertical-align: 0.1em;
  white-space: nowrap;
}

.version {
  color: var(--subtle-foreground);
  font-size: var(--text-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.device-picker,
.profile-chip {
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

/* Quiet compact selects for chrome only */
.select-quiet,
.titlebar select {
  background: transparent;
  color: var(--foreground);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 32px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: background var(--transition);
}

.select-quiet:hover,
.titlebar select:hover {
  background: var(--surface-hover);
}

.select-quiet:focus-visible,
.titlebar select:focus-visible {
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--primary);
}

.btn-compact {
  min-height: 40px !important;
  min-width: 40px;
  padding: 8px 14px !important;
  font-size: var(--text-sm) !important;
  border-radius: var(--radius-sm);
}

/* Theme toggle — 40px hit, icon cross-fade (better-ui) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 40px;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition-property: background-color, color, transform;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
  flex-shrink: 0;
  user-select: none;
}

.theme-toggle:active {
  transform: scale(0.97);
  transition-property: transform;
  transition-duration: var(--duration-press);
  transition-timing-function: var(--ease-out);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
  position: absolute;
  transition-property: opacity, transform;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease-out);
}

.theme-toggle .icon-moon {
  opacity: 1;
  transform: scale(1);
}

.theme-toggle .icon-sun {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

/* ── Form controls — surface, not borders ─────────────────────────────────── */

select,
.inline-input,
input[type="number"].num,
input[type="text"],
input[type="number"] {
  background: var(--surface-recessed);
  color: var(--foreground);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: var(--target-min);
  font: inherit;
  font-size: max(16px, 1em); /* avoid iOS zoom (better-typography) */
  outline: none;
  transition-property: background-color, box-shadow;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
}

select:hover,
.inline-input:hover,
input[type="number"].num:hover,
input[type="text"]:hover,
input[type="number"]:hover {
  background: var(--surface-hover);
}

select:focus-visible,
.inline-input:focus-visible,
input[type="number"].num:focus-visible,
input[type="text"]:focus-visible,
input[type="number"]:focus-visible {
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--primary-soft-strong), 0 0 0 4px var(--primary);
}

/* Connection — text + dot only */
.connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 4px;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: 0.78rem;
  color: var(--success);
  font-weight: 500;
  white-space: nowrap;
}

.connection .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: none;
  flex-shrink: 0;
}

.connection.offline {
  background: transparent;
  color: var(--muted-foreground);
}

.connection.offline .dot {
  background: var(--subtle-foreground);
  box-shadow: none;
}

.connection.warn {
  background: transparent;
  color: var(--warning);
}

.connection.warn .dot {
  background: var(--warning);
  box-shadow: none;
}

/* Battery */
.battery {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

.battery-shell {
  width: 22px;
  height: 11px;
  border: 0;
  border-radius: 2px;
  padding: 1.5px;
  position: relative;
  background: var(--surface-hover);
}

.battery-shell::after {
  content: "";
  position: absolute;
  right: -2.5px;
  top: 3px;
  width: 1.5px;
  height: 5px;
  background: var(--subtle-foreground);
  border-radius: 0 1px 1px 0;
}

.battery-level {
  height: 100%;
  width: 87%;
  border-radius: 1px;
  background: var(--success);
}

/* ── Tabs — text + underline active state ─────────────────────────────────── */

.tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;
  z-index: 21;
  pointer-events: auto;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px 14px;
  margin-bottom: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 1;
  user-select: none;
  transition-property: color, background-color;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
}

.tab span {
  pointer-events: none;
}

.tab .tab-note {
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
  pointer-events: none;
}

.tab img {
  display: none;
}

.tab:active {
  transform: scale(0.97);
}

.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: none;
}

.tab.active img {
  display: none;
}

.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

/* ── Content ──────────────────────────────────────────────────────────────── */

.content {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.panel {
  display: none !important;
}

.panel.active {
  display: block !important;
  min-height: 1px;
  /* No enter animation — tab switches are high-frequency */
}

main.content > section.panel.active {
  display: block !important;
  min-height: 1px;
}

/* Cards = raised surface; soft layered shadow (better-ui shadows over borders) */
.card {
  background: var(--surface-raised);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 18px 20px; /* outer 16 + ~2 visual → inner controls at --radius-sm 8 */
  box-shadow: var(--shadow-soft);
}

.card h3,
.mouse-map h3 {
  margin: 0 0 4px;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--foreground);
  text-wrap: balance;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  max-width: 65ch;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-recessed);
  color: var(--foreground);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* ── Home bento ───────────────────────────────────────────────────────────── */

.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto auto auto;
  gap: 12px;
  min-height: min(64vh, 560px);
  align-content: start;
}

.bento-tile {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 14px 8px;
  min-width: 0;
  box-shadow: none;
}

.bento-hero {
  grid-column: 1 / 3;
  grid-row: 1 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  min-height: 360px;
  padding: 20px 8px;
  background: transparent;
}

.bento-hero img {
  max-width: min(280px, 78%);
  height: auto;
  position: relative;
  z-index: 1;
  filter: var(--image-shadow);
  user-select: none;
  pointer-events: none;
}

.bento-hero-text {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: 18px;
}

.bento-hero-text h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.bento-hero-text p {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  text-wrap: pretty;
}

/* Kept for light-tab preview hook; no wash on home */
.stage-glow {
  display: none;
}

/* Light preview is static — no idle loop (functional tool UI) */

.mouse-map,
.light-preview {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.map-wrap img,
.light-preview img {
  max-width: min(300px, 72%);
  height: auto;
  position: relative;
  z-index: 1;
  filter: var(--image-shadow);
  user-select: none;
  pointer-events: none;
}

.bento-dpi {
  grid-column: 3;
  grid-row: 1;
}

.bento-rate {
  grid-column: 4;
  grid-row: 1;
}

.bento-light {
  grid-column: 3 / 5;
  grid-row: 2;
}

.bento-mode {
  grid-column: 3;
  grid-row: 3;
}

.bento-battery {
  grid-column: 4;
  grid-row: 3;
}

.bento-battery.is-charging .stat-value {
  color: var(--success);
}

.bento-battery.is-charging .stat-sub {
  color: var(--success);
  font-weight: 600;
}

.bento-actions {
  grid-column: 1 / 5;
  grid-row: 4;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  padding: 16px 20px;
}

.bento-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 112px;
}

.stat-label {
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-weight: 500;
  line-height: var(--leading-snug);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--foreground);
}

.stat-value.small {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
}

.stat-sub {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  min-height: 1.2em;
  line-height: var(--leading-snug);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}



.swatch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted-foreground);
  box-shadow: none;
  flex-shrink: 0;
}

.bento-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bento-actions .hint {
  margin: 0;
  font-size: 0.8rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ── Keys ─────────────────────────────────────────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.mouse-map {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 4px 4px 0;
}

.map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.map-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0 8px;
  min-height: 400px;
  background: transparent;
}

#key-hotspots {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  z-index: 2;
  min-height: var(--target-min);
  transition: transform var(--transition);
}

.hotspot:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.hotspot.left {
  flex-direction: row;
}

.hotspot.right {
  flex-direction: row-reverse;
}

.hotspot.top {
  flex-direction: column;
}

.hotspot.bottom {
  flex-direction: column-reverse;
}

.hotspot .pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 0;
  background: var(--primary-soft-strong);
  box-shadow: 0 0 0 3px var(--primary-soft);
  transition: background var(--transition), box-shadow var(--transition);
}

.hotspot .label {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 0;
  font-size: 0.8rem;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--foreground);
  box-shadow: var(--shadow-chip);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.hotspot:hover .pin,
.hotspot.active .pin {
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.hotspot:hover .label {
  background: var(--surface-hover);
}

.hotspot.active .label {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.selected-key {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 0;
  font-weight: 600;
  color: var(--primary);
}

.func-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 520px;
  overflow: auto;
}

.func-group h4 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  font-weight: 500;
}

.func-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.func-options button {
  text-align: left;
  min-height: var(--target-min);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--surface-recessed);
  color: var(--foreground);
  font: inherit;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.func-options button:hover {
  background: var(--surface-hover);
}

.func-options button:active {
  transform: scale(0.97);
}

.func-options button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.func-options button.unproven {
  opacity: 0.45;
  cursor: not-allowed;
}

.func-options button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

/* ── DPI ──────────────────────────────────────────────────────────────────── */

.dpi-layout,
.light-layout,
.macro-layout,
.settings-grid {
  display: grid;
  gap: 12px;
}


.dpi-layout {
  grid-template-columns: 1.4fr 0.8fr;
}

.dpi-stages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.dpi-stage {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: var(--target-min);
  border-radius: var(--radius-md);
  border: 0;
  background: var(--surface-recessed);
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition);
}

.dpi-stage:hover {
  background: var(--surface-hover);
}

.dpi-stage:active {
  transform: scale(0.97);
}

.dpi-stage.active {
  background: var(--primary-soft);
}

.dpi-stage .swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 0;
  box-shadow: none;
}

.dpi-stage .name {
  font-weight: 600;
  color: var(--foreground);
}

.dpi-stage .value {
  font-family: var(--mono);
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.dpi-stage .active-tag {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
  font-weight: 600;
  opacity: 0;
}

.dpi-stage.active .active-tag {
  opacity: 1;
}

.dpi-editor {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 12px;
  align-items: end;
  padding-top: 16px;
  margin-top: 4px;
  background: transparent;
}

.dpi-editor label,
.sliders label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 28px;
  cursor: pointer;
}

.color-label {
  align-items: flex-start;
}

input[type="color"] {
  width: 48px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-recessed);
  padding: 4px;
  cursor: pointer;
}

input[type="color"]:hover {
  background: var(--surface-hover);
}

.rate-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rate-options button {
  min-height: 72px;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  border: 0;
  background: var(--surface-recessed);
  color: var(--foreground);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.rate-options button:hover {
  background: var(--surface-hover);
}

.rate-options button:active {
  transform: scale(0.97);
}

.rate-options button span {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted-foreground);
}

.rate-options button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.rate-options button.active span {
  color: color-mix(in srgb, var(--primary) 75%, var(--muted-foreground));
}

.rate-options button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

/* ── Lighting ─────────────────────────────────────────────────────────────── */

.light-layout {
  grid-template-columns: 0.85fr 1.25fr;
  align-items: start;
}

/* Free-standing mouse preview — no panel behind image */
.light-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  position: relative;
  overflow: visible;
  padding: 16px 8px;
}

.light-orb {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary), transparent 72%);
  filter: blur(32px);
  opacity: 0.45;
  animation: none;
  pointer-events: none;
  z-index: 0;
}

.light-preview .hint {
  position: relative;
  z-index: 1;
  margin-top: 18px;
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.effect-grid button {
  min-height: var(--target-min);
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 0;
  background: var(--surface-recessed);
  color: var(--foreground);
  font: inherit;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.effect-grid button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.effect-grid button:active:not(:disabled) {
  transform: scale(0.97);
}

.effect-grid button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--subtle-foreground);
}

.effect-grid button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.effect-grid button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

.sliders {
  display: grid;
  gap: 14px;
}

.sliders label {
  display: grid;
  grid-template-columns: 100px 1fr 48px;
  align-items: center;
  gap: 12px;
}

.sliders .color-label {
  grid-template-columns: 100px auto;
}

/* ── Macro (not planned) ─────────────────────────────────────────────────── */

.not-planned-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(52vh, 420px);
  padding: 24px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.not-planned-center p {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
}

.macro-layout {
  grid-template-columns: 0.7fr 1.3fr;
}

.macro-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 480px;
  overflow: auto;
}

.macro-list li {
  padding: 12px 14px;
  min-height: var(--target-min);
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--surface-recessed);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.macro-list li:hover {
  background: var(--surface-hover);
}

.macro-list li:active {
  transform: scale(0.97);
}

.macro-list li.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.macro-list li .count {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 400;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.macro-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.event-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-recessed);
}

.event-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.event-table th,
.event-table td {
  padding: 12px 14px;
  text-align: left;
  border: 0;
}

.event-table th {
  position: sticky;
  top: 0;
  background: var(--surface-hover);
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.event-table tbody tr:nth-child(even) td {
  background: var(--surface-hover);
}

.event-table .del {
  border: 0;
  background: transparent;
  color: var(--destructive);
  cursor: pointer;
  font: inherit;
  min-width: var(--target-min);
  min-height: var(--target-min);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.event-table .del:hover {
  background: var(--destructive-soft);
}

/* ── Settings ─────────────────────────────────────────────────────────────── */

.settings-grid {
  grid-template-columns: 1fr 1fr;
}

.settings-grid .card:last-child {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border: 0;
}

.field:last-of-type {
  padding-bottom: 4px;
}

.field label {
  font-weight: 500;
  color: var(--foreground);
}

.field > div:first-child {
  min-width: 0;
}

.num {
  width: 88px;
  text-align: center;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-recessed);
  border: 0;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.segmented button:hover {
  color: var(--foreground);
  background: color-mix(in srgb, var(--surface-hover) 80%, transparent);
}

.segmented button:active {
  transform: scale(0.97);
}

.segmented button.active {
  background: var(--surface-raised);
  color: var(--primary);
  font-weight: 600;
  /* Soft elevation for selected segment within recessed track */
  box-shadow: var(--shadow-soft);
}

.segmented button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

/* Switch — surface track, primary when on */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-block;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch span {
  position: absolute;
  inset: 0;
  background: var(--surface-hover);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}

.switch span::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: var(--surface-raised);
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-soft);
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::before {
  transform: translateX(20px);
}

.switch input:focus-visible + span {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0 16px;
}

.meta-grid div {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-recessed);
  border: 0;
}

.meta-grid span {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.meta-grid strong {
  color: var(--foreground);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── About ────────────────────────────────────────────────────────────────── */

.about-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 0 24px;
}

.about-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.about-brand h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.about-tagline {
  margin: 2px 0 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.about-lead {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--foreground);
  opacity: 0.92;
}

.about-copy {
  margin: 0 0 12px;
  line-height: 1.55;
  max-width: 58ch;
}

.about-meta {
  margin-top: 4px;
}

.about-list {
  margin: 0 0 12px;
  padding-left: 1.2em;
  line-height: 1.6;
  color: var(--foreground);
}

.about-list li {
  margin: 0.25em 0;
}

.about-page .card h3 {
  margin-top: 0;
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  min-height: var(--target-min);
  min-width: 40px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-snug);
  cursor: pointer;
  /* Color can use default ease; transform snaps with ease-out for press feedback */
  transition-property: background-color, color, transform, box-shadow, filter;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
  gap: 6px;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  transition-property: transform;
  transition-duration: var(--duration-press);
  transition-timing-function: var(--ease-out);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.sm {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.85rem;
}

.btn.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
}

.btn.secondary {
  background: var(--surface-recessed);
  color: var(--foreground);
}

.btn.ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.btn.danger {
  background: var(--destructive-soft);
  color: var(--destructive);
  font-weight: 600;
}

.btn.danger:hover:not(:disabled) {
  background: oklch(0.58 0.21 25 / 0.18);
}

[data-theme="dark"] .btn.danger:hover:not(:disabled) {
  background: oklch(0.7 0.16 25 / 0.22);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-soft-strong);
}

/* ── Status bar ───────────────────────────────────────────────────────────── */

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface-raised);
  border: 0;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

.statusbar .btn {
  min-height: 40px;
}

.spacer {
  flex: 1;
}

/* ── Toast — floating elevation allowed ───────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  /* Percentage Y so height-independent (Sonner/Emil pattern) */
  transform: translateX(-50%) translateY(40%);
  background: var(--surface-raised);
  border: 0;
  color: var(--foreground);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  z-index: 50;
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: var(--duration-toast);
  transition-timing-function: var(--ease-out);
  pointer-events: none;
  font-weight: 500;
  font-size: var(--text-sm);
}

.hotspot:hover {
  opacity: 1;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modern entry without JS mount flag when supported */
@supports (animation-timeline: auto) {
  .toast.show {
    transition-behavior: allow-discrete;
  }
}

/* ── Scrollbars (subtle) ──────────────────────────────────────────────────── */

.content::-webkit-scrollbar,
.func-groups::-webkit-scrollbar,
.macro-list::-webkit-scrollbar,
.event-table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.content::-webkit-scrollbar-track,
.func-groups::-webkit-scrollbar-track,
.macro-list::-webkit-scrollbar-track,
.event-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.content::-webkit-scrollbar-thumb,
.func-groups::-webkit-scrollbar-thumb,
.macro-list::-webkit-scrollbar-thumb,
.event-table-wrap::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 999px;
}

.content::-webkit-scrollbar-thumb:hover,
.func-groups::-webkit-scrollbar-thumb:hover,
.macro-list::-webkit-scrollbar-thumb:hover,
.event-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--subtle-foreground);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100%;
  }

  .titlebar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 8px;
  }

  .titlebar-right,
  .titlebar-center {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .title-block {
    flex-wrap: wrap;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    padding: 10px 12px;
    font-size: 0.84rem;
  }

  .bento {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    min-height: 0;
  }

  .bento-hero {
    grid-column: 1 / 3;
    grid-row: auto;
    min-height: 280px;
  }

  .bento-dpi,
  .bento-rate,
  .bento-light,
  .bento-mode,
  .bento-battery,
  .bento-actions {
    grid-column: auto;
    grid-row: auto;
  }

  .bento-light,
  .bento-actions {
    grid-column: 1 / 3;
  }

  .split,
  .dpi-layout,
  .light-layout,
  .macro-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .map-header {
    flex-wrap: wrap;
  }

  .meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .func-options {
    grid-template-columns: 1fr;
  }

  .effect-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dpi-editor {
    grid-template-columns: 1fr;
  }

  .sliders label {
    grid-template-columns: 1fr;
  }
}

/* Reduced motion: keep color/opacity feedback, kill travel & scale */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .toast,
  .theme-toggle svg,
  .btn,
  .tab,
  .theme-toggle {
    transition-duration: 80ms !important;
  }

  .toast {
    transform: translateX(-50%) translateY(0) !important;
  }

  .btn:active:not(:disabled),
  .theme-toggle:active,
  .tab:active {
    transform: none !important;
  }

  .theme-toggle .icon-sun,
  .theme-toggle .icon-moon {
    transform: none !important;
    filter: none !important;
  }
}

/* Hover polish only for fine pointers (touch devices get sticky “hover” otherwise) */
@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover:not(:disabled) {
    background: var(--primary-hover);
  }

  .btn.secondary:hover:not(:disabled) {
    background: var(--surface-hover);
  }

  .btn.ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--foreground);
  }

  .tab:hover {
    background: var(--surface-hover);
    color: var(--foreground);
  }

  .theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--foreground);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Landing Screen
   ═══════════════════════════════════════════════════════════════════════════ */
.landing-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-bg);
  z-index: 1000;
  animation: fadeIn var(--duration) var(--ease-out);
}

.landing-content {
  text-align: center;
  max-width: 800px;
  padding: 40px;
}

.landing-logo {
  margin-bottom: 24px;
}

.landing-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.landing-subtitle {
  font-size: var(--text-md);
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.landing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
  margin-bottom: 40px;
}

.landing-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 200px;
  cursor: pointer;
  transition: var(--transition);
}

.landing-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.landing-card img {
  width: 100%;
  height: auto;
  margin-bottom: 16px;
}

.landing-card h3 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* ── Tooltips ────────────────────────────────────────────────────────────── */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  cursor: help;
  position: relative;
  border: 1px solid var(--divider);
  vertical-align: middle;
}

.info-icon:hover {
  background: var(--surface-hover);
  color: var(--foreground);
}

.info-icon::after {
  content: attr(data-info);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 260px;
  background: var(--surface-default);
  color: var(--foreground);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--divider);
  z-index: 100;
  text-align: left;
}

.info-icon:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}
