/* ---------------------------------------------------------------------------
   Messages › composer (prefix msc-). Uses the app's theme variables, so it
   follows light, dark and midnight. Shared buttons / menus / modals are in
   messages-sidebar.css (prefix msx-).
--------------------------------------------------------------------------- */

.msc { position: relative; padding: 0 20px 14px; }
.msc.compact { padding: 0 12px 10px; }
.msc-box { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: border-color 0.12s, box-shadow 0.12s; }
:root[data-theme="midnight"] .msc-box { border-color: rgba(130, 178, 154, 0.3); }
.msc-box:focus-within { border-color: var(--muted); box-shadow: 0 0 0 3px var(--brand-soft); }
.msc-box[hidden] { display: none; }

/* formatting toolbar */
.msc-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 1px; padding: 5px 6px 0; }
.msc-toolbar[hidden] { display: none; }
.msc-tool { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.msc-tool:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.msc-tool.on { background: var(--brand-soft); color: var(--brand); }
.msc-tool:disabled { opacity: 0.35; cursor: default; }
.msc-tool:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.msc-sep { width: 1px; height: 16px; margin: 0 4px; background: var(--line); }

/* the editor */
.msc-editor { min-height: 44px; max-height: 40vh; overflow-y: auto; padding: 8px 12px; outline: 0; font-size: 15px; line-height: 1.46; color: var(--text); word-break: break-word; white-space: pre-wrap; cursor: text; }
.msc.compact .msc-editor { min-height: 38px; max-height: 30vh; font-size: 14px; }
.msc-editor:empty::before, .msc-editor.empty::before { content: attr(data-placeholder); color: var(--dim); pointer-events: none; }
.msc-editor > div, .msc-editor li { min-height: 1.46em; }
.msc-editor b, .msc-editor strong { font-weight: 700; }
.msc-editor code { padding: 1px 4px; border-radius: 4px; border: 1px solid var(--line); background: var(--hover); color: #c2410c; font-size: 0.92em; white-space: pre-wrap; }
:root[data-theme="midnight"] .msc-editor code { color: #fb923c; }
.msc-editor pre { margin: 4px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--hover); font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.msc-editor blockquote { margin: 4px 0; padding-left: 10px; border-left: 4px solid var(--line); }
:root[data-theme="midnight"] .msc-editor blockquote { border-left-color: rgba(130, 178, 154, 0.35); }
.msc-editor ul, .msc-editor ol { margin: 2px 0; padding-left: 24px; white-space: normal; }
.msc-editor a { color: var(--brand); text-decoration: underline; cursor: text; }
.msc-chip { display: inline-block; padding: 0 4px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; cursor: default; user-select: all; }
.msc-chip[data-kind="special"] { background: #fde68a; color: #7c4a03; }

/* bottom row */
.msc-bottom { display: flex; align-items: center; gap: 1px; padding: 3px 6px 6px; }
.msc-bottom .msc-tool { width: 30px; height: 30px; }
.msc-grow { flex: 1; }
.msc-send { display: inline-flex; align-items: stretch; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); background: var(--hover); }
.msc-send.ready { border-color: var(--brand); background: var(--brand); }
:root[data-theme="midnight"] .msc-send.ready { background: var(--action, var(--brand)); border-color: var(--brand); }
.msc-sendbtn, .msc-laterbtn { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--dim); height: 28px; cursor: pointer; padding: 0; }
.msc-sendbtn { width: 34px; }
.msc-laterbtn { width: 24px; border-left: 1px solid var(--line); }
.msc-send.ready .msc-sendbtn, .msc-send.ready .msc-laterbtn { color: #fff; }
.msc-send.ready .msc-laterbtn { border-left-color: rgba(255, 255, 255, 0.35); }
.msc-send.ready .msc-sendbtn:hover, .msc-send.ready .msc-laterbtn:hover { background: rgba(255, 255, 255, 0.16); }
.msc-sendbtn:disabled, .msc-laterbtn:disabled { cursor: default; }

/* attachments */
.msc-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 10px 0; }
.msc-files[hidden] { display: none; }
.msc-file { position: relative; display: flex; align-items: center; gap: 10px; width: 232px; max-width: 100%; padding: 6px 30px 6px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.msc-file.error { border-color: var(--red); }
.msc-file-thumb { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--hover); color: var(--muted); overflow: hidden; }
.msc-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.msc-file-info { flex: 1; min-width: 0; }
.msc-file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msc-file-meta { font-size: 12px; color: var(--muted); }
.msc-file-meta .err { color: var(--red); }
.msc-progress { height: 3px; margin-top: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.msc-progress i { display: block; height: 100%; background: var(--brand); transition: width 0.15s; }
.msc-file-x, .msc-file-retry { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--line); }
.msc-file-retry { right: 28px; }
.msc-file-x:hover, .msc-file-retry:hover { color: var(--text); background: var(--hover); }
.msc-file.error .msc-file-x { right: 4px; }
.msc-file.error { padding-right: 56px; }

/* drag overlay */
.msc-drop { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--brand); border-radius: 10px; background: color-mix(in srgb, var(--surface) 88%, var(--brand)); color: var(--brand); font-weight: 600; pointer-events: none; }
.msc-drop[hidden] { display: none; }

/* "also send to" */
.msc-also { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.msc-also[hidden] { display: none; }
.msc-also input { accent-color: var(--brand); }

/* archived / join bar */
.msc-bar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--muted); font-size: 14px; }
.msc-bar[hidden] { display: none; }
.msc-bar-text { flex: 1; min-width: 0; }
.msc-bar-text b { color: var(--text); }
.msc-bar-ico { display: inline-flex; color: var(--muted); }

/* autocomplete */
.msc-auto { position: absolute; left: 20px; right: 20px; bottom: calc(100% - 6px); z-index: 20; max-height: 290px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(10, 18, 32, 0.2); }
.msc.compact .msc-auto { left: 12px; right: 12px; }
:root[data-theme="midnight"] .msc-auto { background: var(--surface-2, var(--surface)); box-shadow: 0 14px 38px rgba(0, 0, 0, 0.55); }
.msc-auto[hidden] { display: none; }
.msc-auto-head { padding: 6px 10px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.msc-auto-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 4px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font-size: 14px; text-align: left; cursor: pointer; }
.msc-auto-row.on { background: var(--brand); color: #fff; }
.msc-auto-name { font-weight: 600; white-space: nowrap; }
.msc-auto-sub, .msc-auto-args { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.msc-auto-args { color: var(--dim); }
.msc-auto-row.on .msc-auto-sub, .msc-auto-row.on .msc-auto-args { color: rgba(255, 255, 255, 0.85); }
.msc-auto-glyph { display: inline-flex; width: 24px; justify-content: center; }
.msc-auto-emoji { font-size: 20px; width: 24px; text-align: center; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.msc-auto-row .msg-avatar .msg-presence { border-color: var(--surface); }
.msc-auto-row.on .msg-avatar .msg-presence { border-color: var(--brand); }

@media (max-width: 560px) {
  .msc { padding: 0 10px 10px; }
  .msc-auto { left: 10px; right: 10px; }
  .msc-file { width: 100%; }
}
