/* =====================================================================
   组件：按钮 / 卡片 / 标签 / 表单 / 弹层 / 提示
   全站只有两种「填充」：印泥（主操作）与靛（次操作）。其余一律用线。
   ===================================================================== */

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px var(--sp-4);
  min-height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.btn:hover { background: var(--surface-1); border-color: var(--text-3); }
.btn:active { transform: scale(.988); }
.btn[disabled], .btn.busy { opacity: .45; pointer-events: none; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFBF5;
}

.btn.primary:hover { background: var(--primary-ink); border-color: var(--primary-ink); }
:root[data-theme='dark'] .btn.primary { color: #16100C; }

.btn.accent { background: var(--accent); border-color: var(--accent); color: #FFFBF5; }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 84%, #000); border-color: color-mix(in srgb, var(--accent) 84%, #000); }
:root[data-theme='dark'] .btn.accent { color: #0E1216; }

.btn.gold { background: transparent; border-color: color-mix(in srgb, var(--gold) 55%, transparent); color: var(--gold); }
.btn.gold:hover { background: var(--gold-soft); border-color: var(--gold); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-1); color: var(--text); border-color: transparent; }

.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 32%, transparent); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 8%, transparent); border-color: var(--err); }

.btn.sm { min-height: 29px; padding: 2px var(--sp-3); font-size: 12.5px; }
.btn.lg { min-height: 46px; padding: var(--sp-3) var(--sp-6); font-size: 15px; }
.btn.block { width: 100%; }

/* 涟漪：极淡的墨晕，不是彩色水波 */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: .16;
  transform: scale(0);
  animation: rippleOut 520ms var(--ease-out) forwards;
  pointer-events: none;
}

/* ================= 卡片 ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-5);
  transition: border-color var(--dur) var(--ease-out);
}

.card.pad-sm { padding: var(--sp-4); }
.card.hover:hover { border-color: var(--line-strong); }

.card-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin: calc(var(--sp-1) * -1) 0 var(--sp-4);
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.card-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text);
}

/* ================= 标签 =================
   印上去的标签：细框 + 语义色字，不做彩色胶囊。 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 5px;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: var(--r-xs);
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  line-height: 1.65;
  white-space: nowrap;
  color: var(--text-2);
  background: transparent;
}

.tag.male     { color: var(--male); }
.tag.female   { color: var(--female); }
.tag.common   { color: var(--common); }
.tag.neuter   { color: var(--neuter); }
.tag.trans    { color: var(--trans); }
.tag.intrans  { color: var(--intrans); }
.tag.both     { color: var(--both); }
.tag.primary  { color: var(--primary); }
.tag.gold     { color: var(--gold); }

.tag.stage-new   { color: var(--text-3); }
.tag.stage-lear  { color: var(--accent); }
.tag.stage-young { color: var(--male); }
.tag.stage-mat   { color: var(--gold); }
.tag.stage-long  { color: var(--primary); }

.tag.ghost-tag { color: var(--text-3); border-color: var(--line); }

/* 天城体的标签要单独放大：10px 的天城体没法认 */
.tag.deva {
  font-family: var(--font-deva);
  font-size: 13px;
  line-height: 1.5;
  padding: 1px 7px 2px;
  letter-spacing: 0;
}

/* 词性缩写：辞书里的 n. / adj. */
.tag.pos {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: .02em;
  border: 0;
  padding: 0;
  color: var(--text-2);
}

.dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ================= 表单 ================= */
.input, .textarea, select.input {
  width: 100%;
  padding: 9px var(--sp-3);
  min-height: 40px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.textarea { min-height: 120px; line-height: 1.75; resize: vertical; }
.input:hover, .textarea:hover { border-color: var(--text-3); }

.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent);
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.input.deva { font-family: var(--font-deva); font-size: 17px; line-height: var(--lh-deva); }

select.input {
  cursor: pointer;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B806C' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.field { display: block; margin-bottom: var(--sp-4); }

.flabel {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* 多选筹码：方形印片 */
.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  background: transparent;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}

.chip:hover { border-color: var(--text-3); color: var(--text); }

.chip.on {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  color: var(--primary-ink);
  font-weight: 600;
}

.chip.on::before { content: '·'; font-size: 15px; line-height: 0; margin-top: -2px; }

/* 开关 */
.switch {
  position: relative;
  width: 40px; height: 22px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background var(--dur) var(--ease-out);
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  transition: transform var(--dur) var(--ease-spring);
}

.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on::after { transform: translateX(18px); border-color: transparent; }

/* ================= 空态 ================= */
.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.empty-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: var(--sp-4);
  opacity: .5;
  filter: grayscale(1);
}

.empty-icon svg {
  width: 44px; height: 44px;
  display: inline-block;
  color: var(--primary);
  opacity: .8;
  filter: none;
}

.empty-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.empty-desc {
  color: var(--text-2);
  font-size: 13.5px;
  margin-bottom: var(--sp-5);
  max-width: 42ch;
  margin-inline: auto;
}

.empty-actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }

/* ================= 提示条 ================= */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-left-width: 2px;
  margin-bottom: var(--sp-4);
}

.notice.err  { color: var(--err); }
.notice.warn { color: var(--warn); }
.notice.gold { color: var(--gold); }

/* ================= 弹层 ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: color-mix(in srgb, #14100A 62%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn var(--dur) var(--ease-out) both;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 1.5px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  animation: modalIn var(--dur-slow) var(--ease-spring) both;
}

.modal-card.wide { max-width: 760px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}

.modal-title { font-family: var(--font-ui); font-size: 17px; font-weight: 600; }

.dialog { max-width: 400px; text-align: center; }
.dialog p { color: var(--text-2); margin-bottom: var(--sp-5); white-space: pre-wrap; }
.dialog-actions { display: flex; gap: var(--sp-3); justify-content: center; }

/* ================= Toast ================= */
#toastWrap {
  position: fixed;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  inset: 0;
}

#toastWrap.pos-top-center    { align-items: center; justify-content: flex-start; padding-top: calc(var(--sp-6) + env(safe-area-inset-top, 0px)); }
#toastWrap.pos-bottom-center { align-items: center; justify-content: flex-end;    padding-bottom: calc(var(--sp-7) + env(safe-area-inset-bottom, 0px)); }
#toastWrap.pos-bottom-right  { align-items: flex-end;  justify-content: flex-end;  padding: 0 var(--sp-5) var(--sp-6) 0; }

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(440px, 88vw);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toastIn var(--dur) var(--ease-spring) both;
}

.toast.out { animation: toastOut var(--dur-fast) var(--ease-out) both; }

.toast::before {
  content: '';
  width: 2px;
  align-self: stretch;
  background: var(--accent);
  flex-shrink: 0;
}

.toast.err::before  { background: var(--err); }
.toast.warn::before { background: var(--warn); }
.toast.info::before { background: var(--text-3); }

.toast-action {
  margin-left: auto;
  color: var(--primary);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

/* ================= 加载 ================= */
.lotus-wrap { display: grid; place-items: center; gap: var(--sp-4); padding: var(--sp-8) 0; text-align: center; }

.lotus-loader { color: var(--primary); }
.lotus-loader svg { animation: lotusBloom 2.4s var(--ease-in-out) infinite; }

.l-txt { color: var(--text-2); font-size: 14px; }
.l-sub { color: var(--text-3); font-size: 11.5px; font-family: var(--font-en); letter-spacing: .1em; }

.spinner {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-xs);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton.line { height: 11px; margin-bottom: var(--sp-3); }
.skeleton.block { height: 100px; border-radius: var(--r); }

/* 进度：一条 2px 的刻线，被墨填满 */
.progress {
  height: 2px;
  background: var(--line);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width var(--dur-slow) var(--ease-out);
}

/* ================= 添加到桌面提示条 ================= */
#installHost { position: relative; z-index: 60; }

.install-bar {
  position: fixed;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 520px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 1.5px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  animation: installIn var(--dur-slow) var(--ease-spring) both;
}

@keyframes installIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

.ib-icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--primary); }
.ib-icon svg { width: 100%; height: 100%; }

.ib-text { flex: 1; min-width: 0; }
.ib-title { font-size: 13px; font-weight: 600; line-height: 1.4; }
.ib-desc { font-size: 11px; color: var(--text-3); line-height: 1.5; }

.ib-close {
  flex-shrink: 0;
  width: 24px; height: 24px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1;
  transition: color var(--dur-fast);
}
.ib-close:hover { color: var(--text); }

@media (min-width: 768px) {
  .install-bar { bottom: var(--sp-5); }
}

.ib-steps {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.ib-steps li { font-size: 14px; line-height: 1.7; padding-left: 2px; }

.ib-steps li::marker {
  color: var(--primary);
  font-weight: 600;
  font-family: var(--font-en);
}

/* ================= 分隔 ================= */
.rule {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-6) 0;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.rule::before, .rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ================= 引语 ================= */
.quote-card {
  background: transparent;
  border: 0;
  border-left: 2px solid var(--primary);
  padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-6);
}

.quote-hi {
  font-family: var(--font-deva);
  font-size: 17px;
  line-height: 2;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.quote-zh { color: var(--text-2); font-size: 14px; font-family: var(--font-zh); }

.quote-src {
  margin-top: var(--sp-3);
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: .12em;
  text-transform: uppercase;
}
