/* 认字小助手 —— 小学生生字查询 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --red: #e34d4d;
  --red-light: #f0a8a8;
  --orange: #ff8a3d;
  --green: #34c07c;
  --ink: #3d3a36;
  --bg: #fff7ea;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "微软雅黑", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, #ffe9c9 0 90px, transparent 91px),
    radial-gradient(circle at 88% 20%, #dff3e6 0 70px, transparent 71px),
    radial-gradient(circle at 78% 90%, #ffe1e1 0 100px, transparent 101px),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

header { text-align: center; padding: 26px 16px 8px; }
h1 { font-size: 34px; color: var(--red); letter-spacing: 2px; }
.sub { margin-top: 6px; color: #9a8f80; font-size: 15px; }

main { max-width: 860px; margin: 0 auto; padding: 14px 16px 30px; }

/* ---------- 搜索框 ---------- */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 3px solid var(--orange);
  border-radius: 999px; padding: 6px 10px 6px 20px;
  box-shadow: 0 4px 14px rgba(255, 138, 61, .18);
}
.search-icon { font-size: 20px; }
#q {
  flex: 1; border: 0; outline: 0; font-size: 22px; padding: 8px 4px;
  background: transparent; color: var(--ink); min-width: 0;
}
#clearBtn {
  border: 0; background: #f3ede3; color: #a89a86; width: 34px; height: 34px;
  border-radius: 50%; font-size: 15px; cursor: pointer; flex: none;
}
#clearBtn:hover { background: #ffe3cd; color: var(--orange); }

.hint { margin-top: 12px; text-align: center; color: #9a8f80; font-size: 15px; }
.hint .demo {
  border: 2px solid #ffd9b3; background: #fff; color: #d97a2b; cursor: pointer;
  border-radius: 999px; padding: 3px 12px; margin: 0 3px; font-size: 14px;
}
.hint .demo:hover { background: #fff3e4; }

/* ---------- 历史 ---------- */
.history { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; min-height: 10px; }
.history .h-chip {
  border: 0; background: #ffe9d2; color: #b25f22; cursor: pointer;
  border-radius: 999px; padding: 6px 14px; font-size: 15px;
}
.history .h-chip:hover { background: #ffdcb8; }
.history .h-title { color: #c4b8a6; font-size: 13px; align-self: center; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border-radius: 20px; padding: 16px;
  box-shadow: 0 6px 20px rgba(120, 90, 40, .08); margin-top: 16px;
}

/* ---------- 候选 ---------- */
.cand-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; }
.tab {
  border: 2px solid #f0e6d8; background: #faf6ef; color: #a3947f;
  padding: 7px 20px; border-radius: 999px; font-size: 16px; cursor: pointer;
}
.tab.active { background: #ffeeda; border-color: var(--orange); color: #d97a2b; font-weight: bold; }
.tones { display: flex; gap: 6px; flex-wrap: wrap; }
.tone {
  border: 2px solid #f0e6d8; background: #fff; color: #a3947f; cursor: pointer;
  border-radius: 999px; padding: 4px 12px; font-size: 14px;
}
.tone.active { background: #e2f4ea; border-color: var(--green); color: #1d8a56; font-weight: bold; }

.cand-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.cand-char {
  width: 86px; border: 2px solid #ffe1c4; background: #fffdf9; border-radius: 14px;
  cursor: pointer; text-align: center; padding: 8px 0 6px;
}
.cand-char:hover { border-color: var(--orange); background: #fff6ea; transform: translateY(-2px); }
.cand-char .cc-zi { font-family: "KaiTi", "楷体", "STKaiti", serif; font-size: 40px; line-height: 1.2; color: var(--ink); }
.cand-char .cc-py { font-size: 13px; color: #b08c5a; margin-top: 2px; }

.cand-words { margin-top: 14px; max-height: 380px; overflow: auto; }
.cand-word {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 2px solid #f3ece0; background: #fffdf9; border-radius: 14px;
  padding: 8px 14px; cursor: pointer; margin-bottom: 8px;
}
.cand-word:hover { border-color: var(--orange); background: #fff6ea; }
.cand-word .cw-ges { display: flex; gap: 4px; flex: none; }
.mini-ge {
  width: 46px; height: 46px; border: 2px solid var(--red); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg stroke='%23f0a8a8' stroke-width='2' stroke-dasharray='6 5' fill='none'%3E%3Cline x1='50' y1='0' x2='50' y2='100'/%3E%3Cline x1='0' y1='50' x2='100' y2='50'/%3E%3Cline x1='0' y1='0' x2='100' y2='100'/%3E%3Cline x1='100' y1='0' x2='0' y2='100'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
.mini-ge span { font-family: "KaiTi", "楷体", "STKaiti", serif; font-size: 30px; color: var(--ink); }
.cand-word .cw-txt { min-width: 0; }
.cand-word .cw-py { font-size: 14px; color: #b08c5a; }
.cand-word .cw-ex {
  font-size: 14px; color: #6f675c; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cand-empty { margin-top: 14px; color: #a3947f; font-size: 16px; text-align: center; padding: 20px 0; }

/* ---------- 结果 ---------- */
.ge-row { display: flex; justify-content: center; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 10px; --gs: 160px; }
.ge-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ge-py { font-size: 26px; font-weight: bold; color: #4a4238; letter-spacing: 1px; min-height: 32px; }

.ge {
  width: var(--gs); height: var(--gs); background: #fff;
  border: 3px solid var(--red); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg stroke='%23f0a8a8' stroke-width='1.4' stroke-dasharray='5 4' fill='none'%3E%3Cline x1='50' y1='0' x2='50' y2='100'/%3E%3Cline x1='0' y1='50' x2='100' y2='50'/%3E%3Cline x1='0' y1='0' x2='100' y2='100'/%3E%3Cline x1='100' y1='0' x2='0' y2='100'/%3E%3Crect x='2.5' y='2.5' width='95' height='95'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  box-shadow: 0 6px 16px rgba(227, 77, 77, .14);
}
.ge .zi {
  font-family: "KaiTi", "楷体", "STKaiti", serif;
  font-size: calc(var(--gs) * .76); line-height: 1; color: #33302b; user-select: none;
}
.ge.clickable { cursor: pointer; }
.ge.clickable:hover { box-shadow: 0 6px 20px rgba(227, 77, 77, .3); }
.ge-speak-tip { font-size: 13px; color: #c4b8a6; }

.controls { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; }
.btn-speak {
  border: 0; background: var(--green); color: #fff; font-size: 20px; cursor: pointer;
  padding: 10px 30px; border-radius: 999px; box-shadow: 0 4px 0 #24935d;
}
.btn-speak:active { transform: translateY(2px); box-shadow: 0 2px 0 #24935d; }
.slow { display: flex; align-items: center; gap: 5px; color: #8a7f6f; font-size: 15px; cursor: pointer; }
.slow input { width: 17px; height: 17px; accent-color: var(--green); }

.size-ctl { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid #f0e6d8; border-radius: 999px; padding: 6px 16px; }
.size-label { color: #a3947f; font-size: 14px; }
#sizeSlider { width: 130px; accent-color: var(--orange); }
#sizeVal { color: #d97a2b; font-size: 14px; min-width: 48px; text-align: right; }

/* ---------- 信息卡 ---------- */
.info .line { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #f2ead9; align-items: baseline; }
.info .line:last-child { border-bottom: 0; }
.info b { flex: none; color: var(--orange); font-size: 16px; min-width: 58px; text-align: justify; text-align-last: justify; }
.info span { color: #55504a; font-size: 16px; line-height: 1.8; word-break: break-all; }
.info .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid #ffe1c4; background: #fffaf3; color: #c06a2a; cursor: pointer;
  border-radius: 10px; padding: 4px 12px; font-size: 17px;
  font-family: "KaiTi", "楷体", "STKaiti", serif;
}
.chip:hover { background: #ffefdd; border-color: var(--orange); }
.polyphonic { display: flex; gap: 6px; flex-wrap: wrap; }
.poly { border: 2px solid #dcefe4; background: #f2faf5; color: #1d8a56; border-radius: 999px; padding: 2px 12px; font-size: 15px; cursor: pointer; }
.poly.active { background: var(--green); color: #fff; border-color: var(--green); }

footer { text-align: center; color: #c4b8a6; font-size: 13px; padding: 10px 0 26px; }

.toast {
  position: fixed; left: 50%; bottom: 8vh; transform: translateX(-50%);
  background: rgba(60, 52, 42, .88); color: #fff; font-size: 16px;
  padding: 10px 22px; border-radius: 999px; z-index: 99; max-width: 86vw; text-align: center;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  h1 { font-size: 27px; }
  #q { font-size: 18px; }
  .ge-py { font-size: 20px; min-height: 26px; }
  .cand-char { width: 72px; }
  .cand-char .cc-zi { font-size: 34px; }
  .size-ctl { padding: 4px 10px; }
  #sizeSlider { width: 90px; }
}
