/* Phase U (Slack-parity usability) surfaces: toasts, emoji picker,
 * inline edit, stream pagination, rich text. Kept apart from the
 * 3k-line messenger.css; uses the same design tokens. */

/* ---- buttons ---------------------------------------------------------- */
.ws-btn {
  font: 500 12px/1 var(--font-sans);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
}
.ws-btn:hover:not(:disabled) { border-color: var(--line-3); color: var(--ink-1); }
.ws-btn:disabled { opacity: 0.55; cursor: default; }
.ws-btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.ws-btn--primary:hover:not(:disabled) { background: var(--blue-hi); color: #fff; }
.ws-btn--ghost { background: transparent; }
.ws-btn--danger { background: var(--red); border-color: var(--red); color: #fff; }

/* ---- toasts ----------------------------------------------------------- */
.ws-toaster {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}
.ws-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--ink-1);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.ws-toast--error { border-color: var(--red); }
.ws-toast--success { border-color: var(--green); }
.ws-toast span { flex: 1; }
.ws-toast-close {
  background: transparent;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

/* ---- emoji picker ----------------------------------------------------- */
.ws-emoji-picker {
  position: fixed;
  z-index: 1900;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.ws-emoji-search {
  margin: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-0);
  color: var(--ink-1);
  font-size: 13px;
}
.ws-emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-emoji-tabs button {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
  text-transform: capitalize;
}
.ws-emoji-tabs button.on { border-color: var(--blue-line); color: var(--ink-1); background: var(--blue-soft); }
.ws-emoji-scroll { overflow-y: auto; overflow-x: hidden; padding: 0 8px 8px; }
.ws-emoji-section {
  padding: 6px 2px 4px;
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--ink-4);
  text-transform: uppercase;
}
.ws-emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
.ws-emoji-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-1);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
}
.ws-emoji-cell:hover, .ws-emoji-cell:focus-visible { background: var(--bg-3); outline: none; }
.ws-emoji-cell img { width: 22px; height: 22px; object-fit: contain; }
.ws-emoji-empty { padding: 16px; text-align: center; color: var(--ink-4); font-size: 12px; }
.ws-reaction-img { width: 16px; height: 16px; object-fit: contain; vertical-align: middle; }

/* ---- inline message edit --------------------------------------------- */
.ws-msg.is-editing { background: var(--blue-soft); }
.ws-msg.is-editing .ws-msg-actions { display: none; }
.ws-msg-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.ws-msg-edit-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--blue-line);
  background: var(--bg-0);
  color: var(--ink-1);
  font: 14px/1.5 var(--font-sans);
}
.ws-msg-edit-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.ws-msg-edit-hint { margin-right: auto; font-size: 11px; color: var(--ink-4); }

/* ---- stream pagination ----------------------------------------------- */
.ws-stream-older, .ws-stream-start {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
}
.ws-stream-start { color: var(--ink-4); font-size: 12px; }

/* ---- rich text -------------------------------------------------------- */
.ws-msg-line { white-space: pre-wrap; }
.ws-link { color: var(--blue-hi); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.ws-msg-quote-line {
  margin: 4px 0;
  padding: 2px 0 2px 10px;
  border-left: 3px solid var(--line-3);
  color: var(--ink-2);
  white-space: pre-wrap;
}
.ws-msg-list { margin: 4px 0; padding-left: 22px; }
.ws-msg-list li { margin: 1px 0; }

/* "(edited)" label — was rendering as an unstyled native button. */
.ws-msg-edited {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 11px;
  color: var(--ink-4);
  cursor: pointer;
}
.ws-msg-edited:hover { color: var(--ink-2); text-decoration: underline; }

/* ---- composer attachments -------------------------------------------- */
.ws-composer-box.is-drop { outline: 2px dashed var(--blue-line); outline-offset: -4px; }
.ws-attach-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 6px; }
.ws-attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 6px 28px 6px 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  overflow: hidden;
}
.ws-attach-chip.is-error { border-color: var(--red); }
.ws-attach-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: var(--r-sm); }
.ws-attach-icon { width: 32px; text-align: center; font-size: 18px; }
.ws-attach-meta { display: flex; flex-direction: column; min-width: 0; }
.ws-attach-name { font-size: 12px; color: var(--ink-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-attach-sub { font-size: 11px; color: var(--ink-4); }
.ws-attach-chip.is-error .ws-attach-sub { color: var(--red); }
.ws-attach-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--blue); transition: width 0.2s; }
.ws-attach-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--ink-2);
  cursor: pointer;
  line-height: 18px;
  padding: 0;
}

/* attachment buttons (authed blob fetch) */
button.ws-attachment-image, button.ws-attachment-file { font: inherit; color: inherit; cursor: pointer; }
button.ws-attachment-image { padding: 0; border: 0; background: transparent; }
.ws-attach-loading { display: inline-block; width: 160px; height: 100px; border-radius: var(--r-md); background: var(--bg-2); }
.ws-attach-broken { font-size: 12px; color: var(--ink-4); }

/* ---- message flags / toolbar state ----------------------------------- */
.ws-msg.is-pinned { background: color-mix(in srgb, var(--amber-soft) 35%, transparent); }
.ws-msg-flags { display: flex; gap: 8px; margin: 0 0 2px; }
.ws-msg-flag { font-size: 11px; color: var(--ink-3); }
.ws-msg-flag.pin { color: var(--amber); }
.ws-msg-action.on { color: var(--blue-hi); background: var(--blue-soft); }

/* ---- side drawer list panels ----------------------------------------- */
dialog.ws-drawer {
  margin: 0 0 0 auto;
  height: 100vh;
  max-height: 100vh;
  width: min(420px, 100vw);
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--ink-1);
}
dialog.ws-drawer::backdrop { background: rgba(0, 0, 0, 0.35); }
.ws-drawer-inner { display: flex; flex-direction: column; height: 100%; }
.ws-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-1);
}
.ws-drawer-head h2 { margin: 0; font-size: 15px; }
.ws-drawer-x { background: transparent; border: 0; color: var(--ink-3); font-size: 20px; cursor: pointer; }
.ws-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.ws-list-row + .ws-list-row { border-top: 1px solid var(--line-1); }
.ws-list-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ws-list-main:hover { background: var(--bg-2); }
.ws-list-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-4); }
.ws-list-title { font-size: 13px; font-weight: 600; }
.ws-list-text { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-list-sub { font-size: 11px; color: var(--ink-4); }
.ws-list-tag { font-weight: 400; color: var(--ink-3); }
.ws-list-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); vertical-align: middle; }
.ws-list-empty { padding: 24px 16px; color: var(--ink-4); font-size: 13px; }
.ws-list-empty.is-error { color: var(--red); }

/* ---- preference / time-picker modals --------------------------------- */
.ws-pref-modal { width: min(460px, calc(100vw - 32px)); }
.ws-pref-modal h2 { margin: 0 0 12px; font-size: 16px; }
.ws-pref-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-1); }
.ws-pref-section h3 { margin: 0 0 8px; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.ws-status-input { display: flex; gap: 8px; align-items: center; }
.ws-status-input input { flex: 1; }
.ws-status-emoji {
  width: 38px; height: 38px; font-size: 20px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--bg-2); cursor: pointer;
}
.ws-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ws-chip {
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg-2);
  color: var(--ink-2); font-size: 12px; cursor: pointer;
}
.ws-chip:hover { border-color: var(--blue-line); color: var(--ink-1); }
.ws-field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.ws-radio { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; color: var(--ink-1); }
.ws-time-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.ws-muted { color: var(--ink-4); font-size: 12px; }
.ws-when-list { display: flex; flex-direction: column; gap: 4px; }
.ws-when-item {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 10px; border: 1px solid var(--line-1); border-radius: var(--r-md);
  background: transparent; color: var(--ink-1); font: inherit; cursor: pointer; text-align: left;
}
.ws-when-item:hover { background: var(--bg-2); }
.ws-composer-schedule:disabled { opacity: 0.35; cursor: default; }
.ws-list-main.is-static { cursor: default; }
.ws-list-main.is-static:hover { background: transparent; }

/* ---- channel details / browse (U4) ----------------------------------- */
.ws-channel-name-btn { background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.ws-channel-name-btn:hover:not(:disabled) .chev { color: var(--ink-1); }
.ws-members-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; color: inherit; cursor: pointer; padding: 0; }
.ws-details-modal { width: min(520px, calc(100vw - 32px)); }
.ws-details-head { display: flex; align-items: center; justify-content: space-between; }
.ws-details-head h2 { margin: 0; }
.ws-tabs { display: flex; gap: 4px; margin: 10px 0 12px; border-bottom: 1px solid var(--line-1); }
.ws-tabs button { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ink-3); cursor: pointer; font: inherit; }
.ws-tabs button.on { color: var(--ink-1); border-bottom-color: var(--blue); }
.ws-tab-body { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.ws-inline-edit { display: flex; gap: 6px; }
.ws-inline-edit input { flex: 1; }
.ws-pref-section.is-first { margin-top: 0; padding-top: 0; border-top: 0; }
.ws-pick-list, .ws-member-list, .ws-browse-list { list-style: none; margin: 0; padding: 0; }
.ws-pick-list button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; border-radius: var(--r-sm); }
.ws-pick-list button:hover { background: var(--bg-2); }
.ws-pick-add { margin-left: auto; color: var(--blue-hi); font-size: 12px; }
.ws-member-list li { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--line-1); }
.ws-member-name { flex: 1; font-size: 13px; }
.ws-link-btn { background: transparent; border: 0; color: var(--ink-3); cursor: pointer; font-size: 12px; }
.ws-link-btn:hover { color: var(--red); }
.ws-browse-list { margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.ws-browse-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-1); }
.ws-browse-main { flex: 1; display: flex; flex-direction: column; gap: 2px; background: transparent; border: 0; color: inherit; text-align: left; cursor: pointer; padding: 4px; }

/* ---- profile modal ---------------------------------------------------- */
.ws-profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.ws-profile-avatar {
  width: 56px; height: 56px; border-radius: var(--r-lg); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue), var(--magenta)); color: #fff; font-weight: 700;
}
.ws-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* jump-to-message highlight */
.ws-msg.is-focused { animation: ws-focus-flash 2.4s ease-out; }
@keyframes ws-focus-flash {
  0%, 35% { background: color-mix(in srgb, var(--amber-soft) 70%, transparent); box-shadow: inset 3px 0 0 var(--amber); }
  100% { background: transparent; box-shadow: none; }
}

/* ---- polls ------------------------------------------------------------ */
.ws-poll { margin: 4px 0; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--bg-1); max-width: 460px; }
.ws-poll-q { font-weight: 600; margin-bottom: 8px; }
.ws-poll-opt {
  position: relative; display: flex; justify-content: space-between; gap: 8px;
  width: 100%; margin: 4px 0; padding: 7px 10px; overflow: hidden;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: transparent; color: var(--ink-1); font: inherit; text-align: left; cursor: pointer;
}
.ws-poll-opt:disabled { cursor: default; }
.ws-poll-opt.on { border-color: var(--blue-line); }
.ws-poll-bar { position: absolute; inset: 0 auto 0 0; background: var(--blue-soft); z-index: 0; transition: width 0.3s; }
.ws-poll-text, .ws-poll-count { position: relative; z-index: 1; }
.ws-poll-count { color: var(--ink-3); font-size: 12px; }
.ws-poll-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--ink-4); }
.ws-poll.is-closed .ws-poll-opt { opacity: 0.8; }

/* ---- workspace tools (groups / webhooks / export) --------------------- */
.ws-group-row { flex-wrap: wrap; }
.ws-group-members { flex-basis: 100%; padding: 6px 0 8px 12px; }
.ws-secret-box { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--amber); border-radius: var(--r-md); background: color-mix(in srgb, var(--amber-soft) 40%, transparent); }
.ws-secret-box code { font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.ws-webhook-out { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws-webhook-out button { grid-column: 2; justify-self: end; }
