/* ============================================================
   文字变体生成器 — 样式
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --border: #e4e7f0;
  --border-strong: #d3d8e6;
  --text: #131726;
  --text-2: #5a6178;
  --text-3: #8b92a8;
  --brand: #5b5bd6;
  --brand-2: #7c5cf0;
  --brand-soft: #ecebfd;
  --brand-contrast: #ffffff;
  --ok: #12a150;
  --hl: #fff0b8;
  --hl-border: #f0c94a;
  --shadow-sm: 0 1px 2px rgba(18, 22, 40, .05), 0 1px 3px rgba(18, 22, 40, .04);
  --shadow-md: 0 4px 12px rgba(18, 22, 40, .06), 0 2px 4px rgba(18, 22, 40, .04);
  --shadow-lg: 0 16px 40px rgba(18, 22, 40, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d0f17;
  --bg-soft: #12151f;
  --surface: #151926;
  --surface-2: #1c2130;
  --border: #262c3d;
  --border-strong: #333b50;
  --text: #eef1f8;
  --text-2: #a3aabe;
  --text-3: #767e94;
  --brand: #8b87ff;
  --brand-2: #a98cff;
  --brand-soft: #221f45;
  --brand-contrast: #0d0f17;
  --ok: #35d07f;
  --hl: #4a3a10;
  --hl-border: #b58a1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 320px;
  background:
    radial-gradient(60% 100% at 15% 0%, rgba(91, 91, 214, .14), transparent 70%),
    radial-gradient(50% 100% at 85% 0%, rgba(124, 92, 240, .12), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

html[data-theme="dark"] body::before {
  background:
    radial-gradient(60% 100% at 15% 0%, rgba(139, 135, 255, .16), transparent 70%),
    radial-gradient(50% 100% at 85% 0%, rgba(169, 140, 255, .12), transparent 70%);
}

button { font-family: inherit; font-size: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand__mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 12px rgba(91, 91, 214, .3);
}

.brand__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand__text strong { font-size: 15px; letter-spacing: -.01em; }
.brand__text small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
  user-select: none;
}

.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.btn--primary {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 91, 214, .28);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(91, 91, 214, .36); }
.btn--primary:active { transform: translateY(0); }

.btn--ghost {
  width: 38px;
  padding: 0;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn--ghost:hover { border-color: var(--border-strong); color: var(--text); }

.linkbtn {
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 6px;
  transition: color .15s;
}
.linkbtn:hover { color: var(--brand); }

/* ---------------- 布局 ---------------- */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card--tight { padding-bottom: 18px; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step {
  width: 20px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 800;
}

.card__tools { display: flex; align-items: center; gap: 2px; }

/* ---------------- 输入框 ---------------- */
.field { position: relative; }

textarea#txtInput {
  width: 100%;
  min-height: 132px;
  max-height: 340px;
  resize: vertical;
  padding: 12px 14px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.65;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
textarea#txtInput::placeholder { color: var(--text-3); }
textarea#txtInput:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.field__meta {
  position: absolute;
  left: 14px;
  bottom: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  pointer-events: none;
}
.field__meta .dot { opacity: .5; }
#hitCount.has-hit { color: var(--ok); font-weight: 600; }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
}

.seg { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg__box {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background .16s, border-color .16s, box-shadow .16s;
}
.seg__box strong { font-size: 13.5px; font-weight: 650; }
.seg__box small { font-size: 11.5px; color: var(--text-3); }

.seg:hover .seg__box { background: color-mix(in srgb, var(--surface) 60%, transparent); }

.seg input:checked + .seg__box {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.seg input:checked + .seg__box strong { color: var(--brand); }
.seg input:focus-visible + .seg__box { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------------- 关键词区 ---------------- */
.kw {
  margin-top: 14px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .28s cubic-bezier(.4, 0, .2, 1), opacity .2s, margin-top .24s;
}
.kw.is-open { max-height: 900px; opacity: 1; }

.kw__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.kw__label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.kw__hint { font-size: 11.5px; color: var(--text-3); }

.taginput {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  cursor: text;
  transition: border-color .16s, box-shadow .16s;
}
.taginput:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.taginput__chips { display: contents; }

.taginput input {
  flex: 1 1 120px;
  min-width: 110px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 28px;
  padding: 0 4px;
}
.taginput input::placeholder { color: var(--text-3); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 6px 0 9px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 100%;
  animation: chipIn .16s ease;
}

@keyframes chipIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.chip__count {
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 5px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: inherit;
}
.chip__count.is-zero { opacity: .45; }

.chip__x {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  opacity: .6;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.chip__x:hover { opacity: 1; background: color-mix(in srgb, var(--brand) 20%, transparent); }

.chip--suggest {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-3);
  padding: 0 9px;
  cursor: pointer;
  font-weight: 500;
  animation: none;
}
.chip--suggest:hover { color: var(--brand); border-color: var(--brand); }

.kw__suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.kw__suggest-label { font-size: 11.5px; color: var(--text-3); margin-right: 1px; }

/* ---------------- 开关 ---------------- */
.switches { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.switches--wrap { flex-wrap: wrap; row-gap: 10px; margin-top: 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch__track {
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: 99px;
  background: var(--border-strong);
  position: relative;
  transition: background .18s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s cubic-bezier(.4, 0, .2, 1);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch__text { font-size: 13px; color: var(--text-2); }

.note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--text-3); }

/* ---------------- 字号 ---------------- */
.sizeControl { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.sizeControl__label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.sizeControl output { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; width: 18px; text-align: right; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 99px;
  background: var(--border-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  cursor: pointer;
}

/* ---------------- 结果区 ---------------- */
.results { min-width: 0; }

.results__head { margin-bottom: 14px; }
.results__head h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.results__sub { margin: 0; font-size: 12.5px; color: var(--text-3); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
  gap: 14px;
}

/* ---------------- 变体卡 ---------------- */
.vcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .2s ease, border-color .16s ease;
  display: flex;
  flex-direction: column;
  min-height: 122px;
  overflow: hidden;
}

.vcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow .16s;
}

.vcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.vcard:hover::after { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent); }
.vcard:active { transform: translateY(0); }
.vcard:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.vcard.is-copied { border-color: var(--ok); }
.vcard.is-copied::after { box-shadow: inset 0 0 0 1px var(--ok); }

.vcard__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}

.vcard__name {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vcard__tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-3);
  flex: none;
}

.vcard__copy {
  margin-left: auto;
  flex: none;
  height: 26px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.vcard__copy:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.vcard__copy.is-done { border-color: var(--ok); color: var(--ok); background: transparent; }

.vcard__body {
  flex: 1;
  font-size: var(--preview-size, 20px);
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--text);
  max-height: 190px;
  overflow: hidden;
  position: relative;
  transition: max-height .2s;
}

.vcard.is-expanded .vcard__body { max-height: none; }

.vcard__body mark.hl {
  background: var(--hl);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
  margin: 0 -1px;
  box-shadow: 0 0 0 1px var(--hl-border) inset;
  transition: background .15s;
}

html[data-theme="dark"] .vcard__body mark.hl { color: #ffe9a8; }

/* 只换关键词模式下，未替换的文字稍微淡一点，突出替换结果 */
body[data-mode="keywords"] .vcard__body mark.hl { font-weight: inherit; }

.vcard__body.is-clipped::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}

.vcard__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-3);
}

.vcard__meta { display: flex; align-items: center; gap: 5px; }
.vcard__meta b { color: var(--text-2); font-weight: 650; font-variant-numeric: tabular-nums; }

.vcard__more {
  margin-left: auto;
  background: none;
  border: 0;
  padding: 0;
  font-size: 11.5px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 600;
}
.vcard__more:hover { text-decoration: underline; }

/* ---------------- 空状态 ---------------- */
.empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}
.empty__icon {
  font-size: 46px;
  opacity: .25;
  margin-bottom: 12px;
  line-height: 1;
}
.empty__title { margin: 0 0 4px; font-size: 15px; font-weight: 650; color: var(--text-2); }
.empty__desc { margin: 0; font-size: 13px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #131726;
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .24s cubic-bezier(.4, 0, .2, 1);
  z-index: 100;
  max-width: min(90vw, 460px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
html[data-theme="dark"] .toast { background: #f2f4f9; color: #0d0f17; }

/* ---------------- 页脚 ---------------- */
.footer {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 42px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}
.footer p { margin: 0; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr); gap: 18px; padding: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 14px; gap: 16px; }
  .panel {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .topbar__inner { padding: 10px 14px; }
  .brand__text small { display: none; }
  .grid { grid-template-columns: 1fr; }
  .empty { padding: 48px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
