/* ============================================
   小熊背单词 — 卡通可爱风
   ============================================ */

:root {
  --c-primary: #4FC3A1;        /* 薄荷绿 */
  --c-primary-dark: #3BA888;
  --c-accent:  #FFD93D;        /* 暖黄 */
  --c-blue:    #6BCBEF;
  --c-pink:    #FF8FAB;
  --c-red:     #FF6B6B;
  --c-bg:      #FFF9EC;        /* 米黄底 */
  --c-card:    #FFFFFF;
  --c-text:    #2D3142;
  --c-text-2:  #6B7280;
  --c-border:  #E5E7EB;
  --r:         18px;
  --r-sm:      12px;
  --shadow:    0 4px 14px rgba(79,195,161,.12), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(79,195,161,.18);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 80px;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* ========== 顶部 ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  max-width: 720px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 42px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.1)); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--c-primary-dark); }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--c-text-2); }

.today { text-align: right; }
.today .date { font-size: 14px; color: var(--c-text-2); }
.today .weekday {
  display: inline-block;
  font-size: 12px; padding: 3px 10px;
  background: var(--c-accent); color: #8B6914;
  border-radius: 999px; font-weight: 600;
  margin-top: 4px;
}

/* ========== 统计 ========== */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; padding: 0 20px;
  max-width: 720px; margin: 0 auto;
}
.stat {
  background: var(--c-card);
  border-radius: var(--r);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform .15s;
}
.stat:active { transform: scale(.97); }
.stat-num {
  font-size: 26px; font-weight: 800;
  background: linear-gradient(135deg, var(--c-primary), var(--c-blue));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 12px; color: var(--c-text-2); margin-top: 2px; }
.stat-review .stat-num { background: linear-gradient(135deg, #FF8FAB, #FFD93D); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-new .stat-num     { background: linear-gradient(135deg, #6BCBEF, #4FC3A1); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-master .stat-num  { background: linear-gradient(135deg, #FFD93D, #FF8FAB); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-streak .stat-num  { background: linear-gradient(135deg, #FF6B6B, #FFD93D); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ========== 录入区 ========== */
.add {
  padding: 16px 20px 0;
  max-width: 720px; margin: 0 auto;
}
.add-box {
  display: flex; gap: 8px;
  background: var(--c-card);
  border-radius: var(--r);
  padding: 6px;
  box-shadow: var(--shadow);
}
#wordInput {
  flex: 1;
  border: none; outline: none; background: transparent;
  padding: 12px 14px;
  font-size: 17px;
  color: var(--c-text);
}
.btn-add {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--c-primary); color: white;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, background .15s;
}
.btn-add:hover { background: var(--c-primary-dark); }
.btn-add:active { transform: scale(.92); }
.btn-add:disabled { background: #ccc; cursor: not-allowed; }

.suggest {
  margin-top: 8px;
  background: var(--c-card);
  border-radius: var(--r);
  padding: 8px;
  box-shadow: var(--shadow);
  max-height: 200px; overflow-y: auto;
}
.suggest-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .12s;
}
.suggest-item:hover { background: #F4FBF8; }
.suggest-item .si-word { font-weight: 600; font-size: 15px; }
.suggest-item .si-meaning { color: var(--c-text-2); font-size: 13px; margin-top: 2px; }
.suggest-item .si-add {
  background: var(--c-primary); color: white;
  border-radius: 8px;
  padding: 4px 10px; font-size: 12px;
}
.add-tip {
  margin-top: 8px; padding: 0 8px;
  font-size: 12px; color: var(--c-text-2);
  min-height: 16px;
}

/* ========== 列表 ========== */
.list-section {
  padding: 16px 20px 0;
  max-width: 720px; margin: 0 auto;
}
.list-tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
  background: var(--c-card);
  padding: 4px;
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.tab {
  flex: 1; padding: 10px 6px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  color: var(--c-text-2);
  transition: all .15s;
}
.tab-active {
  background: var(--c-primary); color: white;
  box-shadow: 0 2px 8px rgba(79,195,161,.4);
}

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

.card {
  background: var(--c-card);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .15s, opacity .3s;
  position: relative;
  overflow: hidden;
}
.card.due-new { border-left: 4px solid var(--c-blue); }
.card.due-review-1 { border-left: 4px solid var(--c-primary); }
.card.due-review-2 { border-left: 4px solid var(--c-accent); }
.card.due-review-3 { border-left: 4px solid var(--c-pink); }
.card.due-review-4 { border-left: 4px solid var(--c-red); }
.card.mastered { border-left: 4px solid var(--c-accent); opacity: .7; }

.card.knew-flash { animation: knewFlash .8s ease-out; }
@keyframes knewFlash {
  0%   { background: var(--c-card); }
  30%  { background: #D5F5E3; }
  100% { background: var(--c-card); }
}
.card.knew-flash .btn-know {
  animation: starPop .8s ease-out;
}
@keyframes starPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.25) rotate(-8deg); }
  60%  { transform: scale(1.1) rotate(4deg); }
  100% { transform: scale(1); }
}

.card-head { margin-bottom: 8px; }
.word-row { display: flex; align-items: center; gap: 8px; }
.word {
  font-size: 22px; font-weight: 700;
  color: var(--c-text);
}
.phonetic {
  font-size: 14px; color: var(--c-text-2);
  margin-top: 2px;
  font-family: "Lucida Sans Unicode", "Arial Unicode MS", serif;
  min-height: 18px;
}
.phonetic.loading { color: var(--c-blue); font-style: italic; font-size: 12px; }

.btn-sound, .btn-reveal {
  margin-left: auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #F4FBF8;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-sound:hover, .btn-reveal:hover { background: #E5F5EE; }
.btn-sound:active, .btn-reveal:active { transform: scale(.9); }

.card-body { padding-top: 8px; border-top: 1px dashed var(--c-border); margin-top: 8px; }
.meaning { font-size: 16px; color: var(--c-text); line-height: 1.6; }
.meaning .pos { color: var(--c-primary-dark); font-style: italic; margin-right: 4px; font-weight: 600; }
.meta {
  margin-top: 6px;
  font-size: 12px; color: var(--c-text-2);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.meta-tag {
  background: #F4FBF8;
  padding: 2px 8px;
  border-radius: 999px;
}

.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-know, .btn-forgot {
  flex: 1;
  padding: 11px 0;
  border-radius: var(--r-sm);
  font-size: 15px; font-weight: 700;
  transition: transform .12s, background .15s;
}
.btn-know {
  background: linear-gradient(135deg, #4FC3A1, #6BCBEF);
  color: white;
  box-shadow: 0 3px 10px rgba(79,195,161,.4);
}
.btn-know:hover { filter: brightness(1.05); }
.btn-know:active { transform: scale(.96); }
.btn-forgot {
  background: #FFF5E5;
  color: #C77E20;
}
.btn-forgot:hover { background: #FFE9C7; }
.btn-forgot:active { transform: scale(.96); }

/* 已掌握卡片简洁模式 */
.card.mastered .card-actions { display: none; }

/* ========== 空状态 ========== */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--c-text-2);
}
.empty-icon { font-size: 50px; margin-bottom: 12px; }
.empty p { margin: 4px 0; font-size: 15px; }
.empty-sub { font-size: 13px; color: #9CA3AF; }

/* ========== 设置按钮 ========== */
.fab-settings {
  position: fixed; right: 20px; bottom: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--c-card);
  box-shadow: var(--shadow-lg);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.fab-settings:active { transform: scale(.92); }

/* ========== 弹窗 ========== */
.dlg {
  border: none; border-radius: 20px;
  padding: 0;
  width: min(92vw, 420px);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.dlg::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }
.dlg form { padding: 24px; }
.dlg h2 { margin: 0 0 16px; font-size: 20px; color: var(--c-primary-dark); }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.setting-row label { color: var(--c-text-2); font-size: 14px; }
.setting-row input, .setting-row select {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  flex: 1; max-width: 220px;
}
.setting-row input:focus, .setting-row select:focus { border-color: var(--c-primary); }
.setting-hint { font-size: 12px; color: var(--c-text-2); margin: 6px 0 0; line-height: 1.5; }

.danger-zone {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--c-border);
}
.danger-zone summary {
  cursor: pointer;
  color: var(--c-text-2);
  font-size: 13px;
  margin-bottom: 8px;
}
.danger-zone summary:hover { color: var(--c-red); }
.danger-zone button {
  padding: 8px 12px;
  border-radius: 8px;
  background: #FFF5F5;
  color: var(--c-red);
  font-size: 13px;
}
.danger { background: var(--c-red) !important; color: white !important; }

.dlg-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px;
}
.btn-cancel, .btn-ok {
  padding: 10px 20px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
}
.btn-cancel { background: #F4F4F4; color: var(--c-text-2); }
.btn-ok { background: var(--c-primary); color: white; }

.dlg-foot {
  text-align: center;
  margin: 16px 0 0;
  font-size: 12px;
  color: #9CA3AF;
}

/* ========== Toast ========== */
.toast {
  position: fixed; left: 50%; top: 30%;
  transform: translateX(-50%);
  background: rgba(45,49,66,.92);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  animation: toastIn .2s ease-out;
  max-width: 80vw;
  text-align: center;
}
.toast.ok    { background: rgba(79,195,161,.95); }
.toast.err   { background: rgba(255,107,107,.95); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== 小屏适配 ========== */
@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 18px; }
  .word { font-size: 19px; }
}

/* ========== 庆祝动画（完成今日任务） ========== */
.celebrate { animation: celebrateBg 1s ease-out; }
@keyframes celebrateBg {
  0%   { background: var(--c-card); }
  50%  { background: #FFF8DC; }
  100% { background: var(--c-card); }
}