/* ====== 工作台 · 深色主题 ====== */

:root {
  --bg: #0f1117;
  --bg-soft: #161922;
  --bg-card: #1c2030;
  --bg-elev: #232838;
  --border: #2a3042;
  --text: #e7eaf3;
  --text-soft: #a4abc1;
  --text-dim: #6c7388;
  --primary: #7c9cf5;
  --primary-soft: #2a3a6a;
  --success: #5cd49f;
  --warning: #f0b65a;
  --danger: #f06464;
  --info: #62b6f0;
  --shadow: 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 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.55;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }

/* ====== 顶部导航 ====== */
.topnav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark { font-size: 20px; }
.brand-text { font-size: 15px; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-item {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--text); }
.badge {
  margin-left: 4px; padding: 1px 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 11px;
}

/* ====== 主区 ====== */
.main {
  max-width: 1200px; margin: 0 auto;
  padding: 20px;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.page-title { font-size: 18px; font-weight: 600; }
.page-sub { color: var(--text-soft); font-size: 13px; margin-top: 2px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ====== 卡片 ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}
.card-row { display: flex; gap: 12px; flex-wrap: wrap; }
.col { flex: 1; min-width: 220px; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #0f1117; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: #93aef7; }
.btn-success { background: var(--success); color: #0f1117; border-color: var(--success); font-weight: 600; }
.btn-warn { background: var(--warning); color: #0f1117; border-color: var(--warning); font-weight: 600; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ====== 统计卡 ====== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.stat-label { color: var(--text-soft); font-size: 12px; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 6px; }
.stat-hint { color: var(--text-dim); font-size: 11px; margin-top: 4px; }

/* ====== 列表 / 行 ====== */
.list-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  margin-bottom: 10px;
  transition: border-color .15s;
}
.list-item:hover { border-color: var(--primary); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; }
.list-item-sub { color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.tag {
  display: inline-block;
  padding: 1px 8px; border-radius: 10px;
  font-size: 11px;
  background: var(--bg-elev);
  color: var(--text-soft);
  margin-right: 4px;
}
.tag-warn { background: #5a3f1f; color: #f0b65a; }
.tag-success { background: #1f5a3a; color: #5cd49f; }
.tag-danger { background: #5a1f1f; color: #f06464; }
.tag-info { background: #1f3f5a; color: #62b6f0; }

/* ====== 输入 ====== */
.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.label { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }

.form-row { margin-bottom: 12px; }

/* ====== 待回复消息卡片 ====== */
.draft-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.draft-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-soft);
  margin-bottom: 10px;
}
.draft-meta b { color: var(--text); }

.draft-section { margin-bottom: 10px; }
.draft-section-title { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.draft-question, .draft-content {
  background: var(--bg-soft);
  padding: 10px 12px; border-radius: 6px;
  border-left: 3px solid var(--primary-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.draft-content { border-left-color: var(--success); }
.draft-content[contenteditable="true"]:focus {
  outline: none; border-color: var(--success);
  background: var(--bg);
}
.draft-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 12px;
}

.refs {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-soft);
}
.refs li { margin-bottom: 4px; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty .empty-icon { font-size: 40px; margin-bottom: 8px; }

/* ====== Drawer ====== */
.drawer { position: fixed; inset: 0; z-index: 200; display: flex; }
.drawer[hidden] { display: none; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(640px, 90vw);
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
  animation: slidein .2s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none; color: var(--text);
  font-size: 22px; cursor: pointer;
}

/* ====== 状态栏 ====== */
.footer {
  text-align: center; padding: 14px;
  color: var(--text-dim); font-size: 12px;
}

.muted { color: var(--text-dim); }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.kbd {
  display: inline-block; padding: 1px 6px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 4px; font-size: 11px;
}

.banner {
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.banner-warn { background: #3a2f1a; border-color: #5a4a2a; color: #f0b65a; }
.banner-info { background: #1f3a5a; border-color: #2a4a6a; color: #62b6f0; }
.banner-ok { background: #1f3a2a; border-color: #2a4a3a; color: #5cd49f; }

/* ====== 拖拽上传区 ====== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg-soft);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--bg-elev);
}
.dropzone-icon { font-size: 34px; margin-bottom: 6px; }
.dropzone-text { color: var(--text-soft); font-size: 13px; }
.dropzone-text .link { color: var(--primary); text-decoration: underline; }
.dropzone-hint { color: var(--text-dim); font-size: 11px; margin-top: 6px; }

/* ====== 键值对行 ====== */
.kv-row {
  display: flex; gap: 10px; padding: 4px 0;
  font-size: 13px; border-bottom: 1px dashed var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-k { color: var(--text-dim); min-width: 90px; flex-shrink: 0; }
.kv-v { color: var(--text); flex: 1; }

/* ====== 章节预览 chip ====== */
.chapters-preview {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.chapter-chip {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px;
  font-size: 11px; color: var(--text-soft);
}

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 999;
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ====== 二维码 ====== */
.qr-box {
  display: flex; gap: 14px; align-items: center;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.qr-img {
  width: 100px; height: 100px;
  background: #fff;
  border-radius: 6px;
}

@media (max-width: 720px) {
  .topnav { padding: 0 12px; gap: 8px; }
  .nav-item { padding: 4px 8px; font-size: 12px; }
  .main { padding: 14px; }
}