:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #059669;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

[v-cloak] { display: none; }

button { font: inherit; }

.muted { color: var(--muted); }
.error { color: var(--red); font-size: 14px; }
.pad { padding: 12px 0; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: 12px;
  background: #eef2f7;
  color: var(--text);
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease, background .15s ease;
  font-size: 15px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.tiny { padding: 6px 10px; font-size: 12px; border-radius: 9px; background: #f1f5f9; }
.btn.wide { width: 100%; margin-top: 16px; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 30px 24px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}
.login-hero {
  width: 96px;
  height: 96px;
  margin-bottom: 14px;
}
.login-hero svg { width: 100%; height: 100%; display: block; }
.login-card h1 { margin: 0 0 4px; font-size: 26px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.login-card input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  background: #fbfdff;
}
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

/* ---------- shell ---------- */
.app-shell {
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 84px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(243, 246, 251, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.topnav { display: none; gap: 4px; }
.topnav button {
  border: 0; background: transparent; padding: 8px 14px;
  border-radius: 10px; color: var(--muted); cursor: pointer; font-size: 14px;
}
.topnav button.active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(15,23,42,.06); }

.page { padding: 18px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; font-size: 24px; }

/* ---------- catalog tree ---------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.crumb {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 4px 3px;
  font-size: 14px;
  cursor: pointer;
}
.crumb.current { color: var(--muted); cursor: default; }
.crumb-sep { color: #cbd5e1; font-size: 13px; }
.deck-list { display: flex; flex-direction: column; gap: 10px; }
.deck-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .04);
  cursor: pointer;
}
.deck-name { font-size: 17px; font-weight: 650; }
.deck-arrow { color: #94a3b8; font-size: 24px; line-height: 1; }

/* ---------- catalog ---------- */
.segmented {
  display: flex;
  background: #e8edf5;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
.segmented button.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(15,23,42,.07);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chips button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chips button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
}
.toolbar-actions { display: flex; gap: 8px; }
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 8px;
}

.card-list { display: flex; flex-direction: column; gap: 10px; }
.catalog-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 3px 14px rgba(15,23,42,.04);
}
.catalog-item.done { opacity: .62; }
.check-wrap { display: flex; align-items: center; }
.check-wrap input { width: 18px; height: 18px; accent-color: var(--blue); }
.catalog-main { flex: 1; min-width: 0; }
.row1 { display: flex; align-items: center; gap: 8px; }
.word { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.row2 {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.5;
  color: #4b5563;
  white-space: normal;
  overflow-wrap: anywhere;
}
.row3 { margin-top: 3px; font-size: 12px; color: #9ca3af; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
}
.lv-A1 { background: #dcfce7; color: #166534; }
.lv-A2 { background: #ccfbf1; color: #115e59; }
.lv-B1 { background: #dbeafe; color: #1e40af; }
.lv-B2 { background: #e0e7ff; color: #3730a3; }
.lv-C1 { background: #ffedd5; color: #9a3412; }
.lv-C2 { background: #fee2e2; color: #991b1b; }

.badge {
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.empty { text-align: center; padding: 28px 10px; }

/* ---------- search ---------- */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.search-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  background: #fff;
  outline: none;
}
.search-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.search-help { font-size: 13px; margin: 0 0 10px; }
.catalog-search-form { margin-bottom: 16px; }
.search-result { margin-top: 14px; }
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.word-image {
  margin: 0;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .05);
}
.word-image a { display: block; }
.word-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  object-fit: contain;
  background: #fff;
}
.word-image figcaption {
  padding: 10px 12px;
  font-size: 14px;
  color: #4b5563;
  overflow-wrap: anywhere;
}
.search-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.search-item {
  background: var(--card);
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .04);
}
.search-empty { padding: 40px 12px; }

/* ---------- study ---------- */
.study-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(15,23,42,.06);
}
.study-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.hint {
  margin: 16px 0 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border-left: 4px solid #93c5fd;
  border-radius: 8px;
  color: #4b5563;
  font-size: 15px;
  line-height: 1.6;
}
.target-zh {
  color: var(--blue);
  font-weight: 700;
  background: var(--blue-soft);
  padding: 0 3px;
  border-radius: 4px;
}
.sentence {
  margin: 14px 0;
  font-size: 22px;
  line-height: 1.6;
  font-weight: 650;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.audio-row { display: flex; gap: 8px; margin: 10px 0; }
.answer { margin-top: 6px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.full-sentence {
  font-size: 20px;
  line-height: 1.6;
  font-weight: 600;
  white-space: pre-wrap;
}
.sentence-zh {
  color: #374151;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
}
.detail {
  margin-top: 14px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
}
.detail-label { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.detail p { margin: 0; line-height: 1.75; color: #374151; white-space: pre-wrap; }

.listen-card .listen-sentence { margin-top: 16px; }
.listen-note { font-size: 12px; margin: 14px 0 0; }

.rating-note { font-size: 13px; margin: 8px 0 0; }
.review-result {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--green-soft);
  color: #166534;
  font-size: 14px;
}
.rating-row { display: flex; gap: 10px; margin-top: 18px; }
.btn.rating {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  font-weight: 650;
}
.btn.rating small { font-weight: 400; font-size: 11px; opacity: .8; }
.btn.again { background: var(--red-soft); color: var(--red); }
.btn.hard { background: var(--amber-soft); color: var(--amber); }
.btn.good { background: var(--green-soft); color: var(--green); }

.done-card {
  text-align: center;
  background: var(--card);
  border-radius: 18px;
  padding: 34px 20px;
  box-shadow: 0 8px 30px rgba(15,23,42,.06);
}
.done-icon {
  width: 54px; height: 54px; margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
}
.done-card h3 { margin: 0 0 6px; }

/* ---------- profile ---------- */
.stats-section { margin-bottom: 18px; }
.stats-section h3 { margin: 0 0 8px; font-size: 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stats-grid.three { grid-template-columns: repeat(3, 1fr); }
.stats-grid.two { grid-template-columns: repeat(2, 1fr); }
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 3px 14px rgba(15,23,42,.04);
}
.stat .num { font-size: 28px; font-weight: 750; color: var(--blue); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mycards-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.mycards-head h3 { margin: 0; font-size: 18px; }
.mycards-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mycards-item {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .04);
}
.mycards-main .word { margin-right: 6px; }
.mycards-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.danger-text { color: var(--red); background: var(--red-soft); }

.settings-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-top: 18px;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .04);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.setting-title { font-weight: 650; }
.setting-desc { font-size: 13px; line-height: 1.5; margin-top: 2px; }
.setting-gap {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.mode-tabs { flex: 0 0 auto; min-width: 210px; }
.number-wrap { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.number-input {
  width: 74px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  background: #fbfdff;
  color: var(--text);
}
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
  cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: .2s;
}
.switch .slider:before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider:before { transform: translateX(20px); }

.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.notice {
  color: #166534;
  background: var(--green-soft);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, .45);
}
.modal {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 18px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.card-form-modal {
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
}
.card-form-modal label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.card-form-modal input,
.card-form-modal textarea,
.card-form-modal select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fbfdff;
}
.card-form-modal textarea { min-height: 64px; resize: vertical; }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0;
  color: var(--muted);
  font-size: 13px;
  border-radius: 10px;
  cursor: pointer;
}
.tabbar button.active { color: var(--blue); font-weight: 700; }

@media (max-width: 600px) {
  .setting-row { flex-wrap: wrap; }
  .mode-tabs { width: 100%; min-width: 0; }
}

/* ---------- desktop ---------- */
@media (min-width: 760px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .app-shell { padding-bottom: 30px; }
  .page { padding: 24px; }
}
