:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-active: #f2f6ff;
  --text: #16181d;
  --sub: #8a9099;
  --line: #eceef2;
  --primary: #2f6bff;
  --primary-soft: #eaf1ff;
  --danger: #e34d59;
  --footer-bg: rgba(255, 255, 255, 0.94);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --card: #1a1d21;
    --card-active: #1d2739;
    --text: #e9ecf0;
    --sub: #8b929c;
    --line: #272b31;
    --primary: #5b8cff;
    --primary-soft: #1b2740;
    --danger: #ff6b74;
    --footer-bg: rgba(20, 23, 27, 0.95);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* -------------------------------------------------- 顶部 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

.topbar__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.topbar__hint {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--sub);
  min-height: 0;
}

.topbar__hint:empty { display: none; }

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin-top: 10px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.search svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: var(--sub);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.search input::placeholder { color: var(--sub); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* -------------------------------------------------- 提示条 */

.banner {
  margin: 0 16px 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
}

.banner--warn {
  background: #fff8e6;
  color: #8a5a00;
  border: 1px solid #ffe8b0;
}

.banner--error {
  background: #fdecee;
  color: var(--danger);
  border: 1px solid #f8ccd0;
}

@media (prefers-color-scheme: dark) {
  .banner--warn { background: #2a2213; color: #e8c07a; border-color: #3d3220; }
  .banner--error { background: #2a1719; color: #ff8d94; border-color: #452428; }
}

/* -------------------------------------------------- 列表 */

.content {
  flex: 1;
  padding: 0 16px 12px;
}

.loading,
.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--sub);
  font-size: 14px;
}

.group { margin-bottom: 12px; }

.group__head {
  position: sticky;
  top: 108px;
  z-index: 10;
  padding: 8px 2px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--sub);
  background: var(--bg);
}

.group__body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s ease;
}

.row:last-child { border-bottom: 0; }
.row:active { background: var(--card-active); }
.row.is-checked { background: var(--card-active); }
.row.is-disabled { opacity: 0.45; cursor: not-allowed; }

.row__main { flex: 1; min-width: 0; }

.row__name {
  font-size: 14.5px;
  color: var(--text);
  word-break: break-all;
}

.row__desc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--sub);
  word-break: break-all;
}

.check {
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid #c9cdd4;
  border-radius: 50%;
  position: relative;
  transition: all 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .check { border-color: #4a5058; }
}

.row.is-checked .check {
  background: var(--primary);
  border-color: var(--primary);
}

.row.is-checked .check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
  transform: rotate(42deg);
}

/* 多选：方形圆角 */
body[data-selector-type="multi"] .check { border-radius: 6px; }

/* -------------------------------------------------- 底部操作区 */

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--footer-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.footer__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer__count {
  font-size: 13px;
  color: var(--sub);
  white-space: nowrap;
}

.footer__count b {
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
}

.footer__err {
  font-size: 11.5px;
  color: var(--danger);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.footer__actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.btn {
  height: 38px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:active { opacity: 0.75; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn--primary {
  background: var(--primary);
  color: #fff;
  min-width: 84px;
}

.btn--ghost {
  background: transparent;
  color: var(--sub);
  border-color: var(--line);
}

/* -------------------------------------------------- Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: 78vw;
  padding: 9px 16px;
  border-radius: 18px;
  background: rgba(20, 22, 26, 0.88);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .toast { background: rgba(240, 242, 245, 0.92); color: #16181d; }
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
