:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1f2739;
  --line: #2a3348;
  --text: #eef2ff;
  --muted: #9aa6c2;
  --accent: #4da3ff;
  --accent-2: #3b82f6;
  --ok: #3ddc97;
  --warn: #ff6b6b;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性优先：否则 .overlay{display:flex} 会覆盖掉 hidden */
[hidden] { display: none !important; }


html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 8px);
}

/* 顶栏 */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.title { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 11px; font-size: 13px;
}
.icon-btn:active { background: var(--panel-2); }

/* 上下文 */
.context { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.ctx-label { font-size: 11px; color: var(--muted); }
.ctx-row { display: flex; gap: 8px; margin-top: 6px; }
.ctx-input {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px;
}
.ctx-save {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 14px; font-size: 14px;
}
.ctx-last { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* 候选句 */
.candidates { flex: 0 0 auto; min-height: 46px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: linear-gradient(180deg, #24304a, #1b2437);
  border: 1px solid #33415f; color: var(--text); border-radius: 999px;
  padding: 11px 16px; font-size: 15px; white-space: nowrap;
}
.chip:active { transform: scale(.97); background: var(--accent-2); }
.chip.loading { opacity: .5; }

/* 输入 + 说 */
.composer { flex: 0 0 auto; display: flex; }
#text {
  flex: 1; min-height: 96px; max-height: 32dvh; resize: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; font-size: 19px; line-height: 1.45;
}
#text:focus { outline: none; border-color: var(--accent); }
.speak-btn {
  flex: 0 0 auto; margin-top: auto; height: 68px; display: flex; align-items: center; justify-content: center;
  gap: 10px; background: linear-gradient(180deg, #4da3ff, #2563eb); color: #fff;
  border: none; border-radius: var(--radius); font-size: 26px; font-weight: 700;
  letter-spacing: 6px; box-shadow: 0 8px 24px rgba(59, 130, 246, .35);
}
.speak-btn:active { transform: scale(.97); }
.speak-btn.busy { filter: saturate(.4) brightness(.8); }
.speak-icon { font-size: 22px; }

/* 次级操作 */
.subbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font-size: 13px; white-space: nowrap;
}
.ghost-primary { color: var(--accent); border-color: #3b82f6; background: rgba(59,130,246,.12); }
.drawer-action {
  width: 100%; margin-top: 8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 15px;
}
.ghost:active { color: var(--text); }
.voice-name { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* 朗读遮罩 */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 20, .96);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 24px;
}
.overlay-text {
  font-size: 34px; line-height: 1.4; font-weight: 700; text-align: center;
  max-height: 60dvh; overflow-y: auto; word-break: break-word;
}
.overlay-actions { display: flex; gap: 14px; }
.overlay-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 34px; font-size: 17px;
}

/* 抽屉 */
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 14px 16px calc(env(safe-area-inset-bottom) + 16px);
  max-height: 78dvh; overflow-y: auto;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, .5);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 16px; }
.drawer-add { display: flex; gap: 8px; margin-bottom: 12px; }
.drawer-add input {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 15px;
}
.drawer-add button {
  background: var(--accent-2); color: #fff; border: none; border-radius: 10px; padding: 0 16px; font-size: 14px;
}
.phrase-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.phrase-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.phrase-list .p-text { flex: 1; font-size: 16px; }
.phrase-list .p-del { background: transparent; border: none; color: var(--warn); font-size: 13px; }

.field { display: block; margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.field select, .field input[type="range"] { width: 100%; margin-top: 8px; }
.field select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 15px;
}
.field.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.field.checkbox input { width: 20px; height: 20px; margin: 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; word-break: break-all; }

/* 上下文小标题 + 录音按钮 */
.ctx-head { display: flex; align-items: center; justify-content: space-between; }
.mini-btn {
  background: var(--panel-2); color: var(--accent); border: 1px solid #33415f;
  border-radius: 999px; padding: 6px 12px; font-size: 12px;
}
.mini-btn:active { background: #24304a; }
.mini-btn.listening { color: #ff9f43; border-color: #ff9f43; }

/* 录音遮罩 */
.rec-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 12, 20, .97);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
.rec-wave { font-size: 72px; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.15); opacity: 1; } }
.rec-text { font-size: 19px; color: var(--text); }

/* 导入结果 */
.import-result { font-size: 12px; color: var(--ok); margin-top: 8px; line-height: 1.6; word-break: break-all; }
.field input[type="text"], .field input[type="file"] {
  width: 100%; margin-top: 8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 14px;
}
