:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel2: #ffffff;
  --border: #d8e0e8;
  --border-soft: #e8edf3;
  --text: #1f2937;
  --muted: #667085;
  --dim: #98a2b3;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --in: #16a34a;
  --out: #2563eb;
  --sys: #667085;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 500; }
.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px;
  color: #ffffff;
  background: linear-gradient(135deg, #60a5fa, #1d4ed8);
  box-shadow: 0 0 0 1px rgba(77,163,255,.4), 0 6px 18px rgba(47,129,247,.2);
}
.title { font-weight: 650; font-size: 14px; letter-spacing: .2px; }
.subtitle { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.top-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: #f8fafc;
  min-width: 190px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 3px rgba(139,152,165,.08); }
.dot.connected { background: var(--ok); box-shadow: 0 0 0 3px rgba(63,185,80,.12), 0 0 12px rgba(63,185,80,.5); }
.dot.connecting { background: var(--warn); animation: pulse 1.1s infinite; }
.dot.error { background: var(--err); box-shadow: 0 0 0 3px rgba(248,81,73,.12); }
@keyframes pulse { 50% { opacity: .35; } }
.status-text { font-weight: 600; }
.status-extra { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.top-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 13px;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #2f8df7, #1d4ed8); border-color: #1d4ed8; color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { border-color: #fecaca; background: #fef2f2; color: #b42318; }

.composer {
  overflow: auto;
  border-right: 1px solid var(--border);
  background: #f8fafc;
  padding: 12px;
}
.composer .card { margin-bottom: 0; }
.composer #publishCard textarea { min-height: 300px; }
.layout {
  display: grid;
  grid-template-columns: 340px 400px minmax(0, 1fr);
  height: calc(100vh - 62px);
  min-height: 0;
}
.sidebar {
  overflow: auto;
  border-right: 1px solid var(--border);
  background: #f8fafc;
  padding: 12px;
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: #d8e0e8; border-radius: 8px; }
.card {
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 650; font-size: 12.5px;
  letter-spacing: .3px; color: #344054;
  margin-bottom: 10px;
}
.field { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11.5px; margin-bottom: 9px; }
.field.inline { flex-direction: row; align-items: center; gap: 7px; margin-bottom: 0; }
input, select, textarea {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 9px;
  outline: none;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(47,129,247,.12); }
input::placeholder, textarea::placeholder { color: #98a2b3; }
select { padding-right: 8px; }
textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; min-height: 150px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.with-btn { display: flex; gap: 5px; }
.with-btn input { flex: 1; }
.icon-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  border-radius: 7px;
  padding: 0 9px;
  font-size: 11.5px;
}
.icon-btn:hover { color: var(--text); border-color: #cbd5e1; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; user-select: none; }
.check input { width: 14px; height: 14px; accent-color: var(--accent2); }
.hint { color: var(--dim); font-size: 11.5px; line-height: 1.5; margin-top: 4px; }
.topic-preview {
  font-family: var(--mono); font-size: 11.5px; color: #1d4ed8;
  background: #ffffff; border: 1px dashed #cbd5e1;
  border-radius: 7px; padding: 7px 9px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sub-add { display: grid; grid-template-columns: 1fr 58px auto; gap: 6px; }
.sub-list { list-style: none; padding: 0; margin: 9px 0 0; }
.sub-item {
  display: flex; align-items: center; gap: 7px;
  border-top: 1px solid var(--border-soft);
  padding: 6px 0;
}
.sub-topic { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-state { font-size: 10.5px; color: var(--ok); border: 1px solid #bbf7d0; background: #f0fdf4; padding: 1px 5px; border-radius: 5px; }
.sub-state.bad { color: var(--err); border-color: #fecaca; background: #fef2f2; }
.sub-item .icon-btn { padding: 0 7px; height: 22px; }
.pub-result { margin-top: 8px; font-size: 11.5px; color: var(--muted); min-height: 18px; }
.pub-result.ok { color: var(--ok); }
.pub-result.err { color: var(--err); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  min-height: 50px;
}
.tabs { display: flex; gap: 4px; background: #ffffff; border: 1px solid var(--border-soft); padding: 3px; border-radius: 8px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 6px; padding: 6px 10px; font-weight: 600; font-size: 12px;
}
.tab.active { background: #e8f1ff; color: var(--text); }
.filter { flex: 1; min-width: 120px; max-width: 340px; }
.stats { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; font-family: var(--mono); }
.content { flex: 1; min-height: 0; display: flex; }
.log-pane { flex: 1; min-width: 0; position: relative; overflow: auto; background: #fcfdff; }
.log-head, .log-row {
  display: grid;
  grid-template-columns: 78px 40px minmax(120px, 1fr) 132px 112px;
  gap: 8px;
  align-items: center;
}
.log-head {
  position: sticky; top: 0; z-index: 2;
  padding: 7px 12px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .55px;
  color: var(--dim);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.log-list { padding: 2px 0 40px; }
.log-row {
  padding: 7px 12px 6px;
  border-bottom: 1px solid #eef2f7;
  cursor: pointer;
  grid-template-rows: auto auto;
}
.log-row:hover { background: #f4f8fc; }
.log-row.selected { background: #e8f1ff; box-shadow: inset 3px 0 0 var(--accent); }
.log-time { color: var(--dim); font-family: var(--mono); font-size: 10.5px; }
.log-dir { font-family: var(--mono); font-weight: 700; font-size: 10px; letter-spacing: .4px; }
.log-dir.in { color: var(--in); }
.log-dir.out { color: var(--out); }
.log-dir.sys { color: var(--sys); }
.log-topic { font-family: var(--mono); font-size: 11.5px; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-type { font-size: 10.5px; color: #475467; background: #f1f7ff; border: 1px solid #cbd5e1; border-radius: 5px; padding: 1px 6px; justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.log-meta { color: var(--dim); font-size: 10.5px; font-family: var(--mono); text-align: right; white-space: nowrap; }
.log-sub { grid-column: 1 / -1; color: #98a2b3; font-size: 10.5px; font-family: var(--mono); padding-left: 118px; margin-top: -2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row.dir-sys .log-topic { color: #667085; font-style: italic; }
.log-row.echo { opacity: .6; }
.empty { color: var(--dim); text-align: center; padding: 54px 20px; line-height: 1.8; }
.scroll-bottom {
  position: sticky; bottom: 14px; left: 50%; transform: translateX(-50%);
  border: 1px solid #cbd5e1; background: #e8eef7; color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 11px;
}
.detail-pane { flex: 1; min-width: 0; overflow: auto; padding: 14px 16px 40px; background: #fcfdff; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.detail-title { font-family: var(--mono); font-size: 12px; color: #1f2937; word-break: break-all; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.meta-pill { font-family: var(--mono); font-size: 10.5px; color: #475467; background: #f8fafc; border: 1px solid #d8e0e8; border-radius: 5px; padding: 2px 6px; }
.section-label { color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; margin: 12px 0 7px; }
.valid-list { display: flex; flex-direction: column; gap: 4px; }
.vcheck {
  display: grid; grid-template-columns: 20px 170px 1fr; gap: 6px;
  font-size: 11.5px; padding: 5px 7px; border-radius: 6px;
  background: #f8fafc; border: 1px solid #e8edf3;
}
.vcheck-icon { font-weight: 800; text-align: center; }
.vcheck.ok .vcheck-icon { color: var(--ok); }
.vcheck.warn .vcheck-icon { color: var(--warn); }
.vcheck.fail .vcheck-icon { color: var(--err); }
.vcheck-label { color: #344054; }
.vcheck-detail { color: var(--muted); font-family: var(--mono); font-size: 11px; word-break: break-word; }
.raw-json {
  margin: 0; padding: 12px; background: #f8fafc; border: 1px solid var(--border-soft);
  border-radius: 8px; color: #334155; font-family: var(--mono); font-size: 11.5px;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 52vh; overflow: auto;
}
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(12px);
  padding: 8px 14px; border-radius: 8px; background: #f1f5f9; border: 1px solid #cbd5e1;
  color: var(--text); font-size: 12px; opacity: 0; pointer-events: none; transition: .18s;
  z-index: 50; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: #bbf7d0; }
.toast.warn { border-color: #fde68a; color: #92400e; }
.toast.err { border-color: #fecaca; color: #b42318; }

@media (max-width: 1280px) {
  .layout { grid-template-columns: 300px 350px minmax(0, 1fr); }
}
@media (max-width: 1120px) {
  body { overflow: auto; }
  .layout { display: block; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: none; }
  .main { height: 72vh; min-height: 520px; }
  .content { min-height: 420px; }
  .top-status { min-width: 0; }
  .status-extra { display: none; }
}
@media (max-width: 720px) {
  .topbar { height: auto; min-height: 62px; flex-wrap: wrap; padding: 9px 12px; }
  .top-status { order: 3; margin-left: 0; }
  .top-actions { margin-left: auto; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .filter { max-width: none; flex-basis: 100%; order: 3; }
  .stats { flex-basis: 100%; order: 4; }
  .log-head, .log-row { grid-template-columns: 66px 34px minmax(90px, 1fr) 80px; }
  .log-head span:last-child, .log-meta { display: none; }
  .log-sub { padding-left: 100px; }
  .vcheck { grid-template-columns: 20px 120px 1fr; }
}
.account-ok { color: var(--ok); }
.account-err { color: var(--err); }
#loginFields, #accountSession { margin: 0; }
.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 600;
}
.account-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.sidebar #publishCard { display: none; }
