﻿/* =====================================================================
   组件：按钮 / 卡片 / 标签 / 表单 / 弹层 / 提示
   三种材质的分工写在这里：
     · 按钮 = 渐变 + 内高光（可点）
     · 卡片 = 近白渐变 + 内高光 + 双层投影（浮在纸上）
     · 弹层 = 玻璃（在页面之上）
   ===================================================================== */

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-4);
  min-height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--grad-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;
  box-shadow: var(--inner-light), 0 1px 2px rgba(60, 48, 30, .06);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.btn:hover {
  background: var(--grad-surface-h);
  border-color: var(--line-strong);
  box-shadow: var(--inner-light), 0 4px 12px -6px rgba(60, 48, 30, .28);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0) scale(.988); box-shadow: var(--inner-light); }
.btn[disabled], .btn.busy { opacity: .48; pointer-events: none; }

.btn.primary {
  background: var(--grad-seal);
  border-color: #8C2419;
  color: #FFF8F2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), var(--shadow-brand);
  text-shadow: 0 1px 0 rgba(110, 30, 22, .35);
}

.btn.primary:hover { background: var(--grad-seal-h); border-color: #8C2419; }

:root[data-theme='dark'] .btn.primary { color: #1A1310; text-shadow: none; }

.btn.accent {
  background: var(--grad-indigo);
  border-color: #22405A;
  color: #F6FAFD;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 8px 18px -10px rgba(46, 80, 104, .6);
}

.btn.accent:hover { filter: brightness(1.06); }

:root[data-theme='dark'] .btn.accent { color: #131A1F; }

.btn.gold {
  background: linear-gradient(180deg, #FBF1DA 0%, #F5E7C8 100%);
  border-color: #E4CF9E;
  color: var(--gold);
}

.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: rgba(120, 100, 70, .09); color: var(--text); box-shadow: none; transform: none; }

.btn.danger { color: var(--err); border-color: rgba(167, 53, 44, .28); background: #FFF9F7; }
.btn.danger:hover { background: #FCEFEC; border-color: rgba(167, 53, 44, .5); }

.btn.sm { min-height: 30px; padding: 3px var(--sp-3); font-size: 12.5px; border-radius: var(--r-xs); }
.btn.lg { min-height: 48px; padding: var(--sp-3) var(--sp-6); font-size: 15px; border-radius: var(--r); }
.btn.block { width: 100%; }

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: .18;
  transform: scale(0);
  animation: rippleOut 520ms var(--ease-out) forwards;
  pointer-events: none;
}

/* ================= 卡片 ================= */
.card {
  position: relative;
  background: var(--grad-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--inner-light), var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease-out),
              transform var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out);
}

.card.pad-sm { padding: var(--sp-4); }
.card.hover:hover,
.card:hover:not(.flat) {
  box-shadow: var(--inner-light), var(--shadow);
  border-color: var(--line-strong);
}

.card.flat, .card.flat:hover { box-shadow: var(--inner-light); }

.card-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

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

.card-head .eyebrow { margin-left: auto; }

/* ================= 标签 ================= */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--r-xs);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  line-height: 1.7;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface-1);
  border: 1px solid var(--line-soft);
}

.tag.male     { color: var(--male);     background: var(--male-soft);     border-color: transparent; }
.tag.female   { color: var(--female);   background: var(--female-soft);   border-color: transparent; }
.tag.common   { color: var(--common);   background: var(--common-soft);   border-color: transparent; }
.tag.neuter   { color: var(--neuter);   background: var(--neuter-soft);   border-color: transparent; }
.tag.trans    { color: var(--trans);    background: var(--trans-soft);    border-color: transparent; }
.tag.intrans  { color: var(--intrans);  background: var(--intrans-soft);  border-color: transparent; }
.tag.both     { color: var(--both);     background: var(--both-soft);     border-color: transparent; }
.tag.primary  { color: var(--primary-ink); background: var(--primary-soft); border-color: #EFCFC8; }
.tag.gold     { color: var(--gold);     background: var(--gold-soft);     border-color: #E9D7AE; }

.tag.stage-new   { color: var(--text-3); background: var(--surface-2); border-color: transparent; }
.tag.stage-lear  { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tag.stage-young { color: var(--male);   background: var(--male-soft);   border-color: transparent; }
.tag.stage-mat   { color: var(--gold);   background: var(--gold-soft);   border-color: transparent; }
.tag.stage-long  { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

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

.tag.pos {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: .02em;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-2);
}

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

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

/* ================= 表单 ================= */
.input, .textarea, select.input {
  width: 100%;
  padding: 10px var(--sp-3);
  min-height: 42px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14.5px;
  box-shadow: inset 0 1px 2px rgba(60, 48, 30, .05);
  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: inset 0 1px 2px rgba(60, 48, 30, .04),
              0 0 0 3px rgba(167, 53, 44, .14);
}

.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='%238C8171' 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: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  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: 5px var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--grad-surface);
  box-shadow: var(--inner-light), 0 1px 2px rgba(60, 48, 30, .04);
  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),
              box-shadow var(--dur-fast) var(--ease-out);
}

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

.chip.on {
  background: linear-gradient(180deg, #B8402F 0%, #93291F 100%);
  border-color: #8C2419;
  color: #FFF6F1;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2),
              0 4px 10px -6px rgba(167, 53, 44, .7);
}

:root[data-theme='dark'] .chip.on { color: #1A1210; }

/* 开关 */
.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 3px rgba(60, 48, 30, .12);
  cursor: pointer;
  transition: background var(--dur) var(--ease-out);
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF, #F4EEE2);
  box-shadow: 0 1px 2px rgba(60, 48, 30, .25);
  transition: transform var(--dur) var(--ease-spring);
}

.switch.on { background: var(--grad-seal); border-color: #8C2419; }
.switch.on::after { transform: translateX(18px); }

/* ================= 空态 ================= */
.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--grad-card);
  box-shadow: var(--inner-light), var(--shadow-sm);
}

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

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

.empty-title { font-size: 17px; 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);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid rgba(46, 80, 104, .16);
  margin-bottom: var(--sp-4);
}

.notice.err  { background: #FBEDEA; color: var(--err); border-color: rgba(167, 53, 44, .18); }
.notice.warn { background: #FBF2DF; color: var(--warn); border-color: rgba(150, 96, 26, .2); }
.notice.gold { background: var(--gold-soft); color: var(--gold); border-color: #E9D7AE; }

/* ================= 弹层（玻璃） ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: rgba(48, 38, 26, .34);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  animation: fadeIn var(--dur) var(--ease-out) both;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: saturate(1.4) blur(28px);
  -webkit-backdrop-filter: saturate(1.4) blur(28px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  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);
}

.modal-title { font-size: 18px; font-weight: 600; }

.dialog { max-width: 420px; 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(460px, 88vw);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  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: 3px;
  border-radius: var(--r-pill);
  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: 17px; height: 17px;
  border: 2px 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); }

/* 进度条 */
.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  box-shadow: inset 0 1px 2px rgba(60, 48, 30, .1);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-seal);
  box-shadow: 0 0 8px rgba(167, 53, 44, .35);
  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) + 72px);
  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(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  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: 26px; height: 26px;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1;
  transition: background var(--dur-fast);
}
.ib-close:hover { background: rgba(120, 100, 70, .1); 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: linear-gradient(to right, transparent, var(--line), transparent);
}

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

.quote-hi { font-family: var(--font-deva); font-size: 16px; line-height: 2; color: var(--text-2); margin-bottom: 6px; }
.quote-zh { color: var(--text-3); font-size: 13px; }
.quote-src { margin-top: var(--sp-2); font-size: 10px; color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; }
