/* Theme switcher: a neutral floating control that reads over dark and light themes.
 * Position it per theme with CSS variables on :root, e.g.
 *   :root { --ts-left: auto; --ts-right: 16px; --ts-bottom: 88px; }
 * Defaults: bottom-left, 16px from the edges, above the safe area.
 */
.ts,
.ts * {
  box-sizing: border-box;
  margin: 0;
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}

.ts {
  position: fixed;
  z-index: var(--ts-z, 900);
  left: var(--ts-left, 16px);
  right: var(--ts-right, auto);
  top: var(--ts-top, auto);
  bottom: calc(var(--ts-bottom, 16px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  font: 500 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #fff;
  background: rgba(17, 17, 20, 0.8);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.ts-title-inline {
  padding: 0 6px 0 10px;
  color: rgba(255, 255, 255, 0.75);
}

.ts-list {
  display: flex;
  gap: 2px;
  padding: 0;
  list-style: none;
}

.ts-opt {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.ts-opt:hover { background: rgba(255, 255, 255, 0.14); }
.ts-opt[aria-current="page"] {
  background: #fff;
  color: #111;
  font-weight: 600;
}

.ts-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.ts-toggle .ts-title { color: rgba(255, 255, 255, 0.75); }
.ts-toggle .ts-now { font-weight: 600; }
.ts-chev {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ts-open .ts-chev { transform: rotate(180deg); }

/* Visible focus on any background: white ring with a dark halo. */
.ts a:focus-visible,
.ts button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #111;
}

/* Phones: collapse into one small pill that opens a menu upward. */
@media (max-width: 640px) {
  .ts { left: var(--ts-left, 12px); bottom: calc(var(--ts-bottom, 12px) + env(safe-area-inset-bottom, 0px)); }
  .ts-opt { min-height: 44px; padding: 0 14px; }
  .ts.ts-js { padding: 2px; }
  .ts.ts-js .ts-toggle { display: inline-flex; }
  .ts.ts-js .ts-title-inline { display: none; }
  .ts.ts-js .ts-list {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    display: none;
    flex-direction: column;
    min-width: 100%;
    padding: 6px;
    border-radius: 18px;
    background: rgba(17, 17, 20, 0.92);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
  .ts.ts-js.ts-open .ts-list { display: flex; }
  .ts.ts-js .ts-opt { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .ts-opt, .ts-toggle { transition: background-color 0.15s ease, color 0.15s ease; }
  .ts-chev { transition: transform 0.2s ease; }
}

@media (forced-colors: active) {
  .ts, .ts.ts-js .ts-list { border: 1px solid CanvasText; }
  .ts-opt[aria-current="page"] { outline: 2px solid CanvasText; }
}

@media print {
  .ts { display: none; }
}
