/* Learnly English · 公共扩展样式（Tailwind 之外的组件层） */

:root {
  --lx-primary: #0071e3;
  --lx-primary-dark: #004fa3;
  --lx-success: #34c759;
  --lx-warning: #ff9500;
  --lx-error: #ff3b30;
  --lx-border: #e5e7eb;
  --lx-text: #1c1c1e;
  --lx-text-2: #3a3a3c;
  --lx-text-3: #6e6e73;
  --lx-bg-2: #f8f9fa;
  --lx-bg-3: #f2f2f7;
  --lx-radius: 8px;
  --lx-shadow: 0 4px 16px -2px rgba(28, 28, 30, .06), 0 2px 6px -1px rgba(28, 28, 30, .04);
}

* { -webkit-tap-highlight-color: transparent; }

body { font-family: 'Inter', -apple-system, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif; }

/* ---------- 顶部加载条 ---------- */
#lx-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--lx-primary), var(--lx-success));
  z-index: 9999; transition: width .25s ease, opacity .3s ease; opacity: 0;
}
#lx-progress.on { opacity: 1; }

/* ---------- Toast ---------- */
#lx-toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 10000;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.lx-toast {
  min-width: 240px; max-width: 380px; padding: 12px 14px;
  background: #fff; border: 1px solid var(--lx-border); border-radius: 10px;
  box-shadow: var(--lx-shadow); display: flex; gap: 10px; align-items: flex-start;
  pointer-events: auto; animation: lx-in .22s cubic-bezier(.2, .8, .3, 1);
  font-size: 14px; color: var(--lx-text); line-height: 1.45;
}
.lx-toast.out { animation: lx-out .18s ease forwards; }
.lx-toast .lx-ico { font-size: 20px; line-height: 1; margin-top: 1px; }
.lx-toast.success .lx-ico { color: var(--lx-success); }
.lx-toast.error .lx-ico { color: var(--lx-error); }
.lx-toast.warn .lx-ico { color: var(--lx-warning); }
.lx-toast.info .lx-ico { color: var(--lx-primary); }
.lx-toast b { font-weight: 600; }
@keyframes lx-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes lx-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- 遮罩 / 弹窗 / 抽屉 ---------- */
.lx-mask {
  position: fixed; inset: 0; background: rgba(28, 28, 30, .32);
  backdrop-filter: blur(2px); z-index: 9000; display: flex; align-items: center; justify-content: center;
  animation: lx-fade .18s ease; padding: 24px;
}
@keyframes lx-fade { from { opacity: 0; } to { opacity: 1; } }
.lx-modal {
  background: #fff; border: 1px solid var(--lx-border); border-radius: 12px;
  box-shadow: var(--lx-shadow); width: 100%; max-width: 560px; max-height: 86vh;
  display: flex; flex-direction: column; animation: lx-pop .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes lx-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.lx-modal > header {
  padding: 16px 20px; border-bottom: 1px solid var(--lx-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.lx-modal > header h3 { font-size: 17px; font-weight: 600; margin: 0; }
.lx-modal > .body { padding: 20px; overflow: auto; font-size: 15px; line-height: 1.65; color: var(--lx-text-2); }
.lx-modal > footer {
  padding: 14px 20px; border-top: 1px solid var(--lx-border);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}
.lx-x {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: var(--lx-text-3); cursor: pointer; background: transparent; border: none;
}
.lx-x:hover { background: var(--lx-bg-3); color: var(--lx-text); }

.lx-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw);
  background: #fff; border-left: 1px solid var(--lx-border); z-index: 9500;
  display: flex; flex-direction: column; box-shadow: -12px 0 32px -12px rgba(28, 28, 30, .18);
  animation: lx-slide .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes lx-slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.lx-drawer > header { padding: 16px 18px; border-bottom: 1px solid var(--lx-border); display: flex; align-items: center; justify-content: space-between; }
.lx-drawer > .body { flex: 1; overflow: auto; padding: 12px 14px; }
.lx-drawer .lx-item { padding: 12px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; }
.lx-drawer .lx-item:hover { background: var(--lx-bg-2); border-color: var(--lx-border); }
.lx-drawer .lx-item.unread { background: #f0f7ff; }

/* ---------- 按钮 / 通用 ---------- */
.lx-btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 6px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--lx-border); background: #fff; color: var(--lx-text);
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.lx-btn:hover { background: var(--lx-bg-3); border-color: #d1d5db; }
.lx-btn:active { transform: scale(.985); }
.lx-btn.primary { background: var(--lx-primary); border-color: var(--lx-primary); color: #fff; }
.lx-btn.primary:hover { background: var(--lx-primary-dark); border-color: var(--lx-primary-dark); }
.lx-btn.danger { background: #fff2f1; border-color: var(--lx-error); color: var(--lx-error); }
.lx-btn[disabled] { opacity: .55; cursor: not-allowed; }

.lx-skel { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%); background-size: 400% 100%; animation: lx-shimmer 1.2s linear infinite; border-radius: 6px; }
@keyframes lx-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.lx-empty { padding: 32px 16px; text-align: center; color: var(--lx-text-3); font-size: 14px; }
.lx-empty .material-symbols-outlined { font-size: 40px; display: block; margin-bottom: 8px; color: #c1c6d6; }

/* ---------- 侧边栏 / 顶栏增强 ---------- */
nav a[data-path]:hover { text-decoration: none; }
nav a[data-path].lx-active { background: #0071e3; color: #fff !important; }
nav a[data-path].lx-active .material-symbols-outlined { color: #fff; }
header #hdr-user-menu {
  position: absolute; top: 54px; right: 16px; min-width: 190px; background: #fff;
  border: 1px solid var(--lx-border); border-radius: 10px; box-shadow: var(--lx-shadow);
  padding: 6px; z-index: 9700;
}
header #hdr-user-menu button {
  width: 100%; text-align: left; padding: 9px 12px; border-radius: 7px; border: none;
  background: none; font-size: 14px; color: var(--lx-text-2); cursor: pointer; display: flex; gap: 8px; align-items: center;
}
header #hdr-user-menu button:hover { background: var(--lx-bg-3); color: var(--lx-text); }

/* ---------- 全局搜索浮层 ---------- */
#lx-search-pop {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw); background: #fff; border: 1px solid var(--lx-border);
  border-radius: 12px; box-shadow: var(--lx-shadow); z-index: 9600; overflow: hidden;
}
#lx-search-pop .hit { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; font-size: 14px; }
#lx-search-pop .hit:hover, #lx-search-pop .hit.sel { background: var(--lx-bg-2); }
#lx-search-pop .hit b { font-weight: 600; }
#lx-search-pop .hit span.m { color: var(--lx-text-3); font-size: 13px; }

/* ---------- 单词卡翻转 / 记忆评分 ---------- */
.lx-flip { perspective: 1200px; }
.lx-flip-inner { transition: transform .5s cubic-bezier(.2, .8, .3, 1); transform-style: preserve-3d; position: relative; }
.lx-flip.flipped .lx-flip-inner { transform: rotateY(180deg); }
.lx-flip-face { backface-visibility: hidden; }
.lx-flip-back { position: absolute; inset: 0; transform: rotateY(180deg); }

/* ---------- 评分按钮组 ---------- */
.lx-rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lx-rate button { padding: 10px; border-radius: 8px; border: 1px solid var(--lx-border); background: #fff; font-size: 13px; cursor: pointer; transition: all .15s; }
.lx-rate button:hover { border-color: var(--lx-primary); color: var(--lx-primary); background: #f0f7ff; }
.lx-rate button.sel { border-color: var(--lx-primary); background: #f0f7ff; color: var(--lx-primary); font-weight: 600; }

/* ---------- 选项（做题） ---------- */
.lx-opt { display: block; width: 100%; text-align: left; padding: 12px 16px; border: 1px solid var(--lx-border); border-radius: 8px; background: #fff; cursor: pointer; transition: all .15s; font-size: 15px; }
.lx-opt:hover { border-color: var(--lx-primary); background: #f7fbff; }
.lx-opt.sel { background: #f0f7ff; border: 1.5px solid var(--lx-primary); color: var(--lx-primary); }
.lx-opt.right { background: #f0faf2; border: 1.5px solid var(--lx-success); color: var(--lx-text); }
.lx-opt.wrong { background: #fff5f5; border: 1.5px solid var(--lx-error); color: var(--lx-text); }
.lx-opt[disabled] { cursor: default; }

/* ---------- 音频波形(听说页) ---------- */
.lx-wave { display: flex; align-items: flex-end; gap: 3px; height: 28px; }
.lx-wave i { display: block; width: 3px; background: var(--lx-primary); border-radius: 2px; opacity: .35; }
.lx-wave.on i { animation: lx-wave 1s ease-in-out infinite; opacity: .9; }
.lx-wave i:nth-child(2n) { animation-delay: .1s; }
.lx-wave i:nth-child(3n) { animation-delay: .2s; }
.lx-wave i:nth-child(4n) { animation-delay: .3s; }
@keyframes lx-wave { 0%, 100% { height: 20%; } 50% { height: 100%; } }

/* ---------- 小工具 ---------- */
.lx-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--lx-bg-3); color: var(--lx-text-2); }
.lx-num { font-variant-numeric: tabular-nums; }
.lx-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.lx-scroll::-webkit-scrollbar-thumb { background: #d6d9dd; border-radius: 4px; }
.lx-hide { display: none !important; }
.lx-dim { opacity: .45; pointer-events: none; }

/* 高亮搜索命中 */
mark.lx-hl { background: #fff3c4; color: inherit; padding: 0 2px; border-radius: 3px; }

@media print {
  aside, header, #lx-toasts { display: none !important; }
  .pl-60 { padding-left: 0 !important; }
}
