/* ==========================================================================
   小说生成系统 — 全局样式（现代化浅色主题）
   设计令牌集中在 :root，全站组件统一引用
   ========================================================================== */

:root {
  /* 主色与语义色 */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-active: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --success: #16a34a;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --info: #64748b;
  --info-light: #f1f5f9;
  --info-border: #e2e8f0;

  /* 中性色 */
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #eef2f7;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --hover-bg: #f8fafc;

  /* 侧边栏（深色） */
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.07);
  --sidebar-active-bg: var(--primary);
  --sidebar-active-text: #ffffff;

  /* 圆角 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.14);

  /* 过渡 */
  --transition: 0.18s ease;
}

/* Base reset and layout */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 细滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

a {
  color: var(--primary);
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== 侧边栏（深色） ===== */
.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
}

.logo {
  height: 60px;
  line-height: 60px;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 1px;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
}

.nav-group-label {
  padding: 14px 12px 6px;
  font-size: 11px;
  color: #64748b;
  letter-spacing: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.nav-item .nav-icon {
  margin-right: 9px;
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.main-content {
  flex: 1;
  overflow: auto;
  padding: 24px;
}

/* ===== 侧边栏底部：登录信息 ===== */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition);
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.45);
}

.sidebar-username {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user:hover,
.sidebar-user.active {
  background: var(--sidebar-hover-bg);
}

.sidebar-user:hover .sidebar-username,
.sidebar-user.active .sidebar-username {
  color: #ffffff;
}

.sidebar-logout {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: var(--sidebar-text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-logout:hover {
  background: rgba(220, 38, 38, 0.18);
  border-color: rgba(220, 38, 38, 0.45);
  color: #fca5a5;
}

/* ===== 登录页 ===== */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #1e3a5f 100%);
}

/* 背景装饰光晕 */
.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
}

.login-glow-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  right: -80px;
  background: #3b82f6;
}

.login-glow-2 {
  width: 360px;
  height: 360px;
  bottom: -100px;
  left: -60px;
  background: #8b5cf6;
}

.login-card {
  position: relative;
  width: 380px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 36px 32px 32px;
  animation: login-card-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes login-card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}

.login-brand-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.login-brand-name {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}

.login-brand-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--danger-light);
  color: #b91c1c;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 16px;
  font-size: 13px;
  animation: login-shake 0.35s ease;
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 带图标的输入框 */
.login-field {
  position: relative;
  margin-bottom: 16px;
}

.login-field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.55;
  pointer-events: none;
}

.login-field input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition),
    background var(--transition);
}

.login-field input::placeholder {
  color: var(--text-muted);
}

.login-field input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-submit {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 6px;
  text-indent: 6px; /* 抵消 letter-spacing 让文字视觉居中 */
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
  transition: transform var(--transition), box-shadow var(--transition);
}

.login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(59, 130, 246, 0.45);
}

.login-submit:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

/* Flash messages */
.flash-message {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--primary-active);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  animation: flash-in 0.25s ease;
}

@keyframes flash-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* Toolbar */
.toolbar {
  margin-bottom: 16px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
}

.data-table th,
.data-table td {
  padding: 12px;
  border: none;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.data-table th {
  background: var(--hover-bg);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--hover-bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .col-actions {
  width: 240px;
  min-width: 240px;
  white-space: nowrap;
}

/* 长文本单元格截断（配合 table-layout: fixed 使用） */
.data-table .cell-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .col-actions .btn,
.data-table .col-actions form {
  margin: 2px 6px 2px 0;
}

/* Forms */
.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 160px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:hover {
  border-color: #cbd5e1;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

select.form-control {
  background: var(--card-bg);
}

textarea.form-control {
  resize: vertical;
}

.form-actions {
  margin-top: 20px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.form-inline .form-group {
  margin-bottom: 0;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  background: var(--card-bg);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}

.btn-warning:hover {
  background: #b45309;
  border-color: #b45309;
  color: #fff;
}

.btn-disabled {
  background: #cbd5e1;
  color: #fff;
  border-color: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-disabled:hover {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #fff;
  transform: none;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
}

/* Tags（胶囊形） */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  line-height: 1.6;
  font-weight: 500;
}

.tag-success {
  background: var(--success-light);
  color: var(--success);
}

.tag-info {
  background: var(--info-light);
  color: var(--info);
}

.tag-danger {
  background: var(--danger-light);
  color: var(--danger);
}

/* Status auto-refresh note */
.refresh-note {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 8px;
}

/* Preformatted JSON */
pre.json-pre {
  width: 100%;
  max-width: 100%;
  max-height: 260px;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
}

pre.json-pre.json-success {
  background: var(--success-light);
  border-color: var(--success-border);
}

pre.json-pre.json-failure {
  background: var(--danger-light);
  border-color: var(--danger-border);
}

/* Task status data sections */
.data-section {
  margin-bottom: 16px;
}

.data-section-title {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-size: 13px;
}

.data-section-title .icon {
  margin-right: 4px;
}

/* Utility */
.text-muted {
  color: var(--text-muted);
}

.mb-16 {
  margin-bottom: 16px;
}

.mt-16 {
  margin-top: 16px;
}

/* ------------------------------------------------------------------
   Rough outline / Hero's Journey editor
   ------------------------------------------------------------------ */

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.stage-card {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stage-card-header {
  background: var(--primary-light);
  color: var(--primary-active);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.stage-card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-card-body label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stage-textarea {
  min-height: 60px;
}

/* Swimlane / lifecycle table */
.swimlane-table {
  min-width: 1200px;
  table-layout: fixed;
  font-size: 12px;
}

.swimlane-character-col {
  width: 120px;
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 1;
  border-right: 2px solid var(--border);
}

.swimlane-stage-col {
  min-width: 140px;
  text-align: center;
}

.swimlane-cell {
  padding: 6px;
  vertical-align: top;
}

.swimlane-select {
  margin-bottom: 4px;
  font-size: 12px;
  padding: 4px 6px;
}

.swimlane-textarea {
  min-height: 40px;
  font-size: 12px;
  margin-bottom: 4px;
}

.swimlane-input {
  font-size: 12px;
  padding: 4px 6px;
}

/* ------------------------------------------------------------------
   Market workbench candidate cards
   ------------------------------------------------------------------ */

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.candidate-card {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition);
}

.candidate-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.candidate-card.selected {
  box-shadow: 0 0 0 2px var(--success), var(--shadow-md);
}

.candidate-header {
  background: var(--hover-bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.candidate-title {
  font-weight: 600;
  color: var(--text);
}

.candidate-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.candidate-body {
  padding: 14px 16px;
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
}

.candidate-body p {
  margin: 0 0 8px;
}

.score-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.score {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-active);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.candidate-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ===== Project-scoped layout (v2 refactor) ===== */
.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.breadcrumb a:hover {
  text-decoration: underline;
}

.project-header .tag {
  margin-left: 8px;
}

.project-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.project-nav-item {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}

.project-nav-item:hover {
  color: var(--primary);
}

.project-nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== Pipeline board ===== */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.layer-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layer-count {
  color: var(--text-muted);
  font-size: 12px;
}

.layer-disabled {
  opacity: 0.65;
}

.unit-drill {
  margin-top: 12px;
}

.unit-drill summary {
  cursor: pointer;
  color: var(--primary);
}

.unit-drill-list {
  margin: 8px 0 0;
  padding-left: 18px;
  max-height: 220px;
  overflow: auto;
}

.unit-drill-list a {
  color: var(--primary);
  text-decoration: none;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* ===== Unit editor ===== */
.unit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-breadcrumb .sep {
  color: var(--text-muted);
  margin: 0 6px;
}

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

.unit-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lock-badge {
  color: var(--warning);
  font-size: 12px;
}

.split-editor {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  .split-editor {
    grid-template-columns: 1fr;
  }
}

.json-editor {
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

.lore-list {
  padding-left: 18px;
}

/* ===== Tabs (pure CSS, radio-driven) ===== */
.tabs .tab-radio {
  display: none;
}

.tab-labels {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.tab-labels label {
  padding: 12px 18px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}

.tab-labels label:hover {
  color: var(--primary);
}

.tab-pane {
  display: none;
  padding: 20px;
}

#tab-audit:checked ~ .tab-labels label[for="tab-audit"],
#tab-eval:checked ~ .tab-labels label[for="tab-eval"],
#tab-calls:checked ~ .tab-labels label[for="tab-calls"],
#tab-report:checked ~ .tab-labels label[for="tab-report"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

#tab-audit:checked ~ .pane-audit,
#tab-eval:checked ~ .pane-eval,
#tab-calls:checked ~ .pane-calls,
#tab-report:checked ~ .pane-report {
  display: block;
}

/* ===== Score bars (evaluation panel) ===== */
.score-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-label {
  width: 56px;
  color: var(--text-secondary);
}

.score-bar {
  flex: 1;
  height: 8px;
  background: var(--info-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.score-value {
  width: 24px;
  text-align: right;
  font-weight: 600;
}

.score-total {
  margin-top: 4px;
  font-size: 15px;
}

.eval-text {
  white-space: pre-wrap;
  background: var(--hover-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
}

/* ===== Audit list ===== */
.audit-list {
  list-style: none;
  padding-left: 0;
}

.audit-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.tag-warning {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--warning-light);
  color: var(--warning);
}

.flash-error {
  background: var(--danger-light);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* ===== Markdown report body ===== */
.markdown-body {
  line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 16px 0 8px;
}

.markdown-body table {
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
}

.markdown-body th {
  background: var(--hover-bg);
}

/* 拆书结果：出场人物表格的人物列（首列）固定加宽，名字过长时正常换行 */
.deconstruct-pane .markdown-body table {
  table-layout: fixed;
  width: 100%;
}
.deconstruct-pane .markdown-body table th:first-child,
.deconstruct-pane .markdown-body table td:first-child {
  width: 7em;
}

.markdown-body pre {
  background: var(--hover-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow: auto;
}

/* ===== Candidate radar chart ===== */
.candidate-radar {
  width: 100%;
  height: 220px;
  margin: 8px 0;
}

.eval-reason {
  font-size: 12px;
}

/* ===== Market report structured rendering ===== */
.report-section {
  margin-bottom: 20px;
}

.report-section-title {
  border-left: 3px solid var(--primary);
  padding-left: 10px;
  margin: 16px 0 10px;
}

.report-kv {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.report-key {
  flex-shrink: 0;
  width: 140px;
  font-weight: 500;
  color: var(--text-secondary);
}

.report-val {
  flex: 1;
  min-width: 0;
}

.report-list {
  margin: 4px 0;
  padding-left: 20px;
}

.report-table {
  margin: 8px 0;
}

/* ===== Market report picker & comparison ===== */
.report-select {
  display: inline-block;
  width: auto;
  min-width: 200px;
  padding: 4px 8px;
  font-size: 12px;
  height: 28px;
}

.compare-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.compare-form .form-control {
  width: auto;
  min-width: 220px;
  padding: 4px 8px;
  font-size: 13px;
  height: 30px;
}

.compare-table td {
  vertical-align: top;
}

.compare-table .report-key {
  width: auto;
}

/* ===== Publish tabs (calendar center) ===== */
#pub-metadata:checked ~ .tab-labels label[for="pub-metadata"],
#pub-schedule:checked ~ .tab-labels label[for="pub-schedule"],
#pub-drafts:checked ~ .tab-labels label[for="pub-drafts"],
#pub-records:checked ~ .tab-labels label[for="pub-records"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

#pub-metadata:checked ~ .pane-pub-metadata,
#pub-schedule:checked ~ .pane-pub-schedule,
#pub-drafts:checked ~ .pane-pub-drafts,
#pub-records:checked ~ .pane-pub-records {
  display: block;
}

/* ===== Base settings tabs (framework / profile / lifecycle) ===== */
#bs-framework:checked ~ .tab-labels label[for="bs-framework"],
#bs-profile:checked ~ .tab-labels label[for="bs-profile"],
#bs-lifecycle:checked ~ .tab-labels label[for="bs-lifecycle"],
#bs-location:checked ~ .tab-labels label[for="bs-location"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

#bs-framework:checked ~ .pane-bs-framework,
#bs-profile:checked ~ .pane-bs-profile,
#bs-lifecycle:checked ~ .pane-bs-lifecycle,
#bs-location:checked ~ .pane-bs-location {
  display: block;
}

.chapter-picker {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.chapter-picker label {
  display: block;
  margin-bottom: 6px;
}

/* ===== Calendar ===== */
.calendar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.calendar-title {
  font-weight: 600;
}

.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 0;
}

.calendar-day {
  min-height: 80px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.calendar-day:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

.calendar-blank {
  border: none;
  background: transparent;
}

.calendar-blank:hover {
  box-shadow: none;
}

.calendar-day-num {
  color: var(--text-secondary);
  font-weight: 600;
}

.calendar-entry {
  margin-top: 2px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--primary-light);
  color: var(--primary-active);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-status-published {
  background: var(--success-light);
  color: var(--success);
}

.calendar-status-failed {
  background: var(--danger-light);
  color: var(--danger);
}

/* ===== Stat cards (logs page & dashboard) ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 18px 20px;
  text-align: center;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

/* Quick-link tiles (homepage dashboard) */
.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  background: var(--hover-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  text-align: center;
}

.quick-link:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

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

.prompt-text {
  max-height: 400px;
  overflow: auto;
}

/* ===== Skeleton view ===== */
.skeleton-table td {
  vertical-align: top;
}

.stage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.skeleton-line {
  font-size: 12px;
  margin: 4px 0;
}

.event-group {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-chip {
  background: var(--hover-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 12px;
}

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

.event-chip-brief {
  font-size: 11px;
  margin-top: 2px;
}

/* 事件候选方案（L1 筛选）：每个方案独立一行卡片 */
.event-option {
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  padding: 6px 10px;
}

/* ===== Lifecycle / timeline tables ===== */
.lifecycle-scroll {
  overflow-x: auto;
}

.lifecycle-table th,
.lifecycle-table td,
.timeline-table th,
.timeline-table td {
  min-width: 36px;
  text-align: center;
}

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 1;
  min-width: 140px !important;
  text-align: left !important;
}

.sticky-col-2 {
  position: sticky;
  left: 140px;
  background: var(--card-bg);
  z-index: 1;
  min-width: 90px !important;
}

tr:hover .sticky-col,
tr:hover .sticky-col-2 {
  background: var(--hover-bg);
}

.lifecycle-cell[data-kind="mention"] { color: var(--warning); }
.lifecycle-cell[data-kind="direct"] { color: var(--primary); font-weight: bold; }
.lifecycle-cell[data-kind="active"] { color: var(--success); }
.lifecycle-cell[data-kind="exit"] { color: var(--danger); }

.lane-stage {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.lane-event {
  font-size: 12px;
}

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

.lane-text {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 120px;
}

.fs-mark-inline {
  color: var(--warning);
  font-size: 14px;
}

/* ===== Foreshadow timeline ===== */
.fs-timeline {
  position: relative;
  height: 20px;
  border-bottom: 1px solid var(--border);
}

.fs-mark {
  position: absolute;
  top: 0;
  font-size: 13px;
}

.fs-planted { color: var(--warning); }
.fs-hinted { color: var(--primary); }
.fs-recovered { color: var(--success); }

.fs-overdue td { background: var(--danger-light); }
.fs-dormant td { color: var(--text-muted); }
.fs-due td { background: var(--warning-light); }

/* ===== Query drawer ===== */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}

.drawer-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 101;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
}

.drawer-section {
  margin-bottom: 20px;
}

.drawer-results {
  margin-top: 12px;
}

.query-chain .sep {
  color: var(--text-muted);
  margin: 0 4px;
}

/* Centered modal dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: var(--info-light);
}

.modal-body {
  padding: 16px 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
}

.modal .event-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.modal .event-row .ev-title {
  flex: 2;
}

.modal .event-row .ev-summary {
  flex: 3;
}

.modal .event-row .ev-remove {
  flex-shrink: 0;
}

/* Deconstruct (拆书) two-pane reader */
.deconstruct-reader {
  display: flex;
  gap: 16px;
  height: calc(100vh - 220px);
  min-height: 480px;
}

.deconstruct-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: var(--radius-sm, 6px);
  overflow: hidden;
}

.deconstruct-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  flex-shrink: 0;
}

.deconstruct-chapter-nav {
  flex: 1;
  min-width: 0;
}

.deconstruct-chapter-nav .form-control {
  width: 100%;
}

.deconstruct-chapter-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.deconstruct-pane-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
}

.deconstruct-content {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 15px;
}

.deconstruct-edit-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.deconstruct-edit-form textarea {
  flex: 1;
  resize: none;
  font-family: inherit;
  line-height: 1.7;
}
