/* =========================================================================
   ModHelmX 後台樣式 — 全站唯一來源
   - 主題掛在 <html data-theme>（theme.js 在第一幀之前設定，避免閃爍）。
   - 頁面結構在 templates/_base.html 與 _shell.html，各頁只寫內容，不要再自帶
     :root 色票或整頁版面。需要新色票就加在這裡。
   - 斷點：1080（雙欄內容改單欄）、1000（側欄收成抽屜）、640（手機）。
   ========================================================================= */

:root {
  color-scheme: dark;
  /* OLED 深色：近黑底，靠明度階層而非陰影分層；強調色只有一個綠 */
  --base: #05070c;
  --surface: #0a0e18;
  --card: #0d1220;
  --raised: #151b2c;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #263046;
  --line-soft: rgba(148, 163, 184, 0.11);
  --input-bg: #070a12;
  --input-border: #3a4660;
  --hover: rgba(148, 163, 184, 0.08);
  --scrim: rgba(0, 0, 0, 0.66);
  --grid: rgba(148, 163, 184, 0.05);

  --accentA: #22c55e;
  --accentB: #3b82f6;
  --accent-hover: #4ade80;
  --on-accent: #03120a;
  --accent-tint: rgba(34, 197, 94, 0.12);
  --accent-ink: #4ade80;
  --accent-glow: 0 0 0 1px rgba(74, 222, 128, 0.22), 0 8px 24px -10px rgba(34, 197, 94, 0.6);
  --danger: #ef4444;
  --danger-tint: rgba(239, 68, 68, 0.14);
  --danger-ink: #fca5a5;
  --warn: #f59e0b;
  --warn-tint: rgba(245, 158, 11, 0.14);
  --warn-ink: #fcd34d;
  --info-tint: rgba(59, 130, 246, 0.16);
  --info-ink: #93c5fd;
  --violet-tint: rgba(139, 92, 246, 0.16);
  --violet-ink: #c4b5fd;
  --discord: #5865f2;

  --surface-border: 1px solid var(--line-soft);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 2px var(--base), 0 0 0 4px rgba(74, 222, 128, 0.75);

  /* 字體：Fira Sans 負責英數，中文交給系統字；數字與代碼一律 Fira Code */
  --font-sans: "Fira Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans TC", "Microsoft JhengHei", monospace;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* 與 bot 頭像同一個雙色斜切 M（scripts/brand_mark.py） */
  --brand-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='24' fill='%230b1220'/%3E%3CclipPath id='a'%3E%3Cpolygon points='-51.6,222.3 148.4,-124.1 -24.8,-224.1 -224.8,122.3'/%3E%3C/clipPath%3E%3CclipPath id='b'%3E%3Cpolygon points='-48.4,224.1 151.6,-122.3 324.8,-22.3 124.8,324.1'/%3E%3C/clipPath%3E%3Cpolygon points='20.2,77.3 20.2,22.7 35.1,22.7 50.0,45.0 64.9,22.7 79.8,22.7 79.8,77.3 65.5,77.3 65.5,47.5 54.3,63.6 45.7,63.6 34.5,47.5 34.5,77.3' fill='%232dd4bf' clip-path='url(%23a)'/%3E%3Cpolygon points='20.2,77.3 20.2,22.7 35.1,22.7 50.0,45.0 64.9,22.7 79.8,22.7 79.8,77.3 65.5,77.3 65.5,47.5 54.3,63.6 45.7,63.6 34.5,47.5 34.5,77.3' fill='%233b82f6' clip-path='url(%23b)'/%3E%3C/svg%3E");

  /* 舊名稱：channel-select.js 與動態產生的 DOM 仍在用 */
  --bg: var(--base);
  --card-bg: var(--card);
  --rule-bg: var(--input-bg);
  --rule-text: var(--text);
  --box-bg: var(--card);
  --box-text: var(--text);
  --box-border: var(--input-border);
  --accent1: var(--accentA);
  --accent2: var(--accentB);
}

html[data-theme="light"] {
  color-scheme: light;
  --base: #f5f7fa;
  --surface: #ffffff;
  --card: #ffffff;
  --raised: #f0f3f7;
  --text: #0b1220;
  --muted: #4b5568;
  --line: #dde3eb;
  --line-soft: rgba(11, 18, 32, 0.07);
  --input-bg: #ffffff;
  --input-border: #a3aebf;
  --hover: rgba(11, 18, 32, 0.045);
  --scrim: rgba(11, 18, 32, 0.35);
  --grid: rgba(11, 18, 32, 0.045);

  --accentA: #15803d;
  --accentB: #1d4ed8;
  --accent-hover: #166534;
  --on-accent: #ffffff;
  --accent-tint: rgba(22, 163, 74, 0.1);
  --accent-ink: #15803d;
  --accent-glow: 0 1px 2px rgba(21, 128, 61, 0.3);
  --danger: #b91c1c;
  --danger-tint: rgba(185, 28, 28, 0.08);
  --danger-ink: #b91c1c;
  --warn: #d97706;
  --warn-tint: rgba(217, 119, 6, 0.1);
  --warn-ink: #b45309;
  --info-tint: rgba(29, 78, 216, 0.08);
  --info-ink: #1d4ed8;
  --violet-tint: rgba(124, 58, 237, 0.08);
  --violet-ink: #6d28d9;

  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-lg: 0 20px 50px rgba(11, 18, 32, 0.12);
  --focus-ring: 0 0 0 2px var(--base), 0 0 0 4px rgba(21, 128, 61, 0.6);
}

/* ---------- 基底 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--base);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--line) transparent;
}

::selection {
  background: var(--accent-tint);
  color: var(--text);
}

a {
  color: var(--accent-ink);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--raised);
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.35;
}

[hidden] {
  display: none !important;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.muted { color: var(--muted); }
.ink-ok { color: var(--accent-ink); }
.ink-danger { color: var(--danger-ink); }
.ink-warn { color: var(--warn-ink); }
.num { font-variant-numeric: tabular-nums; }
td.num,
span.num {
  font-family: var(--font-mono);
  font-size: 0.93em;
}
.nowrap { white-space: nowrap; }
.self-start { align-self: flex-start; }
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---------- 圖示（遮罩，顏色跟隨文字） ---------- */
.ico {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: none;
  background-color: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* ---------- 按鈕 ---------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active,
.btn-danger:active,
.icon-btn:active {
  transform: translateY(1px);
}
.btn .ico,
.btn-primary .ico,
.btn-secondary .ico,
.btn-ghost .ico,
.btn-danger .ico {
  width: 18px;
  height: 18px;
}
.btn-primary {
  color: var(--on-accent);
  background: var(--accentA);
  box-shadow: var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  color: var(--text);
  background: var(--raised);
  border-color: var(--line);
}
.btn-secondary:hover { background: var(--hover); }
.btn-ghost {
  color: var(--muted);
  background: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--hover); }
.btn-danger {
  color: var(--danger-ink);
  background: transparent;
}
.btn-danger:hover { background: var(--danger-tint); }
.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}
.btn-sm .ico { width: 16px; height: 16px; }
button:disabled,
.is-busy {
  opacity: 0.6;
  cursor: progress;
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn-sm {
  width: 34px;
  height: 34px;
  border-color: transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
}
.icon-btn-sm .ico { width: 16px; height: 16px; }
.icon-btn-sm:hover { color: var(--danger-ink); background: var(--danger-tint); }

/* ---------- 表單控制項 ---------- */
.app input[type="text"],
.app input[type="number"],
.app input[type="search"],
.app select,
.app textarea,
.input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.app input[type="text"]:hover,
.app input[type="number"]:hover,
.app input[type="search"]:hover,
.app select:hover,
.app textarea:hover {
  border-color: var(--muted);
}
.app input[type="number"] {
  font-family: var(--font-mono);
}
.app textarea {
  min-height: 110px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
}
.app select {
  cursor: pointer;
}
.app input::placeholder,
.app textarea::placeholder {
  color: var(--muted);
}
.app input[type="text"]:focus,
.app input[type="number"]:focus,
.app input[type="search"]:focus,
.app select:focus,
.app textarea:focus,
.app input:focus:hover,
.app select:focus:hover,
.app textarea:focus:hover {
  border-color: var(--accentA);
  box-shadow: var(--focus-ring);
}
.app input[type="color"] {
  width: 42px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  cursor: pointer;
}
.app input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.app input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.app input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

.field-label {
  display: block;
  font-weight: 600;
  line-height: 1.4;
}
.field-help,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-wrap: pretty;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-row {
  display: grid;
  /* 控制項欄位設上限，寬螢幕時輸入框不會拉成一整條 */
  grid-template-columns: minmax(0, 220px) minmax(0, 560px);
  gap: 6px 24px;
  align-items: start;
}
.field-row > .field-text { padding-top: 10px; }
.field-row > .field-text .field-help { margin-top: 4px; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 16px;
}
.affix {
  position: relative;
}
.affix input { padding-right: 44px !important; }
.affix-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form > .affix,
.inline-form > input { max-width: 220px; }

/* 開關：本質上還是 checkbox，JS 讀 .checked 不受影響 */
.app input[type="checkbox"].switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 46px;
  height: 26px;
  flex: none;
  margin: 0;
  border-radius: 999px;
  background: var(--input-border);
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.app input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s var(--ease);
}
.app input[type="checkbox"].switch:checked { background: var(--accentA); }
.app input[type="checkbox"].switch:checked::before { transform: translateX(20px); }
.app input[type="checkbox"].switch.switch-sm { width: 38px; height: 22px; }
.app input[type="checkbox"].switch.switch-sm::before { width: 16px; height: 16px; }
.app input[type="checkbox"].switch.switch-sm:checked::before { transform: translateX(16px); }
.app input[type="checkbox"]:not(.switch) {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accentA);
  cursor: pointer;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--raised);
  border: 1px solid var(--line-soft);
}
.toggle-row .field-help { margin-top: 2px; }

.search {
  position: relative;
}
.search .ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.app .search input { padding-left: 40px; }

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--input-bg);
}
.stepper button {
  width: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.stepper button:hover { background: var(--hover); }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper .stepper-val {
  min-width: 76px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
}

/* 單選做成一排標籤（AutoMod 觸發動作） */
.chip-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-opt {
  position: relative;
  cursor: pointer;
}
.chip-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip-opt span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.chip-opt:hover span { border-color: var(--accentA); }
.chip-opt input:checked + span {
  border-color: var(--accentA);
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.chip-opt input:focus-visible + span { box-shadow: var(--focus-ring); }

/* 表情 → 身份組 */
.pairs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
}
.pair-arrow {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.pair-arrow .ico { width: 16px; height: 16px; }
.pair .emoji-wrap input { flex: 1; min-width: 0; }
.edit-section {
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* 動態語音命名示意 */
.channels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--raised);
}
.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-weight: 600;
}
.channel .ico { width: 16px; height: 16px; color: var(--muted); }
.channel-child {
  margin-left: 22px;
  color: var(--muted);
  font-weight: 500;
}
.channel-new {
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.channel-new .ico { color: var(--accent-ink); }

/* 轉盤預覽 */
.wheel-wrap {
  display: grid;
  place-items: center;
  padding: 8px 0;
}
.wheel-wrap canvas {
  width: 280px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
}

/* ---------- 分段 / 分頁 / 標籤 ---------- */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r);
  background: var(--raised);
}
.seg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn .ico { width: 16px; height: 16px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r);
  background: var(--raised);
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active,
.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--raised);
  color: var(--muted);
}
.chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip-ok { background: var(--accent-tint); color: var(--accent-ink); }
.chip-warn { background: var(--warn-tint); color: var(--warn-ink); }
.chip-danger { background: var(--danger-tint); color: var(--danger-ink); }
.chip-info { background: var(--info-tint); color: var(--info-ink); }
.chip-violet { background: var(--violet-tint); color: var(--violet-ink); }
.token {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--raised);
  color: var(--text);
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 版面：外框 ---------- */
.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  min-height: 100vh;
  align-items: start;
  /* 超寬螢幕時整組置中，不會全部擠在左邊 */
  max-width: 1940px;
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 36px);
  padding: 16px;
  overflow-y: auto;
  background: var(--surface);
  border: var(--surface-border);
  border-radius: var(--r-lg);
  scrollbar-width: thin;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  /* 圖形由 --brand-mark 提供，HTML 裡的 M 只是後備文字 */
  color: transparent;
  font-size: 0;
  background: var(--brand-mark) center / cover no-repeat;
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
}
.drawer-close {
  margin-left: auto;
  display: none;
}
.guild-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.guild-switch:hover { border-color: var(--accentA); }
.guild-switch > .ico { width: 18px; height: 18px; color: var(--muted); }
.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-tint);
  object-fit: cover;
  overflow: hidden;
}
.guild-switch-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.guild-switch-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guild-switch-hint {
  font-size: 12px;
  color: var(--muted);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  padding: 0 12px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  position: relative;
  min-height: 42px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-item .ico { width: 18px; height: 18px; color: var(--muted); transition: color 0.15s ease; }
.nav-item:hover { background: var(--hover); }
.nav-item:hover .ico { color: var(--text); }
.nav-item[aria-current="page"] {
  color: var(--accent-ink);
  font-weight: 600;
  background: var(--accent-tint);
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accentA);
}
.nav-item[aria-current="page"] .ico { color: var(--accent-ink); }
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.scrim { display: none; }
.main { min-width: 0; }
.topbar { display: none; }
.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1640px;
  transition: opacity 0.15s ease;
}
.content.saving {
  opacity: 0.65;
  pointer-events: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 4px 2px;
}
.page-head h1 {
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 70ch;
  text-wrap: pretty;
}
.page-actions {
  display: flex;
  gap: 10px;
  flex: none;
}
.savebar { display: none; }

/* ---------- 卡片與格線 ---------- */
.card,
.settings-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.4;
}
.card-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 70ch;
  text-wrap: pretty;
}
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.card-foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}
.grid-side {
  display: grid;
  /* 右欄隨寬度成長（約三成），最少 320px */
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  gap: 16px;
  align-items: start;
}
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-value-sm {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}
.stat-sub {
  font-size: 13px;
  color: var(--muted);
  text-wrap: pretty;
}

.empty {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  color: var(--muted);
  text-align: center;
}
.loading {
  padding: 20px 0;
  color: var(--muted);
}

/* ---------- 表格（手機自動轉卡片，見 app.js 的 data-label） ---------- */
.table-wrap {
  margin: 0 -20px;
  padding: 0 20px;
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table th:first-child,
.table td:first-child { padding-left: 0; }
.table th:last-child,
.table td:last-child { padding-right: 0; }
.table .num,
.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; }
.table td.empty-cell {
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
}
.table input[type="text"],
.table input[type="number"] {
  min-height: 36px;
  border-radius: var(--r-sm);
}
.cell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user img,
.user .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  background: var(--raised);
  font-size: 13px;
}
.user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rank {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.swatch {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  border-radius: 6px;
}
.pct {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 清單 ---------- */
.list {
  display: flex;
  flex-direction: column;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}
.list-item:first-child { border-top: none; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.list-main {
  flex: 1;
  min-width: 0;
}
.list-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}
.list-meta {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.bar {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--raised);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accentA);
}
details.more > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
.more-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--raised);
  font-size: 13px;
  display: grid;
  gap: 4px;
}

/* ---------- 事件（Logs） ---------- */
.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 180px;
  gap: 10px;
}
.events {
  display: flex;
  flex-direction: column;
}
.event {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}
.event:first-child { border-top: none; padding-top: 0; }
.event-badge {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  background: var(--raised);
  color: var(--muted);
}
.event-badge .ico { width: 18px; height: 18px; }
.tint-ok { background: var(--accent-tint); color: var(--accent-ink); }
.tint-warn { background: var(--warn-tint); color: var(--warn-ink); }
.tint-danger { background: var(--danger-tint); color: var(--danger-ink); }
.tint-info { background: var(--info-tint); color: var(--info-ink); }
.tint-violet { background: var(--violet-tint); color: var(--violet-ink); }
.event-title { font-weight: 650; overflow-wrap: anywhere; }
.event-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.event-detail {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  background: var(--raised);
  overflow-wrap: anywhere;
}
.event-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.diff {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  font-size: 13px;
}
.diff-row {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr);
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--raised);
}
.diff-key { color: var(--muted); overflow-wrap: anywhere; }
.diff-val { overflow-wrap: anywhere; }
.diff-old { color: var(--danger-ink); text-decoration: line-through; }
.diff-new { color: var(--accent-ink); }

/* ---------- Discord 訊息預覽 ---------- */
.dmsg {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--raised);
}
.dmsg-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  font-size: 0;
  background: var(--brand-mark) center / cover no-repeat;
}
.dmsg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.4;
}
.dmsg-name { font-weight: 700; }
.dmsg-bot {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  background: var(--discord);
}
.dmsg-time { font-size: 12px; color: var(--muted); }
.dmsg-body {
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- 公開頁（首頁、伺服器列表） ---------- */
.page {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  /* 淡格線只放公開頁，設定頁保持乾淨 */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
}
.page-inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}
.bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px;
}
.bar-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 56px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.hero h1 {
  font-size: 40px;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 15em;
  text-wrap: balance;
}
.hero p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
  max-width: 62ch;
  text-wrap: pretty;
}
.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-cta .btn-primary {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}
.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
}
.feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.feature .ico { width: 18px; height: 18px; color: var(--accent-ink); }
.foot {
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.guild-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.guild-card:hover { border-color: var(--line); }
.guild-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.guild-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  font-size: 18px;
}
.guild-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.guild-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.guild-card-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}
.guild-card-foot .btn-primary,
.guild-card-foot .btn-secondary { width: 100%; }

/* ---------- 提示訊息 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(92vw, 420px);
  padding: 11px 16px 11px 18px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--raised);
  font-weight: 600;
  box-shadow: var(--shadow-lg), inset 3px 0 0 var(--accentA);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.error {
  box-shadow: var(--shadow-lg), inset 3px 0 0 var(--danger);
}

/* ---------- 表情選擇器（反應身份組、拉霸） ---------- */
.emoji-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.emoji-picker-wrap {
  position: relative;
  display: inline-block;
}
.emoji-picker-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.emoji-picker-btn:hover { border-color: var(--accentA); }
/* 用 fixed 定位（位置由 mhx.placePopover 計算）：放在表格的捲動容器裡時，
   absolute 會被 overflow 裁掉 */
.emoji-picker {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 280px;
  max-width: calc(100vw - 16px);
  max-height: 220px;
  padding: 8px;
  overflow-y: auto;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--shadow-lg);
}
.emoji-picker.open { display: grid; }
.emoji-picker .ep-item {
  padding: 4px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
}
.emoji-picker .ep-item:hover { background: var(--accent-tint); }
.emoji-picker .ep-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
}
.emoji-inline {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
}
.chip .emoji-inline {
  width: 18px;
  height: 18px;
}
.emoji-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* ---------- 響應式：平板 ---------- */
@media (max-width: 1080px) {
  .grid-side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1000px) {
  .shell {
    display: block;
    padding: 12px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(288px, 86vw);
    max-height: none;
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
    border-left: none;
    box-shadow: var(--shadow-lg);
    transform: translateX(-104%);
    transition: transform 0.26s var(--ease);
  }
  .nav-open .sidebar { transform: none; }
  .drawer-close { display: inline-flex; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: var(--surface-border);
    box-shadow: var(--shadow-sm);
  }
  .topbar-title {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .content { margin: 0 auto; }
  .hero { padding: 36px; }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters .search { grid-column: 1 / -1; }
}

/* ---------- 響應式：手機 ---------- */
@media (max-width: 640px) {
  .page { padding: 12px; }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    padding: 2px 2px 0;
  }
  .page-head h1 { font-size: 22px; }
  .page-head .page-actions { display: none; }
  .savebar {
    position: sticky;
    bottom: 0;
    z-index: 15;
    display: flex;
    gap: 10px;
    /* 撐滿畫面寬度並用實心底色：iOS 26 Safari 會拿貼底的 sticky 元素背景色去染底部工具列，
       背景若是透明漸層，它會改抓裡面的綠色按鈕，整條工具列就變綠 */
    margin: 0 -12px;
    padding: 6px 12px max(10px, env(safe-area-inset-bottom));
    background-color: var(--base);
  }
  .savebar::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 16px;
    background: linear-gradient(to top, var(--base), transparent);
    pointer-events: none;
  }
  .savebar > * {
    flex: 1;
    min-height: 46px;
  }
  .card,
  .settings-card {
    padding: 16px;
    border-radius: var(--r);
  }
  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .field-row > .field-text { padding-top: 0; }
  .app input[type="text"],
  .app input[type="number"],
  .app input[type="search"],
  .app select { min-height: 44px; font-size: 16px; }
  .app textarea { font-size: 16px; }
  .card-foot > .btn-primary,
  .card-foot > .btn-secondary { flex: 1; }
  .inline-form > .affix,
  .inline-form > input { max-width: none; flex: 1; }

  /* 表格轉卡片：app.js 會依表頭替每格補上 data-label */
  .table-cards thead { display: none; }
  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .table-cards tr:last-child { border-bottom: none; }
  .table-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 !important;
    border: none;
    text-align: right;
  }
  .table-cards td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
  }
  .table-cards td[data-label=""]::before,
  .table-cards td.lead::before { content: none; }
  .table-cards td.lead {
    justify-content: flex-start;
    padding-bottom: 8px !important;
    text-align: left;
  }
  .table-cards td.empty-cell { justify-content: center; }
  .table-cards td.empty-cell::before { content: none; }
  .table-cards .cell-actions { flex-wrap: wrap; }
  .table-cards td > input[type="text"],
  .table-cards td > input[type="number"],
  .table-cards td > .emoji-wrap { max-width: 60%; }

  .hero {
    padding: 24px;
    border-radius: var(--r-lg);
  }
  .hero h1 { font-size: 28px; }
  .features { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .event {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
  }
  .event-badge { width: 36px; height: 36px; }
  .event-time { grid-column: 2; }
  .diff-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pair { grid-template-columns: minmax(0, 1fr) 34px; }
  .pair-arrow { display: none; }
  .pair .pair-emoji,
  .pair .pair-role { grid-column: 1; }
  .pair .pair-del { grid-column: 2; grid-row: 1 / span 2; }
  .list-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .toast { bottom: 84px; }
}

/* ---------- ChannelSelect 可搜尋頻道下拉選單 ---------- */
.csel {
  position: relative;
  width: 100%;
  font: inherit;
}
.csel-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.csel-trigger:hover { border-color: var(--accentA); }
.csel[aria-expanded="true"] .csel-trigger {
  border-color: var(--accentA);
  box-shadow: var(--focus-ring);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.csel-hash {
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 700;
}
.csel-channel-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.csel-placeholder {
  flex: 1;
  color: var(--muted);
}
.csel-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 0.18s;
}
.csel[aria-expanded="true"] .csel-arrow { transform: scaleY(-1); }
.csel-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--accentA);
  border-top: none;
  border-bottom-left-radius: var(--r-sm);
  border-bottom-right-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  animation: csel-open 0.14s ease both;
}
.csel-dropdown.is-open { display: block; }
@keyframes csel-open {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.csel-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.csel-search-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--muted);
}
.csel-search {
  flex: 1;
  min-width: 0;
  width: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text) !important;
  font: inherit;
}
.csel-search::placeholder { color: var(--muted); }
.csel-list {
  margin: 0;
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.csel-option {
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.93rem;
  cursor: pointer;
  transition: background 0.1s;
}
.csel-option:first-child { color: var(--muted); }
.csel-option.is-highlighted { background: var(--accent-tint); }
.csel-option.is-selected {
  color: var(--accent-ink);
  font-weight: 600;
}
.csel-mark {
  padding: 0 1px;
  border-radius: 2px;
  color: inherit;
  background: var(--accent-tint);
}
.csel-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
