:root {
  --bg: #0c0f16;
  --bg-2: #151a23;
  --bg-3: #1b2230;
  --line: #283041;
  --text: #e8ebf2;
  --muted: #8b93a3;
  --accent: #5b8cff;
  --accent-2: #9d7bff;
  --green: #3ecf8e;
  --red: #ff5d6c;
  --amber: #ffb454;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
  --ring: 0 0 0 4px rgba(91,140,255,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, #0e1219 0%, #090c12 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { max-width: 1180px; margin: 0 auto; padding: 0 16px 60px; }

/* ---------- 首页两栏布局 ---------- */
.home-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.home-main { min-width: 0; }
.home-side { position: sticky; top: 84px; }
@media (max-width: 860px) {
  .home-layout { grid-template-columns: 1fr; }
  .home-side { position: static; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; background: linear-gradient(180deg, rgba(12,15,22,.92), rgba(13,17,25,.78));
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-top { display: flex; align-items: baseline; gap: 6px; }
.brand-slogan { color: var(--muted); font-size: 12px; letter-spacing: .3px; }
.logo img { width: 26px; height: 26px; display: block; border-radius: 7px; box-shadow: 0 0 0 1px rgba(91,140,255,.25); }
.title { font-weight: 700; font-size: 18px; }
.subtitle { color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav-btn {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: .15s;
}
.nav-btn:hover { color: var(--text); background: var(--bg-3); }
.nav-btn.active { color: var(--accent); background: rgba(91,140,255,.14); border-color: transparent; font-weight: 600; }
.badge {
  display: inline-block; min-width: 18px; text-align: center; margin-left: 6px;
  background: var(--red); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 5px;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Screens ---------- */
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-top: 18px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; color: var(--text); }
.panel-sub { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
.hint code { background: var(--bg-3); padding: 1px 6px; border-radius: 6px; color: var(--amber); }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- Dict grid ---------- */
.dict-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 12px; }
.dict-card {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: .15s; position: relative;
}
.dict-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.45); }
.dict-card .dc-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.dict-card .dc-meta { color: var(--muted); font-size: 12px; }
.dict-card .dc-tag {
  position: absolute; top: 12px; right: 12px; font-size: 11px; color: var(--accent-2);
  background: rgba(157,123,255,.16); padding: 2px 8px; border-radius: 8px;
}
.dict-card .dc-del {
  position: absolute; bottom: 12px; right: 12px; font-size: 11px; color: var(--red);
  background: transparent; border: none; cursor: pointer;
}

/* ---------- Settings ---------- */
.settings-panel h3 { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: none; }
.setting-row > label { font-size: 14px; }
.seg { display: flex; background: var(--bg-3); border-radius: 9px; padding: 3px; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 6px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 2.5px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); background: #fff; }

/* 滑块：语速 / 音量 */
.rate-ctl { display: flex; align-items: center; gap: 10px; }
.rate-ctl input[type="range"] { width: 150px; accent-color: var(--accent); cursor: pointer; }
.set-val { color: var(--muted); font-size: 13px; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Buttons / inputs ---------- */
.primary-btn { background: var(--accent); color: #fff; border: none; padding: 10px 18px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; box-shadow: 0 1px 2px rgba(91,140,255,.35); transition: filter .15s, box-shadow .15s, transform .1s; }
.primary-btn:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(91,140,255,.4); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.danger-btn { background: transparent; color: var(--red); border: 1px solid var(--red); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.danger-btn:hover { background: rgba(255,93,108,.1); }
.secondary-btn { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.secondary-btn:hover { border-color: var(--accent); }
.ghost-btn { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.ghost-btn:hover { background: var(--bg-3); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: inherit; text-decoration: underline; }
.text-input, .paste-area {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; width: 100%; font-family: inherit;
}
.text-input:focus, .paste-area:focus, .answer-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.row { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.row.between { justify-content: space-between; }

/* ---------- Drop zone ---------- */
.drop-zone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center;
  color: var(--muted); transition: .15s; cursor: pointer;
}
.drop-zone.drag { border-color: var(--accent); background: rgba(91,140,255,.08); color: var(--text); }
.dz-icon { font-size: 34px; margin-bottom: 8px; }
.dz-sub { font-size: 12px; margin-top: 6px; opacity: .7; }
.paste-area { min-height: 120px; resize: vertical; margin-top: 10px; }

/* ---------- Parsed preview ---------- */
.parsed-preview { max-height: 240px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 6px 0 12px; }
.parsed-preview .pw { display: flex; gap: 10px; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--bg-3); align-items: center; }
.parsed-preview .pw:last-child { border-bottom: none; }
.parsed-preview .pw .e { color: var(--accent); font-weight: 600; min-width: 110px; }
.parsed-preview .pw .z { color: var(--muted); flex: 1; }
.parsed-preview .pw .pw-actions { margin-left: auto; display: flex; gap: 4px; }
.parsed-preview .pw .icon-mini {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.parsed-preview .pw .icon-mini:hover { border-color: var(--accent); }
.parsed-preview .pw.editing { background: var(--bg-3); border-radius: 8px; padding: 6px; }
.parsed-preview .pw .edit-en,
.parsed-preview .pw .edit-zh {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 5px 8px; font-size: 13px; min-width: 0;
}
.parsed-preview .pw .edit-en { flex: 0 0 130px; font-weight: 600; }
.parsed-preview .pw .edit-zh { flex: 1; }
#addWordBtn { margin-bottom: 12px; }

/* ---------- Play ---------- */
.play-wrap { margin-top: 18px; position: relative; }
.last-answer {
  min-height: 0;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
}
.last-answer.show { opacity: 1; transform: none; }
.last-answer .la-word { color: var(--text); font-size: 15px; font-weight: 600; }
.last-answer .la-phonetic { color: var(--muted); font-size: 12px; margin-left: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.last-answer .la-pos { color: var(--accent); font-size: 12px; margin-left: 6px; font-weight: 600; }
.last-answer .la-meaning { display: block; margin-top: 2px; color: var(--text); }
.play-head { display: flex; align-items: center; gap: 14px; }
.progress { flex: 1; height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.counter { color: var(--muted); font-size: 13px; min-width: 64px; text-align: right; }
.word-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 28px; margin-top: 16px; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.5);
  height: 340px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 14px;
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .word-card { height: auto; min-height: 320px; padding: 24px 18px; }
}
.prompt-hint { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.speak-btn { background: var(--bg-3); border: 1px solid var(--line); color: var(--text); padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.speak-btn:hover { border-color: var(--accent); background: var(--bg-2); }
.answer-input {
  width: 100%; max-width: 460px; font-size: 30px; text-align: center; letter-spacing: 3px;
  background: var(--bg-3); border: 2px solid var(--line); color: var(--text);
  padding: 16px 18px; border-radius: 14px; transition: border-color .2s, box-shadow .2s;
}
.answer-input.wrong { border-color: var(--red); animation: shake .3s; }
.answer-input.correct { border-color: var(--green); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.feedback { min-height: 22px; margin-top: 0; font-size: 15px; font-weight: 600; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }
.reveal {
  margin-top: 0; color: var(--muted); font-size: 14px;
  min-height: 60px; max-height: 120px; width: 100%; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
}
.reveal .la-line { width: 100%; text-align: center; line-height: 1.45; }
.reveal b { color: var(--text); }
.reveal .la-phonetic { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-right: 10px; }
.reveal .la-pos { color: var(--accent); font-weight: 600; margin-right: 10px; }
.reveal .la-meaning { color: var(--text); }
.reveal .net-src { color: var(--muted); font-size: 12px; }
.play-controls {
  display: flex; justify-content: center; align-items: center; gap: 14px;
  margin-top: 18px; position: relative;
}
.play-controls .last-answer {
  position: absolute; left: 0; top: 50%;
  max-width: 42%; margin-bottom: 0; text-align: left;
  transform: translateY(-50%); opacity: 0;
  transition: opacity .2s;
}
.play-controls .last-answer.show { opacity: 1; transform: translateY(-50%); }
.play-controls .last-answer .la-word { font-size: 15px; }
.play-controls .last-answer .la-phonetic { font-size: 12px; }
.play-controls .last-answer .la-pos { font-size: 11px; }
.play-controls .last-answer .la-meaning { font-size: 12px; display: block; margin-top: 2px; color: var(--muted); }
.play-btns { display: flex; align-items: center; gap: 14px; }
.play-controls .ghost-btn { padding: 8px 16px; font-size: 13px; }
.play-foot { display: flex; justify-content: center; gap: 24px; margin-top: 18px; }
.stat { color: var(--muted); font-size: 14px; }

/* ---------- Errors ---------- */
.err-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 10px; margin-top: 8px; }
.err-item { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.err-item .ei-word { font-weight: 600; color: var(--accent); }
.err-item .ei-zh { color: var(--muted); font-size: 13px; margin-top: 2px; }
.err-item .ei-count { color: var(--red); font-size: 12px; margin-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 30px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
  box-shadow: var(--shadow); font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- OCR Progress ---------- */
.ocr-progress {
  margin-top: 14px; padding: 14px 16px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px;
}
.ocr-bar {
  height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-bottom: 8px;
}
.ocr-bar-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width .3s;
}
.ocr-status { color: var(--muted); font-size: 13px; }

@media (max-width: 560px) {
  .nav-btn { padding: 8px 10px; font-size: 13px; }
  .title { font-size: 16px; }
  .answer-input { font-size: 22px; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand-slogan { display: none; }
  .nav { order: 3; width: 100%; justify-content: center; }
  .dict-grid { grid-template-columns: 1fr; }
  .err-list { grid-template-columns: 1fr; }
  .word-card { padding: 20px 14px; }
  .play-head { flex-wrap: wrap; gap: 8px; }
  .progress { order: 3; flex-basis: 100%; }
}

/* ---------- 设置弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(420px, 94vw); max-height: 86vh; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 4px 18px; }
.modal-body .setting-row:last-child { border-bottom: none; }
.modal-body .setting-row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.modal-body .setting-row.col label { font-size: 14px; }
.modal-body .setting-row.col input[type="range"] { width: 100%; }
.modal-foot { padding: 14px 18px 18px; display: flex; justify-content: flex-end; }

/* ---------- 错题本删除按钮 ---------- */
.err-item { position: relative; padding-right: 30px; }
.err-item .ei-del {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 6px; line-height: 1;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.err-item .ei-del:hover { color: var(--red); border-color: var(--red); background: rgba(255,93,108,.12); }

/* ---------- 右侧任务列表面板 ---------- */
.daily-tasks-panel { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2) inset, var(--shadow); }
.dtp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dtp-head h2 { font-size: 16px; margin: 0; }
.dtp-head .icon-mini {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.dtp-head .icon-mini:hover { border-color: var(--accent); }
.daily-tasks-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.dtp-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }
.dtp-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 12px; cursor: pointer; transition: .15s; position: relative;
}
.dtp-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.dtp-item.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.dtp-item.done { opacity: .7; }
.dtp-item .dtp-main { flex: 1; min-width: 0; }
.dtp-item .dtp-name { font-weight: 600; font-size: 14px; }
.dtp-item .dtp-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dtp-item .dtp-progress { color: var(--accent); font-size: 12px; margin-top: 4px; }
.dtp-item .dtp-progress-bar {
  height: 5px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 8px;
}
.dtp-item .dtp-progress-bar > div {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .25s;
}
.dtp-item.done .dtp-progress-bar > div { background: var(--green); }
.dtp-item .dtp-status { font-size: 15px; margin: 0 2px; }
.dtp-item .dtp-actions { display: flex; gap: 4px; }
.dtp-item .dtp-actions .icon-mini {
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.dtp-item .dtp-actions .icon-mini:hover { color: var(--text); border-color: var(--accent); }

/* ---------- 每日任务面板 ---------- */
#dailyPanel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow);
}
.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.daily-head h2 { font-size: 17px; margin: 0; }
.daily-done { color: var(--green); font-weight: 600; font-size: 14px; }
.daily-pending { color: var(--accent); font-weight: 600; font-size: 14px; }
.daily-info { display: flex; gap: 22px; flex-wrap: wrap; margin: 4px 0 14px; font-size: 14px; color: var(--text); }
.daily-info b { color: var(--accent); }
.daily-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.daily-done-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; }
.daily-done-item {
  display: flex; justify-content: space-between; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-size: 13px;
}
.daily-done-item span { color: var(--green); font-weight: 600; }

