/* The message field with attachments, dictation and the prompt menu. */

/* ---------- Composer ---------- */

.composer-wrap {
  width: 100%;
  max-width: calc(var(--gutter) + var(--measure) + 48px);
  margin: 0 auto;
  padding: 0 24px 12px;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.12s;
}

.composer:focus-within {
  border-color: #4a4843;
  box-shadow: inset 2px 0 0 var(--amber);
}

.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  line-height: 1.5;
  padding: 5px 0;
  font-size: 15px;
}

.composer-input::placeholder {
  color: var(--text-faint);
}

.send-btn,
.stop-btn {
  flex-shrink: 0;
}

.composer-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 6px;
  padding-left: 15px;
}

.link-btn {
  color: var(--text-muted);
  text-decoration: underline;
  font-size: inherit;
}

.link-btn:hover {
  color: var(--text);
}

/* ---------- Attachments ---------- */

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  white-space: normal;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  max-width: 260px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

a.attachment-chip:hover {
  color: var(--text);
  border-color: #45433e;
}

.attachment-thumb {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.attachment-thumb img {
  display: block;
  max-width: 220px;
  max-height: 160px;
  object-fit: cover;
}

.attach-btn {
  align-self: flex-end;
  margin-left: -6px;
}

.pending-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.pending-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  max-width: 300px;
  padding: 0 2px 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 12.5px;
}

.pending-attachment svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-faint);
}

.pending-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.pending-attachment.uploading .pending-meta {
  color: var(--amber);
}

.pending-attachment.failed {
  border-color: rgba(226, 105, 79, 0.45);
}

.main.dropping .messages {
  outline: 1px dashed var(--amber);
  outline-offset: -12px;
  background: var(--amber-wash);
}

/* ---------- Attachment cards ---------- */

.att {
  position: relative;
  width: 188px;
  flex-shrink: 0;
}

.att-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  text-align: left;
  transition: border-color 0.12s;
}

.att-open:not(:disabled):hover {
  border-color: #4a4843;
}

.att-open:disabled {
  cursor: default;
  opacity: 1;
}

.att-image {
  display: block;
  height: 112px;
  background: #121211;
}

.att-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.att-lines {
  height: 112px;
  margin: 0;
  padding: 8px 10px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre;
  background: #121211;
  /* Fade the last line instead of cutting it hard */
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}

.att-foot {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--line-soft);
  min-width: 0;
}

.att-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text);
}

.att-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.att.uploading .att-meta {
  color: var(--amber);
}

.att.uploading .att-open {
  border-style: dashed;
}

.att.failed .att-open {
  border-color: rgba(226, 105, 79, 0.5);
}

.att.failed .att-meta {
  color: var(--danger);
}

.att-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: rgba(22, 22, 22, 0.85);
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.att-remove svg {
  width: 12px;
  height: 12px;
}

.att-remove:hover {
  color: var(--text);
  border-color: #4a4843;
}

.msg-bubble .msg-attachments {
  margin-top: 10px;
}

.msg-bubble .att {
  width: 168px;
}

.msg-bubble .att-image,
.msg-bubble .att-lines {
  height: 96px;
}

.pending-attachments {
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 2px;
}

/* Preview dialog */
.preview-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.preview-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-title small {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.preview-actions a.btn {
  text-decoration: none;
}

.preview-body {
  padding: 0;
  background: #121211;
}

.preview-body.is-image {
  display: grid;
  place-items: center;
  padding: 16px;
}

.preview-body.is-image img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.preview-text {
  margin: 0;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #ddd9d0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Dictation ---------- */

.mic-btn {
  align-self: flex-end;
}

.mic-btn.listening {
  color: var(--amber-ink);
  background: var(--amber);
}

.mic-btn.listening:hover {
  background: var(--amber-strong);
  color: var(--amber-ink);
}

/* ---------- Saved prompts: "/" menu above the message field ---------- */
.composer {
  position: relative;
}

.prompt-menu {
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: calc(100% + 6px);
  max-height: min(320px, 50vh);
  overflow-y: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 4px;
  z-index: 30;
}

.prompt-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius);
  text-align: left;
  color: var(--text-muted);
}

.prompt-item.active,
.prompt-item:hover {
  background: var(--hover);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--amber);
}

.prompt-name {
  flex: none;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--amber);
}

.prompt-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.prompt-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.prompt-title {
  font-family: var(--font-mono);
  color: var(--amber);
  font-weight: 500;
}

/* Text files: room for "complete", "partly" or "search only" next to the name.
   After .msg-bubble .att, which it overrides. */
.att.is-text {
  width: 230px;
}
