/* =========================================================
 * css/components.css —— 组件：卡片/按钮/徽章/进度环/Toast/模态/命令面板
 * ========================================================= */

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 22px 24px;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.card.hoverable:hover { transform: translateY(-5px); box-shadow: var(--sh-3); border-color: var(--border-2); }
.card.glass {
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}
.card.tight { padding: 16px 18px; }

.card-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.card-title i { color: var(--brand-1); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 17px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  transition: transform .18s, box-shadow .2s, background .2s, color .2s, border-color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; box-shadow: var(--sh-brand);
}
.btn-primary:hover { box-shadow: 0 18px 40px rgba(79, 70, 229, .40); }
.btn-vi { background: linear-gradient(135deg, var(--vi), #0d9488); color: #fff; box-shadow: var(--sh-vi); }
.btn-vi:hover { box-shadow: 0 18px 38px rgba(5, 150, 105, .40); }
.btn-soft { background: rgba(79, 70, 229, .10); color: var(--brand-1); }
.btn-soft:hover { background: rgba(79, 70, 229, .18); }
.btn-ghost { background: var(--surface-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-outline { border: 1.5px solid var(--border-2); color: var(--text-2); background: transparent; }
.btn-outline:hover { border-color: var(--brand-1); color: var(--brand-1); }
.btn-danger { background: rgba(225, 29, 72, .10); color: var(--danger); }
.btn-danger:hover { background: rgba(225, 29, 72, .18); }
.btn-sm { height: 33px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 14px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 11px; }

/* 语音按钮 */
.speak {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: rgba(79, 70, 229, .10); color: var(--brand-1);
  font-size: 13px;
  transition: transform .2s, background .2s, color .2s;
}
.speak:hover { background: var(--brand-1); color: #fff; transform: scale(1.1); }
.speak.on { background: var(--vi); color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, .5); }
  50% { box-shadow: 0 0 0 9px rgba(5, 150, 105, 0); }
}

/* ---------- 徽章 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
  background: rgba(79, 70, 229, .10); color: var(--brand-1);
}
.badge.vi { background: rgba(5, 150, 105, .12); color: var(--vi); }
.badge.warn { background: rgba(245, 158, 11, .14); color: var(--warn); }
.badge.danger { background: rgba(225, 29, 72, .12); color: var(--danger); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.info { background: rgba(14, 165, 233, .12); color: var(--info); }
.badge.gold { background: rgba(212, 160, 23, .14); color: var(--gold); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  transition: border-color .2s, color .2s, background .2s;
}
.chip:hover { border-color: var(--brand-1); color: var(--brand-1); }
.chip.on { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; border-color: transparent; }
.chip.on:hover { color: #fff; }

.pinyin { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); letter-spacing: .2px; }

/* ---------- 进度 ---------- */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-3));
  border-radius: 999px; transition: width .6s cubic-bezier(.3, .8, .3, 1);
}
.bar.vi > i { background: linear-gradient(90deg, var(--vi), var(--vi-soft)); }
.bar.warn > i { background: linear-gradient(90deg, var(--warn), #fbbf24); }

/* 环形进度 */
.ring { position: relative; width: 148px; height: 148px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .fill {
  stroke: url(#ringGrad); stroke-linecap: round;
  transition: stroke-dashoffset 1.1s cubic-bezier(.3, .8, .3, 1);
}
.ring .ring-label {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.ring .ring-label b { font-size: 27px; font-weight: 800; letter-spacing: -1px; display: block; line-height: 1.1; }
.ring .ring-label span { font-size: 11px; color: var(--muted); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl);
  padding: 30px 32px;
  color: #fff;
  background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 52%, #a855f7 100%);
  box-shadow: var(--sh-brand);
  margin-bottom: 24px;
}
.hero::after {
  content: ""; position: absolute; right: -70px; top: -90px;
  width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255, 255, 255, .13);
}
.hero::before {
  content: ""; position: absolute; right: 90px; bottom: -130px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.hero > * { position: relative; z-index: 2; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .22);
  padding: 5px 13px; border-radius: 999px;
  font-size: 12px; font-weight: 600; margin-bottom: 13px;
}
.hero h1 { font-size: 29px; margin-bottom: 10px; }
.hero p { max-width: 640px; color: rgba(255, 255, 255, .9); font-size: 14.5px; }
.hero .hero-vi { color: #a7f3d0; font-weight: 600; }
.hero-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.hero-actions .btn-light { background: #fff; color: var(--brand-1); }
.hero-actions .btn-light:hover { box-shadow: 0 14px 30px rgba(0, 0, 0, .2); }
.hero-actions .btn-ghost { background: rgba(255, 255, 255, .16); color: #fff; }
.hero-actions .btn-ghost:hover { background: rgba(255, 255, 255, .28); }

/* ---------- 统计卡 ---------- */
.stat {
  display: flex; align-items: center; gap: 15px;
  padding: 18px 20px;
}
.stat .ic {
  width: 48px; height: 48px; flex: none; border-radius: 15px;
  display: grid; place-items: center; font-size: 18px;
}
.stat .lbl { font-size: 12.5px; color: var(--muted); }
.stat .val { font-size: 24px; font-weight: 800; letter-spacing: -.6px; line-height: 1.2; }
.stat .unit { font-size: 11.5px; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl tr:hover td { background: var(--surface-2); }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 20px; border-radius: 999px;
  background: rgba(17, 24, 42, .95); color: #fff;
  font-size: 13.5px; box-shadow: 0 14px 32px rgba(0, 0, 0, .3);
  animation: toastIn .3s cubic-bezier(.2, .9, .3, 1.3) both;
  backdrop-filter: blur(8px);
}
.toast.ok { background: linear-gradient(135deg, var(--vi), #0d9488); }
.toast.bad { background: linear-gradient(135deg, #e11d48, #be123c); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }

/* ---------- 模态 ---------- */
.modal-host {
  position: fixed; inset: 0; z-index: 250;
  display: none; place-items: center;
  background: rgba(11, 16, 32, .55); backdrop-filter: blur(5px);
  padding: 20px;
}
.modal-host.show { display: grid; animation: fadeUp .2s both; }
.modal {
  width: min(560px, 100%); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  padding: 26px 28px; animation: pop .3s both;
}
.modal h3 { font-size: 19px; margin-bottom: 8px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 命令面板 (Ctrl+K) ---------- */
.cmdk-host {
  position: fixed; inset: 0; z-index: 280; display: none;
  background: rgba(11, 16, 32, .5); backdrop-filter: blur(6px);
  padding: 12vh 20px 20px; justify-content: center;
}
.cmdk-host.show { display: flex; }
.cmdk {
  width: min(660px, 100%); max-height: 66vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden;
  animation: pop .25s both;
}
.cmdk input {
  height: 56px; border: none; outline: none; background: transparent;
  padding: 0 20px; font-size: 15.5px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.cmdk .list { overflow-y: auto; padding: 8px; }
.cmdk .item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; font-size: 14px; color: var(--text-2);
  cursor: pointer;
}
.cmdk .item .k { font-size: 11px; color: var(--muted); margin-left: auto; }
.cmdk .item.sel { background: rgba(79, 70, 229, .12); color: var(--brand-1); font-weight: 600; }
.cmdk .item i:first-child { width: 18px; text-align: center; color: var(--muted); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty i { font-size: 34px; margin-bottom: 12px; display: block; opacity: .55; }
.empty h4 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }

/* ---------- 主题切换开关 ---------- */
.theme-sw {
  width: 66px; height: 34px; border-radius: 999px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border);
  position: relative; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; color: var(--muted); font-size: 12px;
  transition: background .3s, border-color .3s;
}
.theme-sw .knob {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  box-shadow: 0 4px 10px rgba(79, 70, 229, .4);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
}
[data-theme="dark"] .theme-sw .knob { transform: translateX(32px); }
.theme-sw i { position: relative; z-index: 2; }

/* 按钮态：正在朗读 */
.btn.on { background: var(--vi) !important; color: #fff !important; border-color: var(--vi) !important; }

/* 公式降级显示（KaTeX 不可用时的 Unicode 兜底，绝不显示 LaTeX 源码） */
.math-fallback {
  display: inline-block; font-family: var(--font-mono); font-size: 13.5px;
  background: var(--surface-2); border: 1px dashed var(--border-2);
  border-radius: 8px; padding: 4px 9px; color: var(--text);
  white-space: pre-wrap; line-height: 1.7;
}
.math-inline { white-space: nowrap; }

/* =========================================================
 * 身份（档案）层 —— 顶栏按钮 + 下拉菜单 + 首次问候
 * ========================================================= */
.who-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px 0 4px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text);
  transition: all .18s; max-width: 190px;
}
.who-btn:hover { border-color: var(--brand-1); box-shadow: var(--sh-sm); }
.who-av {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; font-size: 12.5px; font-weight: 700;
}
.who-av.sm { width: 22px; height: 22px; font-size: 11.5px; }
.who-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
}
.who-caret { font-size: 10px; color: var(--muted); }

.who-menu {
  position: fixed; z-index: 200; width: 250px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  padding: 6px; animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.wm-hd {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: var(--muted); padding: 9px 10px 6px;
  display: flex; align-items: center; gap: 6px;
}
.wm-list { display: flex; flex-direction: column; gap: 2px; }
.wm-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; font-size: 13.5px; color: var(--text); text-align: left;
}
.wm-item:hover { background: var(--surface-2); }
.wm-item.on { background: rgba(79, 70, 229, .1); font-weight: 700; }
.wm-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-item.on i { color: var(--brand-1); font-size: 12px; }
.wm-act { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.wm-act button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; font-size: 13px; color: var(--text-2); text-align: left;
}
.wm-act button:hover { background: var(--surface-2); color: var(--text); }
.wm-act button.danger:hover { background: rgba(239, 68, 68, .1); color: #ef4444; }
.wm-act button i { width: 15px; font-size: 12.5px; }
.wm-foot {
  border-top: 1px solid var(--border); margin-top: 6px; padding: 9px 10px 6px;
  font-size: 11.5px; line-height: 1.6; color: var(--muted);
}

/* 首次问候 */
.who-modal {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(11, 16, 32, .55); backdrop-filter: blur(4px); padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.wm-card {
  width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); padding: 30px 28px 24px; text-align: center;
  animation: rise .26s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.wm-ico {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; font-size: 25px; color: #fff;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 10px 26px rgba(79, 70, 229, .32);
}
.wm-card h3 { font-size: 20px; margin-bottom: 8px; }
.wm-card > p { font-size: 13.5px; color: var(--muted); line-height: 1.65; margin-bottom: 18px; }
.wm-input {
  width: 100%; height: 46px; padding: 0 15px; font-size: 15px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface-2); color: var(--text); outline: none; text-align: center;
}
.wm-input:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.wm-btns { display: flex; gap: 10px; margin-top: 16px; }
.wm-btns .btn { flex: 1; justify-content: center; }
.wm-tip {
  margin-top: 14px; font-size: 11.5px; color: var(--muted); line-height: 1.6;
  display: flex; gap: 6px; align-items: flex-start; text-align: left;
}

/* 云端同步对话框 */
.sync-box .sk { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; color: var(--muted); }
.sync-box .sc {
  display: flex; align-items: center; gap: 9px; margin-top: 7px;
}
.sync-box .sc b {
  flex: 1; font-family: var(--font-mono); font-size: 21px; letter-spacing: 3px;
  padding: 9px 13px; border-radius: var(--r);
  background: var(--surface-2); border: 1px dashed var(--border-2); text-align: center;
}
.sync-box .hint { font-size: 12px; color: var(--muted); line-height: 1.65; margin-top: 9px; }
.sync-box .sync-act { margin-top: 13px; }
.sync-box .sync-act .btn { width: 100%; justify-content: center; }

/* 语言切换：两侧都显示，当前语言高亮（一眼看得出还能切） */
#langToggle { display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; height: 34px; }
#langToggle .lt {
  font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 2px 5px; border-radius: 6px; transition: all .18s;
}
#langToggle .lt.on { color: #fff; background: var(--brand-1); }
#langToggle .lt-sep { font-size: 10px; color: var(--border-2); }

/* =========================================================
 * 纯中文审查模式：body.hide-vi —— 隐藏所有越南语译文
 * 用途：你（中国朋友）用中文界面 review 内容时，只看中文。
 * 开关：顶栏 ⇄ 旁边的「越南语」小按钮，或 URL 加 &novi=1
 * ========================================================= */
body.hide-vi .term-vi,
body.hide-vi .def-text.vi,
body.hide-vi .ex-vi,
body.hide-vi .sent-vi,
body.hide-vi .sent-vi .segs,
body.hide-vi .cd-vi,
body.hide-vi .cd-term-hd .vi,
body.hide-vi .fc-vi,
body.hide-vi .fc-def.vi,
body.hide-vi .fc-ex .vi,
body.hide-vi .q-vi,
body.hide-vi .explain .vi,
body.hide-vi .nb-item .vi,
body.hide-vi .trap-box .vi,
body.hide-vi .pv,
body.hide-vi .c-vi,
body.hide-vi .badge.vi,
body.hide-vi .vi-text,
body.hide-vi .mnemonic .vi,
body.hide-vi [data-vi],
body.hide-vi .sub,
body.hide-vi .vi-sub,
body.hide-vi .hero-vi,
body.hide-vi .side-foot .vi,
body.hide-vi .figure-cap,
body.hide-vi .mnemonic,
body.hide-vi .sb,
body.hide-vi .s,
body.hide-vi .side-foot .lbl .sub { display: none !important; }

/* 隐藏后，中文释义不再需要"次色"，恢复正色 */
body.hide-vi .def-text { color: var(--text-2) !important; }
body.hide-vi .sent-zh { border-radius: var(--r) !important; }
.visw { padding: 0 9px; height: 34px; display: inline-flex; align-items: center; font-size: 14px; }
.visw.off { opacity: .38; text-decoration: line-through; }
