/* ============================================================
   htpy — Shared Stylesheet
   Academic design: serif headings, muted navy accent, square edges
   ============================================================ */

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  background: #f8f9fa;
  color: #1e293b;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }

/* --- Page Header (shared across compute, archive, builder pages) --- */
.page-header {
  background: #1e293b;
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 15px;
}
.page-header a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
}
.page-header a:hover { color: white; }
.page-header h1 { font-size: 20px; font-weight: 600; }

/* --- Container --- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}

/* --- Section Title --- */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
}

/* --- Cards --- */
.card-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 16px 20px;
}
a.card {
  display: block;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
}
a.card:hover { border-color: #94a3b8; }
.card.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  font-family: Georgia, "Times New Roman", serif;
}
.card-sub {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}
.card-badge {
  display: inline-block;
  font-size: 11px;
  background: #e2e8f0;
  padding: 2px 7px;
  border-radius: 3px;
  color: #64748b;
  margin-left: 6px;
  vertical-align: middle;
}
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.card-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 8px;
}
.card-range {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}
.card-detail {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* --- SS-type badges on result cards --- */
.card-badge.badge-adams { background: #dbeafe; color: #1d3a5c; }
.card-badge.badge-cess { background: #fef3c7; color: #92400e; }
.card-badge.badge-motivic { background: #d1fae5; color: #065f46; }
.card-badge.badge-novikov { background: #ede9fe; color: #5b21b6; }

/* --- Prime Pills --- */
.prime-row { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.prime-row-label { font-size: 13px; color: #64748b; margin-right: 4px; }
.prime-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  background: #edf2f7;
  border: 1px solid #2b4c7e;
  color: #2b4c7e;
  cursor: pointer;
  text-decoration: none;
}
.prime-pill:hover:not(.disabled) { background: #d6dee8; }
.prime-pill.compute-only {
  background: white;
  border: 1px dashed #2b4c7e;
  color: #2b4c7e;
}
.prime-pill.compute-only:hover { background: #edf2f7; }
.prime-pill.disabled {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

/* ============================================================
   Form Controls (shared across compute, builder, cell-builder)
   ============================================================ */
.section {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 24px;
  margin-bottom: 20px;
}
.section .section-title {
  font-size: 16px;
}
.section-hint {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 12px;
}
.bounds-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.bounds-label {
  font-size: 14px;
  font-weight: 500;
  min-width: 120px;
}
.bounds-input {
  background: white;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 14px;
  width: 100px;
}
.bounds-input:focus { outline: none; border-color: #2b4c7e; }
.bounds-hint { font-size: 12px; color: #64748b; }

/* --- Buttons --- */
.btn {
  padding: 10px 24px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn-primary { background: #2b4c7e; color: white; }
.btn-primary:hover { background: #1d3a5c; }
.btn-primary:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: #64748b;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover { background: #e2e8f0; color: #1e293b; }
.btn-link {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: #2b4c7e;
  border: 1px solid #2b4c7e;
}
.btn-link:hover { background: #edf2f7; }

/* --- Checkboxes & Options --- */
.compute-opt {
  display: block;
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}
.compute-opt input { margin-right: 6px; accent-color: #2b4c7e; }

/* --- Error Messages --- */
.error-msg {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 2px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
  color: #991b1b;
  display: none;
}

@media (max-width: 600px) {
  .bounds-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .bounds-label { min-width: auto; }
}

/* ============================================================
   Computing Overlay
   ============================================================ */
.computing-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(248, 249, 250, 0.95);
  z-index: 100;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.computing-overlay.visible { display: flex; }
.spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #2b4c7e;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-container {
  background: #e2e8f0;
  border-radius: 2px;
  height: 8px;
  overflow: hidden;
  margin: 16px auto;
  max-width: 320px;
}
.progress-bar {
  height: 100%;
  background: #2b4c7e;
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}
.verbose-log {
  max-height: 120px;
  overflow-y: auto;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  margin-top: 12px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.verbose-log div:last-child {
  color: #1e293b;
  font-weight: 500;
}
.compute-done-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.compute-done-actions .btn {
  font-weight: 500;
  text-decoration: none;
}
.compute-done-actions .btn-secondary {
  background: #e2e8f0;
  color: #1e293b;
  border: none;
}
.compute-done-actions .btn-secondary:hover { background: #cbd5e1; }

/* ============================================================
   Landing Page
   ============================================================ */
.landing-header {
  text-align: center;
  padding: 48px 24px 32px;
}
.landing-header h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 8px;
}
.landing-header p {
  color: #64748b;
  font-size: 16px;
}
.landing-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 48px;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.landing-footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: #94a3b8;
}
.landing-footer a {
  color: #64748b;
  text-decoration: none;
  margin: 0 10px;
}
.landing-footer a:hover { color: #2b4c7e; }
@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ============================================================
   Compute SS Page
   ============================================================ */
.page-subtitle {
  text-align: center;
  padding: 24px 24px 8px;
  color: #64748b;
  font-size: 15px;
}
.target-region {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
}
.tab-bar {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.tab-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #64748b;
  border-bottom: 2px solid transparent;
  position: relative;
}
.tab-btn:hover:not(.disabled) {
  color: #1e293b;
  background: #f1f5f9;
}
.tab-btn.active {
  color: #2b4c7e;
  border-bottom-color: #2b4c7e;
  background: white;
}
.tab-btn.disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}
.tab-btn .tab-reason {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  font-size: 11px;
  font-weight: 400;
  padding: 4px 8px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}
.tab-btn.disabled:hover .tab-reason { display: block; }
.tab-panel { display: none; padding: 24px; }
.tab-panel.active { display: block; }

/* --- Built-in sections --- */
.builtin-section + .builtin-section { margin-top: 20px; }
.builtin-section-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}

/* --- Archive select --- */
.archive-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: white;
  color: #1e293b;
  cursor: pointer;
  appearance: auto;
}
.archive-select:focus { outline: none; border-color: #2b4c7e; }
.archive-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  min-height: 32px;
}
.archive-meta-text {
  font-size: 13px;
  color: #64748b;
  flex: 1;
}

/* --- Motivic source toggle --- */
.source-toggle { display: flex; gap: 0; margin-bottom: 16px; }
.source-toggle button {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: white;
  color: #64748b;
}
.source-toggle button:first-child { border-radius: 2px 0 0 2px; }
.source-toggle button:last-child { border-radius: 0 2px 2px 0; border-left: none; }
.source-toggle button.active {
  background: #2b4c7e;
  color: white;
  border-color: #2b4c7e;
}

@media (max-width: 600px) {
  .tab-btn { font-size: 12px; padding: 10px 4px; }
}

/* ============================================================
   Module Builder Page
   ============================================================ */
.builder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #1e293b;
  color: #e2e8f0;
}
.builder-header a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid #475569;
  border-radius: 2px;
}
.builder-header a:hover { background: #334155; color: #e2e8f0; }
.builder-header h1 {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}
.header-btn {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
}
.header-btn:hover { background: #334155; color: #e2e8f0; }
.header-btn:disabled { background: #64748b; cursor: not-allowed; }
.header-btn-primary {
  background: #2b4c7e;
  border: none;
  color: white;
  padding: 6px 16px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.header-btn-primary:hover { background: #1d3a5c; }
.header-btn-primary:disabled { background: #64748b; cursor: not-allowed; }

.form-section {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 20px;
  margin-bottom: 16px;
}
.form-section h2 {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 12px;
}
.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.form-row label {
  font-size: 14px;
  font-weight: 500;
  min-width: 60px;
}
.form-row input[type="text"],
.form-row input[type="number"] {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
}
.form-row input[type="text"]:focus,
.form-row input[type="number"]:focus {
  border-color: #2b4c7e;
  outline: none;
}
.form-row select {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 14px;
  background: white;
}
#name-input { flex: 1; max-width: 200px; }
.gen-entry, .action-entry, .relation-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-radius: 2px;
}
.radio-group {
  display: flex;
  gap: 12px;
  align-items: center;
}
.radio-group label {
  font-size: 14px;
  font-weight: 400;
  min-width: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.relation-entry select { min-width: 70px; }
.relation-entry .rel-eq-zero {
  color: #64748b;
  font-size: 13px;
}
.gen-entry input[type="text"] { width: 80px; }
.gen-entry input[type="number"] { width: 60px; }
.action-entry select { min-width: 70px; }
.remove-btn {
  background: transparent;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}
.remove-btn:hover { color: #991b1b; }
.add-btn {
  background: transparent;
  border: 1px dashed #94a3b8;
  color: #64748b;
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 4px;
}
.add-btn:hover { border-color: #2b4c7e; color: #2b4c7e; }
#json-preview {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 2px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}
.range-row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.range-row label { min-width: auto; }
.range-row input { width: 60px; }
.builder-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: 2px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
.suggestions-panel {
  background: #edf2f7;
  border: 1px solid #c3cdd9;
  border-radius: 2px;
  padding: 12px;
  margin-top: 12px;
}
.suggestions-panel h3 {
  font-size: 13px;
  font-weight: 600;
  color: #1d3a5c;
  margin-bottom: 8px;
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 4px;
  cursor: pointer;
}
.suggestion-item:hover { color: #1d3a5c; }
.suggestion-item input[type="checkbox"] { cursor: pointer; }
.suggestion-desc { color: #64748b; font-size: 12px; }

/* ============================================================
   Cell Complex Builder Page
   ============================================================ */
.builder-input {
  background: white;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 6px 10px;
  border-radius: 2px;
  font-size: 13px;
}
.builder-input:focus { outline: none; border-color: #2b4c7e; }
.builder-table { width: 100%; border-collapse: collapse; }
.builder-table th {
  font-size: 12px;
  color: #64748b;
  text-align: left;
  padding: 4px 8px;
  font-weight: 500;
}
.builder-table td { padding: 4px 8px; }
.builder-remove {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}
.builder-remove:hover { color: #ef4444; }
.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* ============================================================
   Archive Results Page
   ============================================================ */
#playground-section { display: none; }
#playground-list .card-stack { margin-bottom: 0; }
.empty-msg {
  font-size: 14px;
  color: #94a3b8;
  padding: 16px 0;
}

/* ============================================================
   Viewer (base.html)
   ============================================================ */
body.viewer-body {
  height: 100vh;
  overflow: hidden;
  min-height: auto;
}
.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
}
#header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #1e293b;
  color: #e2e8f0;
  position: relative;
}
#module-btn {
  background: transparent;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
#module-btn:hover { background: #334155; }
#module-dropdown {
  position: absolute;
  top: 100%;
  left: 12px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 2px;
  min-width: 220px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-height: 400px;
  overflow-y: auto;
}
#module-dropdown a {
  display: block;
  padding: 8px 14px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 14px;
}
#module-dropdown a:hover { background: #334155; }
#module-dropdown a.active { background: #475569; }
.header-badge {
  padding: 3px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.archive-badge {
  background: #065f46;
  color: #a7f3d0;
}
.playground-badge {
  background: #1e40af;
  color: #bfdbfe;
}
.wasm-badge {
  background: #7c2d12;
  color: #fed7aa;
}
.local-badge {
  background: #374151;
  color: #d1d5db;
}
#import-btn { margin-left: auto; }
#chart-container {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  position: relative;
}
#chart-canvas, #chart-canvas-right {
  flex: 1;
  min-height: 0;
  display: block;
  cursor: grab;
}
#chart-canvas.panning, #chart-canvas-right.panning { cursor: grabbing; }
#chart-controls {
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}
.page-toolbar, .toggle-toolbar, .range-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
}
.page-toolbar { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; }
.toggle-toolbar { border-bottom: 1px solid #e2e8f0; }
.toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-right: 4px;
}
.page-btn {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  color: #334155;
}
.page-btn:hover { background: #e2e8f0; }
.page-btn.active {
  background: #1e293b;
  color: white;
  border-color: #1e293b;
}
.toggle-btn {
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  color: #334155;
  opacity: 0.5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.toggle-btn:hover { background: #e2e8f0; }
.toggle-btn.active {
  opacity: 1;
  background: white;
  border-color: #94a3b8;
}
.swatch {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 1px;
}
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; left: 0; z-index: 80;
  background: white; border: 1px solid #e2e8f0; border-radius: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 180px;
  padding: 4px 0; margin-top: 4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-actions {
  border-top: 1px solid #e2e8f0; padding: 6px 12px;
  display: flex; gap: 8px;
}
.dropdown-actions button {
  font-size: 11px; color: #2b4c7e; background: none;
  border: none; cursor: pointer;
}
.dropdown-actions button:hover { text-decoration: underline; }
.range-input {
  width: 50px;
  padding: 2px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 12px;
  text-align: center;
}
#detail {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 50;
  padding: 20px;
  background: #f8f9fa;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
#detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 2px;
}
#detail-close:hover { background: #e2e8f0; color: #334155; }
#detail h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #1e293b;
}
.detail-field { margin-bottom: 12px; }
.detail-field dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 2px;
}
.detail-field dd {
  font-size: 16px;
  color: #1e293b;
  font-weight: 500;
}
.detail-list {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
}
.gen-row {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}
.gen-idx {
  font-size: 11px;
  color: #94a3b8;
  min-width: 18px;
  text-align: right;
}
.gen-display { font-size: 13px; }
.gen-row .inferred {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 4px;
  white-space: nowrap;
}
.gen-rename-form {
  display: flex;
  gap: 4px;
  align-items: center;
}
.name-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.name-actions button {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: #1e293b;
  color: white;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.name-actions button:hover { background: #334155; }
.name-actions .reset-btn {
  background: white;
  color: #dc2626;
  border-color: #dc2626;
}
.name-actions .reset-btn:hover { background: #fef2f2; }
.combo-entry {
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.combo-entry .combo-del {
  background: transparent;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.combo-entry .combo-del:hover { color: #991b1b; }
.combo-form {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.combo-form .combo-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.combo-form input[type="text"] {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 13px;
  font-family: inherit;
  min-width: 0;
}
.combo-form input[type="text"]:focus { border-color: #2b4c7e; outline: none; }
.cofiber-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.cofiber-btn {
  padding: 5px 10px;
  border: 1px solid #2b4c7e;
  border-radius: 2px;
  background: #2b4c7e;
  color: white;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.cofiber-btn:hover { background: #1d3a5c; }
.cofiber-btn.secondary {
  background: white;
  color: #2b4c7e;
}
.cofiber-btn.secondary:hover { background: #edf2f7; }
.permanent-note {
  font-size: 12px;
  color: #15803d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 2px;
  padding: 6px 10px;
  line-height: 1.4;
}
.permanent-note .perm-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid #16a34a;
  transform: rotate(45deg);
  margin-right: 4px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.permanent-note .perm-reason { color: #4b5563; }
.degree-note {
  font-size: 12px;
  color: #1e40af;
  background: #edf2f7;
  border: 1px solid #c3cdd9;
  border-radius: 2px;
  padding: 6px 10px;
  line-height: 1.4;
}
.degree-note .degree-reason { color: #4b5563; }
.detail-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: white;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.detail-view-btn:hover { border-color: #2b4c7e; background: #edf2f7; color: #1d3a5c; }
.detail-view-btn .badge {
  background: #e2e8f0;
  color: #64748b;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}
#header.header-whatif { background: #92400e; }
#whatif-banner {
  background: #fef3c7; color: #92400e; text-align: center;
  font-size: 13px; padding: 4px 12px; display: none;
  align-items: center; justify-content: center; gap: 8px;
}
#whatif-banner.active { display: flex; }
.deduce-modal-checks { display:flex; flex-direction:column; gap:6px; margin:8px 0 12px; }
.deduce-modal-checks label { display:flex; align-items:center; gap:6px; font-size:13px; cursor:pointer; }
.deduce-modal-checks label.disabled { opacity:0.45; pointer-events:none; }
.deduce-modal-checks input[type=checkbox] { margin:0; }
.deduce-modal-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
.deduce-modal-actions button { padding:4px 14px; border-radius:2px; border:1px solid #cbd5e1; cursor:pointer; font-size:13px; }
.deduce-modal-actions button.primary { background:#1d3a5c; color:white; border-color:#1d3a5c; }
.deduce-modal-toggles { font-size:12px; color:#64748b; margin-bottom:4px; }
.deduce-modal-toggles a { cursor:pointer; color:#1d3a5c; text-decoration:underline; margin-right:8px; }
.results-table { width:100%; border-collapse:collapse; font-size:13px; }
.results-table td { padding:3px 8px; }
.results-table td:last-child { text-align:right; font-variant-numeric:tabular-nums; }
.results-table tr.section-header td { font-weight:600; padding-top:8px; color:#475569; }
.detail-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-modal {
  background: #f8f9fa;
  border-radius: 3px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  width: min(560px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.detail-modal h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
}
.detail-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 2px;
}
.detail-modal-close:hover { background: #e2e8f0; color: #334155; }
.detail-modal-row {
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid #f1f5f9;
}
.detail-modal-row:last-child { border-bottom: none; }
.coeff-input {
  width: 28px;
  padding: 2px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 12px;
  text-align: center;
}
.coeff-input:focus { border-color: #2b4c7e; outline: none; }
.combo-coeff-label {
  font-size: 11px;
  color: #64748b;
}
#diff-status {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 16px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 3px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}
#diff-status button {
  padding: 4px 10px;
  border: 1px solid #475569;
  border-radius: 2px;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 12px;
}
#diff-status button:hover { background: #334155; }
.diff-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.diff-modal {
  background: white;
  border-radius: 3px;
  padding: 20px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.diff-modal h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: #1e293b;
}
.diff-modal label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.diff-modal .modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
.diff-modal .modal-actions button {
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
}
.diff-modal .modal-actions .apply-btn {
  background: #1e293b;
  color: white;
  border-color: #1e293b;
}
.diff-modal .modal-actions .apply-btn:hover { background: #334155; }
.diff-modal .modal-actions .cancel-btn {
  background: white;
  color: #334155;
}
.diff-modal .modal-actions .cancel-btn:hover { background: #f1f5f9; }
.diff-del {
  background: transparent;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  margin-left: 4px;
}
.diff-del:hover { color: #991b1b; }
#chart-canvas.diff-mode { cursor: crosshair; }
#hover-tooltip {
  position: absolute;
  z-index: 55;
  pointer-events: none;
  padding: 4px 8px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 2px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: none;
}
#tab-bar {
  display: flex;
  align-items: stretch;
  background: #334155;
  border-bottom: 1px solid #1e293b;
  overflow-x: auto;
  min-height: 30px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  border-right: 1px solid #475569;
  white-space: nowrap;
  user-select: none;
}
.tab:hover { background: #475569; color: #e2e8f0; }
.tab.active { background: #1e293b; color: #e2e8f0; }
.tab-close {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.tab-close:hover { opacity: 1; }
.tab-add {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  border: none;
  background: transparent;
}
.tab-add:hover { color: #e2e8f0; background: #475569; }

/* Split view */
.layout.split-mode {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto 1fr;
}
.layout.split-mode #header { grid-column: 1 / -1; }
.layout.split-mode #tab-bar { grid-column: 1 / -1; }
.layout.split-mode #chart-container { grid-column: 1; }
.layout.split-mode #chart-container-right {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  position: relative;
  border-left: 2px solid #1e293b;
}
#chart-container-right { display: none; }
.layout.split-mode #chart-container-right { display: flex; }
.split-label {
  padding: 2px 8px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}
#split-choose-btn {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}
#split-choose-btn:hover { border-color: #2b4c7e; }
#split-module-label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}
.link-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #64748b;
  cursor: pointer;
}
.link-toggle input { cursor: pointer; }
.detect-text {
  font-style: italic;
  color: #1d3a5c;
  font-size: 12px;
}
.detect-del, .anno-card-del {
  background: transparent;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  margin-left: 4px;
}
.detect-del:hover, .anno-card-del:hover { color: #991b1b; }
.detect-form, .anno-form {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}
.detect-form input, .anno-form input[type="text"] {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 13px;
  min-width: 0;
}
.detect-form input:focus, .anno-form input[type="text"]:focus { border-color: #2b4c7e; outline: none; }
.detect-form select, .anno-form select {
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  font-size: 13px;
}
.detect-form button, .anno-form button {
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: #1e293b;
  color: white;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.detect-form button:hover, .anno-form button:hover { background: #334155; }
.anno-card {
  border-left: 3px solid #cbd5e1;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.anno-card .anno-icon {
  font-weight: bold;
  font-size: 14px;
  line-height: 1.2;
  flex-shrink: 0;
}
.anno-card .anno-body { flex: 1; }
.anno-tag-btn {
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.5;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.anno-tag-btn:hover { background: #e2e8f0; }
.anno-tag-btn.active { opacity: 1; border-color: #94a3b8; }
.badge-indecomposable {
    display: inline-block;
    font-size: 10px;
    background: #fef3c7;
    color: #92400e;
    padding: 1px 6px;
    border-radius: 2px;
    margin-left: 6px;
    font-weight: 500;
}
#split-quotient-btn {
    font-size: 11px;
    padding: 1px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    margin-left: 6px;
}
#split-quotient-btn:hover { border-color: #2b4c7e; color: #2b4c7e; }
