/* Codex launcher, chat composer and notifications.
 *
 * These surfaces used to be built from CSS-in-JS blobs inside hc.js and
 * drawer.js. Everything redesigned here now lives in this file and the matching
 * injected rules were DELETED from those files, so nothing needs !important.
 *
 * Design law: one accent (#962f2c), a warm grey ramp, two shadows, one radius
 * scale, success/danger/warn used semantically only, system font stack.
 */
:root {
  --cx-accent: #962f2c;
  --cx-accent-soft: #f6eceb;
  --cx-ink: #1d2733;
  --cx-mut: #6b7785;
  --cx-line: #e3e8ef;
  --cx-line-2: #eef1f6;
  --cx-surface: #fff;
  --cx-hover: #f5f6f9;
  --cx-ok: #1a7f37;
  --cx-ok-soft: #e8f4ec;
  --cx-danger: #b00020;
  --cx-danger-soft: #fdecef;
  --cx-warn: #9a6700;
  --cx-warn-soft: #fdf3e3;
  --cx-r-sm: 8px;
  --cx-r-md: 12px;
  --cx-r-lg: 16px;
  --cx-sh-1: 0 1px 2px rgba(29, 39, 51, .08);
  --cx-sh-2: 0 14px 34px -14px rgba(29, 39, 51, .34);
  --cx-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
}

/* Visible focus on every interactive surface this file owns. */
#hc-toaster :focus-visible,
#dw-dock :focus-visible,
.dw-composer :focus-visible,
.hc-mini:focus-visible {
  outline: 2px solid var(--cx-accent);
  outline-offset: 2px;
}

/* ===== notifications: top-right, growing downward ======================== */
/* Below the sticky app header, clear of the bottom-right launcher, the review
   action bar and the composer. */
#hc-toaster {
  position: fixed;
  right: 20px;
  top: 64px;
  width: 340px;
  max-width: 360px;
  z-index: 9000;
  display: none;
}
.hc-toast {
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  box-sizing: border-box;
  background: var(--cx-surface);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-r-md);
  box-shadow: var(--cx-sh-2);
  padding: 13px 14px;
  font-family: var(--cx-font);
  transform-origin: center top;
  transition: transform .42s cubic-bezier(.22, 1, .36, 1), opacity .3s ease, height .3s ease;
  will-change: transform, opacity;
}
.hc-toast.e { border-left: 3px solid var(--cx-danger); }
.hc-toast.s, .hc-toast.w { border-left: 3px solid var(--cx-warn); }
.hc-toast.r, .hc-toast.f { border-left: 3px solid var(--cx-ok); }
.hc-thead { display: flex; align-items: center; gap: 9px; }
.hc-ttitle {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: 12.5px; color: var(--cx-ink);
}
/* A message toast carries its whole sentence in the title, so that one wraps
   instead of being clipped to a single line. */
.hc-toast.i .hc-ttitle, .hc-toast.f .hc-ttitle { white-space: normal; overflow: visible; }
.hc-tstatus { font-size: 11px; font-weight: 600; color: var(--cx-mut); flex: none; }
.hc-toast.r .hc-tstatus, .hc-toast.f .hc-tstatus { color: var(--cx-ok); }
.hc-toast.w .hc-tstatus, .hc-toast.s .hc-tstatus { color: var(--cx-warn); }
.hc-toast.e .hc-tstatus { color: var(--cx-danger); }
.hc-tmsg {
  font-size: 11.5px; color: var(--cx-mut); line-height: 1.45; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hc-tacts { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }
.hc-tdetail {
  margin: 9px 0 0; padding: 9px 10px;
  background: var(--cx-line-2); border-radius: var(--cx-r-sm);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--cx-mut); white-space: pre-wrap; word-break: break-word;
  max-height: 140px; overflow: auto;
}
.hc-tx {
  margin-left: auto; border: none; background: none; cursor: pointer;
  color: var(--cx-mut); font: 600 14px/1 var(--cx-font); padding: 2px 4px;
  border-radius: var(--cx-r-sm);
}
.hc-tx:hover { background: var(--cx-hover); color: var(--cx-ink); }
.hc-spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--cx-line); border-top-color: var(--cx-accent);
  animation: hcspin .7s linear infinite; flex: none;
}
@keyframes hcspin { to { transform: rotate(360deg); } }

/* Shared small buttons: neutral by default, accent only for the one primary. */
.hc-mini {
  font: 600 11px var(--cx-font);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-r-sm);
  padding: 8px 13px;
  min-height: 32px;
  cursor: pointer;
  background: var(--cx-surface);
  color: var(--cx-ink);
}
.hc-mini:hover { background: var(--cx-hover); border-color: #d3dae4; }
.hc-mini.ghost { background: var(--cx-surface); color: var(--cx-mut); }
.hc-mini.ghost:hover { color: var(--cx-ink); }
.hc-mini[disabled] { opacity: .5; cursor: default; }

/* Mobile: full width under the header, side margins, 44px controls. */
@media (max-width: 920px) { #hc-toaster { top: 96px; } }
@media (max-width: 768px) {
  #hc-toaster { left: 12px; right: 12px; width: auto; max-width: none; }
  .hc-mini { min-height: 44px; padding: 10px 16px; }
}

/* ===== Codex launcher: bottom-right, collapsed by default ================ */
#dw-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 300px;
  max-width: 360px;
  background: var(--cx-surface);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-r-md);
  box-shadow: var(--cx-sh-2);
  z-index: 9050;
  font-family: var(--cx-font);
  overflow: hidden;
}
/* Collapsed is the default state: a compact pill that covers nothing. */
#dw-dock.collapsed { width: auto; border-radius: 999px; box-shadow: var(--cx-sh-1); }
#dw-dock.collapsed .dwd-panel { display: none; }
.dwd-h {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 11px 16px;
  border: none; background: none; cursor: pointer;
  font: 600 12.5px var(--cx-font); color: var(--cx-ink);
}
.dwd-h:hover { background: var(--cx-hover); }
/* The Codex mark: inherits the title colour, never competes with it. */
.dwd-ico { flex: none; color: var(--cx-mut); }
.dwd-h:hover .dwd-ico { color: var(--cx-ink); }
.dwd-ttl { font-size: 12.5px; font-weight: 600; color: var(--cx-ink); }
/* The ONE dot in the whole dashboard: a quiet unread signal, no count badge. */
.dwd-udot { width: 7px; height: 7px; border-radius: 50%; background: var(--cx-accent); flex: none; display: none; }
.dwd-list { max-height: 46vh; overflow-y: auto; padding: 0 8px; }
.dwd-empty { font-size: 11px; color: var(--cx-mut); text-align: center; padding: 12px 6px; }
.dwd-row {
  display: flex; align-items: flex-start; gap: 9px;
  width: 100%; box-sizing: border-box; text-align: left;
  padding: 10px 9px; margin: 0 0 2px;
  border: none; background: none; border-radius: var(--cx-r-sm); cursor: pointer;
  font: inherit; color: var(--cx-ink);
  transition: opacity .3s ease, transform .3s cubic-bezier(.22, 1, .36, 1);
}
.dwd-row:hover { background: var(--cx-hover); }
.dwd-row.dwd-enter { opacity: 0; transform: translateY(8px); }
.dwd-body { flex: 1; min-width: 0; }
.dwd-toprow { display: flex; align-items: center; gap: 6px; }
.dwd-rt { flex: 1; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dwd-unread { width: 7px; height: 7px; border-radius: 50%; background: var(--cx-accent); flex: none; }
.dwd-rs { flex: none; font-size: 9.5px; font-weight: 600; color: var(--cx-mut); text-transform: uppercase; letter-spacing: .03em; }
.dwd-prev { font-size: 11.5px; color: var(--cx-mut); line-height: 1.4; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dwd-del {
  flex: none; border: none; background: transparent; color: var(--cx-mut);
  font-size: 12px; line-height: 1; cursor: pointer; padding: 4px 5px;
  border-radius: var(--cx-r-sm); opacity: 0; transition: opacity .12s;
}
.dwd-row:hover .dwd-del, .dwd-del:focus-visible { opacity: 1; }
.dwd-del:hover { color: var(--cx-danger); background: var(--cx-danger-soft); }
.dwd-acts { display: flex; align-items: center; gap: 7px; padding: 9px 11px 12px; border-top: 1px solid var(--cx-line-2); }
.dwd-abtn {
  font: 600 11px var(--cx-font); border: 1px solid var(--cx-accent);
  border-radius: var(--cx-r-sm); padding: 9px 13px; min-height: 36px;
  cursor: pointer; background: var(--cx-accent); color: #fff;
}
.dwd-abtn:hover { background: #7d2724; border-color: #7d2724; }
.dwd-abtn.ghost { background: var(--cx-surface); color: var(--cx-ink); border-color: var(--cx-line); }
.dwd-abtn.ghost:hover { background: var(--cx-hover); }
@media (max-width: 768px) {
  #dw-dock { right: 12px; bottom: 12px; }
  #dw-dock:not(.collapsed) { left: 12px; width: auto; max-width: none; }
  .dwd-abtn { min-height: 44px; padding: 12px 16px; }
  .dwd-del { opacity: 1; min-width: 44px; min-height: 44px; }
}

/* ===== chat composer ===================================================== */
/* The message field grows; Send stays a fully visible rectangle beside it. */
.dw-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--cx-surface);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-r-md);
  padding: 6px;
}
.dw-composer:focus-within { border-color: var(--cx-accent); }
/* A screenshot dragged over the composer: the field says it will take it. */
.dw-composer.drop-on { border-color: var(--cx-accent); background: var(--cx-accent-soft); }
.dw-ta {
  flex: 1; min-width: 0;
  border: none; outline: none; resize: none;
  font: 12.5px/1.5 var(--cx-font); color: var(--cx-ink);
  background: transparent;
  padding: 11px 6px;
  min-height: 44px; max-height: 132px;
  overflow-y: auto;
}
.dw-snd {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--cx-accent);
  border-radius: var(--cx-r-sm);
  background: var(--cx-accent);
  color: #fff;
  font: 600 12.5px var(--cx-font);
  cursor: pointer;
}
.dw-snd:hover { background: #7d2724; border-color: #7d2724; }
.dw-snd[disabled] { background: var(--cx-line); border-color: var(--cx-line); color: var(--cx-mut); cursor: default; }
.dw-attach-btn {
  flex: none; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--cx-line); border-radius: var(--cx-r-sm);
  background: var(--cx-surface); color: var(--cx-mut);
  font: 600 11.5px var(--cx-font); cursor: pointer;
}
.dw-attach-btn:hover { background: var(--cx-hover); color: var(--cx-ink); }
.dw-edit { margin-top: 10px; }
/* Attachments sit ABOVE the field, each with an obvious remove control. */
.dw-attach { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.dw-attach:empty { margin: 0; }
.dw-attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; background: var(--cx-line-2);
  border: 1px solid var(--cx-line); border-radius: var(--cx-r-sm);
  padding: 4px 4px 4px 6px; color: var(--cx-ink);
}
.dw-attach-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; }
/* An image that is still uploading: it holds its place and says so. */
.dw-attach-chip.busy { color: var(--cx-mut); padding-right: 8px; }
.dw-attach-chip.busy .hc-spin { width: 11px; height: 11px; border-width: 2px; }
.dw-attach-chip .st { font-size: 10.5px; font-weight: 600; color: var(--cx-mut); }
.dw-attach-chip .nm { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-attach-x {
  border: none; background: none; cursor: pointer;
  color: var(--cx-mut); font: 600 12px/1 var(--cx-font);
  padding: 5px 6px; border-radius: 6px;
}
.dw-attach-x:hover { color: var(--cx-danger); background: var(--cx-danger-soft); }
/* No decorative status dot in the drawer header: the header text says it. */
#dw-dot { display: none; }
@media (max-width: 768px) {
  .dw-attach-chip .nm { max-width: 96px; }
  .dw-attach-x { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .hc-toast, .hc-spin, .dwd-row, #dw-dock { transition: none; animation: none; }
}
