*{box-sizing:border-box}body{margin:0;background:#f3f6fb;color:#1d2939;font-family:system-ui,"Microsoft YaHei",sans-serif}header{background:#fff;padding:16px max(20px,calc((100vw - 920px)/2));display:flex;justify-content:space-between;align-items:center;gap:12px;border-bottom:1px solid #ddd}main{max-width:920px;margin:25px auto;padding:0 15px}.card{background:white;border-radius:16px;padding:24px;margin-bottom:15px;box-shadow:0 3px 15px #0001}button{border:0;border-radius:9px;padding:10px 15px;background:#2463eb;color:white;cursor:pointer;margin:4px}button:disabled{opacity:.5}input,textarea{display:block;width:100%;padding:12px;margin:7px 0 15px;border:1px solid #bbb;border-radius:8px;font:inherit}.hanzi{font-size:29px;line-height:1.8}.char{cursor:pointer;padding:2px}.char:hover{background:#dbeafe}.pinyin{font-size:18px;color:#64748b}.sentence{border-bottom:1px solid #eee;padding:14px 0}.sentence:last-child{border:0}dialog{border:0;border-radius:16px;box-shadow:0 15px 60px #0005;max-width:95vw}dialog::backdrop{background:#0008}#writer{width:240px;height:240px;margin:auto}#character-content{text-align:center;font-size:24px}small{color:#666}.error{color:#b42318}.success{color:#15803d}pre{white-space:pre-wrap;word-break:break-word}


/* 汉字学习弹窗 */
#character {
  width: min(920px, 96vw);
  max-width: 96vw;
  max-height: 90vh;
  padding: 30px;
  position: relative;
  overflow-y: auto;
  border-radius: 18px;
}
#character::backdrop { background: rgba(18, 31, 25, .65); }
.char-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  color: #52645b;
  font-size: 32px;
  padding: 0 10px;
}
.char-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.char-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.char-heading h2 { font-size: 56px; margin: 0; }
#character button:not(.char-close) { background: #187348; }
#character #replay {
  background: #edf7ef;
  color: #175b3a;
  border: 1px solid #b6d8bf;
}
.writing-grid {
  position: relative;
  width: 260px;
  height: 260px;
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid #81c995;
  background-color: #f5fff7;
  background-image:
    linear-gradient(to right, transparent calc(50% - .5px), #a3d8ad 50%, transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), #a3d8ad 50%, transparent calc(50% + .5px)),
    linear-gradient(45deg, transparent calc(50% - .5px), #d0ead4 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), #d0ead4 50%, transparent calc(50% + .5px));
}
#writer {
  width: 256px;
  height: 256px;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.char-actions { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.char-note { color: #69776f; font-size: 13px; text-align: center; }
.char-right { padding-top: 15px; }
.char-right h3 { color: #17603c; margin: 20px 0 8px; }
.char-pinyin { color: #187348; font-size: 34px; font-weight: 700; margin: 4px 0 12px; }
.char-meaning { font-size: 18px; }
.word-list { display: grid; gap: 8px; }
.word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: #f0faf3;
}
.word-item span { font-size: 15px; color: #53675a; }
#character .word-item button {
  margin: 0;
  padding: 6px 10px;
  white-space: nowrap;
}
@media (max-width: 650px) {
  #character { padding: 42px 15px 18px; }
  .char-layout { grid-template-columns: 1fr; gap: 12px; }
  .char-right { padding-top: 0; }
}


/* ===== 拼音格 + 标准十字田字格 ===== */

.practice-sheet {
  width: 260px;
  max-width: 100%;
  margin: 0 auto;
}

/* 拼音格：上下实线，中间两条虚线 */
.pinyin-grid {
  position: relative;
  width: 100%;
  height: 82px;
  margin-bottom: 12px;
  border-top: 2px solid #67bb7c;
  border-bottom: 2px solid #67bb7c;
  background:
    linear-gradient(
      to bottom,
      transparent calc(33.333% - .5px),
      #8ccc9b calc(33.333% - .5px),
      #8ccc9b calc(33.333% + .5px),
      transparent calc(33.333% + .5px)
    ),
    linear-gradient(
      to bottom,
      transparent calc(66.666% - .5px),
      #8ccc9b calc(66.666% - .5px),
      #8ccc9b calc(66.666% + .5px),
      transparent calc(66.666% + .5px)
    ),
    #f5fff7;
}

/* 使用重复线段把拼音格中间两条横线显示为虚线 */
.pinyin-grid {
  background:
    repeating-linear-gradient(
      to right,
      #79c78d 0 8px,
      transparent 8px 14px
    ) left 33.333% / 100% 1px no-repeat,
    repeating-linear-gradient(
      to right,
      #79c78d 0 8px,
      transparent 8px 14px
    ) left 66.666% / 100% 1px no-repeat,
    #f5fff7;
}

/*
 * 拼音基线位于第三条线附近。
 * 将字母主体放在中间格；声调和上伸部分进入上格。
 */
#grid-pinyin {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #17683e;
  font-family: Arial, "Noto Sans", sans-serif;
  font-size: 43px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* 标准田字格：实线外框、虚线十字、没有对角线 */
#character .writing-grid {
  position: relative;
  width: 260px;
  height: 260px;
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid #67bb7c;
  background: #f5fff7;
  overflow: hidden;
}

/* 中间竖虚线 */
#character .writing-grid::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - .5px);
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    #79c78d 0 8px,
    transparent 8px 14px
  );
  pointer-events: none;
}

/* 中间横虚线 */
#character .writing-grid::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - .5px);
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    #79c78d 0 8px,
    transparent 8px 14px
  );
  pointer-events: none;
}

/* 笔顺动画显示在田字格线条上方 */
#character #writer {
  position: relative;
  z-index: 1;
  width: 256px;
  height: 256px;
  margin: 0 auto;
}

