:root {
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --radius: 6px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.logo-badge {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
  letter-spacing: 0.5px;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.nav-tab.active {
  background-color: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Main container */
.main-content {
  padding: 1.25rem 1.5rem;
  max-width: 100%;
  margin: 0;
  width: 100%;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.input-search,
.select-filter {
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-color);
  outline: none;
}

.input-search {
  min-width: 260px;
}

.input-search:focus,
.select-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Tables */
.table-container {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

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

.table tr:hover {
  background-color: #f8fafc;
}

/* Strict 3-col specific */
.strict-3-col td:first-child {
  font-size: 0.85rem;
}

.col-channel-url {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.col-channel-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.col-url {
  word-break: break-all;
  color: var(--primary);
  text-decoration: none;
}

.col-url:hover {
  text-decoration: underline;
}

.col-summary {
  line-height: 1.6;
}

.col-summary-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.col-summary-text {
  color: #334155;
  white-space: pre-line;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }

.status-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.text-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

.btn-outline {
  background: white;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-block { width: 100%; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: var(--surface-color);
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  z-index: 200;
}

.dropdown-content.show {
  display: block;
}

.dropdown-item {
  color: var(--text-main);
  padding: 0.5rem 1rem;
  text-decoration: none;
  display: block;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.dropdown-item:hover {
  background-color: #f8fafc;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-dialog {
  background: var(--surface-color);
  border-radius: 8px;
  width: 100%;
  max-width: 850px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

body.modal-open {
  overflow: hidden;
}

/* Modal Reading Mode (Full-width desktop reading view) */
.modal-backdrop.modal-reading-mode {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.modal-backdrop.modal-reading-mode .modal-dialog,
.modal-dialog.modal-dialog-reading {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface-color);
}

.modal-backdrop.modal-reading-mode .modal-header,
.modal-dialog.modal-dialog-reading .modal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  background: var(--surface-color);
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-backdrop.modal-reading-mode .modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-backdrop.modal-reading-mode .modal-close {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-backdrop.modal-reading-mode .modal-close:hover {
  background: #e2e8f0;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.modal-backdrop.modal-reading-mode .modal-close::after {
  content: " 关闭 (Esc)";
  font-size: 0.85rem;
}

.modal-backdrop.modal-reading-mode .modal-body,
.modal-dialog.modal-dialog-reading .modal-body {
  flex: 1 0 auto;
  overflow: visible;
  padding: 1.5rem;
  min-height: 0;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: white;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.success-msg {
  background: #dcfce7;
  color: #15803d;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.login-card {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  background: white;
  padding: 2.5rem;
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.login-header .subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

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

/* Detail blocks inside modal */
.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.assessment-checks {
  max-width: 100%;
  table-layout: fixed;
}
.assessment-checks th, .assessment-checks td {
  overflow-wrap: anywhere;
  white-space: normal;
}
@media (max-width: 760px) {
  .assessment-checks th, .assessment-checks td {
    padding: 0.55rem 0.45rem;
    font-size: 0.8rem;
    line-height: 1.55;
  }
  .assessment-checks th:nth-child(1) { width: 26% !important; }
  .assessment-checks th:nth-child(2) { width: 20% !important; }
  .assessment-checks th:nth-child(3) { width: 54%; }
}

.history-item {
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-color);
  font-size: 0.85rem;
}

.history-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

/* Work Logs Timeline */
.work-logs-container {
  width: 100%;
}

.timeline-entry {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.timeline-entry:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.timeline-detail-box {
  border-radius: 4px;
  line-height: 1.6;
}

.timeline-extra-details {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}

/* Project detail reading mode containers & compact tables */
.project-analysis-container,
.project-check-container {
  max-height: none !important;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.project-analysis-table,
.project-check-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.project-analysis-table th,
.project-check-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.project-analysis-table td,
.project-check-table td {
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  font-size: 0.82rem;
  line-height: 1.5;
}

.project-analysis-table .col-analysis-page {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.project-analysis-table .col-analysis-action {
  white-space: nowrap;
  text-align: right;
}

.project-phase-control {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
}
.project-phase-control:hover { border-color: currentColor; }
.project-phase-control:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.col-check-action .btn { display: block; margin-left: auto; margin-bottom: 0.25rem; white-space: normal; }

.ana-subrow td,
.note-subrow td {
  background-color: #f8fafc;
}

.project-notes-list {
  max-height: none;
  overflow: visible;
}

.timeline-wrapper {
  max-height: none;
  overflow: visible;
}

/* -------------------------------------------------------------
 * 8. Research Paths & Thinking Process Tree Styles
 * ------------------------------------------------------------- */
.path-reading-view {
  width: 100%;
  margin: 0;
  padding: 0.5rem 0 2rem 0;
}

.path-header-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.path-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.path-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.path-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.path-seed-box {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.path-seed-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.path-seed-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.path-tree-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
}

.path-tree-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.step-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.step-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.step-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-bottom: 1px solid var(--border-color);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.step-number-badge {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.step-parent-breadcrumb {
  font-size: 0.8rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  margin: 0.5rem 1rem 0 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.step-parent-breadcrumb .crumb-relation {
  color: #0369a1;
  font-weight: 500;
}

.step-card-body {
  padding: 1rem;
}

.step-narrative {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0.75rem;
}

.step-relation-box {
  background: #f0fdf4;
  border-left: 3px solid #22c55e;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  color: #15803d;
  margin-bottom: 0.75rem;
  border-radius: 0 4px 4px 0;
}

.step-sources-box {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  word-break: break-all;
}

.step-sources-box a {
  color: var(--primary);
  text-decoration: underline;
}

.step-meta-details {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.step-meta-details summary {
  cursor: pointer;
  color: #94a3b8;
  margin-bottom: 0.35rem;
  user-select: none;
}

.step-meta-details summary:hover {
  color: var(--text-muted);
}

.step-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.history-snapshot-banner {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #92400e;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

.modal-dialog.modal-dialog-wide {
  max-width: 96vw;
  width: 96vw;
  height: 92vh;
  max-height: 92vh;
}

/* Mind Map XMind-Style Component */
.mindmap-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #f8fafc;
  overflow: hidden;
  position: relative;
  margin-top: 0.75rem;
}

.mindmap-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.mindmap-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mindmap-main-area {
  display: flex;
  position: relative;
  height: 520px;
  min-height: 400px;
  overflow: hidden;
}

.mindmap-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  cursor: grab;
  user-select: none;
}

.mindmap-viewport:active {
  cursor: grabbing;
}

.mindmap-viewport-wrapped {
  overflow: auto;
  overscroll-behavior: contain;
}

.mindmap-scroll-space {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.mindmap-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.mindmap-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.mindmap-edge {
  fill: none;
  stroke: #64748b;
  stroke-width: 2px;
  transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.mindmap-edge:hover,
.mindmap-edge.highlighted {
  stroke: #2563eb;
  stroke-width: 2.5px;
}

.mindmap-node {
  position: absolute;
  background: #ffffff;
  border: 1.5px solid #93c5fd;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  user-select: none;
}

.mindmap-node:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.mindmap-node.selected {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background: #eff6ff;
}

.mindmap-node[data-node-type="seed"] {
  border-color: #f59e0b;
  border-width: 2px;
  background: #fffbeb;
}

.mindmap-node[data-node-type="seed"].selected {
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
  background: #fef3c7;
}

.mindmap-node-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.mindmap-node-title {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mindmap-node-relation {
  font-size: 0.72rem;
  color: #0369a1;
  background: #e0f2fe;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mindmap-node-text {
  font-size: 0.9rem;
  line-height: 1.35;
  color: #334155;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mindmap-node[data-verdict="red"] { border-color: #ef4444; background: #fff7f7; }
.mindmap-node[data-verdict="red"].selected { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }
.mindmap-node[data-verdict="green"] { border-color: #16a34a; background: #f0fdf4; }
.mindmap-node[data-verdict="green"].selected { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2); }
.mindmap-outcome { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.mindmap-outcome[data-verdict="red"] { background: #fff7f7; }
.mindmap-outcome[data-verdict="green"] { background: #f0fdf4; }
.mindmap-outcome .badge { flex-shrink: 0; }

.mindmap-proposal-edge { stroke: #94a3b8; stroke-dasharray: 6 5; }
.mindmap-node.mindmap-proposal-node { border-color: #94a3b8; background: #f1f5f9; color: #334155; }
.mindmap-node.mindmap-proposal-node.selected { border-color: #64748b; background: #e2e8f0; box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.2); }
.mindmap-proposal-node .mindmap-node-header { font-size: 0.8rem; }
.mindmap-proposal-title { font-size: 0.88rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.mindmap-proposal-state { margin: 0.45rem 0; font-size: 0.75rem; color: #475569; }
.mindmap-proposal-actions { margin-top: 0.4rem; }
.proposal-lead-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.proposal-lead-actions .read-identity { margin: 0; max-width: 100%; }
.proposal-lead-actions .read-identity code { word-break: break-all; white-space: normal; }
.proposal-lead-error { margin: 0.5rem 0 0; color: #991b1b; font-size: 0.8rem; line-height: 1.5; overflow-wrap: anywhere; }
.proposal-detail-field { flex-shrink: 0; }
.proposal-detail-field > strong { display: block; margin-bottom: 0.35rem; font-size: 0.82rem; }
.saved-proposal-background { overflow-wrap: anywhere; }
.saved-proposal-background details { margin-top: 0.75rem; }
.proposal-saved-comment { border-top: 1px solid var(--border-color); margin-top: 0.75rem; padding-top: 0.5rem; }

@media (max-width: 760px) {
  .mindmap-main-area { flex-direction: column; height: auto !important; overflow: visible; }
  .mindmap-viewport { flex: none; width: 100%; height: 480px; }
  .mindmap-detail-panel { width: 100%; min-width: 0; max-width: none; height: auto; border-left: 0; border-top: 1px solid var(--border-color); overflow: visible; scroll-margin-top: 64px; }
  .mindmap-detail-title { gap: 0.5rem; flex-wrap: wrap; }
}

.mindmap-collapse-btn {
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #64748b;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  z-index: 5;
}

.mindmap-collapse-btn:hover {
  background: #f1f5f9;
  border-color: #2563eb;
  color: #2563eb;
}

/* Detail panel in mind map */
.mindmap-detail-panel {
  width: clamp(330px, 34%, 460px);
  min-width: 330px;
  max-width: 460px;
  flex-shrink: 0;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.mindmap-detail-panel > * { min-width: 0; flex-shrink: 0; }

.mindmap-detail-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mindmap-detail-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  overflow-wrap: anywhere;
}

.mindmap-detail-narrative {
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  margin-bottom: 0.75rem;
  min-width: 0;
}

.mindmap-detail-relation {
  font-size: 0.82rem;
  color: #0369a1;
  background: #f0f9ff;
  border-left: 3px solid #0284c7;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
  border-radius: 0 4px 4px 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

/* Stored detail prose keeps its own structure and never renders raw HTML. */
.ledger-detail-content {
  min-width: 0;
  max-width: 68ch;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.ledger-detail-content > :first-child { margin-top: 0; }
.ledger-detail-content > :last-child { margin-bottom: 0; }
.ledger-detail-content p { margin: 0 0 0.85em; }
.ledger-detail-content h3, .ledger-detail-content h4,
.ledger-detail-content h5, .ledger-detail-content h6 {
  margin: 1.1em 0 0.45em;
  font-size: 1em;
  line-height: 1.4;
  font-weight: 700;
  color: var(--text-main);
}
.ledger-detail-content h3 { font-size: 1.1em; }
.ledger-detail-content h5, .ledger-detail-content h6 { font-size: 0.95em; }
.ledger-detail-content ul, .ledger-detail-content ol {
  margin: 0 0 0.9em;
  padding-left: 1.4em;
}
.ledger-detail-content li { margin: 0.35em 0; padding-left: 0.15em; }
.ledger-detail-content li > p { margin-bottom: 0.35em; }
.ledger-detail-content li > :last-child { margin-bottom: 0; }
.ledger-detail-content a { overflow-wrap: anywhere; text-underline-offset: 0.15em; }
.ledger-detail-content a:focus-visible, .ledger-detail-table-scroll:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.ledger-detail-content code {
  padding: 0.12em 0.3em;
  background: #e9eef5;
  border-radius: 3px;
  font-size: 0.9em;
  white-space: break-spaces;
  overflow-wrap: anywhere;
}
.ledger-detail-content pre {
  max-width: 100%;
  margin: 0 0 0.9em;
  padding: 0.7em;
  overflow-x: auto;
  background: #edf2f7;
  border-radius: 4px;
  line-height: 1.5;
}
.ledger-detail-content pre code { padding: 0; background: none; white-space: pre; overflow-wrap: normal; }
.ledger-detail-content blockquote {
  margin: 0 0 0.9em;
  padding: 0.2em 0 0.2em 0.8em;
  border-left: 3px solid #cbd5e1;
  color: #475569;
}
.ledger-detail-content blockquote > :last-child { margin-bottom: 0; }
.ledger-detail-content hr { border: 0; border-top: 1px solid #cbd5e1; margin: 1em 0; }
.detail-value-fields { margin: 0; }
.detail-value-field + .detail-value-field { margin-top: 0.85em; }
.detail-value-fields dt { margin-bottom: 0.3em; font-size: 0.88em; font-weight: 600; color: #475569; }
.detail-value-fields dd { margin: 0; min-width: 0; }
.detail-value-fields .detail-value-fields { padding-left: 0.8em; border-left: 2px solid #e2e8f0; }
.detail-value-empty { color: #64748b; font-style: italic; }
.ledger-detail-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin: 0 0 0.9em;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}
.ledger-detail-content table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 0.9em; }
.ledger-detail-content th, .ledger-detail-content td {
  min-width: 8rem;
  max-width: 24rem;
  padding: 0.5em 0.65em;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  vertical-align: top;
}
.ledger-detail-content th { background: #edf2f7; font-weight: 600; }
.ledger-detail-content th:last-child, .ledger-detail-content td:last-child { border-right: 0; }
.ledger-detail-content tbody tr:last-child td { border-bottom: 0; }
.ledger-detail-content .detail-align-left { text-align: left; }
.ledger-detail-content .detail-align-center { text-align: center; }
.ledger-detail-content .detail-align-right { text-align: right; }
.mindmap-detail-panel .mindmap-detail-section { margin: 0 0 1rem; min-width: 0; }
.mindmap-detail-panel .mindmap-detail-section > h3,
.mindmap-detail-panel .mindmap-detail-section > h4 {
  margin: 0 0 0.4rem;
  font-size: 0.83rem;
  line-height: 1.4;
  color: #475569;
}
.mindmap-detail-panel .evidence-links, .mindmap-detail-panel .mindmap-seed-sources,
.mindmap-detail-panel a, .mindmap-detail-meta code { overflow-wrap: anywhere; }

.mindmap-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.mindmap-error-box {
  padding: 1.5rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0;
}

.mindmap-empty-box {
  padding: 2rem 1rem;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  margin: 0.5rem 0;
}

@media (max-width: 760px) {
  .mindmap-detail-panel {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--border-color);
    padding: 0.9rem;
    overflow: visible;
  }
  .mindmap-detail-narrative { padding: 0.6rem; }
  .navbar { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem; }
  .nav-tabs { order: 3; width: 100%; justify-content: space-between; }
  .nav-tab { padding: 0.5rem; }
  .nav-actions { gap: 0.4rem; flex-wrap: wrap; }
  .user-info { display: none; }
  .main-content { padding: 0.75rem; }
  .toolbar, .filters { flex-wrap: wrap; min-width: 0; }
  .input-search { width: 100%; min-width: 0; }
  .select-filter { max-width: 100%; }
  .table-container .table { min-width: 700px; }
  .table-container .strict-3-col { min-width: 640px; }
  .modal-dialog { width: calc(100% - 1.5rem); min-width: 0; }
  .modal-body { overflow-x: auto; padding: 0.75rem; }
  .form-row { flex-direction: column; gap: 0; }
  .detail-section > div:first-child { flex-wrap: wrap; gap: 0.5rem; }
  .login-card { margin: 0.75rem; padding: 1.5rem; }
}

/* Original Reddit bodies stay plain text, with independent stored review labels. */
.discussion-audit, .discussion-capture, .discussion-comments, .discussion-entry {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.discussion-heading, .discussion-entry-header, .discussion-entry-meta, .discussion-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.discussion-heading { justify-content: space-between; margin-bottom: 0.75rem; }
.discussion-heading h4 { margin: 0; }
.discussion-audit p { margin: 0.5rem 0; }
.discussion-legend, .discussion-summary { line-height: 1.7; }
.discussion-summary {
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #f8fafc;
}
.discussion-summary button { margin-left: 0.5rem; }
.discussion-warning { color: #92400e; background: #fffbeb; padding: 0.75rem; border-radius: 4px; }
.discussion-entry {
  margin: 0.75rem 0;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-left: 3px solid #cbd5e1;
  border-radius: var(--radius);
  background: white;
}
.discussion-comment { margin-left: calc(var(--reply-depth, 0) * 0.6rem); }
.discussion-post { background: #f8fafc; border-left-color: #2563eb; }
.discussion-entry:focus { outline: 3px solid #2563eb; outline-offset: 2px; }
.discussion-entry-header { justify-content: space-between; font-size: 0.9rem; }
.discussion-entry-meta { margin-top: 0.4rem; color: var(--text-muted); font-size: 0.8rem; }
.discussion-entry h5 { font-size: 1rem; margin: 0.8rem 0; }
.discussion-original {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.7;
  margin: 0.75rem 0;
  font-size: 0.95rem;
}
.discussion-review { border-top: 1px dashed var(--border-color); padding-top: 0.65rem; font-size: 0.85rem; }
.discussion-demand { display: inline-block; margin-right: 0.75rem; }
.discussion-demand-yes { color: #166534; }
.discussion-demand-no { color: #991b1b; }
.discussion-demand-unknown { color: #92400e; }
.discussion-demand-unmarked { color: #475569; }
.discussion-generate { margin: 0.2rem 0.5rem 0.2rem 0; }
.discussion-lead-status { color: #166534; margin: 0 0.5rem; }
.discussion-lead-error { display: block; color: #991b1b; margin: 0.4rem 0; }
.discussion-saved-parents { margin: 0.75rem 0; }
.discussion-needs { margin: 0.4rem 0; padding-left: 1.2rem; }
.discussion-needs li { margin: 0.35rem 0; }
.discussion-needs button { white-space: normal; text-align: left; overflow-wrap: anywhere; }
.discussion-goals { margin: 0.75rem 0; }
.discussion-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem; margin: 1rem 0; }
.discussion-controls label { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; font-size: 0.85rem; }
.discussion-controls select, .discussion-controls input {
  font: inherit;
  max-width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  color: var(--text-main);
}
.discussion-controls .discussion-search { flex: 1 1 15rem; }
.discussion-results { color: var(--text-muted); font-size: 0.9rem; margin: 0.75rem 0; }
.discussion-pagination { justify-content: center; margin: 1rem 0; }
.discussion-audit button:focus-visible, .discussion-audit a:focus-visible, .discussion-controls :focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
@media (max-width: 760px) {
  .discussion-heading { align-items: flex-start; }
  .discussion-comment { margin-left: calc(var(--reply-depth, 0) * 0.3rem); }
  .discussion-entry { padding: 0.7rem; }
  .discussion-controls label { flex: 1 1 9rem; }
  .discussion-controls .discussion-search { flex-basis: 100%; }
  .discussion-summary { padding: 0.7rem; }
  .discussion-summary button { margin-left: 0; margin-top: 0.4rem; }
  .discussion-audit .btn { min-height: 2.5rem; }
}
:root .read-identity {display:flex; align-items:center; flex-wrap:wrap; gap:0.35rem; margin:0.6rem 0; font-size:0.8rem; color:var(--text-muted);}
.read-identity code {overflow-wrap:anywhere; word-break:break-word; user-select:all; color:var(--text-main);}
.read-management-actions {display:flex; flex-wrap:wrap; gap:0.5rem; margin:0.6rem 0;}
.read-management-panel {padding:1rem; margin:0.75rem 0; border:1px solid var(--border-color); border-radius:6px;}
.read-management-actions .text-danger, .read-management-panel .text-danger {color:var(--danger);}
.sr-only {position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;}
