/* 模块：设置模态框 / Settings modal layout, sliders, and custom color UI. */
/* 设置弹窗与遮罩 */
#settings-backdrop {
  position: fixed;
  top: 0; /* 覆盖到视口顶部，确保在窄视图下不留缝隙 */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 1600; /* 提升到高于页眉的级别，避免被 header 露出缝隙 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}
#settings-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#settings-backdrop,
#settings-modal,
#settings-modal * {
	/* ensure the settings overlay itself never shows Android tap highlights */
	-webkit-tap-highlight-color: transparent;
	tap-highlight-color: transparent;
}
#settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 880px;
  width: calc(100vw - 48px);
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 20px 50px var(--shadow-color);
  z-index: 1620; /* 高于遮罩，确保模态位于最上层 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(.2,.8,.2,1), transform 220ms cubic-bezier(.2,.8,.2,1), visibility 200ms cubic-bezier(.2,.8,.2,1);
}
#settings-modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#settings-modal .modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#settings-modal .modal-title {
  font-weight: 600;
  font-size: 1.25rem;
}
#settings-modal .modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  color: inherit;
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.15s ease, border 0.15s ease, transform 0.15s ease;
}
#settings-modal .modal-close:hover {
  background: var(--hover-bg);
  border-color: var(--border-color);
}
#settings-modal .modal-close:active {
  transform: scale(0.97);
  background: var(--active-bg);
  border-color: var(--border-color);
}

/* ensure the icon inside the button is vertically and horizontally centered using flex */
#settings-modal .modal-close i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 18px; /* icon size tuned to center visually */
  transform: none;
  line-height: normal; /* avoid relying on line-height for centering */
}
#settings-modal .modal-body {
  padding: 12px 16px 16px;
  display: grid;
  gap: 12px;
}

.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-layout-nav {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-layout-nav::-webkit-scrollbar {
  height: 6px;
}

.settings-layout-nav::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 999px;
}

.settings-category-tab {
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  background: var(--secondary-bg);
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  flex: 0 0 auto;
}

.settings-category-tab:hover {
  background: var(--hover-bg);
  border-color: var(--border-color);
}

.settings-category-tab:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.settings-category-tab.active {
  background: linear-gradient(135deg, var(--primary-color), rgba(var(--primary-color-rgb, 51,204,153), 0.55));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.settings-layout-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-category-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 0;
  overflow: visible;
}

.settings-category-panel[data-category="about"] {
  padding-bottom: 10px;
}

.settings-category-panel.active {
  display: flex;
}

.settings-section .settings-dropdown,
.settings-section .color-picker-row {
  align-self: center;
}

.info-value {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--text-muted, #6b7280);
  text-align: left;
  word-break: break-word;
  width: 100%;
}

@media (max-width: 600px) {
  .settings-layout-nav {
    gap: 6px;
  }
  .settings-category-tab {
    padding: 6px 12px;
    font-size: 0.9rem;
  }
}

.settings-loading {
  color: var(--text-muted, #6b7280);
  text-align: center;
  font-size: 0.95rem;
  padding: 28px 8px;
}
/* section 卡片样式 */
.settings-section {
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15,23,42,0.04);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  overflow: visible;
}
.settings-section .section-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.section-icon {
  font-family: 'FluentSystemIcons-regular', 'Segoe MDL2 Assets', sans-serif;
  font-size: 20px;
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.section-info {
  color: var(--text-muted, #6b7280);
  margin-top: 4px;
}
.settings-section .section-title {
  font-weight: 600;
  font-size: 1rem;
}
.settings-section .section-subtitle {
  opacity: 0.7;
  font-size: 0.875rem;
}
/* 文本 + 开关布局 */
.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: center;
}

.settings-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  align-self: center;
}
.settings-action-status {
  font-size: 0.9rem;
  color: var(--text-muted, #6b7280);
  min-height: 1em;
}
.settings-action-status.ok { color: var(--primary-color); }
.settings-action-status.error { color: #d14343; }
.settings-action-status.muted { color: var(--text-muted, #6b7280); }

.settings-action-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--secondary-bg);
  color: var(--text-color);
  font-weight: 600;
  cursor: pointer;
  min-width: 78px;
  transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease, opacity 120ms ease;
}
.settings-action-btn:hover { background: var(--hover-bg); box-shadow: 0 8px 18px rgba(0,0,0,0.08); }
.settings-action-btn:active { transform: scale(0.98); background: var(--active-bg); }
.settings-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}
.settings-action-btn.loading { cursor: progress; }

/* right-side control container slight elevation */
.settings-toggle-row > .settings-dropdown-toggle {
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.settings-toggle-row > .settings-dropdown-toggle:hover {
  transform: translateY(-0.6px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.05);
}
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #d0d0d0;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease, transform 180ms ease;
  will-change: background, box-shadow, transform;
}
.toggle-switch .knob {
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%) translateX(0);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), box-shadow 160ms ease;
  will-change: transform, box-shadow;
}
.toggle-switch.active {
  background: var(--primary-color);
  /* keep subtle elevation when active but do NOT show persistent colored ring */
  box-shadow: 0 8px 26px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.02);
}
.toggle-switch.active .knob {
  transform: translateY(-50%) translateX(19px) scale(1.02);
  box-shadow: 0 6px 18px rgba(0,0,0,0.14);
}

/* focus and keyboard-visible state (element becomes focusable via JS) */
.toggle-switch.focus,
.toggle-switch:focus-visible {
  outline: none;
  box-shadow: 0 8px 24px rgba(var(--primary-color-rgb, 51,204,153), 0.08);
}

/* Note: toggle-switch ring removed — ring is applied only to .color-option */

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .toggle-switch,
  .toggle-switch .knob {
    transition-duration: 1ms !important;
  }
}




/* 颜色选择器 */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}
.color-option {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  border: 0;
  transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px; /* 留出内间距，让外圈不覆盖内圆 */
}
.color-option.selected {
  /* Keep internal selection state but visual ring shown only on hover/focus */
}

/* persistent subtle indicator for currently selected color (smaller than hover ring) */
.color-option.selected {
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb, 51,204,153), 0.16);
  transform: translateY(-1px);
}

/* 统一：settings 模态中所有选中项使用圆角高光 */
.settings-section .dropdown-item.selected,
.settings-section .settings-toggle-row .selected {
  background: var(--hover-bg);
  border-radius: 8px;
}

/* Show theme-color outline (ring) only when hovered or focused for .color-option */
.color-option:hover,
.color-option:focus-visible,
.color-option.focus,
.color-option.selected:hover,
.color-option.selected:focus-visible,
.color-option.selected.focus {
  box-shadow: 0 0 0 2px var(--primary-color);
}

.color-core {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  transition: transform 160ms ease;
  transform-origin: center;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2f2f2f;
  font-size: 12px;
  font-weight: 600;
}

/* 使输入框与顶部搜索浮层的搜索框样式一致 */
.color-hex-input {
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
  backdrop-filter: blur(6px);
  font-size: 1rem;
  line-height: 1.4;
  transition: background 0.18s ease, border 0.18s ease, box-shadow 0.2s ease;
}

/* 将 swatch 显示为圆形按钮（统一样式） */
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  margin: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

/* show theme-color ring on swatches when hovered or keyboard-focused */
.color-swatch:hover,
.color-swatch:focus-visible,
.color-swatch.focus {
  transform: translateY(-0.8px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.06), 0 0 0 4px rgba(var(--primary-color-rgb, 51,204,153), 0.10);
}

body.dark-mode .color-swatch:hover,
body.dark-mode .color-swatch:focus-visible,
body.dark-mode .color-swatch.focus {
  transform: translateY(-0.8px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.20), 0 0 0 4px rgba(var(--primary-color-rgb, 51,204,153), 0.12);
}

/* persistent subtle indicator for selected swatch */
.color-swatch.selected {
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb, 51,204,153), 0.16);
}

.color-option .fluent-icon {
  font-family: 'FluentSystemIcons-regular', 'Segoe MDL2 Assets', sans-serif;
  font-size: 12px;
  line-height: 1;
  color: #ffffff; /* 白色图标 */
  display: inline-block;
}

/* （已合并）hex 输入框样式现在与搜索框一致，移除旧的精简样式 */
.color-option:hover .color-core {
  transform: scale(1.10);
}
.color-option:active .color-core {
  transform: scale(0.90);
}
.color-core.click-anim {
  animation: colorPop 200ms ease;
}

@keyframes colorPop {
  0% { transform: scale(0.90); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1.0); }
}

.color-option.custom .color-core {
  background: #b6b6b6;
}

.color-floating-panel {
  position: absolute;
  top: 48px;
  right: 0;
  width: min(360px, calc(100vw - 120px));
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.25);
  padding: 12px;
  z-index: 20;
  display: grid;
  gap: 10px;
}

.color-panel-header {
  font-weight: 600;
  font-size: 0.95rem;
}

.color-preview {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.color-slider-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.color-slider {
  width: 100%;
  accent-color: var(--primary-color);
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red);
  appearance: none;
}

.color-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}

.color-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}

.color-custom-panel {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
  display: grid;
  gap: 10px;
}
.color-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 8px;
}
.color-swatch:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0,0,0,0.08); }
.color-swatch:active { transform: translateY(0); box-shadow: none; }

.color-custom-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.color-hex-input:focus {
  outline: none;
  border-color: var(--border-color);
  box-shadow: 0 -2px 0 0 var(--primary-color) inset, 0 0 0 1px var(--hover-bg);
  background: var(--input-focus-bg, var(--hover-bg));
}
.color-apply-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--secondary-bg);
  color: var(--text-color);
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.color-apply-btn:hover { box-shadow: 0 6px 14px rgba(0,0,0,0.08); background: var(--hover-bg); }
.color-apply-btn:active { transform: scale(0.98); background: var(--active-bg); }

/* 设置项下拉菜单（复用侧栏折叠箭头样式） */
.settings-dropdown-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
}
.settings-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  /* 使图标不改变父元素的边界：为图标预留右侧空间并将父容器设为相对定位 */
  position: relative;
  padding-right: 40px;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.settings-dropdown-toggle,
.settings-dropdown-toggle .toggle-label,
.settings-dropdown-toggle .toggle-icon {
  color: var(--text-color);
}
.settings-dropdown-toggle:hover { background: var(--hover-bg); border-color: var(--border-color); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,0.06); }
.settings-dropdown-toggle .toggle-label { flex: 1; text-align: left; }
.settings-dropdown-toggle .toggle-label {
  line-height: 20px; /* match icon height for vertical alignment */
  padding-right: 6px; /* small gap before reserved icon area */
}
.settings-dropdown-toggle .toggle-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  /* 使用 translateY 保持垂直居中，旋转只由 CSS 变量控制，避免 JS 覆盖 translateY 导致 Y 轴偏移 */
  /* --toggle-nudge 允许微调图标在 Y 轴上的位置（正值向下，负值向上） */
  transform: translateY(calc(-50% + var(--toggle-nudge, -1px))) rotate(var(--toggle-rotate, -90deg));
  transition: transform 220ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 20px;
  font-size: 14px; /* 控制 glyph 尺寸，避免字体内联基线偏移 */
  text-align: center;
  /* 使用图标中心作为旋转原点，避免视觉上偏向一侧 */
  transform-origin: center center;
  will-change: transform;
}
.settings-dropdown-toggle .toggle-icon { color: var(--text-muted); }

/* Ensure toggle uses readable colors in dark mode when body has dark-mode */
body.dark-mode .settings-dropdown-toggle,
body.dark-mode .settings-dropdown-toggle .toggle-label,
body.dark-mode .settings-dropdown-toggle .toggle-icon {
  color: var(--text-color);
}
body.dark-mode .settings-dropdown-toggle .toggle-icon { color: var(--text-muted); }
.settings-dropdown.open .settings-dropdown-toggle .toggle-icon {
  /* 打开时旋转到 90deg（用户请求） */
  --toggle-rotate: 90deg;
}
.settings-dropdown-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease;
  margin-top: 8px;
  /* 列表由 portal 提供圆角与边框，内部项不应再重复圆角 */
  border-radius: 0;
  border: none;
  background: transparent;
}
.settings-dropdown-list.open {
  max-height: 420px; /* JS 将使用 scrollHeight 覆盖以获得精确高度 */
}
.settings-dropdown-list .dropdown-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.settings-dropdown-list .dropdown-item:hover { transform: translateY(-0.6px); box-shadow: 0 6px 12px rgba(0,0,0,0.05); }
.settings-dropdown-list .dropdown-item:last-child { border-bottom: none; }
.settings-dropdown-list .dropdown-item {
  border-radius: 8px;
  margin: 4px 0;
  padding: 8px 12px;
  transition: background 160ms ease, transform 120ms ease;
  /* 允许文本换行并在单词/符号过长时断行，避免撑开浮层 */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.settings-dropdown-list .dropdown-item:hover {
  background: rgba(0,0,0,0.02); /* subtle rounded highlight for hover */
}
/* 选中状态更明显，使用卡片内高亮（同时保留左侧主题色条） */
.settings-dropdown-list .dropdown-item.selected {
  background: linear-gradient(180deg, rgba(0,0,0,0.01), rgba(0,0,0,0.00));
}

.settings-dropdown-list .dropdown-item.selected {
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

/* Portal 浮层样式：当下拉需要悬浮在模态之上时使用 */
.settings-dropdown-portal {
  position: fixed;
  z-index: 2000; /* 高于模态 (1620) 和遮罩 (1600) */
  min-width: 180px;
  max-width: 420px; /* 允许在需要时更宽，同时 JS 会再做视口限制 */
  background: var(--card-bg); /* 与页眉链接使用相同卡片背景 */
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 28px 80px rgba(0,0,0,0.16), 0 6px 22px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: transform 160ms ease, opacity 140ms ease;
  opacity: 1;
  padding: 6px 6px; /* 内边距让项看起来像链接弹窗 */
}

.settings-dropdown-portal.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px) scale(0.995); }

/* 选中项左侧的主题色竖线（两端圆角） */
.settings-dropdown-list .dropdown-item.selected {
  position: relative;
  padding-left: 14px; /* 给accent bar留出空间 */
  background: transparent;
}
.settings-dropdown-list .dropdown-item.selected::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 4px; /* 两端圆角 */
  background: var(--primary-color);
}
/* Rounded highlight background for selected item */
.settings-dropdown-list .dropdown-item.selected {
  background: var(--hover-bg);
  border-radius: 8px;
  padding-top: 8px;
  padding-bottom: 8px;
  margin: 6px 0; /* create space so rounded corners are visible */
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* Click animation for dropdown items (applied via JS by adding .click-anim) */
@keyframes dropdownClick {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.settings-dropdown-list .dropdown-item.click-anim {
  animation: dropdownClick 180ms ease;
}

/* 使 dropdown-item 更像页眉链接（更细的行高与内边距） */
.settings-dropdown-list .dropdown-item {
  padding: 8px 12px;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* 当 list 高度受限时使其可滚动 */
.settings-dropdown-list.scrollable {
  overflow-y: auto;
}

/* 深色模式适配：下拉选择框 */
.dark-mode .settings-dropdown-list .dropdown-item {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dark-mode .settings-dropdown-list .dropdown-item:hover {
  background: rgba(255,255,255,0.06);
}
.dark-mode .settings-dropdown-list .dropdown-item.selected {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
}
.dark-mode .settings-dropdown-list .dropdown-item.selected {
  background: rgba(255,255,255,0.08);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.dark-mode .settings-dropdown-portal {
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

/* Ensure portal uses dark-mode variables when body has .dark-mode
   (portal is appended to body, so selector should target body.dark-mode .settings-dropdown-portal) */
body.dark-mode .settings-dropdown-portal {
  background: var(--card-bg);
  border-color: var(--border-color);
  color: var(--text-color);
}

/* Dropdown items and selected visuals in dark mode should use subtle light overlays */
body.dark-mode .settings-dropdown-list .dropdown-item {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-color);
}
body.dark-mode .settings-dropdown-list .dropdown-item:hover {
  background: rgba(255,255,255,0.03);
}
body.dark-mode .settings-dropdown-list .dropdown-item.selected {
  background: var(--hover-bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Dark mode: make the left accent bar use a lighter alpha of primary color for contrast */
body.dark-mode .settings-dropdown-list .dropdown-item.selected::before {
  /* use primary color in dark mode for clear accent */
  background: rgba(var(--primary-color-rgb, 51,204,153), 0.95);
}

/* Use primary color as outline for selected color-option in dark mode */
body.dark-mode .color-option.selected {
  /* keep non-ring selection in dark mode; ring appears on hover/focus */
  border-color: rgba(255,255,255,0.03);
}

body.dark-mode .color-option.selected:hover,
body.dark-mode .color-option.selected:focus-visible,
body.dark-mode .color-option.selected.focus {
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb, 51,204,153), 0.18);
}

body.dark-mode .color-option {
  border: 1px solid rgba(255,255,255,0.03);
}

/* Color picker: ensure .color-option background / selected outline adapt in dark mode
   (ring is only applied on hover/focus via the selectors above) */
body.dark-mode .color-core {
  color: var(--text-color);
}
