/* === Theme variables（与 codec / qrcode / regex 同款，方便主题切换同步） === */
:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --card: #fffdfa;
  --card-soft: #faf8f4;
  --text: #252524;
  --muted: #8b8984;
  --line: #e9e5de;
  --accent: #6572c7;
  --accent-soft: #eef0ff;
  --green: #4e9b7b;
  --warn: #c87a3a;
  --error: #c8443a;
  --shadow: 0 18px 55px rgba(75, 65, 50, 0.08);
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Cascadia Code", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d1e24;
  --card: #282930;
  --card-soft: #24252b;
  --text: #f1f0ec;
  --muted: #a1a0a0;
  --line: #3b3c44;
  --accent: #9ca7ff;
  --accent-soft: #30334b;
  --green: #79c3a1;
  --warn: #e0a264;
  --error: #e57872;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-family: var(--font);
  background: radial-gradient(circle at 4% 0%, rgba(218, 211, 193, 0.38), transparent 34%), var(--bg);
  transition: background 0.25s, color 0.25s;
}
body[data-theme="dark"] {
  background: radial-gradient(circle at 4% 0%, rgba(60, 80, 140, 0.22), transparent 36%), var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
.ambient { position: fixed; pointer-events: none; filter: blur(60px); opacity: 0.35; border-radius: 50%; z-index: -1; }
.ambient-one { width: 260px; height: 260px; background: #dfe4ff; top: 9%; right: 8%; }
.ambient-two { width: 220px; height: 220px; background: #f3ddca; bottom: 4%; left: 3%; }
body[data-theme="dark"] .ambient-one { background: #3e4a8a; opacity: 0.55; }
body[data-theme="dark"] .ambient-two { background: #5a3a30; opacity: 0.45; }

/* === Topbar === */
.topbar {
  height: 72px; padding: 0 clamp(20px, 4vw, 64px);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5;
}
.back-link, .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 14px; }
.back-link { color: var(--muted); transition: color 0.2s; }
.back-link:hover { color: var(--accent); }
.brand { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 700; }
.brand-mark { color: var(--accent); font-size: 15px; font-family: var(--mono); }
.beta {
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 7px;
  font-size: 8px; font-family: var(--mono); font-weight: 600; color: var(--muted);
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 10px; width: 36px; height: 36px; transition: color 0.2s, border-color 0.2s;
}
.icon-button:hover { color: var(--accent); border-color: var(--accent); }

/* === Layout === */
.app-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 45px; }
.intro-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; gap: 20px; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: 0.16em; font-weight: 700; margin: 0 0 12px; }
.intro-row h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.12; letter-spacing: -0.05em; margin: 0; font-weight: 700; }
.intro-row h1 em { color: var(--accent); font-style: normal; }
.intro-copy { color: var(--muted); font-size: 15px; margin: 15px 0 0; line-height: 1.7; max-width: 58ch; }
.privacy-note { color: var(--green); display: flex; gap: 10px; align-items: flex-start; font-size: 12px; line-height: 1.5; flex-shrink: 0; }
.privacy-note small { color: var(--muted); }
.privacy-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  display: inline-block; margin-top: 5px; flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 12%, transparent);
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { overflow: hidden; margin-bottom: 18px; }
.surface-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap;
}
.surface-title h2 { font-size: 17px; margin: 6px 0 0; letter-spacing: -0.02em; }
.surface-title .label { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); font-weight: 700; }
.surface-actions { display: flex; align-items: center; gap: 10px; }
.counter { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* === 搜索框 === */
.search-bar { padding: 18px 22px; margin-bottom: 18px; }
.search-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); background: var(--card-soft);
  border-radius: 16px; padding: 4px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.search-row:focus-within { border-color: var(--accent); background: var(--card); }
.search-icon { font-size: 16px; opacity: 0.6; flex-shrink: 0; }
.search-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 16px; padding: 14px 0;
  font-family: var(--font); caret-color: var(--accent);
}
.search-input::placeholder { color: var(--muted); }
.search-input::-webkit-search-cancel-button { display: none; }
.clear-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; padding: 4px 8px; border-radius: 8px; flex-shrink: 0;
}
.clear-btn:hover { color: var(--text); background: var(--card-soft); }
.clear-btn[hidden] { display: none; }

.suggest-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.suggest-chip {
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  border-radius: 99px; padding: 6px 13px; font-size: 12px; font-family: var(--font);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.suggest-chip:hover { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* === 分类 === */
.cat-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 22px 20px; }
.cat-chip {
  border: 1px solid var(--line); background: var(--card-soft); color: var(--text);
  border-radius: 11px; padding: 8px 13px; font-size: 12.5px; font-family: var(--font);
  display: inline-flex; align-items: center; gap: 7px;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-count {
  font-family: var(--mono); font-size: 10.5px; opacity: 0.65;
}
.cat-chip.is-all { font-weight: 600; }

/* === 语义状态 === */
.semantic-state {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--accent); font-weight: 500;
}
.semantic-state[hidden] { display: none; }
.semantic-state.is-failed { color: var(--muted); }
.spinner {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-meta {
  padding: 10px 22px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--card-soft);
}
.result-meta[hidden] { display: none; }

/* === 结果网格 === */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; padding: 18px 22px 22px;
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
}
.face-card {
  border: 1px solid var(--line); background: var(--card-soft);
  border-radius: 15px; padding: 16px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 9px; min-width: 0;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: var(--font);
}
.face-card:hover {
  border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px);
}
.face-card.is-copied { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.face {
  font-size: 19px; line-height: 1.5; color: var(--text);
  word-break: break-all; font-family: var(--mono);
}
.face-desc {
  font-size: 12px; color: var(--muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.face-desc mark {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--text); border-radius: 3px; padding: 0 2px;
}
.face-foot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.face-cat {
  font-size: 10.5px; background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; padding: 2px 7px; font-weight: 600;
}
.face-tag { font-size: 10.5px; color: var(--muted); }
.face-sim {
  margin-left: auto; font-size: 10.5px; color: var(--green); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.face-sim.is-weak { color: var(--muted); font-weight: 500; }

.empty {
  padding: 46px 22px 52px; text-align: center;
  color: var(--muted); font-size: 14px; line-height: 1.8;
}
.empty[hidden] { display: none; }

.global-error {
  color: var(--error); font-size: 13px; line-height: 1.6;
  background: color-mix(in srgb, var(--error) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 28%, transparent);
  border-radius: 14px; padding: 14px 18px; margin: 0;
}
.global-error[hidden] { display: none; }

/* === Toast === */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 22px; border-radius: 99px; font-size: 13px; font-weight: 600;
  z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 600px) {
  .app-shell { padding: 30px 0 36px; width: calc(100% - 24px); }
  .intro-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .search-bar { padding: 14px 16px; }
  .surface-toolbar, .cat-row, .grid { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spinner { animation: none; border-top-color: var(--accent); }
}
