:root {
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --ink: #20201d;
  --muted: #77746d;
  --line: #ded8ca;
  --green: #315f4a;
  --green-soft: #dfe9df;
  --amber: #a46824;
  --red: #9b4d45;
  --shadow: 0 18px 50px rgba(52, 47, 37, .11);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(255,255,255,.85), transparent 35%),
    var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: 100%; max-width: 760px; margin: 0 auto; padding: 26px 22px 48px; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.topbar > div { min-width: 0; }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 28px; letter-spacing: .02em; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.icon-button, .speak-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.5); color: var(--green);
  border-radius: 999px; min-width: 42px; height: 42px; font-weight: 700;
}
.icon-button.off { color: var(--muted); text-decoration: line-through; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 24px 0 20px; border-bottom: 1px solid var(--line); }
.tab { padding: 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); }
.tab.active { color: var(--ink); border-color: var(--green); font-weight: 700; }
.view { display: none; }
.view.active { display: block; }
.session-strip { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; font-size: 13px; }
.session-strip > div:first-child { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.session-strip strong { font-size: 20px; }
.progress-track { flex: 1 1 40px; min-width: 20px; height: 5px; overflow: hidden; border-radius: 10px; background: #ddd7cb; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s; }
.muted { color: var(--muted); }
.word-card {
  width: 100%;
  min-width: 0;
  min-height: 420px; display: flex; flex-direction: column; padding: 26px;
  border: 1px solid rgba(203,196,181,.9); border-radius: 22px; background: var(--surface);
  box-shadow: var(--shadow);
}
.card-meta { display: flex; justify-content: space-between; align-items: center; }
.badge { padding: 6px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; }
.speak-button { height: 34px; padding: 0 12px; }
.word-area { flex: 1; display: grid; place-content: center; text-align: center; padding: 40px 10px 25px; }
.word-area h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(44px, 10vw, 72px); font-weight: 500; letter-spacing: -.03em; overflow-wrap: anywhere; }
.word-pos { color: var(--muted); font-family: Georgia, serif; font-style: italic; }
.divider { height: 1px; background: var(--line); margin-bottom: 22px; }
.answer-area { text-align: center; animation: reveal .25s ease; }
.meaning { font-size: 23px; font-weight: 700; margin: 0 0 24px; }
.label { margin: 0 0 7px; color: var(--muted); font-size: 11px; letter-spacing: .16em; }
.collocation { margin: 0 0 28px; color: var(--green); font-family: Georgia, serif; font-size: 21px; }
.primary-button, .secondary-button, .danger-button {
  min-height: 48px; border-radius: 12px; padding: 0 18px; font-weight: 700;
}
.primary-button { border: 0; background: var(--green); color: white; }
.primary-button kbd { margin-left: 8px; color: rgba(255,255,255,.65); }
kbd { border: 1px solid currentColor; border-radius: 4px; padding: 1px 5px; font-size: 10px; }
.rating-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.rating {
  position: relative; display: grid; gap: 3px; min-height: 72px; padding: 10px 6px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.62);
}
.rating span { color: var(--muted); font-size: 11px; }
.rating kbd { position: absolute; top: 7px; right: 7px; color: #aaa; }
.rating.forgot strong { color: var(--red); }
.rating.fuzzy strong { color: var(--amber); }
.rating.known strong { color: var(--green); }
.hidden { display: none !important; }
.empty-state { padding: 70px 20px; text-align: center; }
.checkmark { width: 70px; height: 70px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 34px; }
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search-box input { width: 100%; height: 44px; border: 0; outline: 0; background: transparent; }
select { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 10px; }
.word-list { display: grid; gap: 8px; }
.word-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.56); }
.word-row h3 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 20px; }
.word-row p { margin: 2px 0; color: var(--muted); font-size: 13px; }
.word-row .phrase { color: var(--green); }
.status-dot { align-self: center; width: 10px; height: 10px; border-radius: 50%; background: #c8c3b8; }
.status-dot.learning { background: var(--amber); }
.status-dot.mastered { background: var(--green); }
.import-panel, .settings-card, .mastery-card { margin-top: 22px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.5); }
.import-panel h3, .settings-card h3 { margin-top: 0; }
.import-panel p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.secondary-button { display: inline-grid; place-items: center; border: 1px solid var(--green); background: transparent; color: var(--green); }
.danger-button { border: 1px solid #d7aaa5; background: transparent; color: var(--red); }
.file-button input { display: none; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card { padding: 18px 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); text-align: center; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 5px; font: 28px Georgia, serif; }
.mastery-card { display: flex; align-items: center; gap: 24px; }
.mastery-card h2 { margin: 4px 0 8px; }
.ring {
  flex: 0 0 120px; width: 120px; height: 120px; display: grid; place-items: center;
  border-radius: 50%; background: conic-gradient(var(--green) 0%, #ddd8cd 0);
  position: relative; font: 24px Georgia, serif;
}
.ring::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; z-index: 1; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.essay-header, .essay-progress { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.essay-header h2 { margin: 3px 0 16px; font-family: Georgia, serif; }
.essay-progress { margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.essay-progress .progress-track { max-width: 280px; }
.essay-card {
  min-height: 470px; display: flex; flex-direction: column; padding: 25px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow);
}
.essay-card h2 { margin: 24px 0 18px; font: 28px Georgia, "Microsoft YaHei", serif; }
.essay-prompt { padding: 18px; border-radius: 13px; background: #f1ede4; line-height: 1.8; }
.essay-prompt p, .essay-answer p { margin-top: 0; }
.essay-answer { flex: 1; margin: 20px 0; animation: reveal .25s ease; }
#essayEnglish { color: #243f34; font: 20px/1.75 Georgia, "Times New Roman", serif; }
.essay-note { padding: 12px 14px; border-left: 3px solid var(--amber); background: #faf5e9; color: #6d604b; font-size: 13px; line-height: 1.65; }
.essay-card > .primary-button { margin-top: auto; }
.essay-actions { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; margin-top: 14px; }
.essay-actions button.mastered { background: var(--green-soft); color: var(--green); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 18px; border-radius: 999px; background: #24241f; color: white; font-size: 13px; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.install-button {
  position: fixed; right: 18px; bottom: 18px; z-index: 5; min-height: 44px;
  padding: 0 16px; border: 0; border-radius: 999px; background: #20201d;
  color: white; box-shadow: 0 10px 28px rgba(0,0,0,.2); font-weight: 700;
}
@keyframes reveal { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 580px) {
  .shell { padding: 20px 14px 36px; }
  .session-strip { gap: 8px; }
  .session-strip > div:first-child .muted { display: none; }
  .word-card { min-height: 390px; padding: 20px; border-radius: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mastery-card { align-items: flex-start; }
  .ring { flex-basis: 90px; width: 90px; height: 90px; }
  .toolbar { grid-template-columns: 1fr; }
}
