:root {
  --bg: #f6f3ea;
  --bg-2: #efeadd;
  --ink: #14211f;
  --ink-soft: #3d4f4b;
  --muted: #74837f;
  --line: #e2dccd;
  --card: #fffdf7;
  --teal: #0f766e;
  --teal-deep: #0b4f4a;
  --teal-soft: #e3f1ee;
  --amber: #b45309;
  --amber-soft: #fdf1dd;
  --blue: #1d4ed8;
  --blue-soft: #e8eefc;
  --danger: #b42318;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 33, 31, .04), 0 12px 28px -18px rgba(20, 33, 31, .35);
  --urdu-font: "Noto Nastaliq Urdu", "Urdu Typesetting", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", "Segoe UI", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 520px at 8% -10%, rgba(15, 118, 110, .10), transparent 60%),
    radial-gradient(900px 460px at 100% 0%, rgba(180, 83, 9, .07), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .01em; }
p { margin: 0 0 10px; }
code {
  font-family: "Cascadia Code", Consolas, monospace;
  background: rgba(15, 118, 110, .08);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .88em;
}

/* ---------------- header ---------------- */
.site-head {
  position: relative;
  background: linear-gradient(135deg, #0d5f59 0%, #0f766e 48%, #14867c 100%);
  color: #f6fbf9;
  padding: 22px 28px 0;
  overflow: hidden;
}
.site-head::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.16) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 62%, rgba(255,255,255,.12) 0 2px, transparent 3px),
    linear-gradient(45deg, transparent 46%, rgba(255,255,255,.05) 47%, rgba(255,255,255,.05) 53%, transparent 54%);
  background-size: 68px 68px, 96px 96px, 48px 48px;
  opacity: .55;
  pointer-events: none;
}
.head-inner {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.brand-mark { flex: none; margin-top: 2px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.18)); }
.brand-text h1 {
  font-size: 22px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  color: #fff;
}
.urdu-inline {
  font-family: var(--urdu-font);
  font-size: 20px;
  color: #f3d08a;
  font-weight: 400;
  line-height: 1.9;
}
.brand-text p { margin: 4px 0 0; font-size: 13px; color: rgba(246, 251, 249, .78); }

.head-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: relative; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  font-size: 12.5px;
  color: #eaf6f2;
  backdrop-filter: blur(6px);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa7a3; flex: none; }
.dot-green { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.dot-amber { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .2); }
.dot-blue { background: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .2); }

.status-rail {
  position: relative;
  max-width: 1180px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, .16);
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: rgba(7, 55, 51, .55);
  border: 0;
  color: #dff1ec;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .18s ease;
}
.rail-item:hover { background: rgba(7, 55, 51, .78); }
.rail-item b { font-size: 13px; font-weight: 600; }
.rail-item i {
  margin-left: auto;
  font-style: normal;
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
}

/* ---------------- tabs ---------------- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 28px 0;
  background: linear-gradient(to bottom, var(--bg) 70%, rgba(246, 243, 234, .2));
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .18s ease;
}
.tab:hover { background: rgba(15, 118, 110, .08); }
.tab.active {
  background: var(--ink);
  color: #fdf6e3;
  box-shadow: 0 8px 18px -12px rgba(20, 33, 31, .8);
}

/* ---------------- layout ---------------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 40px;
}
.panel { display: none; animation: fadeUp .28s ease both; }
.panel.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.grid {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.card-head h2 { font-size: 16.5px; }
.muted { color: var(--muted); font-size: 13.5px; }
.muted.small { font-size: 12.5px; line-height: 1.7; }

.mode-badge {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.mode-badge[data-mode="demo"] { background: var(--amber-soft); color: var(--amber); border-color: #f0d4a4; }
.mode-badge[data-mode="local"] { background: var(--teal-soft); color: var(--teal); border-color: #bfe0d9; }
.mode-badge[data-mode="live"] { background: var(--blue-soft); color: var(--blue); border-color: #c8d6f9; }

/* 语音服务位置：同源 / 隧道已连接 / 本机离线 */
#voiceLocalTag[data-state="local"],
#voiceLocalTag[data-state="online"] { background: var(--teal-soft); color: var(--teal); border-color: #bfe0d9; }
#voiceLocalTag[data-state="offline"] { background: var(--amber-soft); color: var(--amber); border-color: #f0d4a4; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
  background: #eee9dc;
  color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--teal); color: #f4fbf9; box-shadow: 0 10px 20px -14px rgba(15, 118, 110, .9); }
.btn-primary:hover { background: #0c655e; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(15, 118, 110, .06); border-color: #cfd8cf; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.tight { gap: 6px; }
.file-btn { position: relative; }
.select-sm, .field select, .field input[type="text"] {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

/* ---------------- recorder ---------------- */
.recorder {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(140deg, #f7f4ea, #eef4f1);
  border: 1px dashed #cfd8d0;
}
.mic-btn {
  position: relative;
  width: 68px;
  height: 68px;
  flex: none;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #1a9c90, #0b5a54 70%);
  box-shadow: 0 12px 26px -14px rgba(11, 90, 84, .95), inset 0 1px 0 rgba(255,255,255,.25);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.mic-btn:hover { transform: scale(1.04); }
.mic-btn.recording {
  background: radial-gradient(circle at 30% 25%, #ef6a5a, #a52a1c 72%);
  box-shadow: 0 0 0 0 rgba(180, 35, 24, .35);
  animation: recPulse 1.6s infinite;
}
@keyframes recPulse {
  0% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .35); }
  70% { box-shadow: 0 0 0 18px rgba(180, 35, 24, 0); }
  100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0); }
}
.rec-state { display: flex; flex-direction: column; gap: 2px; }
.rec-state strong { font-size: 14.5px; }
.rec-state span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.hint {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
  background: rgba(15, 118, 110, .05);
  border-left: 3px solid rgba(15, 118, 110, .3);
  padding: 9px 12px;
  border-radius: 0 10px 10px 0;
}
.hint b { color: var(--ink-soft); }

/* ---------------- dropzone ---------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 30px 18px;
  margin: 14px 0;
  border: 1.5px dashed #c9d5cd;
  border-radius: 16px;
  background: linear-gradient(140deg, #f9f6ed, #f1f6f3);
  color: var(--teal);
  cursor: pointer;
  text-align: center;
  transition: all .18s ease;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--teal); background: #eaf4f1; }
.dropzone strong { font-size: 14px; color: var(--ink); }
.dropzone span { font-size: 12px; color: var(--muted); }
.preview { margin-top: 12px; display: flex; align-items: flex-start; gap: 10px; }
.preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #fff;
}

/* ---------------- result ---------------- */
.result-card { min-height: 320px; }
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}
.empty-glyph {
  font-family: var(--urdu-font);
  font-size: 46px;
  line-height: 1.7;
  color: #c8d5cf;
}
.empty p { max-width: 320px; margin: 0; }
.small-empty { padding: 22px 10px; }

.block { margin-bottom: 18px; }
.block-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.tag {
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(15, 118, 110, .1);
  color: var(--teal);
  font-weight: 600;
}
.urdu-text {
  font-family: var(--urdu-font);
  font-size: 1.5rem;
  line-height: 2.5;
  direction: rtl;
  text-align: right;
  word-break: break-word;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fbf8ef;
  border: 1px solid #eee7d8;
  white-space: pre-wrap;
}
.zh-text {
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 118, 110, .045);
  border-left: 3px solid rgba(15, 118, 110, .35);
  white-space: pre-wrap;
}

/* 乌尔都语单词 + 浮标 */
.uw {
  cursor: help;
  border-radius: 5px;
  padding: 0 1px;
  transition: background .15s ease, color .15s ease;
  border-bottom: 1px dotted rgba(15, 118, 110, .45);
}
.uw:hover, .uw.active { background: rgba(15, 118, 110, .14); }
.uw.missing { border-bottom-color: rgba(180, 83, 9, .6); }
.uw.missing:hover { background: rgba(180, 83, 9, .12); }
/* 自动校验但只有模型双跑一致的词：虚线下划线 + 悬停标注“低置信” */
.uw.uw-low { border-bottom: 1px dashed rgba(180, 83, 9, .75); }
.uw.uw-low:hover { background: rgba(180, 83, 9, .10); }

.word-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.word-grid.compact { gap: 6px; }
.word-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 84px;
  padding: 8px 11px;
  border-radius: 11px;
  background: #fbf8ef;
  border: 1px solid #ece5d3;
  cursor: help;
  transition: all .15s ease;
}
.word-chip:hover { border-color: #c8d9d2; background: #f4f8f5; transform: translateY(-1px); }
.word-chip .w-urdu {
  font-family: var(--urdu-font);
  font-size: 1.18rem;
  line-height: 2.05;
  direction: rtl;
  text-align: right;
  color: var(--teal-deep);
}
.word-chip .w-roman { font-size: 11px; color: var(--amber); font-weight: 600; letter-spacing: .02em; }
.word-chip .w-zh { font-size: 11.5px; color: var(--ink-soft); line-height: 1.45; }

.warn-list { margin: 6px 0 0; padding: 0; list-style: none; }
.warn-list li {
  font-size: 12.5px;
  line-height: 1.65;
  color: #8a5a12;
  background: var(--amber-soft);
  border: 1px solid #f3dcb6;
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 8px;
}
.warn-list li::before { content: "注意 · "; font-weight: 700; }

/* ---------------- chat ---------------- */
.qa-card { display: flex; flex-direction: column; min-height: 60vh; padding-bottom: 16px; }
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 2px 16px;
  overflow-y: auto;
  max-height: 56vh;
}
.msg { display: flex; gap: 10px; animation: fadeUp .24s ease both; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid #cfe3dd;
}
.msg.user .msg-avatar { background: #f0e7d6; color: #8a5a12; border-color: #e5d6b8; }
.msg-body { min-width: 0; max-width: min(78ch, 92%); }
.msg.user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  background: #fbf8ef;
  border: 1px solid #ece5d3;
  border-radius: 4px 14px 14px 14px;
  padding: 12px 15px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--ink);
}
.msg.user .bubble {
  background: var(--teal);
  border-color: var(--teal);
  color: #f3fbf8;
  border-radius: 14px 4px 14px 14px;
}
.bubble .urdu-text { margin-top: 8px; font-size: 1.25rem; padding: 10px 12px; }
.bubble .zh-sub { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.msg.user .bubble .zh-sub { color: rgba(255,255,255,.75); }
.msg-meta { margin-top: 5px; font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip {
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #ded6c4;
  background: #fffdf7;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.composer textarea {
  flex: 1;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
}
.composer textarea:focus { outline: 2px solid rgba(15, 118, 110, .25); outline-offset: 1px; }
.icon-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.icon-btn.recording { background: #fdeceb; border-color: #efb4ae; color: var(--danger); animation: recPulse 1.6s infinite; }

/* ---------------- form ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field input[type="text"] { width: 100%; padding: 10px 12px; border-radius: 11px; }
.field input[type="text"]:focus { outline: 2px solid rgba(15, 118, 110, .25); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.essay-title {
  font-family: var(--urdu-font);
  font-size: 1.7rem;
  line-height: 2.2;
  text-align: right;
  direction: rtl;
  color: var(--teal-deep);
  margin-bottom: 2px;
}
.essay-sub { font-size: 13px; color: var(--muted); text-align: right; margin-bottom: 12px; }
.essay-paras { display: flex; flex-direction: column; gap: 12px; }
.essay-para {
  padding: 12px 14px;
  border-radius: 13px;
  background: #fbf8ef;
  border: 1px solid #eee7d8;
}
.essay-para .p-index {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--teal);
  margin-bottom: 4px;
}
.essay-para .urdu-text { background: transparent; border: 0; padding: 0; font-size: 1.35rem; line-height: 2.35; }
.essay-para .para-zh {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e4ddcc;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}
.outline { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-soft); }
.outline li { margin-bottom: 4px; }

/* ---------------- vocab ---------------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-bottom: 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }

/* ---------------- footer & tooltip ---------------- */
.site-foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 34px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.foot-item b { display: block; color: var(--ink-soft); font-size: 12px; margin-bottom: 2px; }

.tip {
  position: fixed;
  z-index: 90;
  max-width: 280px;
  padding: 11px 13px;
  border-radius: 12px;
  background: #10201d;
  color: #f6f1e2;
  box-shadow: 0 18px 38px -16px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .13s ease, transform .13s ease;
}
.tip.pinned { pointer-events: auto; }
.tip-actions { pointer-events: auto; }
.tip.show { opacity: 1; transform: translateY(0); }
.tip::after {
  content: "";
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: #10201d;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.tip.below::after { bottom: auto; top: -5px; }
.tip-word { font-family: var(--urdu-font); font-size: 1.3rem; line-height: 2; direction: rtl; text-align: right; color: #fdf6e3; }
.tip-roman { font-size: 12px; color: #f3c969; font-weight: 600; margin-bottom: 3px; }
.tip-zh { font-size: 13px; line-height: 1.6; }
.tip-base { font-size: 11px; color: rgba(246, 241, 226, .6); margin-top: 4px; }
.tip-base:empty { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 8px);
  z-index: 100;
  background: var(--ink);
  color: #fdf6e3;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 16px 34px -14px rgba(0, 0, 0, .55);
  opacity: 0;
  transition: all .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .site-head { padding: 18px 16px 0; }
  main { padding: 14px 16px 32px; }
  .tabs { padding: 12px 16px 0; }
  .grid { grid-template-columns: 1fr; }
  .status-rail { grid-template-columns: repeat(2, 1fr); }
  .brand-text h1 { font-size: 19px; }
  .site-foot { padding: 16px; }
  .chat { max-height: none; }
}
@media (max-width: 520px) {
  .head-side { width: 100%; }
  .status-rail { grid-template-columns: 1fr 1fr; }
  .rail-item i { display: none; }
  .urdu-text { font-size: 1.32rem; }
  .field-row { grid-template-columns: 1fr; }
  .msg-body { max-width: 88%; }
  .tabs { padding-bottom: 4px; }
}

/* ---------------- 多用户 / 记忆 / 生词本 / 自迭代 ---------------- */
.user-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  color: rgba(255, 255, 255, .85);
}
.user-box select {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  max-width: 130px;
  padding: 2px 2px;
  outline: none;
}
.user-box select option { color: var(--ink); background: #fffdf7; }
.user-box .btn { color: #f6fbf9; border-color: rgba(255, 255, 255, .3); }
.user-box .btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.memory-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 12px;
  border: 1px solid rgba(15, 118, 110, .14);
}
.memory-bar .btn { margin-left: auto; }
.memory-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
  flex: none;
}

/* 浮标里的操作按钮：点按固定后才可交互 */
.tip.pinned { pointer-events: auto; }
.tip-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.tip-actions:empty { display: none; }
.tip-btn {
  border: 1px solid rgba(243, 201, 105, .55);
  background: rgba(243, 201, 105, .12);
  color: #f3c969;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 7px;
  padding: 3px 9px;
  cursor: pointer;
}
.tip-btn:hover { background: rgba(243, 201, 105, .24); }
.tip-btn:disabled { opacity: .55; cursor: default; }
.tip-flag { font-size: 10.5px; color: rgba(246, 241, 226, .55); }

/* 对话中的推理过程 */
.reason-box {
  margin: 0 0 8px;
  border: 1px dashed rgba(15, 118, 110, .35);
  border-radius: 10px;
  background: rgba(15, 118, 110, .05);
  font-size: 12px;
  color: var(--ink-soft);
}
.reason-box summary {
  cursor: pointer;
  padding: 6px 10px;
  font-weight: 600;
  color: var(--teal);
  list-style: none;
}
.reason-box summary::-webkit-details-marker { display: none; }
.reason-box .reason-text {
  padding: 0 10px 8px;
  max-height: 170px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.65;
  color: var(--muted);
}
.msg-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg-meta .tag { font-size: 10px; }

/* 生词本 / 待确认队列 */
.wb-item, .pending-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 9px 10px;
}
.wb-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.wb-item .wb-word { flex: 1; min-width: 0; }
.wb-item .wb-del {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px;
}
.wb-item .wb-del:hover { color: var(--danger); }

.pending-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.pending-item .pi-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pending-item .pi-word {
  font-family: var(--urdu-font); font-size: 1.15rem; direction: rtl;
  color: var(--ink);
}
.pending-item .pi-zh { font-size: 12.5px; color: var(--ink-soft); }
.pending-item .pi-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.pending-item .pi-ctx {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  padding-left: 8px; border-left: 2px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pending-item .pi-actions { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.pending-item input {
  border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 7px; font-size: 12px; background: #fffdf7;
  min-width: 0; flex: 1;
}
.pending-item .pi-edit { display: flex; gap: 6px; margin-top: 6px; }
.src-tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; font-weight: 700; }
.src-agent { background: var(--amber-soft); color: var(--amber); }
.src-user { background: var(--teal-soft); color: var(--teal-deep); }
.src-query { background: var(--blue-soft); color: var(--blue); }

.manual-add {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr .9fr auto;
  gap: 6px;
  margin-top: 10px;
}
.manual-add input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  background: #fffdf7;
  min-width: 0;
}
.manual-add input[lang="ur"] { font-family: var(--urdu-font); font-size: 1rem; }

.essay-stream { margin: 0 0 12px; }
.essay-stream-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fbf9f2;
  border: 1px solid var(--line);
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

@media (max-width: 720px) {
  .manual-add { grid-template-columns: 1fr 1fr; }
  .user-box { order: 3; }
}

/* ---------------- 后端不可达提示条 ---------------- */
#netBar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #3b1d18;
  border: 1px solid #7c3a2d;
  color: #ffe8e1;
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .8);
  font-size: 13px;
}
#netBar[hidden] { display: none; }
#netBar .net-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #f97362;
  box-shadow: 0 0 0 3px rgba(249, 115, 98, .25);
  flex: none;
}
#netBar .net-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#netBar .net-text b { font-size: 13px; }
#netBar .net-sub { font-size: 12px; color: #f3c9be; line-height: 1.5; word-break: break-all; }
#netBar .net-retry {
  margin-left: auto;
  flex: none;
  background: #f97362;
  color: #2a100c;
  border-color: transparent;
}

/* ---------------- 邀请码准入 ---------------- */
.gate-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 30, 27, .62);
  backdrop-filter: blur(4px);
}
.gate-mask[hidden] { display: none; }
.gate-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px 22px;
}
.gate-card h2 { font-size: 1.2rem; margin-bottom: 8px; }
.gate-card input {
  width: 100%;
  margin: 6px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
.gate-hint { min-height: 20px; margin-top: 10px; font-size: 12.5px; color: var(--danger); }

/* ---------------- 语音模式切换 ---------------- */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}

/* ---------------- 实时转译 ---------------- */
.live-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfaf4;
}
.live-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.live-stat { font-size: 12px; color: var(--muted); }
.live-line { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); }
.live-line:first-of-type { border-top: 0; }
.live-k { font-size: 12px; color: var(--muted); padding-top: 4px; }
.live-urdu {
  font-family: var(--urdu-font);
  font-size: 1.18rem;
  line-height: 2.1;
  direction: rtl;
  text-align: right;
  min-height: 34px;
  word-break: break-word;
}
.live-zh { font-size: 14px; color: var(--ink-soft); min-height: 26px; line-height: 1.75; }
.live-note { margin-top: 8px; font-size: 12px; color: var(--amber); line-height: 1.6; }
.live-note:empty { display: none; }
.live-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.live-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fdfcf7;
}
.live-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.live-item-no { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.live-item-urdu { font-family: var(--urdu-font); direction: rtl; text-align: right; font-size: 1.16rem; line-height: 2; }
.live-item-zh { margin-top: 6px; font-size: 13.5px; color: var(--ink-soft); }
.live-item.pending { border-style: dashed; }
.live-item.pending .live-item-zh { color: var(--muted); }
.live-item.error { border-color: rgba(180, 35, 24, .35); }

