/* Breaking the Scroll — unified theme toggle (all tools) */

.bts-theme-toggle {
  position: relative;
  flex-shrink: 0;
}

.bts-theme-toggle__segmented {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--cin-border, rgba(255, 122, 26, 0.22));
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="light"] .bts-theme-toggle__segmented {
  background: rgba(27, 27, 27, 0.04);
  border-color: rgba(217, 119, 6, 0.22);
}

.bts-theme-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--cin-muted, rgba(255, 255, 255, 0.72));
  font: 600 0.72rem/1 var(--cin-sans, Inter, system-ui, sans-serif);
  cursor: pointer;
  white-space: nowrap;
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.bts-theme-toggle__btn:hover {
  color: var(--cin-text, #fff);
  background: rgba(255, 255, 255, 0.06);
}

.bts-theme-toggle__btn.is-active {
  color: var(--cin-text, #fff);
  background: rgba(255, 106, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 26, 0.35);
}

html[data-theme="light"] .bts-theme-toggle__btn {
  color: rgba(27, 27, 27, 0.62);
}

html[data-theme="light"] .bts-theme-toggle__btn:hover {
  color: #1b1b1b;
  background: rgba(27, 27, 27, 0.05);
}

html[data-theme="light"] .bts-theme-toggle__btn.is-active {
  color: #9a3412;
  background: rgba(217, 119, 6, 0.14);
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.28);
}

.bts-theme-toggle__btn:focus-visible {
  outline: 2px solid var(--cin-accent, #ff6a00);
  outline-offset: 2px;
}

.bts-theme-toggle__icon {
  font-size: 0.95rem;
  line-height: 1;
}

/* Mobile dropdown */
.bts-theme-toggle__mobile {
  display: none;
  position: relative;
}

.bts-theme-toggle__menu-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--cin-border, rgba(255, 122, 26, 0.22));
  background: rgba(255, 255, 255, 0.04);
  color: var(--cin-text, #fff);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}

html[data-theme="light"] .bts-theme-toggle__menu-btn {
  background: rgba(27, 27, 27, 0.04);
  color: #1b1b1b;
}

.bts-theme-toggle__menu-btn:hover,
.bts-theme-toggle__menu-btn[aria-expanded="true"] {
  border-color: var(--cin-accent, #ff6a00);
}

.bts-theme-toggle__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--cin-border, rgba(255, 122, 26, 0.22));
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 300;
}

html[data-theme="light"] .bts-theme-toggle__menu {
  background: rgba(248, 244, 237, 0.98);
  border-color: rgba(217, 119, 6, 0.22);
  box-shadow: 0 12px 32px rgba(27, 27, 27, 0.12);
}

.bts-theme-toggle__menu.is-hidden {
  display: none;
}

.bts-theme-toggle__menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cin-text, #fff);
  font: 500 0.85rem/1.2 var(--cin-sans, Inter, system-ui, sans-serif);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease;
}

html[data-theme="light"] .bts-theme-toggle__menu-item {
  color: #1b1b1b;
}

.bts-theme-toggle__menu-item:hover,
.bts-theme-toggle__menu-item.is-active {
  background: rgba(255, 106, 0, 0.16);
}

html[data-theme="light"] .bts-theme-toggle__menu-item.is-active {
  background: rgba(217, 119, 6, 0.14);
  color: #9a3412;
}

.bts-theme-toggle__menu-item:focus-visible {
  outline: 2px solid var(--cin-accent, #ff6a00);
  outline-offset: 1px;
}

@media (max-width: 640px) {
  .bts-theme-toggle__segmented {
    display: none;
  }
  .bts-theme-toggle__mobile {
    display: block;
  }
}

/* Login page floating toggle */
.login-theme-mount {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 100;
}

/* Global smooth theme transitions */
html.theme-transitions,
html.theme-transitions body,
html.theme-transitions .bts-tool-nav,
html.theme-transitions .lm-header,
html.theme-transitions .rf-top,
html.theme-transitions .ns-header,
html.theme-transitions .access-card,
html.theme-transitions .lm-card,
html.theme-transitions .rf-messages,
html.theme-transitions .ns-card,
html.theme-transitions .ss-surface,
html.theme-transitions .bts-theme-toggle__btn,
html.theme-transitions .bts-theme-toggle__menu-btn {
  transition:
    background 280ms ease,
    background-color 280ms ease,
    color 280ms ease,
    border-color 280ms ease,
    box-shadow 280ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-transitions,
  html.theme-transitions * {
    transition-duration: 0.01ms !important;
  }
}

/* Legacy homepage toggle (keep working) */
.theme-toggle__btn.is-active {
  color: var(--cin-text, #fff);
  background: rgba(255, 106, 0, 0.22);
}
