/* Debug Context Layer styling (consistent dark theme with WhipBot Backoffice & Labs) */
.debug-context-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(8, 10, 16, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.debug-context-modal.hidden {
  display: none !important;
}

.debug-context-dialog {
  background: #10121a;
  border: 1px solid #30394e;
  border-radius: 16px;
  width: 100%;
  max-width: 1400px;
  height: 94vh;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  color: #f3f6ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.debug-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #171b26;
  border-bottom: 1px solid #30394e;
  gap: 16px;
}

.debug-context-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.debug-context-badge {
  background: linear-gradient(135deg, #7e3fbb, #bc76ff);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-context-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-context-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.debug-context-btn {
  background: #242c3d;
  color: #f3f6ff;
  border: 1px solid #3a465f;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.debug-context-btn:hover {
  background: #323d54;
  border-color: #516284;
}

.debug-context-btn.primary {
  background: #7e3fbb;
  border-color: #9d5dd9;
  color: #fff;
}

.debug-context-btn.primary:hover {
  background: #9048d6;
}

.debug-context-close-btn {
  background: transparent;
  border: none;
  color: #9aa7bf;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.debug-context-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.debug-context-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: #141722;
  border-bottom: 1px solid #283042;
  overflow-x: auto;
}

.debug-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #9aa7bf;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  white-space: nowrap;
}

.debug-tab-btn:hover {
  color: #f3f6ff;
  background: rgba(255, 255, 255, 0.04);
}

.debug-tab-btn.is-active {
  color: #fff;
  background: #1f2535;
  border-color: #3b4761;
}

.debug-context-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.debug-tab-content {
  display: none;
}

.debug-tab-content.is-active {
  display: block;
}

/* Grid & Cards */
.debug-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.debug-grid-3 {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 16px;
}

@media (max-width: 1100px) {
  .debug-grid-3 {
    grid-template-columns: 1fr;
  }
  .debug-grid-2 {
    grid-template-columns: 1fr;
  }
}

.debug-card {
  background: #161a25;
  border: 1px solid #2c3547;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-card-title {
  font-size: 14.5px;
  font-weight: 750;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  border-bottom: 1px solid #283042;
  padding-bottom: 10px;
}

.debug-card-title span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-kv-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.debug-kv-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa7bf;
}

.debug-kv-value {
  font-size: 13.5px;
  color: #e2e8f0;
  line-height: 1.45;
  word-break: break-word;
}

.debug-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.debug-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
}

.debug-chip-kink {
  background: rgba(222, 77, 125, 0.16);
  color: #f472b6;
  border: 1px solid rgba(222, 77, 125, 0.4);
}

.debug-chip-dislike {
  background: rgba(255, 141, 155, 0.15);
  color: #ff8d9b;
  border: 1px solid rgba(255, 141, 155, 0.4);
}

.debug-chip-rule {
  background: rgba(88, 166, 255, 0.15);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.35);
}

.debug-pre-box {
  background: #0d1017;
  border: 1px solid #242c3d;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Calendar styling (aligned with temporal-memory-lab) */
.debug-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.debug-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  min-height: 280px;
}

@media (max-width: 950px) {
  .debug-cal-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.debug-cal-col {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 8px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debug-cal-col.today {
  border-color: #58a6ff;
  background: #0c1829;
}

.debug-cal-col-header {
  font-weight: 700;
  font-size: 12px;
  color: #8b949e;
  border-bottom: 1px solid #21262d;
  padding-bottom: 4px;
  text-transform: capitalize;
}

.debug-cal-col.today .debug-cal-col-header {
  color: #58a6ff;
}

.debug-cal-card {
  background: #1f2937;
  border-left: 4px solid #58a6ff;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  color: #f0f6fc;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}

.debug-cal-card:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

.debug-cal-card .ev-title {
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.debug-cal-card .ev-time {
  font-size: 10.5px;
  color: #8b949e;
  display: block;
}

.debug-cal-card .ev-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 3px;
  font-weight: 700;
  text-transform: uppercase;
}

.debug-cal-card.modality-proposal {
  border-left-style: dashed;
  border-left-width: 5px;
  background: #2a2416 !important;
  border-left-color: #e3b341 !important;
}

.debug-cal-card.modality-proposal .ev-badge {
  background: rgba(227, 179, 65, 0.2);
  color: #e3b341;
  border: 1px solid rgba(227, 179, 65, 0.4);
}

.debug-cal-card.modality-intention {
  border-left-style: dotted;
  border-left-width: 5px;
  background: #201a2c !important;
  border-left-color: #a371f7 !important;
}

.debug-cal-card.modality-intention .ev-badge {
  background: rgba(163, 113, 247, 0.2);
  color: #d2a8ff;
  border: 1px solid rgba(163, 113, 247, 0.4);
}

.debug-cal-ev-free { border-left-color: #388bfd; background: #11253e; }
.debug-cal-ev-exercise { border-left-color: #a371f7; background: #261b3d; }
.debug-cal-ev-availability { border-left-color: #3fb950; background: #132d20; }
.debug-cal-ev-unavailability { border-left-color: #f85149; background: #351a1d; }
.debug-cal-ev-work { border-left-color: #d29922; background: #352a14; }
.debug-cal-ev-appointment { border-left-color: #f0883e; background: #372314; }
.debug-cal-ev-moment { border-left-color: #58a6ff; background: #0c1829; }

.debug-history-list {
  font-size: 13px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.debug-history-item {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 10px;
}

.debug-history-item.user-item {
  border-left: 3px solid #58a6ff;
}

.debug-history-item.bot-item {
  border-left: 3px solid #8b949e;
}

.debug-history-item .stamp {
  font-size: 10px;
  color: #8b949e;
  margin-top: 4px;
}

/* Matrix & Daily rhythm styling inside Debug Context Layer (from screenshot) */
.debug-rhythm-matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 11px;
  color: #d9cbd5;
  margin-bottom: 12px;
}

.debug-matrix-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.debug-matrix-key::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.debug-matrix-key-sleep { color: #4c86ef; }
.debug-matrix-key-work-home { color: #10b7b0; }
.debug-matrix-key-work-office { color: #f05a28; }
.debug-matrix-key-free { color: #d7d3dc; }
.debug-matrix-key-eating { color: #44c878; }
.debug-matrix-key-drinking { color: #51b9f2; }
.debug-matrix-key-toilet { color: #d4a7f7; }
.debug-matrix-key-ejaculation { color: #ff4e99; }

.debug-matrix-key-eating::before,
.debug-matrix-key-drinking::before,
.debug-matrix-key-toilet::before,
.debug-matrix-key-ejaculation::before {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.debug-rhythm-matrix-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #11141e;
  margin-bottom: 14px;
}

.debug-rhythm-matrix {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(26px, 1fr));
  min-width: 680px;
  background: #161b26;
}

.debug-rhythm-matrix-head {
  min-height: 28px;
  display: grid;
  place-items: center;
  color: #9aa7bf;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.debug-rhythm-matrix-day {
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-content: center;
  padding: 0 4px;
  background: #1c2230;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.debug-rhythm-matrix-day.is-current-day {
  background: #3e1837;
  color: #fff;
  outline: 2px solid #ff5aa7;
  outline-offset: -2px;
  z-index: 3;
}

.debug-rhythm-matrix-cell {
  position: relative;
  min-height: 32px;
  min-width: 0;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: 3px 1px;
  border: 0;
  border-right: 1px solid rgba(40, 50, 70, 0.5);
  border-bottom: 1px solid rgba(40, 50, 70, 0.5);
  color: var(--matrix-text, #fff);
  cursor: help;
  transition: transform 0.1s, filter 0.1s;
}

.debug-rhythm-matrix-cell:hover {
  filter: brightness(1.2);
  z-index: 2;
}

.debug-rhythm-matrix-cell.is-current-time {
  z-index: 4;
  outline: 2px solid #ff5aa7;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px #fff, 0 0 10px rgba(255, 90, 167, 0.6);
}

.debug-matrix-hits {
  position: absolute;
  right: 2px;
  bottom: 3px;
  left: 2px;
  display: grid;
  gap: 1px;
  align-items: end;
}

.debug-matrix-hit {
  display: block;
  width: var(--hit-width);
  min-width: 2px;
  height: 2.5px;
  border-radius: 2px;
}

.debug-matrix-hit-eating { background: #44c878; }
.debug-matrix-hit-drinking { background: #51b9f2; }
.debug-matrix-hit-toilet { background: #d4a7f7; }
.debug-matrix-hit-ejaculation { background: #ff4e99; }

.debug-rhythm-matrix-cell.state-sleep { background: var(--matrix-background, #4c86ef); }
.debug-rhythm-matrix-cell.state-work_home { background: #087f82; }
.debug-rhythm-matrix-cell.state-work_office { background: #c83b16; }
.debug-rhythm-matrix-cell.state-free { background: #d7d3dc; }

/* Inschatting box uit screenshot */
.debug-rhythm-prediction-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px;
  border-radius: 10px;
  background: rgba(255, 0, 128, 0.08);
  border: 1px solid rgba(255, 85, 170, 0.35);
  margin-bottom: 8px;
}

.debug-rhythm-prediction-title {
  color: #fff0f8;
  font-size: 13.5px;
  font-weight: 750;
  line-height: 1.4;
}

.debug-rhythm-prediction-line {
  color: #e2b8d4;
  font-size: 12.5px;
  line-height: 1.45;
}

.debug-rhythm-disclaimer {
  font-size: 11px;
  color: #8b949e;
  margin: 0;
  line-height: 1.4;
}

/* Structured conversation memory cards (Kink-lab style) */
.debug-conv-structured {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.debug-conv-topic-card {
  background: #0f131c;
  border: 1px solid #252e42;
  border-radius: 8px;
  padding: 10px 12px;
}

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

.debug-conv-topic-title {
  font-size: 13px;
  font-weight: 700;
  color: #ff8ec4;
}

.debug-conv-topic-time {
  font-size: 11px;
  color: #8b949e;
}

.debug-conv-summary-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: #e2e8f0;
  margin: 0 0 6px 0;
}

.debug-conv-highlights-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 0 0;
  padding: 0;
  list-style: none;
}

.debug-conv-highlight-item {
  font-size: 11.5px;
  line-height: 1.4;
  color: #9aa7bf;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid #58a6ff;
  border-radius: 0 4px 4px 0;
}

.debug-conv-status-badge {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.15);
  color: #79c0ff;
  border: 1px solid rgba(88, 166, 255, 0.3);
  margin-right: 6px;
}

/* Emotion Lab state shown in the shared debug & context panel. */
.debug-emotion-state {
  margin-bottom: 18px;
}

.debug-emotion-source {
  color: #b7c1d6;
  font-size: 12px;
  line-height: 1.45;
  margin: -3px 0 12px;
}

.debug-emotion-leaders-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin: 0 0 7px;
}

.debug-emotion-leaders-heading strong {
  color: #fff0f8;
  font-size: 13px;
}

.debug-emotion-leaders-heading span {
  color: #8b949e;
  font-size: 11px;
}

.debug-emotion-leaders {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 15px;
}

.debug-emotion-leader {
  background: #0f131c;
  border: 1px solid #283042;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
}

.debug-emotion-leader > span {
  color: #9aa7bf;
  font-size: 11px;
}

.debug-emotion-leader > strong {
  color: #fff0f8;
  font-size: 13px;
}

.debug-emotion-leader em {
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
}

.debug-emotion-leader em.is-positive { color: #65d6ac; }
.debug-emotion-leader em.is-negative { color: #ff8c9f; }
.debug-emotion-leader em.is-neutral { color: #9aa7bf; }

@media (max-width: 620px) {
  .debug-emotion-leaders { grid-template-columns: 1fr; }
}

.debug-emotion-groups {
  display: grid;
  gap: 14px;
}

.debug-emotion-group > strong {
  display: block;
  color: #f1e2f5;
  font-size: 13px;
  margin-bottom: 7px;
}

.debug-emotion-meters {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.debug-emotion-meter {
  background: #0f131c;
  border: 1px solid #283042;
  border-radius: 7px;
  padding: 8px 10px;
}

.debug-emotion-meter > div:first-child {
  align-items: baseline;
  color: #bac4d7;
  display: flex;
  font-size: 11.5px;
  justify-content: space-between;
}

.debug-emotion-meter strong {
  color: #fff0f8;
  font-size: 13px;
}

.debug-emotion-track {
  background: #252c3a;
  border-radius: 999px;
  height: 5px;
  margin: 6px 0 5px;
  overflow: hidden;
}

.debug-emotion-track i {
  background: linear-gradient(90deg, #b46cff, #ff79c6);
  border-radius: inherit;
  display: block;
  height: 100%;
}

.debug-emotion-meter em {
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.debug-emotion-meter em.is-positive { color: #65d6ac; }
.debug-emotion-meter em.is-negative { color: #ff8c9f; }
.debug-emotion-meter em.is-neutral { color: #9aa7bf; }

