:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #1d2530;
  background: #f7f8fa;
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f7f8fa; }
button, input, select { font: inherit; letter-spacing: 0; }

.topbar {
  height: 68px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #dfe3e8;
  background: #ffffff;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #146c5b;
  border-radius: 6px;
  font-weight: 750;
}
.brand h1 { margin: 0; font-size: 17px; line-height: 1.25; }
.brand p { margin: 3px 0 0; color: #697381; font-size: 12px; }
.status-cluster { display: flex; align-items: center; gap: 8px; color: #697381; font: 12px ui-monospace, monospace; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; }
.status-dot.connecting { background: #d69c24; }
.status-dot.connected { background: #23845f; }
.status-dot.error { background: #bc3c3c; }

.workspace { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.controls { padding: 20px; border-right: 1px solid #dfe3e8; background: #ffffff; overflow-y: auto; }
.control-section { padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid #e7eaee; }
.control-section:last-child { border-bottom: 0; margin-bottom: 0; }
.control-section h2, .conversation h2 { margin: 0; font-size: 14px; font-weight: 700; }
.control-section label:not(.switch) { display: block; margin: 14px 0 6px; color: #505b68; font-size: 12px; }
input[type="url"], input[type="password"], select {
  width: 100%; height: 38px; padding: 0 10px; border: 1px solid #cfd5dc; border-radius: 5px; outline: none; background: #fff;
}
input:focus, select:focus { border-color: #146c5b; box-shadow: 0 0 0 2px rgb(20 108 91 / 12%); }
select:disabled { color: #87919d; cursor: not-allowed; background: #f1f3f5; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
button { height: 36px; padding: 0 13px; border: 1px solid #cfd5dc; border-radius: 5px; color: #27313d; background: #ffffff; cursor: pointer; }
button:hover:not(:disabled) { background: #f1f3f5; }
button.primary { border-color: #146c5b; color: #ffffff; background: #146c5b; }
button.primary:hover:not(:disabled) { background: #0f5b4d; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
.icon-button { width: 32px; height: 32px; padding: 0; font-size: 21px; line-height: 1; }

.switch { position: relative; width: 40px; height: 22px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #b7bec7; transition: background 150ms ease; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 150ms ease; }
.switch input:checked + span { background: #146c5b; }
.switch input:checked + span::after { transform: translateX(18px); }
.meter { width: 100%; height: 7px; margin-top: 14px; overflow: hidden; border-radius: 4px; background: #e5e8ec; }
.meter span { display: block; width: 0; height: 100%; background: #d4982d; transition: width 80ms linear; }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 10px; }
.counters div { display: flex; justify-content: space-between; padding: 8px; background: #f4f6f7; border-radius: 4px; }
.counters dt { color: #697381; font-size: 12px; }
.counters dd { margin: 0; font: 12px ui-monospace, monospace; }
#debug-log { height: 210px; margin: 0; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #d9e0e8; background: #20262d; border-radius: 5px; font: 11px/1.45 ui-monospace, monospace; }

.conversation { min-width: 0; display: flex; flex-direction: column; background: #f7f8fa; }
.conversation-header { min-height: 64px; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #dfe3e8; }
.conversation-header p { margin: 4px 0 0; color: #697381; font-size: 12px; }
.interim-preview { margin: 16px 24px 0; padding: 10px 14px; border-left: 3px solid #d4982d; background: #fff8e8; }
.interim-preview span { color: #83621f; font-size: 11px; }
.interim-preview p { margin: 4px 0 0; color: #424b56; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.messages { width: min(920px, 100%); margin: 0 auto; padding: 28px clamp(18px, 5vw, 64px) 80px; overflow-y: auto; flex: 1; }
.empty-state { padding: 80px 16px; text-align: center; color: #8a939e; font-size: 13px; }
.pair-card { margin-bottom: 14px; border: 1px solid #d8dde3; border-left: 3px solid #d4982d; border-radius: 7px; background: #ffffff; overflow: hidden; }
.pair-card.completed { border-left-color: #23845f; }
.pair-card.interrupted { border-left-color: #8a939e; }
.pair-card.filtered { border-left-color: #b27318; }
.pair-card.failed { border-left-color: #bc3c3c; }
.pair-header { min-height: 38px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e7eaee; background: #fafbfc; }
.pair-direction { color: #7c5d20; font-size: 12px; font-weight: 700; }
.pair-status { color: #697381; font-size: 11px; }
.pair-card.playing .pair-status { color: #146c5b; font-weight: 700; }
.pair-card.filtered .pair-status, .pair-card.filtered .pair-copy.target p { color: #8a5a14; }
.pair-card.failed .pair-status { color: #bc3c3c; }
.pair-copy { padding: 13px 14px; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
.pair-copy + .pair-copy { border-top: 1px solid #eef0f2; }
.pair-copy > span { padding-top: 2px; color: #8a939e; font-size: 11px; }
.pair-copy p { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.pair-copy.target p { color: #146c5b; }
.pair-footer { min-height: 30px; padding: 6px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #eef0f2; background: #fafbfc; }
.pair-footer code { color: #8a939e; font-size: 10px; }
.pair-error { color: #bc3c3c; font-size: 11px; text-align: right; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; gap: 10px; }
  .brand h1 { font-size: 15px; }
  .status-cluster { max-width: 42%; overflow: hidden; }
  .workspace { min-height: calc(100vh - 64px); grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid #dfe3e8; }
  .debug-section { display: none; }
  .conversation { min-height: 58vh; }
  .interim-preview { margin: 12px 14px 0; }
  .messages { padding: 20px 14px 56px; }
  .pair-copy { grid-template-columns: 34px minmax(0, 1fr); }
}
