/* 乙述 · 浮动主题切换
   圆形汉堡按钮 + 上方弹出皮肤面板
   位置由组件根节点 data-ys-theme-toggle-placement 控制
   - "bottom-left"（默认）：按钮贴左下，面板在按钮正上方
   - "bottom-right"：按钮贴右下，面板在按钮正上方
*/
.ys-theme-toggle {
  position: fixed;
  z-index: 240;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  --ys-tt-inset: 22px;
  --ys-tt-btn-size: 56px;
}

.ys-theme-toggle[data-ys-theme-toggle-placement="bottom-left"] {
  left: var(--ys-tt-inset);
  bottom: var(--ys-tt-inset);
  align-items: flex-start;
}

.ys-theme-toggle[data-ys-theme-toggle-placement="bottom-right"] {
  right: var(--ys-tt-inset);
  bottom: var(--ys-tt-inset);
  left: auto;
  align-items: flex-end;
}

/* 圆形汉堡按钮 */
.ys-theme-toggle-btn {
  pointer-events: auto;
  position: relative;
  width: var(--ys-tt-btn-size);
  height: var(--ys-tt-btn-size);
  border-radius: 50%;
  border: 1px solid rgba(200, 146, 62, 0.55);
  background:
    radial-gradient(circle at 30% 30%, rgba(232, 195, 121, 0.95), rgba(196, 138, 64, 0.95) 60%, rgba(140, 92, 32, 0.95));
  color: #fff8e7;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  box-shadow:
    0 8px 24px rgba(140, 100, 50, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(70, 40, 10, 0.28);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ys-theme-toggle-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 12px 30px rgba(140, 100, 50, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(70, 40, 10, 0.32);
}

.ys-theme-toggle-btn:active {
  transform: scale(0.97);
}

.ys-theme-toggle-btn:focus-visible {
  outline: 2px solid rgba(232, 195, 121, 0.85);
  outline-offset: 3px;
}

/* 按钮上的"光流"扫光 */
.ys-theme-toggle-btn::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 240, 210, 0.32);
  pointer-events: none;
}

/* 按钮中央三道横线（汉堡） */
.ys-theme-toggle-btn-icon {
  display: block;
  width: 22px;
  height: 14px;
  position: relative;
}

.ys-theme-toggle-btn-icon span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 248, 230, 0.95);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

.ys-theme-toggle-btn-icon span:nth-child(1) { top: 2px; }
.ys-theme-toggle-btn-icon span:nth-child(2) { top: 6px; }
.ys-theme-toggle-btn-icon span:nth-child(3) { top: 10px; }

.ys-theme-toggle-btn-label {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff8e7;
  text-shadow: 0 1px 0 rgba(60, 30, 5, 0.35);
}

.ys-theme-toggle-btn[aria-expanded="true"] {
  background:
    radial-gradient(circle at 30% 30%, rgba(232, 195, 121, 0.95), rgba(168, 114, 50, 0.95) 60%, rgba(80, 50, 18, 0.95));
}

/* 弹出面板 */
.ys-theme-toggle-panel {
  pointer-events: auto;
  width: 220px;
  border-radius: 16px;
  border: 1px solid rgba(232, 195, 121, 0.22);
  background:
    linear-gradient(160deg, rgba(34, 37, 33, 0.96), rgba(20, 24, 22, 0.96));
  color: #efe6d6;
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px) saturate(1.18);
  -webkit-backdrop-filter: blur(18px) saturate(1.18);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.ys-theme-toggle-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 0% 0%, rgba(232, 195, 121, 0.12), transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(125, 162, 200, 0.10), transparent 40%);
  pointer-events: none;
}

.ys-theme-toggle-panel[data-open="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ys-theme-toggle-panel-title {
  position: relative;
  font-size: 12px;
  letter-spacing: 0.32em;
  color: rgba(232, 195, 121, 0.85);
  font-weight: 700;
  padding: 0 6px 6px;
  border-bottom: 1px solid rgba(232, 195, 121, 0.18);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ys-theme-toggle-panel-title small {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(232, 195, 121, 0.45);
  font-weight: 500;
}

/* 选项按钮 */
.ys-theme-option {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.16s ease;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.ys-theme-option:hover {
  background: rgba(232, 195, 121, 0.08);
  border-color: rgba(232, 195, 121, 0.32);
  transform: translateY(-1px);
}

.ys-theme-option:focus-visible {
  outline: 2px solid rgba(232, 195, 121, 0.7);
  outline-offset: 2px;
}

.ys-theme-option[data-active="true"] {
  background: rgba(232, 195, 121, 0.14);
  border-color: rgba(232, 195, 121, 0.5);
}

.ys-theme-option-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(232, 195, 121, 0.5);
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.ys-theme-option[data-active="true"] .ys-theme-option-dot {
  border-color: #e8c379;
  background:
    radial-gradient(circle at 35% 35%, #f3d290, #c8923e 70%, #6f4f1d);
  box-shadow: 0 0 12px rgba(232, 195, 121, 0.42);
}

.ys-theme-option-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ys-theme-option-label {
  font-size: 14px;
  font-weight: 700;
  color: #f4ebd8;
  line-height: 1.2;
}

.ys-theme-option[data-active="true"] .ys-theme-option-label {
  color: #f3d290;
}

.ys-theme-option-sub {
  font-size: 11px;
  color: rgba(232, 195, 121, 0.62);
  line-height: 1.2;
}

.ys-theme-option-check {
  font-size: 14px;
  color: #f3d290;
  opacity: 0;
  transition: opacity 0.18s ease;
  font-weight: 800;
}

.ys-theme-option[data-active="true"] .ys-theme-option-check {
  opacity: 1;
}

/* 弹出箭头指向按钮 */
.ys-theme-toggle-panel::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 22px;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(135deg, rgba(34, 37, 33, 0.96) 50%, transparent 51%),
    rgba(20, 24, 22, 0.96);
  border-right: 1px solid rgba(232, 195, 121, 0.22);
  border-bottom: 1px solid rgba(232, 195, 121, 0.22);
  transform: rotate(45deg);
}

.ys-theme-toggle[data-ys-theme-toggle-placement="bottom-right"] .ys-theme-toggle-panel::after {
  left: auto;
  right: 22px;
}

/* 移动端：缩小按钮、贴底高度避让 */
@media (max-width: 768px) {
  .ys-theme-toggle {
    --ys-tt-inset: 16px;
    --ys-tt-btn-size: 50px;
  }
  .ys-theme-toggle-panel {
    width: min(220px, calc(100vw - 32px));
  }
}

/* ========== 跟随系统模式：原生浅色沿用主题层的现有渐变 ========== */
/* 由于主题面板始终是暗金容器（与首页 / 对话页当前暗背景协调），
   浅色模式下保持面板暗色以提升对比度，避免浅米色容器叠在浅米色背景上看不清。 */
@media (prefers-reduced-motion: reduce) {
  .ys-theme-toggle-panel,
  .ys-theme-option {
    transition-duration: 0.01ms !important;
  }
}
