/* Context breakdown, composer predictions and retired-input notices (Control UI v2026.11.6).
   Synced from ui/src/styles/chat/context-breakdown.css (verbatim below the marker), plus the popover rules of
   ui/src/styles/chat/layout.css (.context-usage__open / __separator / __latest / skeleton), the prediction rules of
   composer-surface.css and the .chat-notice rules of grouped.css. Tokens come from composer-tokens.css (the
   Context panel is in its scope); the transcript notice uses ClawChats' own colours. */

/* ── context popover (layout.css) ── */
.context-usage__popover {
  --details-separator: var(--border);
}
.context-usage__open {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.context-usage__open svg {
  width: 11px;
  height: 11px;
  transition: transform 150ms var(--ease-out);
}
.context-usage__open:hover:not(:disabled) {
  color: var(--text);
}
.context-usage__open:hover:not(:disabled) svg {
  transform: translateX(2px);
}
.context-usage__separator {
  height: 1px;
  margin: 10px 0;
  background: var(--details-separator);
}
.context-usage__latest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 26px;
  color: var(--muted);
  font-size: 12px;
}
.context-usage__latest .context-usage__stats {
  margin: 0 0 0 auto;
}
.context-usage__report-skeleton {
  margin-top: 10px;
  height: 141px;
}
.context-usage__skeleton-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  column-gap: 6px;
  align-items: center;
}
.context-usage__skeleton-bar {
  height: 5px;
  margin-bottom: 6px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--muted) 20%, transparent);
}
.context-usage__skeleton-row {
  height: 26px;
  :is(i, span, b) {
    height: 8px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--muted) 15%, transparent);
  }
  i {
    width: 8px;
    justify-self: center;
  }
  span {
    width: 70%;
  }
  b {
    width: 36px;
  }
}

/* ── composer predictions (composer-surface.css) ── */
.agent-chat__composer-combobox[data-prediction] {
  display: grid;
}
.agent-chat__composer-combobox[data-prediction] > textarea,
.agent-chat__composer-prediction {
  grid-area: 1 / 1;
}
.agent-chat__composer-combobox[data-prediction] > .agent-chat__composer-placeholder {
  visibility: hidden;
}
.agent-chat__composer-prediction {
  max-height: calc(var(--chat-composer-editor-line) * 3 + var(--chat-composer-editor-inset-block) * 2);
  overflow: hidden;
  padding-block: var(--chat-composer-editor-inset-block);
  color: var(--muted);
  font-size: var(--chat-composer-editor-size);
  line-height: var(--chat-composer-editor-line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.agent-chat__composer-prediction,
.agent-chat__composer-prediction-actions {
  animation: composer-prediction-in 120ms ease-out;
}
@keyframes composer-prediction-in {
  from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-chat__composer-prediction,
  .agent-chat__composer-prediction-actions { animation: none; }
}
/* With a keyboard: a Tab keycap ends the ghost text, no action row (composer-prediction.js header).
   Keycap: the Control UI's .agent-chat__hint kbd, sized to sit in the editor line. */
.agent-chat__composer-prediction kbd {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 0 5px;
  font: 11px/16px var(--mono);
  vertical-align: 1px;
  white-space: nowrap;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.agent-chat__composer-prediction-actions {
  display: none;
  justify-content: space-between;
  gap: 12px;
  padding-block: 4px;
}
.agent-chat__composer-prediction-actions button {
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--control-ui-text-xs);
  cursor: pointer;
}
.agent-chat__composer-prediction-actions button:hover {
  color: var(--text-strong);
}
/* Touch-only (keyboard-hints.ts TOUCH_ONLY_QUERY): no Tab key, so the Control UI's action row. */
@media (any-hover: none) and (any-pointer: coarse) {
  .agent-chat__composer-prediction kbd { display: none; }
  .agent-chat__composer-prediction-actions { display: flex; }
}

/* ── retired (unsent) inputs in the transcript (grouped.css .chat-notice) ── */
.cc-retired-input .chat-notice {
  display: grid;
  gap: 7px;
  margin: 10px auto 18px;
  padding: 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}
.cc-retired-input .chat-notice__body {
  width: min(560px, 100%);
  margin: 0 auto;
}
.cc-retired-input .chat-notice__actions {
  display: flex;
  justify-content: center;
}

/* ── Context side panel: empty / error state (PanelEmptyState) ── */
.chat-context__empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.chat-context__empty > svg {
  width: 22px;
  height: 22px;
}
.chat-context__empty strong {
  color: var(--text-strong);
  font-size: 13px;
}
.chat-context__empty p {
  margin: 0;
  font-size: 12px;
}
.chat-context-panel .chat-context__empty .chat-context__refresh {
  padding: 0 10px;
  box-shadow: inset 0 0 0 1px var(--border-strong);
  color: var(--text-strong);
}
.chat-context-panel button {
  cursor: pointer;
}
.chat-context-panel button:disabled {
  cursor: default;
}
/* Control UI paints "Workspace files" with its --accent (a red brand hue there). ClawChats' accent is the same green as
   --ok (Tool schemas), so files take their own categorical hue instead (deviation, known-gaps/composer-b1.md). */
.chat-context-panel,
.input-area {
  --context-files: #a78bfa;
}
[data-theme="light"] .chat-context-panel,
[data-theme="light"] .input-area {
  --context-files: #6d28d9;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(var(--rise-start-y, 4px));
  }
}

/* ── synced verbatim: ui/src/styles/chat/context-breakdown.css ── */
.chat-context__bar {
  display: flex;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-hover);
  gap: 1px;
}
.chat-context__segment {
  flex: none;
}
.chat-context__total {
  --context-color: var(--ctx-color, var(--muted));
}
.chat-context__messages {
  --context-color: var(--info);
}
.chat-context__files {
  --context-color: var(--context-files, var(--accent));
}
.chat-context__tools {
  --context-color: var(--ok);
}
.chat-context__skills {
  --context-color: var(--warn);
}
.chat-context__system {
  --context-color: var(--muted);
}
.chat-context__segment,
.chat-context__swatch {
  background: var(--context-color);
}
.chat-context__row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto 14px;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: start;
  font-size: 12px;
}
.chat-context__swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.chat-context__label {
  overflow-wrap: anywhere;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-context__tokens {
  text-align: end;
  color: var(--muted);
  white-space: nowrap;
}
.chat-context__note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin: 8px 0;
}
.chat-context--popover {
  margin-top: 10px;
  .chat-context__bar {
    height: 5px;
    margin: 0 0 6px;
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--muted) 20%, transparent);
  }
  .chat-context__row {
    grid-template-columns: 16px minmax(0, 1fr) auto;
    min-height: 26px;
    height: 26px;
    padding: 0;
    border-radius: 0;
  }
  .chat-context__swatch {
    justify-self: center;
  }
  .chat-context__note {
    margin: 0;
  }
  .context-usage__report-skeleton {
    margin-top: 0;
  }
}

openclaw-chat-context-panel,
.chat-context-panel {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

openclaw-chat-context-panel {
  height: 100%;
}
.chat-context-panel {
  overflow: hidden;
  container: context-panel / size;
  .chat-context__refresh,
  .chat-context__compact {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    height: 28px;
    gap: 6px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
  }
  .chat-context__refresh > svg {
    width: 14px;
    height: 14px;
  }
  .chat-context__compact {
    width: 100px;
    box-shadow: inset 0 0 0 1px var(--border-strong);
    color: var(--text-strong);
  }
  .chat-context__compact--high {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: none;
  }
  .chat-context__compact:disabled {
    color: var(--muted);
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--border);
  }
  .chat-context__compact .btn__spinner {
    width: 13px;
    height: 13px;
  }
}
.chat-context-page {
  --context-page-padding: 20px;
  min-width: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  .chat-context__refresh {
    width: 28px;
  }
  .chat-context__bar {
    margin: 12px 0 0;
  }
  .chat-context__segment {
    transition:
      width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
      opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .chat-context__row {
    height: 36px;
    min-height: 36px;
    padding: 0 8px;
    column-gap: 10px;
    border-radius: var(--radius-sm);
    font: inherit;
    opacity: 1;
    transition: background-color 0.2s ease-out;
  }
  .chat-context__label {
    min-width: 0;
  }
  .chat-context__label small {
    margin-left: 6px;
    color: var(--muted);
    font-size: 12px;
  }
  .chat-context__tokens {
    color: var(--text);
    font-size: 12px;
  }
  .chat-context__row > svg {
    width: 14px;
    height: 14px;
    color: var(--muted);
    opacity: 0.7;
    transition: transform 0.15s;
  }
  .chat-context__row[aria-expanded="true"] > svg {
    transform: rotate(90deg);
  }
  .chat-context__row[aria-expanded="true"] .chat-context__label {
    color: var(--text-strong);
  }
  .chat-context__row--deferred .chat-context__swatch {
    background: transparent;
  }
  .chat-context__row--deferred .chat-context__label {
    color: var(--muted);
  }
  .chat-context__accordion {
    margin: 0 32px 8px 26px;
    padding: 2px 0 4px;
    --rise-start-y: -3px;
    animation: rise 180ms ease-out;
  }
  .chat-context__source + .chat-context__source {
    margin-top: 10px;
  }
  .chat-context__source-heading {
    display: flex;
    align-items: center;
    height: 22px;
    color: var(--muted);
    font-size: 11px;
  }
  .chat-context__entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    height: 28px;
    column-gap: 12px;
    font-size: 12px;
    color: var(--muted);
  }
  .chat-context__entry-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    color: var(--text);
    mask-image: linear-gradient(to right, black calc(100% - 20px), transparent);
  }
  .chat-context__path {
    margin-left: 8px;
    color: var(--muted);
  }
  .chat-context__unverified {
    border-bottom: 1px dotted var(--muted);
  }
  .chat-context__search {
    display: flex;
    align-items: center;
    height: 30px;
    margin: 2px 0 6px;
    padding: 0 8px;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
  }
  .chat-context__search:focus-within {
    border-color: var(--border-strong);
  }
  .chat-context__search > svg {
    width: 13px;
    height: 13px;
  }
  .chat-context__search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 12px;
  }
  .chat-context__search input::placeholder {
    color: var(--muted);
  }
  .chat-context__show-all {
    display: block;
    height: 30px;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
  }
  .chat-context__no-matches {
    color: var(--muted);
    font-size: 12px;
  }
  .chat-context__swatch {
    transition: opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .chat-context__row.chat-context__highlighted {
    background: var(--bg-hover);
  }
}
.chat-context-page__header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  padding: 18px var(--context-page-padding) 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-region--mobile-host > .chat-mobile-host .chat-context-page__header {
  background: var(--popover);
}
.chat-context-page__title {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
}
.chat-context-page__title h2 {
  flex: 1;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-context__refreshing {
  animation: btn-spinner-spin 0.8s linear infinite;
}
.chat-context-page__numbers {
  display: flex;
  align-items: baseline;
  height: 34px;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chat-context-page__numbers strong {
  color: var(--text-strong);
  font-size: 26px;
  font-weight: 500;
  line-height: 34px;
  letter-spacing: -0.6px;
}
.chat-context-page__percent {
  margin-left: auto;
}
.chat-context-page__percent--high {
  color: var(--warn);
}
.chat-context-page__legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.chat-context-page__latest {
  display: flex;
  align-items: center;
  height: 44px;
  margin-top: 16px;
  gap: 4px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.chat-context-page__latest b {
  color: var(--text);
  font-weight: 500;
}
.chat-context-panel__scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 202px;
}
.chat-context-page__list {
  padding: 8px calc(var(--context-page-padding) - 8px);
}
.chat-context-page__divider {
  height: 1px;
  margin: 6px 8px;
  background: var(--border);
}
.chat-context-page--highlight .chat-context__segment:not(.chat-context__highlighted) {
  opacity: 0.25;
}
.chat-context-page--highlight
  .chat-context__row:not(.chat-context__highlighted)
  .chat-context__swatch {
  opacity: 0.35;
}
.chat-context-page--loading
  :is(
    .chat-context-page__numbers > *,
    .chat-context-page__legend > *,
    .chat-context-page__latest > *,
    .chat-context__label,
    .chat-context__tokens,
    .chat-context__swatch
  ) {
  color: transparent;
  background: var(--bg-hover);
  border-radius: 3px;
  animation: context-skeleton 1.4s ease-in-out infinite;
  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}
.chat-context-page--loading .chat-context__label {
  width: 110px;
}
.chat-context-page--loading .chat-context__tokens {
  width: 40px;
}
.chat-context-page.chat-context-page--loading .chat-context-page__latest b,
.chat-context-page.chat-context-page--loading .chat-context__label,
.chat-context-page.chat-context-page--loading .chat-context__label small {
  color: transparent;
}
@keyframes context-skeleton {
  50% {
    opacity: 0.5;
  }
}
@media (hover: hover) {
  .chat-context-panel .chat-context__refresh:not(:disabled):hover,
  .chat-context-panel
    .chat-context__compact:not(:disabled):not(.chat-context__compact--high):hover {
    background: var(--bg-hover);
  }
  .chat-context-page {
    .chat-context__entry:hover .chat-context__entry-name,
    .chat-context__show-all:hover {
      color: var(--text-strong);
    }
  }
}
@container context-panel (max-width: 390px) {
  .chat-context-page {
    --context-page-padding: 16px;
  }
  .chat-context-page__numbers strong {
    font-size: 24px;
  }
}
/* A bottom dock must not reserve its entire height for the fixed header. */
@container context-panel (max-height: 320px) {
  .chat-context-page__header {
    position: static;
  }
  .chat-context-panel__scroll {
    scroll-padding-top: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-context-page {
    .chat-context__segment,
    .chat-context__swatch,
    .chat-context__row,
    .chat-context__row > svg {
      transition: none;
    }
  }
  .chat-context__refreshing,
  .chat-context-page .chat-context__accordion {
    animation: none;
  }
}
