/* ===== 泊霖AI 自然拼读 · 浅色清新风 ===== */
:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #18212b;
  --ink-2: #3b4856;
  --muted: #7b8794;
  --line: #e4eaf0;
  --line-2: #d3dbe4;
  --accent: #0e9f8c;        /* 青绿：主色、命中高亮 */
  --accent-ink: #0a6f62;
  --accent-soft: #e2f5f1;
  --ipa: #3457d5;           /* 靛蓝：音标 */
  --ipa-soft: #e9eefc;
  --warm: #f59e0b;          /* 琥珀：占比条 */
  --warm-soft: #fff4dc;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(16, 32, 48, 0.04), 0 8px 24px -12px rgba(16, 32, 48, 0.18);
  --radius: 16px;
  --ipa-font: "Charis SIL", "Doulos SIL", "Gentium Plus", "Lucida Sans Unicode", "Segoe UI", "Noto Sans", "Arial Unicode MS", sans-serif;
  --nav-h: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

/* ---------- 顶部 ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(245, 248, 251, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  display: flex; align-items: center; gap: 18px;
  max-width: 1200px; margin: 0 auto; padding: 12px 24px 8px;
}
.brand {
  display: inline-flex; align-items: baseline; gap: 2px; text-decoration: none;
  font-size: 21px; font-weight: 900; letter-spacing: -0.2px; color: var(--ink); white-space: nowrap;
}
.brand span { color: var(--accent); }
.brand em { margin-left: 8px; font-style: normal; font-size: 14px; font-weight: 700; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; flex: 1; }
.ctl { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ctl select {
  height: 36px; min-width: 160px; padding: 0 32px 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%237b8794' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center / 18px;
  color: var(--ink); font-size: 14px; font-weight: 600; appearance: none; -webkit-appearance: none;
}
.ctl select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.seg button {
  height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 13px; transition: all .15s;
}
.seg button.active { background: var(--surface); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(16, 32, 48, 0.12); }
.seg-wide { margin: 4px 0 10px; }
.seg-wide button { padding: 0 18px; height: 34px; }
.summary { display: none; }
.back { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.back:hover { color: var(--accent-ink); }

.tabs {
  display: flex; gap: 2px; max-width: 1200px; margin: 0 auto; padding: 0 24px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative; flex: 0 0 auto; height: 40px; padding: 0 14px; border: 0; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.tabs button::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: transparent; transition: background .15s;
}
.tabs button.active { color: var(--ink); }
.tabs button.active::after { background: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 14px 24px 40px; }
.status { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.lead { margin: 4px 0 14px; color: var(--ink-2); font-size: 14px; }
.foot { margin: 36px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- 搜索 ---------- */
.search {
  display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 8px 0 16px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { flex: 0 0 auto; color: var(--muted); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font-size: 19px; font-weight: 600; letter-spacing: 0.4px;
}
.search input::placeholder { color: #aab4bf; font-weight: 500; font-size: 15px; letter-spacing: 0; }
.search button, .search select {
  height: 40px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800;
}
.search select { padding: 0 10px; background: var(--surface-2); color: var(--ink); font-weight: 700; }
.search.slim { height: 46px; box-shadow: none; }
.search.slim input { font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.chip {
  height: 32px; padding: 0 13px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-weight: 700; font-size: 14px; letter-spacing: 0.3px; transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- 读音统计 ---------- */
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 4px 0 12px; }
.result-head h2 { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: 1px; color: var(--ink); }
.result-head .meta { color: var(--muted); font-size: 14px; }
.tip {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: var(--warm-soft);
  color: #7a4b00; font-size: 14px; line-height: 1.6;
}
.sound-block {
  margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.sound-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.ipa-big {
  display: inline-flex; align-items: center; height: 42px; padding: 0 14px; border-radius: 12px;
  background: var(--ipa-soft); color: var(--ipa); font-family: var(--ipa-font); font-size: 24px; font-weight: 700;
}
.ipa-big.silent { background: var(--surface-2); color: var(--muted); font-family: inherit; font-size: 15px; }
.pct { font-size: 20px; font-weight: 900; color: var(--ink); min-width: 60px; }
.bar { flex: 1; min-width: 100px; max-width: 320px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #35c4b0); }
.cnt { color: var(--muted); font-size: 13px; }
.ph-tip { width: 100%; color: var(--ink-2); font-size: 13px; }
.ex-list { display: flex; flex-wrap: wrap; gap: 8px; }
.more-btn {
  margin-top: 10px; height: 34px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 700;
}
.more-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.note { margin: 14px 0 8px; color: var(--muted); font-size: 13px; }

/* ---------- 单词卡：字母块 + 下方音标 ---------- */
.wd {
  position: relative; display: inline-flex; flex-direction: column; gap: 3px; padding: 9px 36px 8px 11px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface); text-align: left; color: var(--ink);
  vertical-align: top; transition: border-color .12s, transform .12s, box-shadow .12s;
}
.wd:hover { border-color: var(--accent); box-shadow: 0 4px 14px -6px rgba(14, 159, 140, 0.4); }
.wd:active { transform: scale(0.98); }
.wd.playing { border-color: var(--accent); background: var(--accent-soft); }
.wd::after {
  content: ""; position: absolute; right: 10px; top: 11px; width: 18px; height: 18px; opacity: 0.35;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2318212b' d='M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4.03v8.05A4.5 4.5 0 0 0 16.5 12zM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.wd:hover::after, .wd.playing::after { opacity: 0.9; }
.wd-row { display: inline-flex; align-items: flex-end; gap: 2px; }
.u { display: inline-flex; flex-direction: column; align-items: center; min-width: 14px; padding: 2px 3px 1px; border-radius: 6px; }
.u b { font-size: 21px; font-weight: 800; letter-spacing: 0.3px; line-height: 1.15; color: var(--ink); }
.u small { font-family: var(--ipa-font); font-size: 12.5px; line-height: 1.3; min-height: 1.3em; color: var(--ipa); }
.u:nth-child(even) b { color: #2f6f63; }
.u.hit { background: var(--accent); }
.u.hit b, .u.hit small { color: #fff; }
.u.silent b { color: #b3bcc6 !important; font-weight: 700; }
.u.silent small { color: #c4ccd5; }
.u.irr { box-shadow: inset 0 0 0 1.5px var(--danger); }
.u.irr.hit { box-shadow: inset 0 0 0 1.5px #fff; }
.wd-ipa { font-family: var(--ipa-font); font-size: 13.5px; color: var(--ink-2); }
.wd-zh { font-size: 12.5px; color: var(--muted); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 字母组合表 ---------- */
.group { margin-bottom: 26px; }
.group h3 { margin: 0 0 2px; font-size: 19px; font-weight: 900; }
.group .gdesc { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.gcard {
  display: flex; flex-direction: column; gap: 5px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); text-align: left; transition: all .12s;
}
.gcard:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.gcard .gk { display: flex; align-items: baseline; gap: 8px; font-size: 26px; font-weight: 900; color: var(--ink); letter-spacing: 0.5px; }
.gcard .gk em { font-size: 12px; font-style: normal; color: var(--muted); font-weight: 600; }
.gsound { display: grid; grid-template-columns: 62px 42px 1fr; align-items: baseline; gap: 6px; font-size: 13px; }
.gsound .ipa { font-family: var(--ipa-font); color: var(--ipa); font-size: 15px; font-weight: 700; }
.gsound .p { color: var(--accent-ink); font-weight: 800; }
.gsound .ex { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 拼读拼盘 ---------- */
.grid-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px 8px; -webkit-overflow-scrolling: touch; }
table.pgrid { border-collapse: separate; border-spacing: 5px; }
.pgrid th { position: sticky; background: var(--bg); color: var(--ink); font-size: 18px; font-weight: 900; padding: 4px 6px; z-index: 1; }
.pgrid thead th { top: 0; }
.pgrid tbody th { left: 0; }
.pgrid td { padding: 0; }
.pcell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-width: 92px; height: 84px;
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: all .12s;
}
.pcell:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pcell b { font-size: 18px; font-weight: 900; }
.pcell span { font-family: var(--ipa-font); font-size: 13px; color: var(--ipa); line-height: 1.3; }
.pcell i { font-style: normal; font-size: 11px; color: var(--muted); }
.pcell.empty { background: transparent; border-style: dashed; opacity: 0.45; cursor: default; }

/* ---------- 单词拆分列表 ---------- */
.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.word-list .wd { width: 100%; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 14px; }
.pager button { height: 38px; padding: 0 18px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); font-weight: 700; }
.pager button:disabled { opacity: 0.4; cursor: default; }

/* ---------- 规则讲解 ---------- */
.rule {
  margin-bottom: 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.rule h3 { margin: 0 0 8px; font-size: 20px; font-weight: 900; }
.rule h3::before { content: ""; display: inline-block; width: 6px; height: 20px; margin-right: 10px; border-radius: 3px; background: var(--accent); vertical-align: -3px; }
.rule p { margin: 6px 0 10px; color: var(--ink-2); line-height: 1.7; }
.rule table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 14px; }
.rule td, .rule th { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rule th { color: var(--muted); font-weight: 700; font-size: 12px; }
.rule .ipa { font-family: var(--ipa-font); color: var(--ipa); font-weight: 700; }
.rule .k { color: var(--accent-ink); font-weight: 900; font-size: 16px; }
.rule .ex-list { margin: 4px 0 10px; }
.rule .linky {
  display: inline-block; margin: 0 6px 6px 0; padding: 2px 10px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface-2); color: var(--accent-ink); font-weight: 800; font-size: 14px;
}
.rule .linky:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- 底部导航（手机） ---------- */
.bottom-nav { display: none; }

/* ---------- 设置面板（手机） ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; background: rgba(24, 33, 43, 0.45); }
.sheet-card {
  width: 100%; max-height: 82vh; overflow-y: auto; padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface); box-shadow: 0 -10px 40px rgba(16, 32, 48, 0.2);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; margin: 4px auto 14px; border-radius: 4px; background: var(--line-2); }
.sheet-card h2 { margin: 0 0 12px; font-size: 18px; }
.sheet-card .controls { flex-direction: column; align-items: stretch; gap: 14px; }
.sheet-card .ctl { flex-direction: column; align-items: stretch; gap: 6px; font-size: 13px; }
.sheet-card .ctl select { height: 46px; font-size: 16px; min-width: 0; width: 100%; }
.sheet-card .seg { width: 100%; }
.sheet-card .seg button { flex: 1; height: 38px; font-size: 15px; }
.sheet-done { width: 100%; height: 48px; margin-top: 18px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 800; }

/* ---------- 详情抽屉 ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(24, 33, 43, 0.45); }
.drawer-card {
  width: min(880px, 100%); height: 100%; overflow-y: auto; padding: 18px 22px 40px; background: var(--bg);
  box-shadow: -10px 0 40px rgba(16, 32, 48, 0.2); animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-head h2 { margin: 0; font-size: 26px; font-weight: 900; }
.drawer-head button { width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); font-size: 22px; line-height: 1; }

/* ================= 手机 ================= */
@media (max-width: 760px) {
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .top-inner { gap: 10px; padding: 10px 14px 6px; }
  .brand { font-size: 19px; }
  .brand em { display: none; }
  .top .controls, .back { display: none; }
  .summary {
    display: inline-flex; align-items: center; gap: 4px; margin-left: auto; height: 34px; max-width: 60vw; padding: 0 8px 0 12px;
    border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 700; color: var(--ink-2);
  }
  .summary span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .summary svg { flex: 0 0 auto; color: var(--muted); }
  .tabs { display: none; }
  main { padding: 12px 14px 24px; }
  .status { font-size: 12px; margin-bottom: 10px; }
  .search { height: 50px; padding-left: 12px; border-radius: 14px; }
  .search input { font-size: 18px; }
  .search input::placeholder { font-size: 14px; }
  .search button { padding: 0 14px; height: 38px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 10px -14px 14px; padding: 2px 14px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .result-head h2 { font-size: 28px; }
  .result-head .meta { font-size: 13px; }
  .sound-block { padding: 14px 12px; border-radius: 14px; }
  .sound-top { gap: 6px 10px; }
  .ipa-big { height: 38px; font-size: 21px; padding: 0 12px; }
  .pct { font-size: 18px; min-width: 52px; }
  .bar { flex-basis: 100%; max-width: none; order: 5; }
  .ex-list { gap: 8px; }
  .ex-list .wd { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .ex-list .wd .wd-row { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .u b { font-size: 19px; }
  .u small { font-size: 11.5px; }
  .wd-zh { max-width: 100%; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .gcard { padding: 10px 11px; }
  .gcard .gk { font-size: 22px; }
  /* 手机上例词太挤，换到下一行完整显示 */
  .gsound { grid-template-columns: 1fr auto; font-size: 12px; row-gap: 0; }
  .gsound .ipa { font-size: 15px; }
  .gsound .ex { grid-column: 1 / -1; white-space: normal; line-height: 1.35; margin-bottom: 3px; }
  .pcell { min-width: 78px; height: 76px; }
  .word-list { grid-template-columns: 1fr; }
  .rule { padding: 14px; border-radius: 14px; }
  .rule h3 { font-size: 18px; }
  .rule table { font-size: 13px; }
  .rule td, .rule th { padding: 6px 6px; }
  .drawer-card { padding: 14px 14px 30px; }
  .drawer-head h2 { font-size: 22px; }

  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700;
  }
  .bottom-nav svg { width: 24px; height: 24px; fill: currentColor; transition: transform .15s; }
  .bottom-nav button.active { color: var(--accent-ink); }
  .bottom-nav button.active svg { transform: translateY(-1px); }
  .foot { margin-top: 24px; }
}
