:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12), 0 4px 6px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  padding: 20px 16px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.app-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: 1px; }
.app-header .subtitle { font-size: 0.8rem; opacity: 0.85; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.center { text-align: center; }
.card h2 { font-size: 1.05rem; margin-bottom: 12px; color: var(--text); }
.card h2 .section-sub { font-size: 0.72rem; font-weight: normal; color: var(--text-light); margin-left: 8px; }

/* 可折叠卡片标题 */
.card.collapsible .section-title {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.card.collapsible .section-title .caret {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-light);
  transition: transform .2s ease;
  line-height: 1;
}
.card.collapsible.collapsed .section-title .caret { transform: rotate(-90deg); }
.card.collapsible.collapsed .section-title { margin-bottom: 0; }
.card h2 .count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 10px; background: var(--primary); color: #fff;
  font-size: 0.75rem; font-weight: normal; line-height: 1;
}
.card.collapsible.collapsed .item-list { display: none; }

textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fafafa;
  resize: vertical;
}
input[type="text"] { margin-bottom: 10px; }
textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--primary); background: #fff; }

button {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform .06s ease, background .2s;
}
button:active { transform: scale(0.97); }
button.primary { background: var(--primary); color: #fff; width: 100%; }
button.primary:hover { background: var(--primary-dark); }
button.secondary {
  background: #fff; color: var(--text-light);
  border: 1px solid var(--border);
  padding: 8px 14px; font-size: 0.85rem; border-radius: 8px;
  flex: 0 0 auto;
}
button.secondary:hover { background: #f3f4f6; color: var(--text); border-color: var(--primary); }
button.secondary.mini { padding: 4px 10px; font-size: 0.75rem; }
.data-card { padding: 12px 16px; }
.data-card h2 { margin-bottom: 8px; }
.io-row { display: flex; gap: 8px; }

/* 云同步账号区 */
.account-area { flex: 1; min-width: 0; }
.account-guest { font-size: 0.85rem; color: var(--text-light); margin-bottom: 6px; }
.account-active { font-size: 0.85rem; color: #047857; margin-bottom: 4px; }
.account-sync-info { font-size: 0.75rem; color: var(--text-light); margin-bottom: 6px; }
.account-login-row { display: flex; gap: 8px; }
.invite-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 0.9rem; outline: none; font-family: inherit;
}
.invite-input:focus { border-color: var(--primary); }
.account-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.account-btn-row .secondary { padding: 6px 12px; font-size: 0.82rem; }
.hidden-file { display: none; }
button.big-primary {
  background: var(--primary); color: #fff;
  font-size: 1.15rem; padding: 14px 36px;
  border-radius: 30px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 200px;
  position: relative;
}
button.big-primary:hover { background: var(--primary-dark); }
button.big-secondary {
  background: #fff; color: var(--primary);
  border: 2px solid var(--primary);
  font-size: 1.15rem; padding: 12px 36px;
  border-radius: 30px; box-shadow: var(--shadow);
  width: 100%; max-width: 200px;
  position: relative;
}
button.big-secondary:hover { background: #eef2ff; }
.start-row { display: flex; flex-direction: row; justify-content: center; align-items: stretch; gap: 12px; max-width: 420px; margin: 0 auto; }
.mode-hint { margin-top: 10px; font-size: 0.75rem; color: var(--text-light); }
.badge-dot {
  position: absolute;
  top: 4px; right: 8px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--danger);
  display: none;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
}

.item-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.item-list li {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95rem;
}
.item-list li .item-content { margin-bottom: 6px; word-break: break-word; }
.item-list li .item-content .en-text { font-size: 1.05rem; font-weight: 600; }
.item-list li .item-content .mean-text { margin-left: 8px; color: var(--text); }
/* 音标：显示小一号、灰色斜体 */
.phon-small {
  font-size: 0.75rem;
  color: var(--text-light);
  font-style: italic;
  margin-left: 4px;
  white-space: nowrap;
}
.item-list li .item-meta { font-size: 0.75rem; color: var(--text-light); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item-list li .item-meta .date { color: var(--text-light); }

/* 超过4天未添加新项的悬停提示图标 */
.stale-hint {
  display: inline-flex; align-items: center;
  margin-left: 8px; font-size: 0.9rem;
  color: #d97706; cursor: help; line-height: 1;
}
.stale-hint.hidden { display: none; }
/* 忘记复习 badge */
.item-list li .item-meta .forget-badge {
  display: inline-flex; align-items: center; gap: 2px;
  background: #fef3c7; color: #92400e;
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.75rem; border: 1px solid #fde68a;
  cursor: help; line-height: 1.4;
  white-space: nowrap;
}
.item-list li .item-meta .forget-badge:hover { background: #fde68a; }
.item-list li.empty { text-align: center; color: var(--text-light); padding: 18px; font-style: italic; background: transparent; border: none; }

/* 精确搜索行 */
.exact-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.exact-search-row .exact-search {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 0.95rem; outline: none; font-family: inherit;
  margin-bottom: 0;
}
.exact-search-row .exact-search:focus { border-color: var(--primary); }
.exact-search-row .secondary { flex-shrink: 0; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 16px; padding: 22px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-progress { text-align: center; font-size: 0.8rem; color: var(--text-light); }
.modal-quiz {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  min-height: 120px; justify-content: center;
  padding: 8px 0;
}
.modal-actions { display: flex; gap: 12px; }
.modal-actions button { flex: 1; padding: 14px 0; font-size: 1rem; border-radius: 12px; }
.modal-actions .check { background: var(--success); color: #fff; }
.modal-actions .cross { background: var(--danger); color: #fff; }
.modal-actions .readd { background: #f59e0b; color: #fff; }
.modal-actions .readd:hover { background: #d97706; }
.close-btn { background: #f3f4f6; color: var(--text-light); width: 100%; padding: 8px; font-size: 0.85rem; }
.skip-btn {
  background: #fff; color: #d97706;
  border: 1px dashed #fcd34d; width: 100%;
  padding: 8px; font-size: 0.85rem; margin-top: 6px;
}
.skip-btn:hover { background: #fffbeb; border-color: #d97706; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(31,41,55,0.95); color: #fff;
  padding: 10px 18px; border-radius: 24px; font-size: 0.85rem;
  z-index: 2000; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
}
.toast.hidden { display: none; }

/* 列表项操作按钮 */
.item-list li .item-actions { margin-top: 8px; display: flex; gap: 6px; justify-content: flex-end; }
.item-list li .item-actions button {
  background: #f3f4f6; color: var(--text-light); padding: 5px 12px;
  font-size: 0.8rem; border-radius: 8px; font-weight: 500;
}
.item-list li .item-actions button:hover { background: #e5e7eb; color: var(--text); }
.item-list li .item-actions button[data-memorize-key] { background: #eef2ff; color: var(--primary); }
.item-list li .item-actions button[data-memorize-key]:hover { background: #c7d2fe; }

/* 设置行 */
.setting-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-label {
  font-size: 0.85rem; color: var(--text-light);
  text-align: right;
}

/* 阶段时间轴（含每档出题方向） */
.stages {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px; padding: 6px 0;
}
.stage {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 8px;
  background: #f3f4f6; color: var(--text-light);
  font-size: 0.7rem; line-height: 1.4;
  border: 1px solid transparent;
}
.stage .stage-label { font-weight: 600; }
.stage .stage-mode {
  background: #fff; border: 1px solid var(--border);
  border-radius: 6px; padding: 0 4px; font-size: 0.65rem;
}
.stage .stage-date { color: var(--text-light); }
.stage .stage-mark { font-weight: bold; }
.stage.done { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.stage.done .stage-date { color: #047857; }
.stage.current { background: #eef2ff; color: var(--primary); border-color: #c7d2fe; font-weight: 600; }
.stage.current .stage-date { color: var(--primary); }
.stage.today { box-shadow: 0 0 0 2px #fbbf24; }

/* 编辑弹窗 */
.edit-card { max-width: 520px; gap: 12px; }
.edit-section { display: flex; flex-direction: column; gap: 6px; }
.edit-label {
  font-size: 0.85rem; color: var(--text-light);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.edit-label-hint { font-size: 0.72rem; color: var(--text-light); opacity: 0.8; font-weight: normal; }
.entry-form { display: flex; flex-direction: column; gap: 10px; }
.entry-row { display: flex; align-items: center; gap: 8px; }
.entry-row .entry-label {
  flex: 0 0 50px;
  font-size: 0.85rem; color: var(--text-light);
  text-align: right;
}
.entry-row .entry-input {
  flex: 1;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 1rem;
  background: #fafafa; color: var(--text); min-width: 0;
  margin-bottom: 0;
}
.entry-row .entry-input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* 音标行（每个单词一条，音标显示小一号） */
.phon-rows {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  background: #fafafa; border: 1px dashed var(--border);
  border-radius: 10px;
}
.phon-row { display: flex; align-items: center; gap: 8px; }
.phon-row .phon-word {
  flex: 0 0 90px;
  font-size: 0.8rem; font-weight: 600; color: var(--text);
  text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.phon-row .phon-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem; font-style: italic;   /* 音标显示小一号 */
  font-family: Georgia, "Times New Roman", serif;
  background: #fff; color: var(--primary);
  outline: none;
  margin-bottom: 0;
}
.phon-row .phon-input:focus { border-color: var(--primary); }
.phon-empty { font-size: 0.78rem; color: var(--text-light); font-style: italic; text-align: center; padding: 4px; }

/* chip 容器（中文释义） */
.chip-box {
  display: flex; flex-wrap: wrap; gap: 8px;
  min-height: 44px; padding: 8px;
  background: #fafafa; border: 1px dashed var(--border);
  border-radius: 10px; align-items: center;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2ff; color: var(--primary);
  padding: 6px 8px 6px 12px; border-radius: 18px;
  font-size: 0.95rem; user-select: none;
  cursor: default; line-height: 1.4;
  min-height: 32px;
}
.chip .chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.08); color: inherit; font-size: 13px;
  margin-left: 2px; cursor: pointer;
}
.chip .chip-x:hover { background: rgba(220,38,38,0.2); color: #dc2626; }
.chip-add {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 32px; padding: 0 10px;
  background: #fff; color: var(--text-light);
  border: 1px dashed var(--border); border-radius: 18px;
  font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.chip-add:hover { background: #f3f4f6; color: var(--primary); border-color: var(--primary); }
.chip-input {
  border: 1px solid var(--primary); background: #fff;
  border-radius: 18px; padding: 6px 12px;
  font-size: 0.95rem; min-width: 120px; outline: none;
  font-family: inherit; height: 32px;
  margin-bottom: 0;
}

/* 记忆弹窗：出题内容 */
.quiz-en {
  /* 逐词单元横排；每个单元内单词在上、音标在下左对齐 */
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 24px;
  row-gap: 10px;
  text-align: left;
  font-size: 2.4rem;
  line-height: 1.25;
  color: var(--text);
  padding: 8px 0;
  word-break: break-word;
}
.quiz-word-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
/* 遮罩态（请回忆英文…）保持居中 */
.quiz-en.masked {
  display: block;
  text-align: center;
}
/* 音标跟在英文下，小一号；纯文字无底框，与单词字形严格左对齐 */
.quiz-phon {
  font-size: 1rem;
  font-style: italic;
  color: var(--primary);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.4;
  padding: 0;
}
.quiz-meaning {
  font-size: 1.6rem;
  line-height: 1.4;
  color: var(--primary);
  text-align: center;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 8px 18px;
  max-width: 100%;
  word-break: break-word;
}
.quiz-en.masked, .quiz-meaning.masked {
  font-size: 1rem;
  color: var(--text-light);
  font-style: italic;
  background: transparent;
  border-color: transparent;
  padding: 12px 8px;
}

/* 对照按钮 */
.modal-actions .peek {
  background: #f3f4f6; color: var(--text); flex: 0 0 auto;
  padding: 14px 16px; font-size: 0.9rem;
}
.modal-actions .peek:hover { background: #e5e7eb; }

@media (min-width: 768px) {
  .app-header { padding: 28px; }
  .app-header h1 { font-size: 1.8rem; }
  .container { padding: 20px 16px 100px; }
  .card { padding: 20px; }
  .edit-card { padding: 24px; }
}
