:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e4e7ec;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --ok: #0f9d6e;
  --warn: #b45309;
  --err: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.page { max-width: 900px; margin: 0 auto; padding: 28px 20px 48px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.3px; }
.brand .sub { margin: 0; color: var(--muted); font-size: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; gap: 3px; }
.brand-mark span { width: 3px; border-radius: 2px; background: var(--accent); }
.brand-mark span:nth-child(1) { height: 10px; }
.brand-mark span:nth-child(2) { height: 18px; }
.brand-mark span:nth-child(3) { height: 13px; }

.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 12px; background: #eef0f2; color: var(--muted); white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-idle { background: #eef0f2; color: var(--muted); }
.status-connecting { background: #fef3c7; color: var(--warn); }
.status-active { background: #dcfce7; color: var(--ok); }
.status-error { background: #fee2e2; color: var(--err); }

.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.notice-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

.controlbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 18px; }
.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit; }
.btn:hover:not(:disabled) { border-color: #c9d2e3; background: #fafbfe; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.control-divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.field select { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12px; color: var(--text); background: #fff; font-family: inherit; }

.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px 16px; margin-bottom: 18px; }
.stage-label { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-bottom: 12px; }
.current-box { min-height: 132px; position: relative; }
.text-en { color: var(--muted); font-size: 14px; min-height: 24px; word-break: break-word; }
.text-zh { font-size: 27px; font-weight: 600; line-height: 1.5; margin-top: 6px; word-break: break-word; letter-spacing: .2px; white-space: pre-line; }
.text-zh.is-error { color: #d92d20; font-size: 18px; }
.text-zh.is-error .raw { display: block; font-size: 13px; font-weight: 400; color: #667085; margin-top: 6px; }
.caret { display: inline-block; width: 2px; height: 24px; background: var(--accent); vertical-align: -4px; margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.stage-meta { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
body.hide-en .text-en { display: none; }

.history-section { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 24px 8px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.history-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.history-head span { font-size: 12px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.history li { padding: 12px 0; border-bottom: 1px solid #f0f1f3; }
.history li:last-child { border-bottom: none; }
.h-row { display: flex; align-items: flex-start; gap: 12px; }
.h-index { flex: 0 0 24px; height: 24px; border-radius: 6px; background: #f1f5f9; color: var(--muted); font-size: 11px; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.h-body { min-width: 0; }
.h-en { color: var(--muted); font-size: 12px; word-break: break-word; }
.h-zh { font-size: 16px; margin-top: 2px; word-break: break-word; }
body.hide-en .h-en { display: none; }

.foot { margin-top: 18px; color: var(--muted); font-size: 12px; }
.foot p { margin: 4px 0; }

@media (max-width: 560px) {
  .page { padding: 18px 14px 36px; }
  .brand h1 { font-size: 18px; }
  .text-zh { font-size: 22px; }
  .stage, .history-section { padding-left: 16px; padding-right: 16px; }
}
