/* chat-panel.css — "rolling treatment" layout.
   Reads as a document column, not a chat. Slate-rule left margin (2px cinnamon
   for user, 1px hairline for assistant) carries turn-taking. Source Serif italic
   for assistant prose, Inter 500 for user lines, mono for slate labels and stage
   directions. No bubbles, no colored alert boxes - one stage-direction style
   replaces tool-call boxes and system-message boxes both. */

.ic-chat-shell {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 50;
  pointer-events: none;
  font-family: var(--body, 'Inter', system-ui, sans-serif);
}
.ic-chat-shell > * { pointer-events: auto; }

/* ============================================================
   CLOSED TAB — vertical slate at right edge
   ============================================================ */
.ic-chat-tab {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 44px;
  height: 160px;
  background: #FBF9F4;
  border: 1px solid var(--ink-ghost, rgba(31,27,22,0.10));
  border-right: none;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  box-shadow: -6px 0 18px rgba(31,27,22,0.06);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  transition: transform 0.18s ease, background 0.12s ease;
}
.ic-chat-tab:hover {
  background: var(--canvas, #F4F1EA);
  transform: translateY(-50%) translateX(-3px);
  box-shadow: -10px 0 24px rgba(31, 27, 22, 0.10);
}
.ic-chat-shell.is-open .ic-chat-tab { display: none; }
.ic-chat-tab-rule {
  /* 1px cinnamon hairline running the height of the tab — the signature element */
  position: absolute;
  top: 14px; bottom: 14px;
  left: 50%;
  width: 1px;
  background: var(--accent, #C97A4F);
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.ic-chat-tab:hover .ic-chat-tab-rule { opacity: 1; }
.ic-chat-tab-label {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--ink-muted, #645a4f);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  z-index: 1;
  background: inherit;
  padding: 6px 0;
}
.ic-chat-tab-dot {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s, box-shadow 0.2s;
}
.ic-chat-tab-dot.on {
  background: var(--accent, #C97A4F);
  box-shadow: 0 0 0 0 rgba(201, 122, 79, 0.5);
  animation: ic-chat-dot-soft 2.2s ease-out infinite;
}
@keyframes ic-chat-dot-soft {
  0%   { box-shadow: 0 0 0 0 rgba(201, 122, 79, 0.5); }
  60%  { box-shadow: 0 0 0 8px rgba(201, 122, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 122, 79, 0); }
}

/* ============================================================
   OPEN PANEL — treatment document column
   ============================================================ */
.ic-chat-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: #FBF9F4;
  border-left: 1px solid var(--ink-ghost, rgba(31,27,22,0.10));
  box-shadow: -12px 0 30px rgba(31,27,22,0.07);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.1, 1);
}
.ic-chat-shell.is-open .ic-chat-panel { transform: translateX(0); }

/* ---- Slate header ---- */
.ic-chat-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px 10px;
  background: #FBF9F4;
}
.ic-chat-head-text { min-width: 0; }
.ic-chat-eyebrow {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted, #645a4f);
  display: flex; align-items: baseline; gap: 8px;
}
.ic-chat-eyebrow .scope {
  color: var(--accent-deep, #A85E3B);
  max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ic-chat-title {
  /* Reuse the eyebrow for identity - skip a separate big title to keep the
     panel feeling like a document, not an app screen */
  display: none;
}
.ic-chat-rule {
  /* Hairline rule under the header, the divider in the wireframe */
  margin: 0 22px;
  height: 1px;
  background: var(--ink-ghost, rgba(31,27,22,0.10));
}
.ic-chat-close {
  background: transparent;
  border: none;
  color: var(--ink-faint, #9c9388);
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.12s;
}
.ic-chat-close:hover { color: var(--ink, #1F1B16); }

/* ---- Message column ---- */
.ic-chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 8px;
  display: flex; flex-direction: column;
  gap: 18px;
  background: #FBF9F4;
}
.ic-chat-list::-webkit-scrollbar { width: 6px; }
.ic-chat-list::-webkit-scrollbar-thumb { background: var(--ink-ghost, rgba(31,27,22,0.10)); border-radius: 3px; }

/* Empty state */
.ic-chat-empty {
  padding: 40px 8px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-muted, #645a4f);
  line-height: 1.55;
}
.ic-chat-empty::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--accent, #C97A4F);
  margin-bottom: 14px;
  opacity: 0.6;
}

/* ---- Entries — the heart of the treatment layout ----
   Each entry has a left slate rule (different weight per role), a mono slate
   label above the prose, and the prose itself with role-specific type. */
.ic-chat-msg {
  position: relative;
  padding-left: 14px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.ic-chat-msg::before {
  /* The slate rule */
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background: var(--ink-ghost, rgba(31,27,22,0.10));
}
.ic-chat-msg-user::before {
  width: 2px;
  background: var(--accent, #C97A4F);
}
.ic-chat-msg-slate {
  /* Slate line: a role chip on the left, the time pushed to the right. The chip
     carries who-said-what at a glance; the time stays small + muted + mono. */
  display: flex; align-items: baseline; gap: 8px;
}
.ic-chat-msg-slate .role {
  /* Small role chip — "You" / "Agent". Subtle pill, weighted enough to scan. */
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 9px;
  line-height: 1.2;
  color: var(--ink-muted, #7A7269);
  background: var(--ink-ghost, rgba(31,27,22,0.10));
}
.ic-chat-msg-slate .time {
  /* Muted mono time, right-aligned via the spacer below. */
  margin-left: auto;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-faint, #9c9388);
  font-variant-numeric: tabular-nums;
}
/* User chip uses the cinnamon accent (matches the 2px user rule); agent stays
   neutral ink. This is the primary at-a-glance you-vs-agent differentiator. */
.ic-chat-msg-user .ic-chat-msg-slate .role {
  color: #fff;
  background: var(--accent, #C97A4F);
  letter-spacing: 0.14em;
}

.ic-chat-msg-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink, #1F1B16);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ic-chat-msg-user .ic-chat-msg-body {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
}
.ic-chat-msg-assistant .ic-chat-msg-body,
.ic-chat-msg-system   .ic-chat-msg-body,
.ic-chat-msg-tool     .ic-chat-msg-body {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
}

/* ---- Stage directions — one style for tool calls, async pushes, system notes.
       Replaces the old blue + yellow boxes. ---- */
.ic-chat-stage-list {
  display: flex; flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}
.ic-chat-stage {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-style: italic;
  color: var(--ink-faint, #9c9388);
  letter-spacing: 0.01em;
  word-break: break-all;
}
.ic-chat-stage::before { content: '['; opacity: 0.6; }
.ic-chat-stage::after  { content: ']'; opacity: 0.6; }
.ic-chat-stage.is-pending { color: var(--accent-deep, #A85E3B); }
.ic-chat-stage.is-error { color: #A33; }

/* ---- Thinking dots — same gesture, no bubble ---- */
.ic-chat-thinking {
  display: inline-flex;
  gap: 6px;
  padding: 2px 0;
}
.ic-chat-thinking span {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--accent, #C97A4F);
  border-radius: 50%;
  opacity: 0.45;
  animation: ic-chat-dot-bounce 1.4s infinite ease-in-out both;
}
.ic-chat-thinking span:nth-child(1) { animation-delay: -0.32s; }
.ic-chat-thinking span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ic-chat-dot-bounce {
  0%, 80%, 100% { transform: scale(0.55); opacity: 0.25; }
  40%           { transform: scale(1);    opacity: 1; }
}

/* ---- Pending runs strip (between list and composer) ---- */
.ic-chat-pending {
  padding: 0 22px;
  display: flex; flex-direction: column;
  gap: 4px;
  background: #FBF9F4;
}
.ic-chat-pending:not(:empty) { padding-bottom: 8px; }
.ic-chat-pending-item {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-style: italic;
  font-size: 11px;
  color: var(--accent-deep, #A85E3B);
  letter-spacing: 0.02em;
  padding: 4px 0;
}
.ic-chat-pending-item::before { content: '['; opacity: 0.6; }
.ic-chat-pending-item::after  { content: ']'; opacity: 0.6; }

/* ---- Composer — single line, no background, hairline rule above ---- */
.ic-chat-composer {
  border-top: 1px solid var(--ink-ghost, rgba(31,27,22,0.10));
  padding: 14px 22px 18px;
  background: #FBF9F4;
  display: flex; flex-direction: column;
  gap: 10px;
  position: relative;
}
/* Cinnamon focus underline - subtle indicator that composer is active without
   adding a heavy outline. The line grows from center on focus. */
.ic-chat-composer::after {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  height: 1px;
  width: 0;
  background: var(--accent, #C97A4F);
  transition: width 0.18s ease, left 0.18s ease;
}
.ic-chat-composer.is-focused::after {
  left: 22px;
  width: calc(100% - 44px);
}
.ic-chat-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink, #1F1B16);
  resize: none;
  outline: none;
  min-height: 28px;
  max-height: 220px;
  box-sizing: border-box;
  line-height: 1.5;
  padding: 0;
}
.ic-chat-input::placeholder {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  color: var(--ink-faint, #9c9388);
  font-weight: 400;
  font-size: 14px;
}
.ic-chat-input:focus { outline: none; }
.ic-chat-composer-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  min-height: 18px;
}
.ic-chat-hint {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 9.5px;
  color: var(--ink-faint, #9c9388);
  letter-spacing: 0.08em;
}
.ic-chat-send {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  color: var(--accent-deep, #A85E3B);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.12s;
}
.ic-chat-send:hover:not(:disabled) { color: var(--accent, #C97A4F); }
.ic-chat-send:disabled { opacity: 0.35; cursor: not-allowed; }
.ic-chat-composer.is-busy .ic-chat-send::after {
  content: ' · sending…';
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .ic-chat-panel { width: 360px; }
}
@media (max-width: 760px) {
  .ic-chat-panel { width: 100vw; max-width: 100vw; }
  .ic-chat-tab { top: auto; bottom: 80px; }
}
