/* 全站主题面板：入口位于页头；桌面为右侧浮层，移动端为底部面板。 */
.ya-ts-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
}

.ya-ts-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--yw-z-dialog) - 1);
  background: rgb(10 10 10 / 0.28);
  backdrop-filter: blur(2px);
}

.ya-ts-backdrop[hidden], .ya-ts-panel[hidden] { display: none; }

.ya-ts-panel {
  position: fixed;
  z-index: var(--yw-z-dialog);
  top: 72px;
  right: max(20px, calc((100vw - var(--yw-container)) / 2));
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 92px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--yw-radius-2xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--yw-shadow-2xl);
}

.ya-ts-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.ya-ts-title { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 700; }
.ya-ts-subtitle { margin: 4px 0 0; color: var(--muted-foreground); font-size: 12px; }
.ya-ts-close {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--yw-radius-md); background: transparent;
  color: var(--muted-foreground); cursor: pointer;
}
.ya-ts-close svg { width: 17px; height: 17px; }
.ya-ts-close:hover { background: var(--muted); color: var(--foreground); }
.ya-ts-close:focus-visible, .ya-ts-option:focus-visible, .ya-ts-swatch:focus-visible,
.ya-ts-reset:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.ya-ts-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.ya-ts-section-head { margin-bottom: 10px; }
.ya-ts-section-head h3 { margin: 0; font-size: 13px; font-weight: 700; }
.ya-ts-section-head p { margin: 3px 0 0; color: var(--muted-foreground); font-size: 11px; }

.ya-ts-options { display: grid; gap: 8px; }
.ya-ts-options--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ya-ts-options--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ya-ts-options--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ya-ts-option {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--yw-radius-md); background: var(--card); color: var(--foreground);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: border-color var(--yw-dur-fast) var(--yw-ease),
    background-color var(--yw-dur-fast) var(--yw-ease), color var(--yw-dur-fast) var(--yw-ease);
}
.ya-ts-option svg { width: 15px; height: 15px; flex: none; }
.ya-ts-option:hover { border-color: var(--primary-border); color: var(--primary-text); }
.ya-ts-option[aria-pressed="true"] {
  border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.ya-ts-swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ya-ts-swatch {
  display: grid; grid-template-columns: 18px 1fr 18px; align-items: center; gap: 9px;
  min-height: 38px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--yw-radius-md); background: var(--card); color: var(--foreground);
  text-align: left; font-size: 12px; font-weight: 600; cursor: pointer;
}
.ya-ts-swatch:hover { border-color: var(--ya-swatch); }
.ya-ts-swatch[aria-pressed="true"] {
  border-color: var(--ya-swatch); box-shadow: inset 0 0 0 1px var(--ya-swatch);
}
.ya-ts-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--ya-swatch); box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--border); }
.ya-ts-check { visibility: hidden; color: var(--ya-swatch); font-weight: 800; text-align: center; }
.ya-ts-swatch[aria-pressed="true"] .ya-ts-check { visibility: visible; }

.ya-ts-radius-options .ya-ts-option:nth-child(1) { border-radius: 0; }
.ya-ts-radius-options .ya-ts-option:nth-child(2) { border-radius: 6px; }
.ya-ts-radius-options .ya-ts-option:nth-child(3) { border-radius: 14px; }

.ya-ts-more { border-bottom: 1px solid var(--border); }
.ya-ts-more > summary {
  display: flex; align-items: center; justify-content: space-between; min-height: 48px;
  color: var(--foreground); font-size: 13px; font-weight: 700; cursor: pointer; list-style: none;
}
.ya-ts-more > summary::-webkit-details-marker { display: none; }
.ya-ts-more > summary::after {
  content: "+"; color: var(--muted-foreground); font-size: 18px; font-weight: 400;
  transition: transform var(--yw-dur-fast) var(--yw-ease);
}
.ya-ts-more[open] > summary::after { transform: rotate(45deg); }
.ya-ts-more > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.ya-ts-more-body { display: grid; gap: 14px; padding: 2px 0 18px; }
.ya-ts-preference { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 12px; }
.ya-ts-preference-label { color: var(--muted-foreground); font-size: 12px; font-weight: 600; }

.ya-ts-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-top: 16px;
}
.ya-ts-reset { padding: 0; border: 0; background: transparent; color: var(--primary-text); font-size: 12px; font-weight: 600; cursor: pointer; }
.ya-ts-saved { color: var(--text-tertiary); font-size: 11px; }

@media (max-width: 640px) {
  .ya-theme-panel-open { overflow: hidden; }
  .ya-ts-panel {
    top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(82dvh, 680px);
    padding: 20px 16px max(20px, env(safe-area-inset-bottom));
    border-width: 1px 0 0; border-radius: var(--yw-radius-2xl) var(--yw-radius-2xl) 0 0;
  }
  .ya-ts-saved { display: none; }
}

@media (max-height: 620px) {
  .ya-ts-panel { top: 12px; max-height: calc(100dvh - 24px); }
}

@media (prefers-reduced-motion: reduce) { .ya-ts-panel { scroll-behavior: auto; } }
