/* ============================================================
   同步单词（教材详情 + 单元卡片）
   —— 仅服务于「我的 › 同步单词」流程，独立样式，不影响其它页面
   ============================================================ */
:root {
  --fu: clamp(13px, 3.4vw, 18px); /* 尺寸基准，随屏缩放 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  background: linear-gradient(160deg, #e7f7ee 0%, #f1fbf4 40%, #eafaf0 100%);
  min-height: 100vh;
  font-size: var(--fu);
  -webkit-font-smoothing: antialiased;
}

/* ===== 视图一：教材详情 ===== */
.sync-detail {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(1.6rem + env(safe-area-inset-top)) 1.6rem calc(1.6rem + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.sd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.sd-title-wrap { min-width: 0; flex: 1; }
.sd-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.32;
  letter-spacing: 0.01rem;
  color: #17301f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.sd-sub {
  margin: 0.5rem 0 0;
  font-size: 1.25rem;
  color: #6b7280;
  font-weight: 600;
}
.sd-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.7rem; flex-shrink: 0; }
.sd-switch {
  border: 1px solid rgba(249, 115, 22, 0.26);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.56rem 1.05rem;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.02rem;
  color: #ea6a12;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 0.25rem 0.7rem rgba(234, 106, 18, 0.16);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.sd-switch:active { transform: scale(0.96); }
.sd-switch-ic { width: 1.2rem; height: 1.2rem; display: block; }

/* 封面舞台 */
.sd-cover-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.2rem 0;
  min-height: 30vh;
}
.sd-ring {
  position: absolute;
  width: 92%;
  aspect-ratio: 1 / 1;
  max-width: 400px;
}
.sd-ring svg { width: 100%; height: 100%; display: block; }
.sd-ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: rgba(31, 122, 74, 0.16); }
.ring-fg {
  stroke: #12a150;
  stroke-linecap: round;
  stroke-dasharray: 0 289.03;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dasharray 0.6s ease;
}
.sd-cover {
  position: relative;
  width: 42%;
  max-width: 180px;
  aspect-ratio: 3 / 4;
  border-radius: 0.8rem;
  overflow: hidden;
  box-shadow: 0 1rem 2.4rem rgba(31, 92, 56, 0.22);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sd-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sd-cover-txt {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; text-align: center;
  color: #fff; font-weight: 800; font-size: 1.5rem; line-height: 1.4;
  text-shadow: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.25);
}
.sd-cover-empty { color: #9ca3af; font-size: 1.15rem; font-weight: 700; }

/* 统计 */
.sd-stats {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.4rem 0 1.4rem;
}
.sd-stat { text-align: center; }
.sd-stat-num { font-size: 1.9rem; font-weight: 900; color: #17301f; line-height: 1.1; }
.sd-stat-num.gray { color: #9ca3af; }
.sd-stat-num b { font-weight: 900; }
.sd-stat-label {
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.sd-stat-label i { width: 0.7rem; height: 0.7rem; border-radius: 50%; display: inline-block; }
.sd-stat-label.sd-learned i { background: #fbbf24; }
.sd-stat-label.sd-mastered i { background: #34c77b; }
.sd-stat-label.gray { color: #9ca3af; }

/* 底部按钮 */
.sd-foot { padding-top: 0.4rem; }
.sd-start {
  width: 100%;
  border: none;
  cursor: pointer;
  padding: 1.15rem 1rem;
  border-radius: 1.6rem;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.08rem;
  color: #fff;
  background: linear-gradient(135deg, #3fd07f 0%, #1fae66 100%);
  box-shadow: 0 0.7rem 1.5rem rgba(31, 174, 102, 0.35);
}
.sd-start:active { transform: scale(0.98); }
.sd-start:disabled { background: #cbd5d1; box-shadow: none; color: #f4f7f5; cursor: default; }

/* ===== 视图二：单元卡片 ===== */
.sync-units {
  min-height: 100vh;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(0.8rem + env(safe-area-inset-top)) 1.2rem calc(2rem + env(safe-area-inset-bottom));
}
.su-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0 1rem;
  position: sticky;
  top: 0;
  background: linear-gradient(160deg, #e7f7ee 0%, #f1fbf4 100%);
  z-index: 5;
}
.su-back {
  border: none;
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  color: #17301f;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
.su-back:active { transform: scale(0.94); }
.su-title { font-size: 1.4rem; font-weight: 900; color: #17301f; }
.su-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding-top: 0.4rem;
}
.unit-mac {
  position: relative;
  border: none;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  border-radius: 1.2rem;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.06);
  overflow: hidden;
  text-align: center;
}
.unit-mac:active { transform: scale(0.97); }
.um-idx { font-size: 1.7rem; font-weight: 900; color: #2b3a30; letter-spacing: 0.02rem; }
.um-count {
  position: absolute;
  left: 1.1rem; right: 1.1rem; bottom: 1.1rem;
  font-size: 1.05rem; font-weight: 700; color: rgba(43, 58, 48, 0.72);
}
.um-badge {
  position: absolute;
  top: 0.7rem; right: 0.7rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #1fae66;
  background: rgba(255, 255, 255, 0.75);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
}
.su-empty { grid-column: 1 / -1; text-align: center; color: #9ca3af; padding: 4rem 0; font-size: 1.15rem; }

/* toast */
.sd-toast {
  position: fixed;
  left: 50%; bottom: 12%;
  transform: translateX(-50%) translateY(1rem);
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.7rem 1.3rem;
  border-radius: 1.4rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 99;
  max-width: 80vw;
}
.sd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
