/* ============ 灵译 · 智能翻译词典 ============ */
:root {
  --primary: #4f7cff;
  --primary-2: #7b5cff;
  --accent: #22d3ee;
  --text: #1c2333;
  --text-2: #5a6478;
  --text-3: #8a94a8;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --radius: 20px;
  --radius-lg: 28px;
  --shadow: 0 20px 60px rgba(30, 40, 80, 0.18);
  --shadow-sm: 0 8px 24px rgba(30, 40, 80, 0.12);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============ 背景层 ============ */
.bg-layer {
  position: fixed;
  inset: -40px;
  background-size: cover;
  background-position: center;
  z-index: -3;
  transition: opacity 1.2s var(--ease-out), transform 6s ease;
  filter: saturate(1.05);
}
.bg-layer.zoom { transform: scale(1.06); }
.bg-veil {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(160deg, rgba(240, 244, 255, 0.72) 0%, rgba(235, 240, 255, 0.55) 40%, rgba(245, 242, 255, 0.7) 100%);
  backdrop-filter: blur(2px);
}
.bg-veil.off { background: linear-gradient(160deg, #eef2ff 0%, #e7ecff 45%, #f3efff 100%); }

.bg-toolbar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-spring);
}
.bg-toolbar.show { opacity: 1; transform: translateY(0); }
.bg-copyright { font-size: 11px; color: var(--text-2); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ 毛玻璃 ============ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ============ 布局 ============ */
.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-radius: var(--radius);
  animation: dropIn .7s var(--ease-out) both;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  font-size: 28px;
  filter: drop-shadow(0 4px 10px rgba(79, 124, 255, 0.4));
  animation: float 4s ease-in-out infinite;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 1px; display: flex; align-items: baseline; gap: 10px; }
.brand-sub { font-size: 12px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.engine-badge {
  font-size: 12px;
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.5);
  transition: all .4s;
}
.engine-badge.ok { color: #16a34a; background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.3); }
.engine-badge.down { color: #dc2626; background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); }

.user-box { display: flex; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

/* ============ Hero ============ */
.hero { flex: 1; padding-top: 40px; }
.hero-title {
  text-align: center;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: 1px;
  animation: dropIn .8s var(--ease-out) .05s both;
}
.grad {
  background: linear-gradient(120deg, var(--primary), var(--primary-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  text-align: center;
  color: var(--text-2);
  margin: 12px 0 30px;
  font-size: 15px;
  animation: dropIn .8s var(--ease-out) .12s both;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 22px;
  animation: dropIn .9s var(--ease-out) .2s both;
}

/* ============ Tabs ============ */
.tabs { display: flex; gap: 6px; padding: 4px; background: rgba(0,0,0,0.04); border-radius: 14px; margin-bottom: 16px; }
.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all .35s var(--ease-out);
  position: relative;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 14px rgba(30,40,80,0.12);
  transform: translateY(-1px);
}

/* ============ 输入区 ============ */
.input-wrap {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 18px;
  padding: 14px;
  transition: box-shadow .4s, border-color .4s, transform .3s var(--ease-spring);
}
.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,124,255,0.15), var(--shadow-sm);
  transform: translateY(-2px);
}
.input-area {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  min-height: 72px;
  font-family: inherit;
}
.input-area::placeholder { color: var(--text-3); }
.input-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; flex-wrap: wrap; }

.lang-picker { display: flex; gap: 4px; background: rgba(0,0,0,0.04); border-radius: 10px; padding: 3px; }
.lang-btn {
  border: none; background: transparent; padding: 6px 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer;
  transition: all .3s var(--ease-out);
}
.lang-btn.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(30,40,80,0.1); }
.input-actions { display: flex; align-items: center; gap: 8px; }

/* ============ 按钮 ============ */
.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .3s var(--ease-out);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(79,124,255,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(79,124,255,0.45); }
.btn-primary:active { transform: translateY(0) scale(0.97); box-shadow: 0 4px 12px rgba(79,124,255,0.3); }
.btn-primary.big { padding: 12px 26px; font-size: 15px; border-radius: 14px; }
.btn-primary.full { width: 100%; justify-content: center; }

.btn-ghost {
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.5);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .3s var(--ease-out);
}
.btn-ghost:hover { background: #fff; box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.icon-btn {
  border: none; background: transparent; color: var(--text-2);
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .3s var(--ease-out);
}
.icon-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); transform: scale(1.06); }
.icon-btn:active { transform: scale(0.92); }

/* 点击涟漪 */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transform: scale(0);
  animation: ripple .6s ease-out forwards;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(3); opacity: 0; } }

/* ============ 加载 ============ */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 30px; color: var(--text-2); font-size: 14px;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(79,124,255,0.2);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 结果区 ============ */
.result { margin-top: 18px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 680px) { .result-grid { grid-template-columns: 1fr; } }

.result-card {
  border-radius: 18px;
  padding: 18px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: var(--shadow-sm);
  animation: popIn .55s var(--ease-spring) both;
  position: relative;
  transition: transform .3s var(--ease-out), box-shadow .3s;
}
.result-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.result-card.best { border-color: rgba(79,124,255,0.5); background: linear-gradient(135deg, rgba(79,124,255,0.08), rgba(123,92,255,0.06)), rgba(255,255,255,0.65); }

.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.result-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; }
.tag-online .tag-dot { background: linear-gradient(135deg, #22c55e, #16a34a); }
.tag-local .tag-dot { background: linear-gradient(135deg, #f59e0b, #f97316); }
.best-badge {
  font-size: 11px; color: var(--primary); font-weight: 700;
  background: rgba(79,124,255,0.12); padding: 3px 10px; border-radius: 999px;
}
.result-text { font-size: 18px; line-height: 1.8; font-weight: 500; word-break: break-word; }
.result-text.en { font-size: 17px; }

.score-bar { margin-top: 12px; }
.score-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.score-track { height: 6px; border-radius: 999px; background: rgba(0,0,0,0.06); overflow: hidden; }
.score-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width 1s var(--ease-out); }

.speak-btn {
  margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--primary);
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  border: none; background: rgba(79,124,255,0.1); padding: 6px 12px; border-radius: 10px;
  transition: all .3s;
}
.speak-btn:hover { background: rgba(79,124,255,0.18); }

/* 评委明细 */
.judges { margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(0,0,0,0.08); }
.judge-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); margin: 5px 0; }
.judge-name { width: 64px; flex-shrink: 0; }
.judge-track { flex: 1; height: 4px; background: rgba(0,0,0,0.05); border-radius: 99px; overflow: hidden; }
.judge-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--primary)); transition: width 1s var(--ease-out); }
.judge-val { width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* ============ 单词卡 ============ */
.word-card {
  border-radius: 18px; padding: 22px;
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: var(--shadow-sm);
  animation: popIn .55s var(--ease-spring) both;
}
.word-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.word-main { display: flex; align-items: baseline; gap: 14px; }
.word-title { font-size: 34px; font-weight: 800; letter-spacing: .5px; }
.word-phonetic { color: var(--text-3); font-size: 15px; }
.pos-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.pos-chip {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: rgba(79,124,255,0.12); padding: 4px 12px; border-radius: 999px;
}
.word-audio {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border: none; color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(79,124,255,0.4);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .3s var(--ease-spring);
}
.word-audio:hover { transform: scale(1.1); }
.word-audio:active { transform: scale(0.92); }
.word-audio.playing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 8px 20px rgba(79,124,255,0.4);} 50% { box-shadow: 0 0 0 14px rgba(79,124,255,0.15);} }

.meaning { margin-top: 14px; }
.meaning-pos { font-size: 15px; font-weight: 700; color: var(--text); margin: 12px 0 6px; }
.meaning-item { margin: 8px 0; padding-left: 14px; position: relative; }
.meaning-item::before { content: ''; position: absolute; left: 0; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.meaning-def { font-size: 14px; color: var(--text); line-height: 1.6; }
.meaning-example { font-size: 13px; color: var(--text-2); font-style: italic; margin-top: 3px; line-height: 1.6; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,25,45,0.35);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .35s ease both;
}
.modal {
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  animation: popIn .5s var(--ease-spring) both;
  position: relative;
}
.modal.wide { max-width: 720px; }
.modal h2 { font-size: 22px; font-weight: 800; margin-bottom: 18px; }
.modal-close { position: absolute; top: 14px; right: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.7);
  font-size: 14px; outline: none; transition: all .3s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,0.12); }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-err { color: #dc2626; font-size: 13px; margin-top: 10px; text-align: center; }

/* 管理后台 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: rgba(255,255,255,0.6); border-radius: 14px; padding: 14px; text-align: center; }
.stat-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.admin-body { max-height: 380px; overflow-y: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.05); }
.admin-table th { color: var(--text-2); font-weight: 600; position: sticky; top: 0; background: rgba(255,255,255,0.9); }
.del-btn { border: none; background: rgba(239,68,68,0.1); color: #dc2626; padding: 4px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; }

/* ============ 深度翻译进度条 ============ */
.llm-progress {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: var(--shadow-sm);
  animation: popIn .4s var(--ease-spring) both;
}
.llm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-2); }
.llm-head #llmStatus { font-weight: 600; }
.llm-head #llmEta { color: var(--primary); font-variant-numeric: tabular-nums; }
.progress-track { height: 10px; border-radius: 999px; background: rgba(0,0,0,0.06); overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary), var(--primary-2));
  transition: width .5s var(--ease-out);
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%);} 100% { transform: translateX(100%);} }
.llm-partial { margin-top: 10px; font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; min-height: 20px; }

/* ============ 反馈 / 数据收集 ============ */
.feedback {
  margin-top: 18px;
  padding: 20px;
  border-radius: 18px;
  animation: popIn .55s var(--ease-spring) both;
}
.feedback-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feedback-hint { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; line-height: 1.6; }
.feedback-row { margin-bottom: 12px; }
.feedback-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.feedback-row textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.7);
  font-size: 14px; line-height: 1.6; outline: none; resize: vertical; font-family: inherit;
  transition: all .3s;
}
.feedback-row textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,0.12); }
.feedback-row.inline { display: flex; align-items: center; gap: 12px; }
.feedback-row.inline label { margin-bottom: 0; }
.stars { display: flex; gap: 4px; }
.stars button {
  border: none; background: transparent; font-size: 24px; cursor: pointer; color: #d1d5db;
  transition: all .2s var(--ease-spring);
}
.stars button.on { color: #f59e0b; transform: scale(1.15); }
.stars button:hover { transform: scale(1.2); }
.score-hint { font-size: 12.5px; color: var(--text-2); }

/* ============ 动画 ============ */
@keyframes dropIn { from { opacity: 0; transform: translateY(24px);} to { opacity: 1; transform: translateY(0);} }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.97);} to { opacity: 1; transform: translateY(0) scale(1);} }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes float { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-4px);} }

.hidden { display: none !important; }

.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 20px 0 6px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
