/* Conversation reading, recording and sharing. Scrolling and focus remain native. */
.chat-layout,
[data-chat-attachment],
.recorder-panel {
  --craft-chat-paper: #fcf8ff;
  --craft-chat-white: #fff;
  --craft-chat-text: #2e2339;
  --craft-chat-quiet: #685774;
  --craft-chat-edge: #dfd1e8;
  --craft-chat-violet: #64448b;
  --craft-chat-plum: #efe4f7;
  --craft-chat-warm: #97562e;
  --craft-chat-warm-fill: #fff0e3;
  --craft-chat-error: #8d304f;
  --craft-chat-error-fill: #fae9ef;
}
.dark :is(.chat-layout,[data-chat-attachment],.recorder-panel) {
  --craft-chat-paper: #211b2c;
  --craft-chat-white: #2a2237;
  --craft-chat-text: #f5edf9;
  --craft-chat-quiet: #cec0da;
  --craft-chat-edge: #4b3e58;
  --craft-chat-violet: #e1c8ff;
  --craft-chat-plum: #3a2c4a;
  --craft-chat-warm: #ffd1ab;
  --craft-chat-warm-fill: #44332e;
  --craft-chat-error: #ffc0cf;
  --craft-chat-error-fill: #452b3e;
}

/* Filters and a quiet, separate header for the list proper. */
.chat-page .chat-layout .chat-tabs {
  gap: 4px;
  padding: 4px;
  margin-block: 12px 10px;
  border: 1px solid var(--craft-chat-edge);
  border-radius: 16px;
  background: var(--craft-chat-paper);
}
.chat-layout .chat-tabs > button {
  flex: 1 1 0;
  min-height: 44px;
  min-width: 0;
  padding-inline: 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--craft-chat-quiet);
  font-size: .82rem;
}
.chat-layout .chat-tabs > button[aria-pressed=true] {
  border-color: var(--craft-chat-edge);
  background: var(--craft-chat-white);
  color: var(--craft-chat-text);
  box-shadow: 0 1px 5px #1f102917;
  font-weight: 750;
}
.craft-chat-section {
  display:flex;
  align-items:center;
  justify-content:space-between;
  min-width:0;
  gap:10px;
  margin:12px 6px 6px;
  color:var(--craft-chat-quiet);
  font-size:.78rem;
  font-weight:680;
}
.craft-chat-section span:last-child {
  min-width:24px;
  text-align:center;
  font-variant-numeric:tabular-nums;
  letter-spacing:.03em;
}

/* Persistent hierarchy for unread conversations without a badge at the left of the name. */
.chat-page .chat-layout .chat-list-panel .chat-item {
  margin-block: 0 4px;
  padding-block: 11px;
  border: 1px solid transparent;
  border-radius: 15px;
}
.chat-page .chat-layout .chat-list-panel .chat-item:is(.active,[data-chat-unread]) {
  border-color: var(--craft-chat-edge);
  background: var(--craft-chat-white);
}
.chat-layout .chat-item[data-chat-unread] .grow h4,
.chat-layout .chat-item[data-chat-unread] .grow p { color:var(--craft-chat-text);font-weight:740; }
.chat-layout .chat-item:is([data-chat-type=city],[data-chat-type=group],[data-chat-type=agenda]) > .conversation-avatar {
  border-radius: 15px;
  background: var(--craft-chat-warm-fill);
  color: var(--craft-chat-warm);
}
.chat-layout .chat-item .chat-item-meta time {
  align-self:start;
  font-variant-numeric:tabular-nums;
}

/* Activity belongs above the inbox and has its own amber icon and panel heading. */
.chat-page .chat-layout .chat-activity-shortcut {
  margin-block: 0 13px;
  min-height: 62px;
  border-color: var(--craft-chat-edge);
  background: linear-gradient(104deg,var(--craft-chat-warm-fill),var(--craft-chat-paper) 80%);
}
.chat-layout .activity-chat-icon {
  border-radius: 13px;
  background: var(--craft-chat-warm-fill);
  color: var(--craft-chat-warm);
}
.craft-activity-heading { display:grid;gap:2px;min-width:0; }
.craft-activity-heading small { font-size:.72rem;color:var(--craft-chat-quiet); }

/* A distinct thread top and an intact, readable surface below it. */
.chat-layout .chat-header {
  background: var(--craft-chat-paper);
  border-block-end: 1px solid var(--craft-chat-edge);
}
.chat-layout .chat-header > :is(.screen-search,[data-action=cm-chat-menu]) {
  border:1px solid var(--craft-chat-edge);
  border-radius:14px;
}
.chat-layout .chat-header :is(.chat-person,.chat-group-title,.craft-activity-heading) p {
  color:var(--craft-chat-quiet);
}
.chat-layout .chat-header > .conversation-avatar {
  border-radius: 14px;
  color:var(--craft-chat-warm);
  background:var(--craft-chat-warm-fill);
}
.chat-page .chat-layout .message-row:not(.mine) .message-bubble {
  border-color: var(--craft-chat-edge);
  background: var(--craft-chat-white);
  color: var(--craft-chat-text);
  box-shadow: none;
}
.chat-page .chat-layout .message-row.mine .message-bubble {
  background: color-mix(in srgb,var(--chat-outgoing) 88%,#f6dbea);
  color: var(--chat-outgoing-ink);
  box-shadow:none;
}
.chat-layout .message-bubble .reply-quote {
  border-radius: 8px;
  background: color-mix(in srgb,var(--chat-outgoing-ink) 9%,transparent);
}
.chat-layout .message-bubble .message-meta {
  padding-inline: 1px;
  font-variant-numeric: tabular-nums;
}
.craft-chat-welcome {
  display:grid;
  align-content:center;
  justify-items:center;
  gap:8px;
  min-height: min(230px,46vh);
  width: min(100%,274px);
  margin: auto;
  text-align:center;
  color: var(--craft-chat-text);
}
.craft-chat-welcome > span {
  display:grid;
  place-items:center;
  width:48px;
  height:48px;
  color:var(--craft-chat-violet);
  background:var(--craft-chat-plum);
  border-radius:17px;
}
.craft-chat-welcome p { margin:0;color:var(--craft-chat-quiet);font-size:.84rem; }

/* Sending and failures are readable near the user's actual next action. */
.chat-layout .chat-main .chat-composer {
  border-radius: 18px;
  background: var(--craft-chat-paper);
  border-color: var(--craft-chat-edge);
}
.chat-layout .chat-composer .send-message {
  border-radius: 13px;
}
.chat-layout .chat-composer .record-mode {
  background:var(--craft-chat-plum);
  color:var(--craft-chat-violet);
}
.chat-layout .chat-pending-text.send-failed {
  padding: 9px 11px;
  background: var(--craft-chat-error-fill);
  border-color: color-mix(in srgb,var(--craft-chat-error) 38%,var(--craft-chat-edge));
}
.chat-layout .chat-pending-text.send-failed small,
.chat-layout .chat-pending-text.send-failed button { color:var(--craft-chat-error); }
[data-chat-attachment] .attachment-stage {
  border:1px solid var(--craft-chat-edge);
  border-radius:18px;
  background:var(--craft-chat-paper);
}
[data-chat-attachment] label { color:var(--craft-chat-text);font-weight:690; }
[data-chat-attachment] .form-error:not(:empty) {
  margin-block: 9px 11px;
  padding: 8px 11px;
  color:var(--craft-chat-violet);
  background:var(--craft-chat-plum);
  border-radius:11px;
}
[data-chat-attachment][data-attachment-state=error] .form-error {
  color:var(--craft-chat-error);
  background:var(--craft-chat-error-fill);
}

/* One real playback clock and separate available and played portions of the range. */
.chat-layout .record-scrubber {
  position:relative;
  isolation:isolate;
  display:grid;
  align-items:center;
  min-height:30px;
  width:100%;
}
.chat-layout .record-scrubber::before,
.chat-layout .record-scrubber :is(.record-buffer-track,.record-played-track) {
  position:absolute;
  inset-inline:7px;
  width:auto;
  height:4px;
  border-radius:999px;
  pointer-events:none;
}
.chat-layout .record-scrubber::before { content:"";background:color-mix(in srgb,currentColor 16%,transparent); }
.chat-layout .record-scrubber .record-buffer-track { opacity:.28; }
.chat-layout .record-scrubber .record-played-track {
  transform-origin:left center;
  background:currentColor;
}
.chat-layout .record-scrubber input[type=range] {
  position:relative;
  appearance:none;
  width:100%;
  height:32px;
  color:inherit;
  background:transparent;
}
.chat-layout .record-scrubber input::-webkit-slider-runnable-track { height:14px;background:transparent; }
.chat-layout .record-scrubber input::-moz-range-track { height:14px;background:transparent; }
.chat-layout .record-scrubber input::-webkit-slider-thumb {
  appearance:none;
  width:14px;
  height:14px;
  border:0;
  border-radius:50%;
  background:currentColor;
}
.chat-layout .record-scrubber input::-moz-range-thumb { width:14px;height:14px;border:0;border-radius:50%;background:currentColor; }
.chat-layout .record-scrubber input:focus-visible { outline:2px solid currentColor;outline-offset:1px;border-radius:7px; }
.chat-layout .record-clock {
  display:flex;
  align-items:baseline;
  flex-wrap:wrap;
  gap:3px;
  line-height:1.35;
}
.chat-layout .record-clock [data-playing-time] { font-weight:740; }
.chat-layout .record-clock .record-buffer-status:not(:empty) { font-size:.68rem; }
.chat-layout .record-speed { border:1px solid color-mix(in srgb,currentColor 23%,transparent);border-radius:11px; }
@media(prefers-reduced-motion:no-preference) {
 .chat-layout .record-player.playing:not([data-player-seeking]) .record-scrubber:not(:has(input:active)) .record-played-track {
   transition:transform 220ms linear;
 }
}

/* Recording modes and trim keep their controls large and their numbers at rest. */
.recorder-panel .recorder-formats {
  gap:6px;
  padding:4px;
  border:1px solid var(--craft-chat-edge);
  border-radius:17px;
  background:var(--craft-chat-paper);
}
.recorder-panel .recorder-formats button {
  min-height:44px;
  border:1px solid transparent;
  border-radius:13px;
  color:var(--craft-chat-quiet);
}
.recorder-panel .recorder-formats button[aria-pressed=true] {
  border-color:var(--craft-chat-edge);
  background:var(--craft-chat-white);
  color:var(--craft-chat-violet);
}
.recorder-panel .clip-editor {
  display:grid;
  padding:12px;
  border:1px solid var(--craft-chat-edge);
  border-radius:16px;
  background:var(--craft-chat-paper);
}
.recorder-panel .clip-editor .clip-labels > span {
  display:grid;
  gap:2px;
  min-width:0;
  padding:6px 9px;
  border-radius:9px;
  background:var(--craft-chat-white);
  color:var(--craft-chat-quiet);
}
.recorder-panel .clip-editor .clip-labels output { color:var(--craft-chat-text); }

@media (max-width:380px) {
  .chat-page .chat-layout .chat-list-panel .chat-item { padding-inline:8px; }
  .chat-layout .chat-header > :is(.screen-search,[data-action=cm-chat-menu]) { border-color:transparent; }
  .chat-layout .chat-header :is(.chat-group-title,.chat-person) h4 {
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  .chat-layout .record-speed { min-width:36px;font-size:.8rem; }
}
@media (forced-colors:active) {
  .chat-layout .record-scrubber::before { background:CanvasText;opacity:.35; }
  .chat-layout .record-scrubber .record-played-track { background:Highlight; }
}
