/* ── ASANMOD Chat Core: tokens, panel shell, list, identity bar ── */

:root {
  /* z-index tokens */
  --z-chat-composer: 2;
  --z-chat-mobile-tabs: 40;

  /* chat sizing */
  --chat-max-w: 760px;
  --chat-bubble-w: 82%;
  --chat-bubble-w-mobile: 82%;
  --chat-bubble-radius: 16px;
  --chat-composer-radius: 22px;
  --chat-gap: 14px;
  --chat-font-s: 14px;
  --chat-font: 15px;
  --chat-font-l: 16px;
  --chat-padding-x: 16px;
  --mobile-chat-chrome-h: 292px;
  --chat-bubble-min-height: 44px;
}

/* ── Conversation panel internal shell ── */

.conversation-panel > .panel-header:not([hidden]),
.conversation-panel .chat-transcript-head:not([hidden]),
.conversation-panel .chat-session-identity {
  display: flex;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  padding: 10px 16px 0;
}

.conversation-panel .conversation-signal-stack:not([hidden]) {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}

.conversation-panel > .panel-header {
  padding-bottom: 8px;
  border-bottom: 0;
}

.conversation-signal-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px;
}

/* ── Chat session identity bar ── */

.chat-session-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 10px 16px 0 !important;
  border-bottom: 1px solid rgba(75, 215, 232, 0.08);
  flex: 0 0 auto;
}

.chat-session-identity-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.chat-session-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(75, 215, 232, 0.25);
  box-shadow: 0 0 6px rgba(75, 215, 232, 0.16);
  flex: 0 0 auto;
  transition: background 300ms ease;
}

.chat-session-identity[data-chat-state="active"] .chat-session-icon {
  background: rgba(75, 215, 232, 0.55);
  box-shadow: 0 0 10px rgba(75, 215, 232, 0.25);
}

.chat-session-identity[data-chat-state="loading"] .chat-session-icon {
  animation: sessionIdentityPulse 900ms ease-in-out infinite;
}

@keyframes sessionIdentityPulse {
  0%,
  100% {
    background: rgba(75, 215, 232, 0.15);
  }
  50% {
    background: rgba(75, 215, 232, 0.45);
  }
}

.chat-session-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: 0 0 auto;
  white-space: nowrap;
}

.chat-session-id-badge {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 550;
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(75, 215, 232, 0.06);
  border: 1px solid rgba(75, 215, 232, 0.12);
}

.chat-session-id-badge[data-session-kind="none"] {
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-weight: 400;
  font-style: italic;
}

.chat-session-id-badge[data-session-kind="pending"] {
  border-style: dashed;
  opacity: 0.75;
}

.chat-session-provenance {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  max-width: min(38%, 300px);
  margin-left: auto;
  overflow: hidden;
  color: #dff8ef;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  border: 1px solid rgba(101, 214, 166, 0.24);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(101, 214, 166, 0.14),
    rgba(101, 214, 166, 0.06)
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 5px 10px;
}

.chat-session-provenance[hidden] {
  display: none;
}

.chat-session-provenance::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #65d6a6;
  box-shadow: 0 0 10px rgba(101, 214, 166, 0.45);
  flex: 0 0 auto;
}

.chat-session-provenance span {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-session-provenance span + span {
  color: rgba(223, 248, 239, 0.72);
  font-weight: 520;
}

.chat-session-loading {
  display: inline-flex;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(75, 215, 232, 0.12);
  border-top-color: rgba(75, 215, 232, 0.55);
  border-radius: 50%;
  animation: sessionLoadingSpin 600ms linear infinite;
  flex: 0 0 auto;
}

.chat-session-loading[hidden] {
  display: none;
}

@keyframes sessionLoadingSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Chat transcript head ── */

.chat-transcript-head {
  border-top: 1px solid rgba(75, 215, 232, 0.12);
  padding: 10px 16px 0;
}

.chat-transcript-head h3 {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.2;
}

/* ── Chat count ── */

.chat-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: rgba(8, 15, 19, 0.72);
  color: var(--text-muted);
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 11px;
}

/* ── Conversation empty state ── */

.conversation-empty {
  align-self: center;
  width: min(520px, calc(100% - 32px));
  margin: auto auto 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}

.conversation-empty[hidden] {
  display: none;
}

/* ── Conversation list ── */

.conversation-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--chat-gap);
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 18px 18px 22px;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 34%),
    rgba(4, 9, 12, 0.22);
  scrollbar-width: thin;
}

/* ── Codex bridge status (chat-adjacent) ── */

.codex-form-head,
.chat-transcript-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.codex-form-head {
  display: none;
}

.codex-text-form label,
.codex-bridge-status,
.codex-form-context {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.codex-bridge-status {
  order: 3;
  margin: 0;
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.codex-form-context {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
