/* 「纸与墨」配色，和 iOS 端 Theme.swift 一致。 */
:root {
  --paper: #f5f2ec;
  --ink: #16202b;
  --night: #1b2633;
  --night-raised: #2c3a4a;
  --night-line: #3a4757;
  --night-muted: #aeb8c4;
  --bar: #e9e4da;
  --line: #c9c2b4;
  --line-soft: #d8d2c6;
  --muted: #5b6470;
  --muted-dark: #4a5360;
  --chip: #efebe3;
  --accent: #c2410c;
  --accent-soft: #fdebe3;
  --accent-text: #9a3412;
  --ok: #15803d;
  --white: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bar);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* 桌面上是居中的一列，手机上铺满。 */
#app {
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}

@media (min-width: 481px) {
  #app { box-shadow: 0 0 0 1px var(--line-soft); }
}

button, select, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; flex: none; }

.muted { color: var(--muted); }
.center { height: 100%; display: grid; place-items: center; text-align: center; padding: 24px; }

.screen { height: 100%; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 通用部件 ---------- */

.big-btn {
  width: 100%;
  min-height: 64px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--paper);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
}
.big-btn:active:not(:disabled) { opacity: 0.85; }
.big-btn.h56 { min-height: 56px; }
.big-btn.light { background: var(--paper); color: var(--ink); }
.big-btn.hot { background: var(--accent); color: var(--white); }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.icon-btn.ring { border: 1.5px solid var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  max-width: 100%;
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 12px;
  margin-top: var(--safe-top);
  flex: none;
}
.header .titles { flex: 1; min-width: 0; text-align: center; }
.header .title { font-size: 16px; font-weight: 700; }
.header .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .spacer { width: 44px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
.dot.off { background: var(--muted); }
.dot.hot { background: var(--accent); }

.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ---------- 登录 ---------- */

.auth {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: calc(40px + var(--safe-top)) 16px 32px;
}
.auth h1 { margin: 0; font-size: 28px; }
.auth p { margin: 0; color: var(--muted); font-size: 15px; text-align: center; }

/* ---------- 首页 ---------- */

.home { padding: calc(16px + var(--safe-top)) 20px calc(32px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 20px; }
.home-top { display: flex; align-items: center; gap: 12px; padding: 0 4px; min-height: 44px; }
.home-top h1 { margin: 0; font-size: 28px; flex: 1; }
#user-btn { width: 44px; height: 44px; display: grid; place-items: center; }

.lang-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  text-align: left;
  width: 100%;
}
.lang-row small { font-size: 13px; color: var(--muted); }
.lang-row b { font-size: 17px; font-weight: 600; flex: 1; }

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border-radius: 24px;
  background: var(--white);
  border: 1.5px solid var(--line);
  text-align: left;
  width: 100%;
}
.card.dark { background: var(--night); border-color: var(--night); color: var(--paper); }
.card.new { border: 2px solid var(--accent); }
.card-head { display: flex; align-items: center; gap: 14px; }
.card-head .ico { width: 44px; height: 44px; display: grid; place-items: center; }
.card.new .ico { color: var(--accent); }
.card-head .t { flex: 1; min-width: 0; }
.card-head h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.card-head .s { font-size: 13px; color: var(--muted); }
.card.dark .card-head .s { color: var(--night-muted); }
.card-head .chev { opacity: 0.6; }
.card p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted-dark); }
.card.dark p { color: #d6dce3; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 10px; background: var(--chip); }
.card.dark .tag { background: var(--night-raised); }
.badge-new { font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: 2px 8px; border-radius: 8px; }

.usage { padding: 8px 4px 0; font-size: 13px; }
.usage .row { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted-dark); }
.usage .row b { color: var(--ink); font-weight: 600; }
.usage .track { height: 6px; border-radius: 3px; background: #e2dcd0; overflow: hidden; }
.usage .fill { height: 100%; border-radius: 3px; background: var(--ink); }
.usage .fill.full { background: var(--accent); }

/* ---------- 选语言的底部面板 ---------- */

.sheet-back { position: absolute; inset: 0; background: rgba(22, 32, 43, 0.4); display: flex; align-items: flex-end; z-index: 10; }
.sheet {
  width: 100%;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sheet h2 { margin: 0; font-size: 20px; }
.field-label { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.choices { display: grid; gap: 8px; }
.choices.c3 { grid-template-columns: repeat(3, 1fr); }
.choices.c2 { grid-template-columns: repeat(2, 1fr); }
.choices.c4 { grid-template-columns: repeat(4, 1fr); }
.choice {
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--white);
  border: 1.5px solid var(--line-soft);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.choice.col { flex-direction: column; justify-content: center; gap: 2px; min-height: 56px; text-align: center; font-size: 16px; }
.choice.col small { font-size: 11px; font-weight: 400; opacity: 0.75; }
.choice.mid { justify-content: center; min-height: 48px; font-size: 14px; padding: 0 4px; }
.choice[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.status-line.err { color: var(--accent-text); }

/* ---------- 实时对话 / 代理人 ---------- */

.intro { padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.intro.mid { height: 100%; justify-content: center; }
.intro h1 { margin: 0; font-size: 26px; line-height: 1.25; }
.intro p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }

textarea, .text-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  padding: 14px;
  font-size: 16px;
  resize: none;
  display: block;
}
textarea::placeholder, input::placeholder { color: #b5b0a6; }
textarea.goal { border-color: var(--accent); border-radius: 16px; font-size: 17px; margin-top: 8px; }

.goal-banner { margin: 0 16px 8px; padding: 12px; border-radius: 14px; background: var(--accent-soft); display: flex; gap: 10px; font-size: 14px; flex: none; }
.goal-banner svg { color: var(--accent); margin-top: 1px; }
.goal-banner span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.turns { padding: 8px 16px; display: flex; flex-direction: column; gap: 14px; }
.turn { max-width: 300px; display: flex; flex-direction: column; gap: 6px; align-self: flex-start; }
.turn.far { align-self: flex-end; align-items: flex-end; }
.turn .who { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.turn.last .who { color: var(--accent-text); }
.bubble { padding: 14px 16px; border-radius: 6px 20px 20px 20px; background: var(--white); border: 1px solid #e2dcd0; display: flex; flex-direction: column; gap: 6px; }
.turn.last .bubble { border: 2px solid var(--accent); }
.turn.far .bubble { border-radius: 20px 6px 20px 20px; background: var(--night); border-color: var(--night); }
.bubble .orig { font-size: 14px; color: var(--muted); }
.bubble .tran { font-size: 18px; font-weight: 600; }
.turn.far .bubble .orig { color: var(--night-muted); }
.turn.far .bubble .tran { color: var(--paper); }

.aturn { display: flex; flex-direction: column; gap: 8px; }
.aturn .orig { display: flex; gap: 8px; font-size: 14px; color: var(--muted-dark); }
.aturn .orig b { width: 32px; flex: none; font-size: 12px; color: var(--muted); padding-top: 2px; }
.report { display: flex; gap: 10px; padding: 14px; border-radius: 16px; background: var(--white); border: 1.5px solid var(--accent); font-size: 18px; font-weight: 600; }
.report svg { color: var(--accent); margin-top: 3px; }
.spoken { padding: 10px 14px; border-radius: 14px; background: var(--night); color: var(--paper); font-size: 15px; }
.spoken small { display: block; font-size: 11px; font-weight: 600; color: var(--night-muted); margin-bottom: 4px; }

.controls { flex: none; background: var(--bar); padding: 16px 20px calc(20px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.status-line { font-size: 13px; color: var(--muted-dark); text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 19px; }
.live-row { display: flex; align-items: center; gap: 16px; }
.round { width: 56px; height: 56px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; flex: none; }
.meter { flex: 1; min-height: 72px; border-radius: 36px; background: var(--accent); color: var(--white); display: grid; place-items: center; font-weight: 600; }
.meter.paused { background: var(--muted); }
.end-btn { height: 56px; padding: 0 20px; border-radius: 28px; background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 600; flex: none; }

/* ---------- 场景与术语 ---------- */

.setup { padding: 8px 20px; display: flex; flex-direction: column; gap: 28px; }
.setup section { display: flex; flex-direction: column; gap: 10px; }
.setup .field-label { margin: 0; }
.terms { background: var(--white); border: 1.5px solid var(--line-soft); border-radius: 16px; overflow: hidden; }
.term { display: flex; align-items: center; gap: 10px; min-height: 52px; padding-left: 16px; font-size: 15px; border-bottom: 1px solid #ece7de; }
.term .a { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.term .b { flex: 1; min-width: 0; text-align: right; overflow-wrap: anywhere; }
.term .arrow { color: var(--muted); }
.term .scene-tag { font-size: 11px; font-weight: 600; color: var(--muted-dark); background: var(--chip); padding: 3px 8px; border-radius: 8px; margin-right: 12px; white-space: nowrap; }
.term .del { color: var(--muted); }
.term-add { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 8px 0 16px; }
.term-add input { flex: 1; min-width: 0; border: 0; background: none; font-size: 15px; padding: 8px 0; }
.term-add .arrow { color: var(--muted); }
.term-add button { min-width: 44px; min-height: 44px; font-size: 14px; font-weight: 600; }
.footer { flex: none; padding: 16px 20px calc(16px + var(--safe-bottom)); }

/* ---------- 我的声纹 ---------- */

.voice-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.voice-row .state { flex: 1; min-width: 120px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pill.solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.voice-box { background: var(--white); border: 1.5px solid var(--accent); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.voice-box .read-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--accent-text); }
.voice-box .read-text { margin: 0; font-size: 18px; line-height: 1.6; font-weight: 600; }
.voice-box .track { height: 6px; border-radius: 3px; background: #e2dcd0; overflow: hidden; }
.voice-box .fill { height: 100%; background: var(--accent); }
.hint.err { color: var(--accent-text); }
.status-line.voice { font-size: 12px; color: var(--muted); margin-top: -8px; }

/* ---------- 设置、我的、声纹引导 ---------- */

.icon-btn.avatar { overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-blank { display: grid; place-items: center; border-radius: 50%; background: var(--chip); color: var(--muted-dark); border: 1.5px solid var(--line); }

.guide { display: flex; gap: 14px; padding: 18px; border-radius: 20px; background: var(--accent-soft); }
.guide .g-ico { color: var(--accent); padding-top: 2px; }
.guide .g-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.guide b { font-size: 17px; }
.guide p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--muted-dark); }
.guide .g-btns { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.guide .pill:not(.solid) { border-color: #e7c4b5; }

.link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--accent-text); min-height: 44px; }
.intro .hint { display: flex; align-items: center; gap: 6px; }

.rows { background: var(--white); border: 1.5px solid var(--line-soft); border-radius: 16px; overflow: hidden; }
.rows > * + * { border-top: 1px solid #ece7de; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.toggle-row .t { flex: 1; min-width: 0; }
.toggle-row b { font-size: 15px; font-weight: 600; }
.toggle-row .hint { margin-top: 2px; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: #d5cfc3; position: relative; flex: none; transition: background 0.15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--white); transition: transform 0.15s; box-shadow: 0 1px 2px rgba(22, 32, 43, 0.25); }
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"] i { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .switch, .switch i { transition: none; } }
.link-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 16px; text-align: left; font-size: 15px; }
.link-row .t { flex: 1; font-weight: 600; }
.link-row small { font-size: 13px; color: var(--muted); max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row.danger { color: var(--accent-text); }

.profile { flex-direction: row !important; align-items: center; gap: 16px !important; padding: 8px 4px; }
.profile .avatar.big { width: 72px; height: 72px; flex: none; display: block; }
.profile b { font-size: 20px; }
.profile p { margin: 2px 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.usage-card { background: var(--white); border: 1.5px solid var(--line-soft); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.usage-card .big-num { font-size: 15px; color: var(--muted-dark); }
.usage-card .big-num b { font-size: 30px; color: var(--ink); }
.usage-card .track { height: 6px; border-radius: 3px; background: #e2dcd0; overflow: hidden; }
.usage-card .fill { height: 100%; background: var(--ink); }
.usage-card .fill.full { background: var(--accent); }

.noise-turn { align-self: center; max-width: 90%; font-size: 13px; color: var(--muted); text-align: center; padding: 6px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.noise-turn span { display: block; font-size: 11px; font-weight: 600; margin-bottom: 2px; }

/* ---------- 录制声纹的弹窗 ---------- */

.voice-sheet { gap: 16px; max-height: 92%; overflow-y: auto; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.5; color: var(--muted-dark); }
.voice-box.quiet { border-color: var(--line-soft); }
.voice-box.quiet .read-label { color: var(--muted); }
.voice-box .read-label { display: flex; align-items: center; gap: 6px; }
.dialog-text { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted-dark); }
.dialog-text.err { color: var(--accent-text); }
.center-text { text-align: center; }
.text-btn { min-height: 44px; font-size: 15px; font-weight: 600; color: var(--muted-dark); align-self: center; padding: 0 16px; }
