/* Analyse Mode -- full-page view inside #main. Naturally slots between
   the chat header and composer (flex sibling) instead of overlaying. */

.analyse-panel {
  background: #0d0e12;                /* var(--bg) */
  color: #e8e9ee;                     /* var(--fg) */
  overflow-y: auto;
  font-family: inherit;
  font-size: 13px;
  padding: 0;
  display: none;                      /* hidden by default */
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;                      /* allow scroll inside flex */
}
.analyse-panel:not(.hidden) { display: flex; }

/* When the analysis page is open, hide chat + composer so the panel
   gets the entire content area. */
body.analyse-open #chat,
body.analyse-open #composer { display: none; }

.analyse-panel .ap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  border-bottom: 1px solid #262933;
  background: #0d0e12;
  position: sticky;
  top: 0;
  z-index: 2;
}
.analyse-panel .ap-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e8c86b;                    /* var(--accent) */
}
.analyse-panel .ap-close {
  background: none;
  border: 1px solid #3a4052;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: #9ea3b0;
  padding: 7px 14px;
  line-height: 1;
  transition: all 0.12s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.analyse-panel .ap-close:hover {
  color: #e8c86b;
  border-color: #e8c86b;
}

.analyse-panel .ap-zone {
  padding: 18px 32px;
  border-bottom: 1px solid #262933;
  line-height: 1.5;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.analyse-panel .ap-zone.hidden { display: none; }
.analyse-panel .ap-zone.collapsed {
  max-height: 52px;
  overflow: hidden;
  opacity: 0.45;
  pointer-events: none;
}

.analyse-panel .ap-zone p {
  margin: 8px 0;
  color: #cbcdd5;
}

.analyse-panel .chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: #242833;
  color: #e8c86b;
  border: 1px solid #3a4052;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.analyse-panel label,
.analyse-panel .ap-intent-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ea3b0;
  margin-bottom: 4px;
}
.analyse-panel select,
.analyse-panel input[type="text"],
.analyse-panel textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3a4052;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: #0d0e12;               /* var(--bg) */
  color: #e8e9ee;
  box-sizing: border-box;
  margin-top: 4px;
}
.analyse-panel select:focus,
.analyse-panel input[type="text"]:focus,
.analyse-panel textarea:focus {
  outline: none;
  border-color: #e8c86b;
}
.analyse-panel textarea { resize: vertical; min-height: 56px; }
.analyse-panel input[type="range"] {
  width: 100%;
  margin-top: 4px;
}

.analyse-panel #intent-hint {
  display: block;
  font-size: 11px;
  color: #9ea3b0;
  margin: 4px 0 14px;
  font-style: italic;
  line-height: 1.4;
}

.analyse-panel .ap-questions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.analyse-panel .ap-q {
  font-size: 12px;
  font-weight: 500;
  color: #cbcdd5;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
}
.analyse-panel .ap-q .req { color: #c96b6b; }
.analyse-panel .ap-choices {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.analyse-panel .ap-choice {
  font-size: 12px;
  font-weight: 400;
  color: #cbcdd5;
  text-transform: none;
  letter-spacing: normal;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.analyse-panel .ap-choice input { margin: 0; }

.analyse-panel #ap-submit {
  margin-top: 16px;
  padding: 8px 14px;
  background: #e8c86b;
  color: #0d0e12;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.analyse-panel #ap-submit:hover { filter: brightness(1.08); }
.analyse-panel #ap-submit:disabled { opacity: 0.5; cursor: default; }

/* Specialist accordion cards (inspired by PocketLegal's AI Team pattern) */
.analyse-panel .ap-spec-card {
  border: 1px solid #262933;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #1c1f27;
  overflow: hidden;
}
.analyse-panel .ap-spec-card[open] { background: #181b22; }
.analyse-panel .ap-spec-summary {
  display: grid;
  grid-template-columns: 14px minmax(90px, 1.4fr) 1fr 40px 72px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  user-select: none;
}
.analyse-panel .ap-spec-summary::-webkit-details-marker { display: none; }
.analyse-panel .ap-spec-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a4052;
  transition: background 0.12s;
}
.analyse-panel .ap-spec-card.running .ap-spec-icon {
  background: #e8c86b;
  box-shadow: 0 0 6px rgba(232, 200, 107, 0.7);
  animation: ap-pulse 1.2s ease-in-out infinite;
}
.analyse-panel .ap-spec-card.complete .ap-spec-icon { background: #4a7a4a; }
@keyframes ap-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.analyse-panel .ap-spec-summary strong {
  color: #e8e9ee;
  font-weight: 500;
  font-size: 12px;
}
.analyse-panel .ap-spec-bar {
  display: block;
  height: 5px;
  background: #262933;
  border-radius: 3px;
  overflow: hidden;
}
.analyse-panel .ap-spec-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8c7140, #e8c86b);
  transition: width 0.3s ease;
}
.analyse-panel .ap-spec-card.queued .ap-spec-bar > span { background: #3a4052; }
.analyse-panel .ap-spec-card.running .ap-spec-bar > span {
  background: linear-gradient(90deg, #3a4052, #e8c86b);
  width: 35% !important;
  animation: ap-slide 1.5s ease-in-out infinite;
}
@keyframes ap-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
.analyse-panel .ap-spec-conf {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #e8c86b;
  font-weight: 600;
  text-align: right;
}
.analyse-panel .ap-spec-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ea3b0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.analyse-panel .ap-spec-card.running .ap-spec-status { color: #e8c86b; }
.analyse-panel .ap-spec-card.complete .ap-spec-status { color: #4a7a4a; }
.analyse-panel .ap-spec-card.queued { opacity: 0.55; }

/* Body shown when a specialist accordion is opened */
.analyse-panel .ap-spec-body {
  padding: 0 14px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: #cbcdd5;
  border-top: 1px solid #262933;
  padding-top: 10px;
  margin-top: 2px;
}
.analyse-panel .ap-spec-body h1,
.analyse-panel .ap-spec-body h2,
.analyse-panel .ap-spec-body h3,
.analyse-panel .ap-spec-body h4 {
  color: #e8c86b;
  text-transform: none;
  letter-spacing: normal;
  margin: 10px 0 4px;
}
.analyse-panel .ap-spec-body h3 { font-size: 12px; font-weight: 600; }
.analyse-panel .ap-spec-body h4 { font-size: 11px; font-weight: 600; }
.analyse-panel .ap-spec-body p { margin: 6px 0; }
.analyse-panel .ap-spec-body ul,
.analyse-panel .ap-spec-body ol { margin: 6px 0; padding-left: 22px; }
.analyse-panel .ap-spec-body li { margin: 2px 0; }
.analyse-panel .ap-spec-body strong { color: #e8e9ee; font-weight: 600; }
.analyse-panel .ap-spec-body code { background: #0d0e12; padding: 1px 5px; border-radius: 3px; font-size: 11px; }

.analyse-panel .persona-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.analyse-panel .persona-tabs button {
  background: #1c1f27;
  border: 1px solid #262933;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
  color: #9ea3b0;
}
.analyse-panel .persona-tabs button.active {
  background: #e8c86b;
  color: #0d0e12;
  border-color: #e8c86b;
}
.analyse-panel .persona-body {
  font-size: 13px;
  line-height: 1.6;
  color: #cbcdd5;
}
.analyse-panel .persona-body h1,
.analyse-panel .persona-body h2,
.analyse-panel .persona-body h3,
.analyse-panel .persona-body h4 {
  color: #e8c86b;
  text-transform: none;
  letter-spacing: normal;
  margin: 14px 0 6px;
}
.analyse-panel .persona-body h1 { font-size: 15px; }
.analyse-panel .persona-body h2 { font-size: 14px; }
.analyse-panel .persona-body h3 { font-size: 13px; font-weight: 600; }
.analyse-panel .persona-body h4 { font-size: 12px; font-weight: 600; }
.analyse-panel .persona-body p { margin: 8px 0; }
.analyse-panel .persona-body ul,
.analyse-panel .persona-body ol { margin: 8px 0; padding-left: 22px; }
.analyse-panel .persona-body li { margin: 3px 0; }
.analyse-panel .persona-body strong { color: #e8e9ee; font-weight: 600; }
.analyse-panel .persona-body em { color: #cbcdd5; }
.analyse-panel .persona-body code {
  background: #0d0e12;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.analyse-panel .persona-body pre {
  margin: 8px 0;
}
.analyse-panel .ap-scribe {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #262933;
}
.analyse-panel .confidence-strip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #262933;
  font-size: 11px;
  color: #9ea3b0;
  font-variant-numeric: tabular-nums;
}

.analyse-panel .error {
  color: #c96b6b;
  padding: 10px;
  font-size: 13px;
  background: rgba(201, 107, 107, 0.08);
  border: 1px solid #c96b6b;
  border-radius: 6px;
}
.analyse-panel pre {
  background: #0d0e12;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #262933;
  overflow-x: auto;
  font-size: 12px;
  white-space: pre-wrap;
  color: #e8e9ee;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}
.analyse-panel code { font-family: inherit; }
.analyse-panel .ap-silence {
  font-size: 13px;
  color: #9ea3b0;
  font-style: italic;
  padding: 8px 0;
}

.analyse-panel h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: #e8c86b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.analyse-panel #ap-copy {
  margin-top: 10px;
  background: #1c1f27;
  border: 1px solid #3a4052;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  color: #e8e9ee;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.analyse-panel #ap-copy:hover { border-color: #e8c86b; color: #e8c86b; }

/* Re-analyse button in the header */
#reanalyse-btn { white-space: nowrap; }

/* Active-persona badge next to the clock */
.persona-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #e8c86b;
  border-radius: 14px;
  background: rgba(232, 200, 107, 0.08);
  color: #e8c86b;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s;
}
.persona-badge:hover { background: rgba(232, 200, 107, 0.18); }
.persona-badge.hidden { display: none; }
.persona-badge strong { color: #e8e9ee; font-weight: 600; }
.persona-badge .badge-extra {
  background: #3a4052;
  color: #e8e9ee;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
}

/* Previous-runs history inside the panel */
.analyse-panel .ap-history details { cursor: pointer; }
.analyse-panel .ap-history summary {
  font-size: 11px;
  font-weight: 600;
  color: #9ea3b0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  list-style: none;
  padding: 2px 0;
}
.analyse-panel .ap-history summary::-webkit-details-marker { display: none; }
.analyse-panel .ap-history summary::before { content: "▸ "; color: #e8c86b; }
.analyse-panel .ap-history details[open] summary::before { content: "▾ "; }
.analyse-panel .ap-history summary strong { color: #e8e9ee; }
.analyse-panel .ap-history-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.analyse-panel .ap-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1c1f27;
  border: 1px solid #262933;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.analyse-panel .ap-history-row:hover {
  border-color: #e8c86b;
  background: #242833;
}
.analyse-panel .ap-history-row.current {
  border-color: #4a7a4a;
  background: #1f2a1f;
  cursor: default;
}
.analyse-panel .ap-history-row.current::before {
  content: "● ";
  color: #4a7a4a;
  margin-right: 4px;
}

/* Meta-row below the situation summary on a loaded past run */
.analyse-panel .ap-meta-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #262933;
  font-size: 11px;
}
.analyse-panel .ap-meta-k {
  color: #9ea3b0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  font-size: 10px;
}
.analyse-panel .ap-meta-v {
  color: #e8e9ee;
  font-variant-numeric: tabular-nums;
}
.analyse-panel .ap-hr-main { display: flex; gap: 10px; align-items: center; }
.analyse-panel .ap-hr-intent {
  color: #e8c86b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.analyse-panel .ap-hr-conf { color: #e8e9ee; font-variant-numeric: tabular-nums; }
.analyse-panel .ap-hr-when { color: #9ea3b0; }
.analyse-panel .ap-hr-actions { display: flex; gap: 8px; align-items: center; }
.analyse-panel .ap-hr-state { color: #9ea3b0; font-size: 10px; }
.analyse-panel .ap-hr-del {
  background: none;
  border: 1px solid #3a4052;
  color: #9ea3b0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
}
.analyse-panel .ap-hr-del:hover {
  color: #c96b6b;
  border-color: #c96b6b;
}

/* ===================== Nebula accents =====================
   Re-skins the analyse panel onto the Nebula glass system: glass
   surface, blue accent (replacing the legacy amber), consistent
   buttons. Override block, so structural rules above stay intact. */

.analyse-panel {
  background: var(--glass-bg);
  color: var(--fg);
  border-left: 1px solid var(--glass-border);
  box-shadow: var(--glass-hi);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
@supports not (backdrop-filter: blur(1px)) { .analyse-panel { background: var(--bg-2); } }

.analyse-panel .ap-header {
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.analyse-panel .ap-header h2 { font-family: var(--font-display); color: var(--accent); }
.analyse-panel .ap-zone { border-bottom: 1px solid var(--glass-border); }

/* Blue accent + glass surfaces (was amber #e8c86b / solid #1c1f27 etc.) */
.analyse-panel .ap-close,
.analyse-panel .ap-hr-del { border-color: var(--glass-border); color: var(--fg-faint); }
.analyse-panel .ap-close:hover { color: var(--accent); border-color: var(--accent); }
.analyse-panel .ap-spec-conf,
.analyse-panel .ap-spec-card.running .ap-spec-status,
.analyse-panel .ap-spec-body h1,
.analyse-panel .ap-spec-body h2,
.analyse-panel .ap-spec-body h3,
.analyse-panel .ap-spec-body h4 { color: var(--accent); }

.analyse-panel .ap-spec-card { border-color: var(--glass-border); background: var(--glass-bg); }
.analyse-panel .ap-spec-card[open] { background: var(--glass-bg-2); }
.analyse-panel .ap-spec-bar { background: var(--glass-bg); }
.analyse-panel .ap-spec-bar > span { background: var(--user); }
.analyse-panel .ap-spec-card.running .ap-spec-bar > span { background: var(--user); }
.analyse-panel .ap-spec-card.running .ap-spec-icon { background: var(--accent); }

/* Submit + primary action buttons */
.analyse-panel #ap-submit {
  background: var(--user);
  color: #fff;
  border-radius: var(--r-sm);
  box-shadow: var(--glow);
}
.analyse-panel #ap-submit:hover { box-shadow: 0 0 24px rgba(96,165,250,.6); filter: none; }
