/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: inline-block;
}
.subtitle {
  margin-left: 10px;
  font-size: 12px;
  color: var(--muted);
}
.status {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status.credits { cursor: default; }
.status.credits-negative { color: #dc2626; background: rgba(220, 38, 38, 0.08); }

/* ===== 顶栏右侧：状态徽标 + 设置 ===== */
.topbar-right { position: relative; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.settings-popover {
  position: absolute;
  top: 40px;
  right: 0;
  width: 300px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 20;
}
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-name { font-size: 13px; font-weight: 600; }
.settings-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ===== 主工作区布局 ===== */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1320px;
  margin: 16px auto;
  padding: 0 16px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

/* ===== 输入面板 ===== */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.lang-select { min-width: 92px; }

.mode-seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
}
.mode-btn {
  border: none;
  background: #fff;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.mode-btn + .mode-btn { border-left: 1px solid var(--border); }
.mode-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ===== 输入编辑器（含术语高亮层）===== */
.editor-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 380px;
}
.highlight-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  pointer-events: none;
}

textarea {
  position: relative;
  z-index: 1;
  flex: 1;
  resize: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-height: 380px;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* 高亮展示期间隐藏文字（仅保留光标），文字由底层高亮层渲染 */
textarea.text-hidden { color: transparent; caret-color: var(--text); }

/* mark 不可加水平 padding：高亮层与 textarea 透明原文必须逐像素对齐，
   否则一行多个术语时后续文字累积偏移，选区与视觉文字错位 */
mark.hl-hit { background: #bbf7d0; color: inherit; border-radius: 3px; }
mark.hl-fuzzy { background: #bfdbfe; color: inherit; border-radius: 3px; }
mark.hl-miss { background: #fde68a; color: inherit; border-radius: 3px; }
/* 普通用户：统一中性高亮（不暴露词库命中情况） */
mark.hl-neutral { background: #e0e7ff; color: inherit; border-radius: 3px; }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.char-count { font-size: 12px; color: var(--muted); }

/* ===== 输出面板 ===== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 4px;
}
.empty-title { font-size: 15px; margin: 0; }
.hint { font-size: 12px; margin: 0; color: #9ca3af; }

.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.error-box { margin: auto; max-width: 90%; }
.error-link { color: var(--accent); }

.result { display: flex; flex-direction: column; height: 100%; }
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.result-title { font-size: 14px; font-weight: 600; }

.translation {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  background: #fbfbfe;
}

.meta-line {
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--muted);
}

/* 术语对照表 */
.glossary-section h3, .unmatched-section h3 {
  font-size: 13px;
  margin: 14px 0 8px;
}
.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.glossary-table th, .glossary-table td {
  border-bottom: 1px solid var(--border);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}
.glossary-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.glossary-table td:first-child { font-weight: 500; white-space: nowrap; }

/* ===== 输入区底部：术语提取状态 ===== */
.term-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 100px;
  overflow-y: auto;
}
.ts-summary { font-size: 12px; color: var(--muted); margin-right: 4px; }
.ts-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 2px 4px 2px 9px;
  border-radius: 999px;
}
.ts-chip i {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
}
.ts-hit { background: #dcfce7; color: #166534; }
.ts-hit i { background: #86efac; color: #14532d; }
.ts-fuzzy { background: #dbeafe; color: #1e40af; }
.ts-fuzzy i { background: #93c5fd; color: #1e3a8a; }
.ts-miss { background: #fef3c7; color: #92400e; }
.ts-miss i { background: #fcd34d; color: #78350f; }
/* 普通用户：无徽章的中性词条 */
.ts-plain { background: #eef2ff; color: #3730a3; }

/* 中性信息徽章（不暴露词库语义） */
.info-badge {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

/* 顶栏文字按钮（词库） */
.text-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0 12px;
  height: 32px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.text-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ===== 词库总览弹层（仅管理员） ===== */
.glossary-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.glossary-dialog {
  width: min(880px, 92vw);
  height: min(620px, 86vh);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.glossary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.glossary-head h3 { margin: 0; font-size: 15px; }
.glossary-body { flex: 1; display: flex; min-height: 0; }
.glossary-files {
  width: 220px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
  flex-shrink: 0;
}
.glossary-file {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.glossary-file:hover { background: #f3f4f6; }
.glossary-file.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.glossary-file small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.glossary-terms { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.glossary-search {
  margin: 10px 12px 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.glossary-search:focus { border-color: var(--accent); }
.glossary-list { flex: 1; overflow-y: auto; padding: 0 12px; }
.glossary-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.glossary-list th, .glossary-list td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.glossary-list th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: #fff; }
.glossary-count { padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }

.processing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== 输出面板：流水线阶段条 ===== */
.stage-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.stage { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; flex-shrink: 0; }
.stage.active { color: var(--accent); font-weight: 600; }
.stage.active .stage-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.stage.done { color: var(--success); }
.stage.done .stage-dot { background: var(--success); }
.stage.error { color: var(--error); font-weight: 600; }
.stage.error .stage-dot { background: var(--error); }
.stage-ms { font-size: 11px; color: #9ca3af; }
.stage-sep { color: #d1d5db; font-size: 12px; }
@keyframes pulse { 50% { opacity: 0.35; } }
