/* ============================================================
   vibe单词 —— 全站高级主题化组件层（选择器 Sheet + 模态对话框）
   统一接管原生 <select> 与 alert/confirm/prompt，杜绝刺眼系统白框。
   全部样式基于 CSS Design Tokens，自动适配 9 套皮肤 × 深浅双主题。
   ============================================================ */

/* ---------- 1. 自定义 Select 触发器（替代原生 <select> 外观，保留原生 DOM） ---------- */
.vibe-sel-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
}
.vibe-sel-native {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  z-index: -1 !important;
}
.vibe-sel-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl, 12px);
  padding: 10px 12px;
  min-height: 42px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  background: var(--card-solid);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color .2s var(--ease, ease), box-shadow .2s var(--ease, ease), background-color .2s var(--ease, ease), transform .14s var(--spring, ease);
}
.vibe-sel-btn:hover {
  border-color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
}
.vibe-sel-btn:active {
  transform: scale(.985);
}
.vibe-sel-btn:focus-visible,
.vibe-sel-btn.is-open {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.vibe-sel-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.vibe-sel-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vibe-sel-arrow {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ink2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .24s var(--ease-out, ease), color .2s;
}
.vibe-sel-btn.is-open .vibe-sel-arrow {
  transform: rotate(180deg);
  color: var(--brand);
}

/* 适配 App 端薄雾留白二级设置页的右对齐紧凑布局 */
:root[data-shell="app"][data-style="frost"] #view-settings[data-sub] .set-grp .field .vibe-sel-wrap {
  flex: 0 1 216px;
}
:root[data-shell="app"][data-style="frost"] #view-settings[data-sub] .set-grp .field .vibe-sel-btn {
  font-size: 14.5px;
  padding: 9px 11px;
  min-height: 40px;
}

/* 适配 Web 端设置页重设计（web/pages-redesign.css）的 46px 高表单输入框 */
html[data-client="web"] #view-settings .field .vibe-sel-btn {
  height: 46px;
  min-height: 46px;
  border-radius: 14px;
  background: var(--bg);
  padding: 0 14px 0 16px;
  font-size: 15px;
}

/* 适配多巴胺糖果皮肤的描边质感 */
:root[data-style="candy"] .vibe-sel-btn {
  border-width: 1.5px;
}

/* ---------- 2. 浮层遮罩共享基础 ---------- */
.vibe-ui-mask {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(10, 14, 24, .44);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
  animation: vibeMaskIn .2s var(--ease-out, cubic-bezier(.16, 1, .3, 1)) backwards;
}
:root[data-theme="dark"] .vibe-ui-mask {
  background: rgba(4, 7, 15, .64);
}
.vibe-ui-mask.is-closing {
  animation: vibeMaskOut .18s var(--ease, ease) forwards;
  pointer-events: none;
}

/* ---------- 3. 高级选择器 Sheet（移动端底部抽屉 / 桌面端居中悬浮面板） ---------- */
.vibe-sheet {
  width: 100%;
  max-width: 520px;
  max-height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--card-solid);
  color: var(--ink);
  border: 1px solid var(--card-line, var(--line));
  border-bottom: none;
  border-radius: max(var(--r-card, 20px), 22px) max(var(--r-card, 20px), 22px) 0 0;
  box-shadow: var(--shadow-lift, 0 -18px 48px -20px rgba(0, 0, 0, .35));
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: vibeSheetUp .3s var(--ease-out, cubic-bezier(.16, 1, .3, 1)) backwards;
  will-change: transform;
}
.vibe-ui-mask.is-closing .vibe-sheet {
  animation: vibeSheetDown .18s var(--ease, ease) forwards;
}

.vibe-sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--soft2, var(--line));
  margin: 2px auto 10px;
  flex: none;
}
.vibe-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.vibe-sheet-title-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vibe-sheet-title {
  font-family: var(--font-disp, var(--font-ui));
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.3;
}
.vibe-sheet-meta {
  font-size: 11.5px;
  color: var(--ink2);
}
.vibe-sheet-close {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink2);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .16s var(--spring, ease), background-color .18s, color .18s;
}
.vibe-sheet-close:hover {
  background: var(--soft2);
  color: var(--ink);
}
.vibe-sheet-close:active {
  transform: scale(.86);
}

.vibe-sheet-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 2px 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
}

.vibe-opt {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--r-item, 14px);
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .18s var(--ease, ease), background-color .18s var(--ease, ease), transform .14s var(--spring, ease), box-shadow .18s;
}
.vibe-opt:hover:not(:disabled) {
  border-color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  background: var(--brand-soft);
  background: color-mix(in srgb, var(--brand) 6%, var(--card-solid));
}
.vibe-opt:active:not(:disabled) {
  transform: scale(.985);
}
.vibe-opt:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.vibe-opt:disabled {
  opacity: .42;
  cursor: not-allowed;
}
.vibe-opt.is-selected {
  background: var(--brand-soft);
  background: color-mix(in srgb, var(--brand) 11%, var(--card-solid));
  border-color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 52%, transparent);
  box-shadow: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent);
}
.vibe-opt-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vibe-opt-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.38;
  color: var(--ink);
  word-break: break-word;
}
.vibe-opt.is-selected .vibe-opt-title {
  color: var(--brand);
}
.vibe-opt-sub {
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--ink2);
  word-break: break-word;
}
.vibe-opt-check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s var(--spring, ease);
}
.vibe-opt-check svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: scale(.5);
  opacity: 0;
  transition: transform .22s var(--spring, ease), opacity .16s;
}
.vibe-opt.is-selected .vibe-opt-check {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand, #fff);
  box-shadow: none;
  box-shadow: 0 3px 10px -3px color-mix(in srgb, var(--brand) 55%, transparent);
}
.vibe-opt.is-selected .vibe-opt-check svg {
  transform: scale(1);
  opacity: 1;
}

/* 桌面网页端（非 App 壳且宽屏）呈现居中卡片弹窗 */
@media (min-width: 640px) {
  :root:not([data-shell="app"]) .vibe-ui-mask.is-sheet-mode {
    align-items: center;
    padding: 20px;
  }
  :root:not([data-shell="app"]) .vibe-sheet {
    max-width: 440px;
    max-height: min(74vh, 520px);
    border-bottom: 1px solid var(--card-line, var(--line));
    border-radius: max(var(--r-card, 20px), 20px);
    padding: 18px 20px 20px;
    animation: vibePopIn .24s var(--ease-out, cubic-bezier(.16, 1, .3, 1)) backwards;
  }
  :root:not([data-shell="app"]) .vibe-ui-mask.is-closing .vibe-sheet {
    animation: vibePopOut .16s var(--ease, ease) forwards;
  }
  :root:not([data-shell="app"]) .vibe-sheet-grip {
    display: none;
  }
}

/* ---------- 4. 高级模态对话框（替代 confirm / prompt / alert） ---------- */
.vibe-ui-mask.is-dialog-mode {
  align-items: center;
  padding: 20px;
}
.vibe-dlg {
  width: min(100%, 376px);
  background: var(--card-solid);
  color: var(--ink);
  border: 1px solid var(--card-line, var(--line));
  border-radius: max(var(--r-card, 20px), 20px);
  box-shadow: var(--shadow-lift, 0 24px 56px -18px rgba(0, 0, 0, .42));
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: vibePopIn .24s var(--ease-out, cubic-bezier(.16, 1, .3, 1)) backwards;
}
.vibe-ui-mask.is-closing .vibe-dlg {
  animation: vibePopOut .16s var(--ease, ease) forwards;
}

.vibe-dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.vibe-dlg-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.vibe-dlg-badge {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.vibe-dlg.is-danger .vibe-dlg-badge {
  background: var(--red-soft);
  color: var(--red);
}
.vibe-dlg-badge svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vibe-dlg-title {
  font-family: var(--font-disp, var(--font-ui));
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -.01em;
}
.vibe-dlg.is-danger .vibe-dlg-title {
  color: var(--red);
}
.vibe-dlg-msg {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-body, var(--ink2));
  white-space: pre-line;
  word-break: break-word;
  max-height: 46vh;
  overflow-y: auto;
}
.vibe-dlg-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.vibe-dlg-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl, 12px);
  padding: 11px 38px 11px 13px;
  font-family: inherit;
  font-size: 15.5px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.vibe-dlg-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.vibe-dlg-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--soft2);
  color: var(--ink2);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.vibe-dlg-copybox {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl, 12px);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  resize: none;
  outline: none;
}
.vibe-dlg-copybox:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.vibe-dlg-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.vibe-dlg-btn {
  flex: 1 1 0;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--r-ctl, 12px);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .14s var(--spring, ease), opacity .18s, background-color .18s, border-color .18s;
}
.vibe-dlg-btn:active {
  transform: scale(.97);
}
.vibe-dlg-btn.is-ghost {
  background: var(--soft);
  color: var(--ink-body, var(--ink));
}
.vibe-dlg-btn.is-ghost:hover {
  background: var(--soft2);
}
.vibe-dlg-btn.is-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand, #fff);
  box-shadow: var(--btn-sh, none);
}
.vibe-dlg-btn.is-primary:hover {
  opacity: .92;
}
.vibe-dlg-btn.is-danger {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}
:root[data-theme="dark"] .vibe-dlg-btn.is-danger {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}
@supports (color: color-mix(in srgb, #000 50%, #fff)) {
  :root[data-theme="dark"] .vibe-dlg-btn.is-danger {
    background: color-mix(in srgb, var(--red) 72%, #160909);
    border-color: color-mix(in srgb, var(--red) 80%, transparent);
    color: #ffffff;
  }
}
.vibe-dlg-btn.is-danger:hover {
  opacity: .92;
}

/* ---------- 5. 皮肤个性微调 ---------- */
:root[data-style="candy"] .vibe-sheet,
:root[data-style="candy"] .vibe-dlg {
  border: 1.5px solid var(--line);
}
:root[data-style="candy"] .vibe-opt {
  border-width: 1.5px;
}
:root[data-style="cyberpunk"] .vibe-sheet,
:root[data-style="cyberpunk"] .vibe-dlg {
  border-color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
  box-shadow: 0 22px 54px -18px rgba(0, 0, 0, .72);
  box-shadow: 0 22px 54px -18px rgba(0, 0, 0, .72), 0 0 0 1px color-mix(in srgb, var(--brand) 16%, transparent);
}
:root[data-style="graphite"] .vibe-opt,
:root[data-style="swiss"] .vibe-opt {
  background: transparent;
}
:root[data-style="graphite"] .vibe-opt.is-selected,
:root[data-style="swiss"] .vibe-opt.is-selected {
  background: var(--brand-soft);
}

/* ---------- 6. 触屏/平板 GPU 保护 & 无障碍动效降级 ---------- */
@media (pointer: coarse), (hover: none) {
  .vibe-ui-mask {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: rgba(10, 14, 24, .56);
  }
  :root[data-theme="dark"] .vibe-ui-mask {
    background: rgba(4, 7, 15, .72);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vibe-ui-mask,
  .vibe-sheet,
  .vibe-dlg,
  .vibe-ui-mask.is-closing,
  .vibe-ui-mask.is-closing .vibe-sheet,
  .vibe-ui-mask.is-closing .vibe-dlg {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes vibeMaskIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes vibeMaskOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes vibeSheetUp {
  from { transform: translate3d(0, 100%, 0); }
  to { transform: none; }
}
@keyframes vibeSheetDown {
  from { transform: none; }
  to { transform: translate3d(0, 100%, 0); }
}
@keyframes vibePopIn {
  from { opacity: 0; transform: translateY(8px) scale(.95); }
  to { opacity: 1; transform: none; }
}
@keyframes vibePopOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(4px) scale(.96); }
}
