:root {
  --primary: #534AB7;
  --primary-weak: #EEEDFE;
  --text: #2C2C2A;
  --text-2: #5F5E5A;
  --text-3: #888780;
  --bg: #F6F5F2;
  --card: #FFFFFF;
  --border: #E4E2DC;
  --danger: #A32D2D;
  --ok: #3B6D11;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }

.page { display: none; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.page.active { display: block; }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input {
  flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); outline: none; color: var(--text);
}
.search-bar input:focus { border-color: var(--primary); }
.search-bar.slim input { padding: 9px 12px; font-size: 14px; }
.search-bar button { flex-shrink: 0; }

button {
  font-family: inherit; font-size: 15px; cursor: pointer;
  border: none; border-radius: var(--radius); padding: 0 18px;
}
.btn-primary {
  background: var(--primary); color: #fff; height: 44px; font-weight: 500;
}
.btn-primary:active { opacity: .85; }
.btn-ghost {
  background: var(--card); color: var(--text-2); height: 44px;
  border: 1px solid var(--border); font-size: 14px;
}
.btn-ghost.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-danger {
  background: #FCEBEB; color: var(--danger); height: 44px;
  border: 1px solid #F0C1C1; width: 100%;
}
.btn-primary.small { height: 36px; font-size: 14px; }

.hint { font-size: 13px; color: var(--text-3); margin: 4px 0; }
.dim { opacity: .75; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.row-desc { margin: 4px 0; font-size: 14px; color: var(--text-2); }
.row-desc.err { color: var(--danger); }
.row-btns { display: flex; gap: 10px; margin-top: 10px; }
.block-title { font-size: 14px; font-weight: 500; color: var(--text-2); margin: 18px 4px 8px; }
.foot-note { text-align: center; font-size: 12px; color: var(--text-3); margin: 28px 0 8px; }

/* 查词结果 */
.dict-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; }
.dict-word { font-size: 26px; font-weight: 600; letter-spacing: .3px; }
.dict-phon { color: var(--text-3); font-size: 14px; margin: 2px 0 10px; }
.dict-trans { font-size: 15px; white-space: pre-line; }
.dict-trans .line { margin: 4px 0; }
.dict-tag {
  display: inline-block; font-size: 12px; color: var(--primary);
  background: var(--primary-weak); border-radius: 6px; padding: 1px 8px; margin-left: 8px; vertical-align: middle;
}
.dict-morph { font-size: 13px; color: var(--text-3); margin-top: 6px; }
.dict-actions { margin-top: 14px; display: flex; gap: 10px; }
.dict-example { margin-top: 8px; font-size: 14px; color: var(--text-2); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.dict-example b { color: var(--text); }

/* 剧集页 */
.series-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.series-item:active { background: #FAF9F7; }
.series-name { font-weight: 500; font-size: 16px; }
.series-meta { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.chev { color: var(--text-3); font-size: 18px; }
.sub-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sub-head h2 { font-size: 18px; margin: 0; flex: 1; }
.sent-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.sent-text { font-size: 15px; }
.sent-text w { border-bottom: 1.5px solid var(--primary); color: var(--primary); font-weight: 500; cursor: pointer; }
.sent-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  font-size: 13px; background: var(--primary-weak); color: var(--primary);
  padding: 2px 10px; border-radius: 999px; cursor: pointer;
}
.chip-plain { background: var(--bg); color: var(--text-2); }
.icon-btn {
  background: none; border: none; color: var(--text-3); font-size: 14px;
  height: 30px; padding: 0 4px; cursor: pointer;
}

/* 词表 */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.letter-head { font-size: 13px; color: var(--text-3); margin: 14px 4px 6px; font-weight: 500; }
.word-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 6px; cursor: pointer;
}
.word-row .w { font-size: 16px; font-weight: 500; }
.word-row .ph { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.word-row .tr { font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 底部导航 */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: center; gap: 0;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tab {
  flex: 1; max-width: 140px; background: none; color: var(--text-3);
  height: 56px; font-size: 11px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
#tabbar .tab .tab-ico { font-size: 20px; line-height: 1; }
#tabbar .tab.active { color: var(--primary); font-weight: 500; }

/* 弹层 */
#sheet-mask, #detail-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90;
}
#sheet, #detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 8px; font-size: 16px; font-weight: 500;
  flex-shrink: 0;
}
.sheet-body {
  flex: 1 1 auto; min-height: 0; /* 关键：允许内容区收缩，否则移动端无法滚动 */
  padding: 4px 18px 16px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.sheet-foot { display: flex; gap: 10px; padding: 0 18px calc(16px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.sheet-foot button { flex: 1; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 6px; }
#sheet input, #sheet select, #sheet textarea, #detail textarea {
  width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: #FCFBFA;
  outline: none; color: var(--text);
}
#sheet input:focus, #sheet select:focus, #sheet textarea:focus { border-color: var(--primary); }
#sheet-new-series { margin-top: 8px; }
.mic-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mic-bar button.rec { background: #FCEBEB; color: var(--danger); border-color: #F0C1C1; }

.empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 36px 0; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
