.messages .msg-doc-chip { min-width: 0; max-width: 100%; }
.messages .msg-doc-name { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.messages .msg-doc-ext { flex: 0 0 auto; }
/* Conversation surfaces: the Perch's warmth, with the work kept in focus. */
:root {
  --work-ground: #131022; --work-card: #1c182e; --work-ink: #f2eef8;
  --work-muted: #b3a9c4; --work-line: #383045; --work-accent: #d9c19a;
  --work-soft: #9889c00d;
}
[data-theme="light"] {
  --work-ground: #f8f6f2; --work-card: #fffdfa; --work-ink: #30283e;
  --work-muted: #70677b; --work-line: #e4dfe5; --work-accent: #624b7d;
  --work-soft: #5c477508;
}
.messages { max-width: 1000px; margin-inline: auto; width: 100%; padding-inline: 28px; }
.messages .msg { gap: 16px; padding-block: 22px; }
.messages .msg.assistant { background: transparent; border: 0; box-shadow: none; border-radius: 0; }
.messages .msg-body { min-width: 0; }
.messages .msg-avatar { width: 34px; height: 34px; flex: 0 0 34px; background: transparent; border: 0; box-shadow: none; }
.messages .msg-avatar-img { width: 34px; height: 34px; border-radius: 0; object-fit: contain; }
.messages .msg-header { margin-bottom: 10px; }
.messages .msg-header .msg-time { font: 500 11px/1.5 var(--ff-body, Inter, sans-serif); color: var(--work-muted); letter-spacing: .015em; opacity: 1; }
.messages .msg-content { color: var(--work-ink); line-height: 1.75; overflow-wrap: anywhere; }
/* Streaming replaces these blocks every ~60ms. Replaying their entrance
   fade would dim the entire answer on every update, not just the new text. */
.messages .msg-content.streaming > * { animation: none; opacity: 1; }
.messages .msg.user .msg-content { background: var(--work-soft); border: 1px solid var(--work-line); border-radius: 20px 20px 6px 20px; padding: 14px 18px; }
.messages .msg-actions { gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.messages .msg-action-btn { min-width: 34px; min-height: 34px; border-radius: 10px; color: var(--work-muted); }
.messages .routing-badge { display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; background: var(--work-soft); border: 1px solid var(--work-line); color: var(--work-muted); gap: 8px; }
.messages .routing-badge-reason { flex: 1 1 220px; white-space: normal; }
.messages .routing-badge-switch { min-height: 36px; border-radius: 8px; padding: 6px 10px; background: var(--work-card); color: var(--work-accent); border: 1px solid var(--work-line); }
.input-area { padding: 12px 20px max(8px, env(safe-area-inset-bottom)); border-top: 0; background: var(--s0); }
.input-area .input-wrap { max-width: 900px; margin-inline: auto; border-radius: 20px; border: 1px solid var(--work-line); background: var(--s1); box-shadow: none; }
[data-theme="light"] .input-area .input-wrap { background: var(--work-card); border-color: var(--work-line); }
.input-area .input-wrap:focus-within { border-color: var(--work-muted); box-shadow: none; }
.input-footer { gap: 8px; flex-wrap: wrap; }
.input-tools { gap: 5px; min-width: 0; }
.msg-activity { margin: 0 0 16px; max-width: 100%; border: 1px solid var(--work-line); border-radius: 14px; background: var(--work-soft); color: var(--work-muted); font-size: 12px; }
.msg-activity > summary { display: flex; align-items: center; gap: 9px; list-style: none; cursor: pointer; min-height: 44px; padding: 10px 14px; }
.msg-activity > summary::-webkit-details-marker, .msg-memory-details > summary::-webkit-details-marker { display: none; }
.msg-activity > summary::after { content: '⌄'; margin-left: auto; font-size: 17px; }
.msg-activity[open] > summary::after { transform: rotate(180deg); }
.activity-indicator { width: 6px; height: 6px; background: var(--work-accent); border-radius: 50%; flex: 0 0 6px; }
.activity-indicator.working { animation: activityBreathe 1.8s ease-in-out infinite; }
.activity-count { color: var(--work-muted); white-space: nowrap; font-size: 11px; }
.activity-list { padding: 0 14px 6px; border-top: 1px solid var(--work-line); }
.activity-entry { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--work-line); overflow-wrap: anywhere; align-items: start; }
.activity-entry:last-child { border-bottom: 0; }
.activity-result { font-size: 10px; line-height: 1.8; color: var(--work-muted); }
.activity-entry.failed .activity-result { color: #bb6878; }
.activity-list .tool-use-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px;
  width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--work-muted); opacity: 1; font-size: 12px; line-height: 1.65;
}
.activity-list .tool-use-banner > svg { display: none; animation: none; }
.activity-list .tool-use-banner strong { color: var(--work-ink); font-weight: 500; }
.activity-list .tool-use-banner a {
  display: inline-flex; align-items: baseline; gap: 7px; max-width: 100%; min-width: 0;
  min-height: 32px; padding: 4px 8px; margin-block: -4px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--work-accent); font-weight: 500; line-height: 1.6;
  text-decoration: none; overflow-wrap: anywhere;
  transition: background-color .16s ease, border-color .16s ease;
}
.activity-list .tool-use-banner a::after { content: '↗' / ''; flex-shrink: 0; opacity: .6; font-size: 12px; }
.activity-list .tool-use-banner a:hover { background: var(--work-soft); border-color: var(--work-line); }
.activity-list .tool-use-banner a:focus-visible { outline: 2px solid var(--work-accent); outline-offset: 2px; background: var(--work-soft); }
.activity-list .tool-query-list { display: block; width: 100%; margin: 0; padding-left: 16px; }
.activity-list .tool-query-list li { background: transparent; border-radius: 0; padding: 2px 0; }
.msg-memory-details { width: fit-content; max-width: 100%; margin-top: 16px; color: var(--work-muted); font-size: 12px; }
.msg-memory-details > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 36px; padding: 4px 0; }
.msg-memory-details[open] { width: 100%; }
.msg-memory-details[open] .msg-memory-chip-chevron { transform: rotate(180deg); }
.msg-memory-content { border: 1px solid var(--work-line); border-radius: 14px; padding: 16px; background: var(--work-card); margin-top: 6px; }
.msg-memory-content .msg-memory-chip-popover-title { color: var(--work-muted); }
.msg-memory-content .msg-memory-chip-item { gap: 12px; padding: 8px 0; }
.msg-memory-content .msg-memory-chip-item-label { color: var(--work-ink); overflow-wrap: anywhere; }
.msg-memory-content .msg-memory-chip-item-type { color: var(--work-muted); white-space: normal; }
.msg-memory-manage { min-height: 44px; padding: 10px 0; color: var(--work-accent); border: 0; background: transparent; font: inherit; cursor: pointer; }
.msg-activity summary:focus-visible, .msg-memory-details summary:focus-visible { outline: 2px solid var(--work-accent); outline-offset: 3px; border-radius: 8px; }
@keyframes activityBreathe { 50% { opacity: .3; } }

/* Images and process maps are part of the same conversation surface. */
.messages .msg-artifacts { gap: 18px; margin-top: 14px; }
.messages .artifact-card {
  width: 100%; max-width: 100%; border: 1px solid var(--work-line); border-radius: 18px;
  background: var(--s1); color: var(--work-ink); box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; animation: none;
  transition: border-color .16s ease;
}
[data-theme="light"] .messages .artifact-card { background: var(--work-card); }
.messages .artifact-card:hover { border-color: var(--work-line); box-shadow: none; }
.messages :is(.artifact-card-header, .artifact-card-map-header, .ig-grid-head) {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--work-line); background: transparent;
}
.messages :is(.artifact-card-title, .artifact-card-map-title) {
  display: flex; align-items: center; gap: 10px; flex: 1 1 180px; min-width: 0;
  color: var(--work-ink); font-size: 14px; font-weight: 600; line-height: 1.5;
  white-space: normal; overflow-wrap: anywhere;
}
.messages :is(.artifact-card-title, .artifact-card-map-title) svg { color: var(--work-accent); flex-shrink: 0; }
.messages .artifact-card-map-meta { gap: 10px; flex-wrap: wrap; }
.messages .artifact-card-badge { background: transparent; color: var(--work-muted); padding: 0; font-size: 11px; font-weight: 400; }
.messages .artifact-card-preview { display: block; width: 100%; padding: 12px; border: 0; background: var(--work-soft); font: inherit; }
.messages .artifact-card-preview img { max-height: 440px; object-fit: contain; border-radius: 10px; animation: none; transform: none; }
.messages .artifact-card-preview:hover img { transform: none; }
.messages .artifact-card-preview:focus-visible { outline: 2px solid var(--work-accent); outline-offset: -4px; }
.messages .artifact-card-overlay { background: #17102026; }
.messages .artifact-card-open-icon { color: #fff8ed; background: #211b3bb8; border: 1px solid #ffffff40; border-radius: 12px; }
.messages .artifact-card-body { padding: 16px 20px 20px; gap: 14px; border-top: 1px solid var(--work-line); }
.messages .artifact-card-prompt { color: var(--work-muted); line-height: 1.65; }
.messages .artifact-card-actions { gap: 8px; }
.messages .artifact-card-btn {
  min-height: 40px; gap: 7px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--work-line); background: transparent; color: var(--work-accent);
  font-size: 12px; font-weight: 500; transition: background-color .16s ease, border-color .16s ease;
}
.messages .artifact-card-btn:hover { background: var(--work-soft); border-color: var(--work-muted); color: var(--work-ink); }
.messages :is(.artifact-card-btn, .imr-tool-btn):focus-visible, .artifact-brief summary:focus-visible { outline: 2px solid var(--work-accent); outline-offset: 2px; }
.artifact-brief { color: var(--work-muted); font-size: 12px; }
.artifact-brief summary { cursor: pointer; width: fit-content; padding: 6px 0; min-height: 32px; }
.artifact-brief p { color: var(--work-ink); font-size: 13px; line-height: 1.65; margin: 10px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.messages .artifact-card-map-canvas { height: clamp(400px, 55vh, 520px); background: var(--s1); animation: none; }
.messages .imr-toolbar { padding: 8px 12px; gap: 5px; background: var(--work-soft); border-bottom: 1px solid var(--work-line); backdrop-filter: none; flex-wrap: wrap; }
.messages .imr-tool-btn { width: 34px; height: 34px; border-radius: 8px; color: var(--work-muted); }
.messages .imr-tool-btn:hover { background: var(--work-soft); border-color: var(--work-line); color: var(--work-ink); }
.messages .imr-hint { color: var(--work-muted); }
.messages .imr-svg { background-color: var(--s1); background-image: radial-gradient(var(--work-line) .7px, transparent .7px); background-size: 22px 22px; }
.messages .agent-map-card .agent-phases { padding: 20px; gap: 18px; }
.messages .agent-phase { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 5px 10px; opacity: 1; align-items: center; }
.messages .agent-phase-icon { grid-column: 1; grid-row: 1; }
.messages .agent-phase-label { grid-column: 2; color: var(--work-ink); font-size: 13px; font-weight: 500; }
.messages .agent-phase-pending .agent-phase-label { color: var(--work-muted); }
.messages :is(.agent-phase-detail, .agent-phase-steps, .agent-phase-bar) { grid-column: 2; margin-left: 0; }
.messages :is(.agent-phase-detail, .agent-phase-steps) { color: var(--work-muted); line-height: 1.6; font-style: normal; }
.messages .agent-phase-bar { background: var(--work-line); height: 3px; margin-top: 3px; }
.messages .agent-phase-bar-fill { background: var(--work-accent); }
.messages .dotgrid { height: clamp(210px, 30vw, 320px); background: var(--work-soft); border-color: var(--work-line); border-radius: 16px; }
.messages .artifact-card-preview--dots { padding: 0; }
.messages .artifact-card-preview--dots .dotgrid { border: 0; border-radius: 0; }
.messages .dotgrid-canvas { opacity: .5; }
.messages .dotgrid-title { color: var(--work-ink); text-shadow: none; animation: none; top: 20px; left: 20px; font-size: 14px; }
.messages .dotgrid-status { color: var(--work-muted); text-shadow: none; top: 46px; left: 20px; right: 20px; white-space: normal; line-height: 1.6; max-height: 3.2em; }
.messages .dotgrid-pill { color: var(--work-muted); background: var(--s1); border-color: var(--work-line); box-shadow: none; backdrop-filter: none; border-radius: 8px; }
.messages .img-gen-prompt--below { color: var(--work-muted); font-size: 12px; line-height: 1.6; padding: 4px; }
.messages .artifact-card-error { background: var(--work-soft); border-color: #b85b6b55; color: var(--work-ink); line-height: 1.65; }
.messages .artifact-card.artifact-error { padding: 0; }
.messages .artifact-card-error > .artifact-card-error { width: 100%; border: 0; background: transparent; }
@media (max-width: 760px) {
  .messages :is(.artifact-card-header, .artifact-card-map-header, .ig-grid-head) { padding: 14px 16px; }
  .messages .artifact-card-body, .messages .agent-map-card .agent-phases { padding: 16px; }
  .messages .artifact-card-btn { min-height: 44px; }
  .messages .artifact-card-actions .artifact-card-btn { flex: 1 1 auto; justify-content: center; }
  .messages .imr-tool-btn { width: 40px; height: 40px; }
  .messages .artifact-card-map-canvas { height: 400px; }
}

/* Voice is a conversation with Athena, not an empty connection screen. */
.perch-sky { background-image: linear-gradient(90deg, #27213f, rgba(28,20,48,.22) 48%, transparent 80%), url('../perch/perch-scene-v5.webp'); }
.voice-mode.voice-room, [data-theme="light"] .voice-mode.voice-room {
  position: fixed; inset: 0; z-index: 6000; display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start; gap: 0;
  background: var(--work-ground); color: var(--work-ink); overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) clamp(20px, 5vw, 72px) max(24px, env(safe-area-inset-bottom));
  animation: none; overscroll-behavior: contain; isolation: isolate;
}
.voice-mode.voice-room::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 310px; z-index: -1; pointer-events: none;
  background: linear-gradient(0deg, var(--work-ground), transparent), url('../perch/perch-scene-v5.webp') center 45% / cover;
  opacity: .18; animation: none; transform: none;
}
.voice-room-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; width: 100%; max-width: 1160px; margin: 0 auto; }
.voice-kicker { display: block; color: var(--work-accent); font-size: 10px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase; margin-bottom: 10px; }
.voice-room-header h1 { font: 500 18px/1.4 var(--ff-heading, Inter, sans-serif); color: var(--work-ink); margin: 0; }
.voice-exit { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--work-line); background: var(--work-card); color: var(--work-ink); font: 400 27px/1 system-ui; cursor: pointer; }
.voice-room-main { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr); gap: 64px; align-items: center; width: 100%; max-width: 1000px; margin: auto; padding: 48px 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--work-line) transparent; }
.voice-room-main::-webkit-scrollbar { width: 4px; }
.voice-room-main::-webkit-scrollbar-track { background: transparent; }
.voice-room-main::-webkit-scrollbar-thumb { background: var(--work-line); border-radius: 999px; }
.voice-presence { text-align: center; }
.voice-portrait { display: grid; place-items: center; position: relative; width: 240px; height: 240px; margin: 0 auto; }
.voice-portrait::before { content: ''; position: absolute; inset: 25px; border-radius: 50%; background: radial-gradient(circle, #9889c026, transparent 70%); }
.voice-portrait athena-owl { --athena-size: 220px; position: relative; }
.voice-state-mark { display: flex; justify-content: center; gap: 5px; height: 20px; margin: 0 0 14px; align-items: center; }
.voice-state-mark span { width: 4px; height: 4px; border-radius: 5px; background: var(--work-accent); opacity: .65; }
.voice-room[data-state="listening"] .voice-state-mark span { animation: activityBreathe 2s ease-in-out infinite; }
.voice-room[data-state="speaking"] .voice-state-mark span { height: 16px; animation: voiceBars .8s ease-in-out infinite alternate; }
.voice-room .voice-state-mark span:nth-child(2) { animation-delay: .25s; }
.voice-room .voice-state-mark span:nth-child(3) { animation-delay: .5s; }
.voice-room h2 { color: var(--work-ink); font: 500 clamp(24px, 2.8vw, 34px)/1.15 var(--ff-heading, Inter, sans-serif); letter-spacing: -.04em; margin: 0 0 14px; }
#voiceModeHint { color: var(--work-muted); font-size: 14px; line-height: 1.65; max-width: 340px; margin: 0 auto; }
.voice-conversation { min-width: 0; display: grid; gap: 16px; }
.voice-exchange { background: var(--work-soft); border: 1px solid var(--work-line); border-radius: 20px; padding: 22px 24px; }
.voice-exchange-athena { background: var(--work-card); }
.voice-speaker { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; color: var(--work-accent); margin-bottom: 12px; font-weight: 600; }
.voice-exchange p { margin: 0; font-size: 16px; line-height: 1.7; color: var(--work-ink); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto; scrollbar-width: thin; }
.voice-exchange p:empty::before { content: attr(data-placeholder); color: var(--work-muted); font-size: 14px; }
.voice-recovery { order: -1; border: 1px solid #b85b6b55; border-radius: 16px; padding: 18px; color: var(--work-ink); }
.voice-recovery p { font-size: 14px; line-height: 1.6; margin: 0 0 14px; }
.voice-recovery span { display: block; font-size: 12px; color: var(--work-muted); margin-top: 12px; }
.voice-room-footer { flex-shrink: 0; width: 100%; max-width: 760px; margin: 0 auto; padding-top: 16px; text-align: center; background: var(--work-ground); }
.voice-controls { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.voice-controls button, .voice-recovery button { min-height: 48px; padding: 12px 20px; border: 1px solid var(--work-line); border-radius: 14px; background: var(--work-card); color: var(--work-ink); font: 500 13px var(--ff-heading, Inter, sans-serif); display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; }
.voice-controls button:disabled { opacity: .45; cursor: default; }
.voice-controls button[aria-pressed="true"], .voice-recovery button { background: #57406f; color: #fffaf2; border-color: #76628b; }
.voice-controls .voice-end { color: var(--work-muted); background: transparent; }
.voice-help { margin: 18px auto 0; color: var(--work-muted); font-size: 12px; line-height: 1.7; max-width: 560px; }
.voice-help summary { cursor: pointer; padding: 8px; }
.voice-help p { margin: 8px 0 0; }
.voice-room button:focus-visible, .voice-help summary:focus-visible { outline: 2px solid var(--work-accent); outline-offset: 4px; }
.voice-room [hidden] { display: none; }
body.voice-open { overflow: hidden; }
body.voice-open aristos-support { visibility: hidden; }
@keyframes voiceBars { to { transform: scaleY(.35); opacity: .4; } }
@media (max-width: 760px) {
  .input-area { padding-inline: 12px; }
  .messages { padding-inline: 16px; }
  .messages .msg { gap: 10px; padding-block: 18px; }
  .messages .msg-avatar, .messages .msg-avatar-img { width: 28px; height: 28px; flex-basis: 28px; }
  .messages .msg-action-btn { min-width: 40px; min-height: 40px; }
  .msg-memory-details > summary { min-height: 44px; }
  .activity-entry { grid-template-columns: 1fr; gap: 3px; }
  .voice-mode.voice-room { padding-inline: 20px; }
  .voice-room-main { grid-template-columns: 1fr; gap: 20px; padding: 16px 0 24px; align-content: start; }
  .voice-portrait { width: 100px; height: 100px; }
  .voice-portrait athena-owl { --athena-size: 96px; }
  .voice-room h2 { font-size: 26px; }
  .voice-room-header h1 { font-size: 15px; }
  .voice-exchange { padding: 18px 20px; border-radius: 16px; }
  .voice-exchange p { font-size: 14px; max-height: 160px; }
  .voice-controls { gap: 8px; }
  .voice-controls button { padding: 12px 14px; flex: 1 1 auto; }
}
@media (max-height: 650px) and (min-width: 761px) {
  .voice-room-main { padding: 22px 0; gap: 32px; }
  .voice-portrait { width: 150px; height: 150px; }
  .voice-portrait athena-owl { --athena-size: 140px; }
  .voice-exchange p { max-height: 100px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .messages .artifact-card, .messages .artifact-card *, .messages .img-gen-placeholder * { animation: none !important; transition: none !important; }
  .activity-list .tool-use-banner a { transition: none; }
  .activity-indicator, .voice-room *, .voice-room *::before { animation: none !important; transition: none !important; }
}
