/* 六级词汇 · 记忆台 —— 暖纸色，无外部字体依赖 */

:root {
  --bg: #f6f2ea;
  --bg-deep: #eee7da;
  --card: #fffdf8;
  --ink: #241f1b;
  --ink-2: #6a6055;
  --ink-3: #9c9184;
  --line: #e5ddcf;
  --line-soft: #efe8db;
  --accent: #b0522f;
  --accent-ink: #8d3f21;
  --accent-soft: #f6e3d7;
  --ok: #56794f;
  --ok-soft: #e7efe1;
  --warn: #a87c26;
  --warn-soft: #f6ecd5;
  --bad: #a8432b;
  --bad-soft: #f8e1d9;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 45, 30, .05), 0 14px 34px -20px rgba(60, 45, 30, .34);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* 组件用了 display:flex/grid，会盖掉 UA 的 [hidden]{display:none} */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -18%, #fffdf6 0%, rgba(255, 253, 246, 0) 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 14px;
  background: linear-gradient(to bottom, rgba(246, 242, 234, .96) 65%, rgba(246, 242, 234, 0));
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(160deg, #b95a35, #97411f);
  color: #fff8f0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 6px 14px -8px rgba(150, 60, 25, .8);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-text strong {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.sync-state .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c3b8a7;
  transition: background .25s;
}

.sync-state[data-state="ok"] .dot { background: #6f9a63; }
.sync-state[data-state="syncing"] .dot { background: #d9a441; animation: pulse 1s infinite ease-in-out; }
.sync-state[data-state="err"] .dot { background: #bf5a3d; }

@keyframes pulse { 50% { opacity: .25; } }

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-deep);
  border-radius: 999px;
  flex: none;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
}

.tab:hover { color: var(--ink); }

.tab.is-on {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(70, 55, 35, .1);
}

/* ---------- 通用 ---------- */

.panel { animation: rise .3s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.study-head { margin: 10px 0 18px; }

.bar {
  height: 3px;
  border-radius: 3px;
  background: var(--bg-deep);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #c9704a, #a84a28);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.study-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.meta-text {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

.seg {
  display: flex;
  gap: 1px;
  padding: 2px;
  background: var(--bg-deep);
  border-radius: 8px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--ink-3);
  padding: 4px 11px;
  border-radius: 6px;
  cursor: pointer;
}

.seg button.is-on {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(70, 55, 35, .12);
}

/* ---------- 卡片 ---------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  padding: 22px 34px 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  cursor: pointer;
  outline: none;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1), box-shadow .25s;
}

.card:hover { box-shadow: 0 1px 2px rgba(60, 45, 30, .05), 0 22px 44px -24px rgba(60, 45, 30, .38); }

.card:active { transform: scale(.994); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: .03em;
  color: var(--ink-3);
  background: #f4efe5;
  white-space: nowrap;
}

.chip-tier { color: var(--accent-ink); background: var(--accent-soft); }
.chip-tier[data-tier="2"] { color: var(--warn); background: var(--warn-soft); }
.chip-tier[data-tier="3"] { color: var(--ok); background: var(--ok-soft); }
.chip-tier[data-tier="4"] { color: #3f6b3a; background: #e2eede; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 0;
}

.term {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 6.4vw, 48px);
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -.012em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cta {
  display: inline-block;
  margin-top: 26px;
  padding: 8px 16px;
  border: 1px dashed #ddd2c0;
  border-radius: 999px;
  color: var(--ink-3);
  font-size: 12.5px;
  letter-spacing: .02em;
  transition: border-color .16s, color .16s, background .16s;
}

.card:hover .cta { border-color: #cbb89f; color: var(--ink-2); background: #fdf9f1; }

.card.is-revealed .cta { display: none; }

.meaning-wrap {
  width: 100%;
  max-width: 520px;
  margin-top: 20px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .26s ease, transform .26s ease;
  pointer-events: none;
}

.card.is-revealed .meaning-wrap { opacity: 1; transform: none; }

.rule {
  height: 1px;
  width: 44px;
  margin: 0 auto 18px;
  background: var(--line);
}

.meaning {
  margin: 0;
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card:not(.is-revealed) .meaning { color: var(--ink-3); font-size: 14px; }

.card.is-quiz { min-height: 300px; }

.card-foot {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  margin: 0 2px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fdfaf3;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ---------- 评分按钮 ---------- */

.ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
  animation: rise .22s ease both;
}

.rate {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .12s;
}

.rate span { font-size: 14.5px; font-weight: 600; }
.rate small { font-size: 11px; color: var(--ink-3); letter-spacing: .01em; }

.rate:active { transform: scale(.98); }

.rate.again:hover { border-color: #dcb6a9; background: var(--bad-soft); }
.rate.hard:hover { border-color: #ddc79b; background: var(--warn-soft); }
.rate.good:hover { border-color: #b8cbb0; background: var(--ok-soft); }
.rate.easy:hover { border-color: #e0bdaa; background: var(--accent-soft); }

/* ---------- 选择题 ---------- */

.choices {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  animation: rise .22s ease both;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .12s;
}

.choice .idx {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #f4efe5;
  color: var(--ink-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.choice .txt { flex: 1; overflow-wrap: anywhere; }

.choice:not(:disabled):hover { border-color: #cdbca6; background: #fffcf4; }
.choice:disabled { cursor: default; }

.choice.is-right { border-color: #a9c29f; background: var(--ok-soft); }
.choice.is-right .idx { background: #d6e5cd; color: #3f6b3a; }
.choice.is-wrong { border-color: #d9ac9c; background: var(--bad-soft); }
.choice.is-wrong .idx { background: #f0cfc4; color: var(--bad); }
.choice.is-dim { opacity: .48; }

/* ---------- 完成状态 ---------- */

.done {
  margin-top: 26px;
  text-align: center;
  animation: rise .3s ease both;
}

.done-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 20px;
}

.done h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.done-text {
  margin: 0 auto;
  max-width: 420px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.75;
}

.done-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.keys {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ---------- 按钮 / 表单 ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .1s, color .16s;
}

.btn:hover { border-color: #cdbca6; background: #fffcf4; }
.btn:active { transform: scale(.985); }

.btn.primary {
  background: linear-gradient(170deg, #b95a35, #a14722);
  border-color: #9c4522;
  color: #fff9f3;
  font-weight: 500;
  box-shadow: 0 6px 16px -10px rgba(150, 60, 25, .9);
}

.btn.primary:hover { background: linear-gradient(170deg, #c26339, #a84d26); border-color: #a84d26; }

.btn.danger { color: var(--bad); border-color: #e2c3b8; }
.btn.danger:hover { background: var(--bad-soft); border-color: #d9a897; }

.input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
  transition: border-color .16s, box-shadow .16s;
}

.input::placeholder { color: #b3a89a; }

.input:focus {
  outline: none;
  border-color: #cba98f;
  box-shadow: 0 0 0 3px rgba(176, 82, 47, .1);
}

.input.narrow { width: 88px; }

.select { cursor: pointer; padding-right: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row + .row { margin-top: 10px; }

.row #codeInput { flex: 1 1 220px; }
.row #importGroup { flex: 1 1 200px; }

.row-center { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.hint { font-size: 12.5px; color: var(--ink-3); }

/* ---------- 词库 ---------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0 20px;
}

.stat {
  padding: 14px 14px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .03em; }

.bank-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.bank-tools .input { flex: 1; min-width: 160px; }
.bank-tools select.input { flex: 0 0 150px; min-width: 0; }

.word-list { display: flex; flex-direction: column; }

.wrow {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(0, 2fr) 68px 58px 32px;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft);
}

.wrow:hover { background: rgba(255, 252, 244, .7); }

.wterm {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: -.005em;
  overflow-wrap: anywhere;
}

.wmean {
  color: var(--ink-2);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wtier {
  justify-self: start;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
  background: #f4efe5;
  white-space: nowrap;
}

.wtier[data-t="1"] { color: var(--accent-ink); background: var(--accent-soft); }
.wtier[data-t="2"] { color: var(--warn); background: var(--warn-soft); }
.wtier[data-t="3"] { color: var(--ok); background: var(--ok-soft); }
.wtier[data-t="4"] { color: #3f6b3a; background: #e2eede; }

.wdue {
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wdel {
  appearance: none;
  border: 0;
  background: transparent;
  color: #c4b8a8;
  font-size: 17px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.wdel:hover { background: var(--bad-soft); color: var(--bad); }

.bank-empty {
  padding: 52px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.8;
}

.bank-empty p { margin: 0 auto 20px; max-width: 380px; }

/* ---------- 数据页 ---------- */

.block {
  padding: 20px 22px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.block h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
}

.block .desc {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
}

.block.danger { border-color: #ecd8cf; }
.block.danger h3 { color: var(--bad); }

/* ---------- 弹窗 ---------- */

.sheet {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 70px -30px rgba(50, 35, 20, .5);
}

.sheet::backdrop { background: rgba(48, 38, 28, .35); backdrop-filter: blur(2px); }

.sheet-inner { margin: 0; display: flex; flex-direction: column; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}

.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover { background: var(--bg-deep); color: var(--ink); }

.sheet-body { padding: 0 20px 6px; }

.textarea {
  width: 100%;
  min-height: 220px;
  max-height: 46vh;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, var(--sans);
  font-size: 13px;
  line-height: 1.8;
  resize: vertical;
  margin-bottom: 10px;
}

.textarea:focus {
  outline: none;
  border-color: #cba98f;
  box-shadow: 0 0 0 3px rgba(176, 82, 47, .1);
}

.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #2e2722;
  color: #fdf7ef;
  font-size: 13px;
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 60;
  max-width: calc(100vw - 40px);
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 手机 ---------- */

@media (max-width: 680px) {
  .shell { padding: 0 16px 64px; }
  .topbar { padding: 12px 0 10px; gap: 10px; }
  .brand-text strong { font-size: 13.5px; }
  .tab { padding: 6px 13px; font-size: 13px; }
  .card { min-height: 320px; padding: 18px 20px 20px; border-radius: 18px; }
  .card-body { padding: 14px 0; }
  .meaning { font-size: 16.5px; }
  .ratings { grid-template-columns: repeat(2, 1fr); }
  .rate { flex-direction: row; justify-content: center; gap: 8px; padding: 13px 8px; }
  .rate small { color: var(--ink-3); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .wrow { grid-template-columns: 1fr 32px; gap: 2px 10px; padding: 12px 2px; }
  .wterm { grid-column: 1; }
  .wmean { grid-column: 1; -webkit-line-clamp: 1; }
  .wbar, .wdue, .wtier { display: none; }
  .wdel { grid-column: 2; grid-row: 1 / span 2; }
  .keys { display: none; }
  .study-meta { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
