:root {
  --brand: #334155;
  --brand-hover: #1e293b;
  --accent: #2ecc71;
  --accent-hover: #27ae60;
  --accent-soft: #eefaf3;
  --bg: #f4f6f8;
  --card: #fff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --mention: #2563eb;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--brand); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .5px; }
.brand span { font-weight: 400; opacity: .7; margin-left: 4px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top .ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.admin-badge { padding: 2px 8px; border-radius: 4px; background: #f59e0b; color: #fff; font-size: 12px; font-weight: 700; }
.post.deleted .content { color: var(--muted); font-style: italic; }
.mine-badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: #e0e7ff; color: #4338ca; font-size: 11px; }
.status.paused i { background: #94a3b8; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08); color: #fff; font-size: 13px; cursor: pointer;
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.status.warming i { background: #f59e0b; animation: pulse 1s infinite; }
.status.ready i { background: var(--accent); }
.status.error i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; max-width: 1100px; margin: 20px auto; padding: 0 16px; }
/* Grid items default to min-width:auto, which lets the scrolling forum nav widen the page. */
.layout > * { min-width: 0; }
button, .status { white-space: nowrap; }
.sidebar { display: flex; flex-direction: column; gap: 10px; }
.sidebar nav { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); padding: 6px; border: 1px solid var(--line); }
.sidebar nav a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.sidebar nav small { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 4px 2px; }

button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 7px 14px; color: var(--text); }
button:disabled { opacity: .5; cursor: not-allowed; }
.block { width: 100%; padding: 10px; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover:not(:disabled) { background: var(--brand-hover); }
.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.accent:hover:not(:disabled) { background: var(--accent-hover); }
.ghost { background: transparent; }
.danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.link { border: 0; background: none; padding: 2px 6px; color: var(--muted); font-size: 13px; }
.link:hover { color: var(--brand); }
.link.model { color: var(--accent-hover); font-weight: 600; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 17px; }
.thread-item { display: block; padding: 14px 18px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.thread-item:last-child { border-bottom: 0; }
.thread-item:hover { background: #fafbfc; }
.thread-item .title { font-weight: 600; margin-bottom: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 12px; }
.ai-badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.op-badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: #fef3c7; color: #b45309; font-size: 11px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumb a { color: var(--muted); }
.thread-title { margin: 0 0 14px; font-size: 22px; }
.post { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); scroll-margin-top: 70px; }
.post:last-child { border-bottom: 0; }
.post.flash { animation: flash 1.2s; }
@keyframes flash { from { background: #fef9c3; } }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.post-head .name { font-weight: 600; }
.post-head .floor { margin-left: auto; color: var(--muted); font-size: 13px; }
.content { line-height: 1.7; word-break: break-word; white-space: pre-wrap; }
.content .mention { color: var(--mention); cursor: pointer; }
.content .img { display: inline-block; padding: 0 6px; margin: 0 2px; border-radius: 4px; background: var(--bg); color: var(--muted); font-size: 12px; }
.content.pending:empty::before { content: "正在输入…"; color: var(--muted); }
.content.pending::after { content: "▍"; animation: pulse 1s infinite; color: var(--accent); }
.post-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; margin-left: -6px; }

.composer { margin-top: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.composer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.composer input[name=author] { width: 160px; }
.composer textarea { width: 100%; min-height: 80px; resize: vertical; }
.composer .spacer { flex: 1; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dialog-form h3 { margin: 0 0 4px; }
.dialog-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.dialog-form label.check { flex-direction: row; align-items: center; color: var(--text); }
.dialog-form input:not([type=checkbox]):not([type=range]), .dialog-form select, .dialog-form textarea { width: 100%; color: var(--text); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { flex-direction: row !important; display: inline-flex !important; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; color: var(--text) !important; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: transform .25s; max-width: 90vw; z-index: 100;
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  .top { gap: 8px; padding: 10px 12px; }
  .brand span { display: none; }
  .status span { max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
  .layout { grid-template-columns: 1fr; margin-top: 12px; padding: 0 10px; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar .block { width: auto; flex: 1; }
  .sidebar nav { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .hint { display: none; }
  .post { grid-template-columns: 32px 1fr; padding: 12px; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }
}
