/* Deck Hub — "Command Deck" chat panel (todo.md #14). Loaded on any page
   that includes chat.js (currently just www/gallery/index.html). Assumes
   theme.css has already defined the --aws-* tokens (squid-ink/purple/
   blue/mist/green/etc) and the Amazon Ember --aws-font stack — this file
   never redefines them, only consumes them, matching deck.css's own
   layering convention (theme.css -> deck.css -> ... -> this).

   z-index: 400+, above every existing modal (confirm-modal tops out at
   301) — the chat launcher/panel is a persistent global affordance that
   must never be occluded by a deck-management modal opened on top of it. */

.deckhub-chat-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(173, 92, 255, .35);
  background: var(--aws-squid-ink);
  color: #fff;
  font-family: var(--aws-font);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(22, 29, 38, .28);
  transition: padding-right .25s cubic-bezier(.2, .7, .3, 1), border-color .25s cubic-bezier(.2, .7, .3, 1), box-shadow .25s ease;
}
.deckhub-chat-launcher:hover {
  padding-right: 26px;
  border-color: rgba(173, 92, 255, .7);
  box-shadow: 0 16px 40px rgba(22, 29, 38, .34);
}
.deckhub-chat-launcher.open { display: none; }
/* The launcher carries no status dot or pending-count badge: assistant
   events surface in the gallery's notifications bell (index.html). */

.deckhub-chat-panel {
  --dhc-blue-text: #1474a8;
  position: fixed;
  right: 16px;
  top: 16px;
  bottom: 16px;
  z-index: 403;
  width: min(var(--dhc-chat-width, 420px), calc(100vw - 32px));
  border-radius: 20px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  background: linear-gradient(165deg, #fff 0%, #f6f7fa 100%);
  border: 1px solid rgba(22, 29, 38, .1);
  box-shadow: 0 24px 60px rgba(22, 29, 38, .22);
  clip-path: inset(0 0 0 0 round 20px);
  transform: translateX(0);
  opacity: 1;
  transition: transform .32s cubic-bezier(.2, .7, .3, 1), opacity .32s ease;
}
.deckhub-chat-resize-handle {
  position: absolute;
  z-index: 8;
  top: 56px;
  bottom: 16px;
  left: 0;
  width: 9px;
  cursor: ew-resize;
  touch-action: none;
}
.deckhub-chat-resize-handle::after {
  content: "";
  position: absolute;
  top: 42%;
  bottom: 42%;
  left: 2px;
  width: 2px;
  min-height: 44px;
  border-radius: 2px;
  background: rgba(173, 92, 255, .28);
  transition: background .15s ease, top .15s ease, bottom .15s ease;
}
.deckhub-chat-resize-handle:hover::after,
.deckhub-chat-resizing .deckhub-chat-resize-handle::after {
  top: 35%;
  bottom: 35%;
  background: var(--aws-purple);
}
.deckhub-chat-resizing {
  cursor: ew-resize !important;
  user-select: none !important;
}
.deckhub-chat-panel.open { display: flex; }
.deckhub-chat-panel.entering {
  transform: translateX(24px);
  opacity: 0;
}

/* ---------- in-page presentation viewer ----------
   The viewer and chat form one workspace. The deck remains a normal,
   interactive deck iframe while the assistant panel stays available. */
.deckhub-chat-viewer {
  position: fixed;
  inset: 16px calc(var(--dhc-chat-width, 420px) + 32px) 16px 16px;
  z-index: 402;
  display: none;
  min-width: 620px;
  font-family: var(--aws-font);
}
.deckhub-chat-viewer-draft {
  min-height: 52px;
  padding: 8px 12px 8px 18px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(173, 92, 255, .2);
  background: rgba(173, 92, 255, .08);
}
.deckhub-chat-viewer-draft[hidden] { display: none; }
.deckhub-chat-viewer-draft-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.deckhub-chat-viewer-draft strong {
  color: #6f2ba9;
  font-size: 12px;
}
.deckhub-chat-viewer-draft span {
  overflow: hidden;
  color: rgba(22, 29, 38, .56);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-draft-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 2px;
  border: 1px solid rgba(22, 29, 38, .14);
  border-radius: 6px;
  background: rgba(22, 29, 38, .05);
}
.deckhub-chat-draft-compare button {
  min-width: 76px;
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(22, 29, 38, .62);
  font-family: var(--aws-font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.deckhub-chat-draft-compare button.active {
  background: #fff;
  color: #6f2ba9;
  box-shadow: 0 1px 3px rgba(22, 29, 38, .14);
}
.deckhub-chat-draft-compare button:focus-visible {
  outline: 2px solid var(--aws-purple);
  outline-offset: 2px;
}
.deckhub-chat-viewer.open { display: block; }
.deckhub-chat-viewer-shell {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(22, 29, 38, .12);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(22, 29, 38, .28);
}
.deckhub-chat-viewer-head {
  min-height: 62px;
  padding: 10px 12px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(22, 29, 38, .1);
  background: #fff;
}
.deckhub-chat-viewer-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 12px;
  align-items: baseline;
}
.deckhub-chat-viewer-kicker {
  grid-column: 1 / -1;
  color: #1474a8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.deckhub-chat-viewer-copy strong {
  max-width: 52vw;
  overflow: hidden;
  color: var(--aws-squid-ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-viewer-copy > span:last-child {
  color: rgba(22, 29, 38, .5);
  font-size: 12px;
}
.deckhub-chat-viewer-controls {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}
.deckhub-chat-viewer-controls button,
.deckhub-chat-viewer-controls a {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(22, 29, 38, .62);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.deckhub-chat-viewer-controls button:hover,
.deckhub-chat-viewer-controls a:hover {
  background: rgba(22, 29, 38, .07);
  color: var(--aws-squid-ink);
}
.deckhub-chat-viewer-controls svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.deckhub-chat-viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #111820;
}
.deckhub-chat-viewer-stage iframe {
  position: absolute;
  width: 1920px;
  height: 1080px;
  border: 0;
  background: #fff;
  transform-origin: top left;
}
/* Status rail — still by default; shimmers while the agent is working. */
.deckhub-chat-rail {
  height: 2px;
  flex-shrink: 0;
  background: rgba(22, 29, 38, .08);
  position: relative;
  overflow: hidden;
}
.deckhub-chat-rail::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--aws-purple), transparent);
  transform: translateX(-100%);
  opacity: 0;
}
.deckhub-chat-panel.working .deckhub-chat-rail::after {
  opacity: 1;
  animation: dhc-shimmer 1.3s linear infinite;
}
@keyframes dhc-shimmer {
  to { transform: translateX(350%); }
}

.deckhub-chat-head {
  flex-shrink: 0;
  padding: 14px 16px 10px;
  position: relative;
}
.deckhub-chat-head .kicker {
  font-family: var(--aws-font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dhc-blue-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.deckhub-chat-head .kicker-actions { display: flex; gap: 4px; }
.deckhub-chat-activity {
  min-height: 44px;
  padding: 6px 16px;
  margin: 0 10px 8px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(173, 92, 255, .2);
  border-radius: 8px;
  background: #f6f1fb;
  box-shadow: inset 3px 0 0 #8d39cc;
}
.deckhub-chat-activity[hidden] { display: none; }
.deckhub-chat-activity-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid rgba(22, 29, 38, .09);
  border-radius: 50%;
  background: #fff;
}
.deckhub-chat-activity-mark i {
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: #8d39cc;
  animation: dhc-activity-wave .9s ease-in-out infinite;
}
.deckhub-chat-activity-mark i:nth-child(2) {
  height: 18px;
  background: #1474a8;
  animation-delay: .12s;
}
.deckhub-chat-activity-mark i:nth-child(3) {
  background: #e56f13;
  animation-delay: .24s;
}
@keyframes dhc-activity-wave {
  0%, 100% { transform: scaleY(.45); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}
.deckhub-chat-activity-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.deckhub-chat-activity-copy strong {
  color: #3f2455;
  font-family: var(--aws-font);
  font-size: 12px;
  font-weight: 800;
}
.deckhub-chat-activity-copy > span {
  overflow: hidden;
  color: rgba(22, 29, 38, .62);
  font-family: var(--aws-font);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-activity-time {
  color: rgba(22, 29, 38, .5);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.deckhub-chat-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: rgba(22, 29, 38, .58);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.deckhub-chat-icon-btn:hover {
  background: rgba(22, 29, 38, .07);
  color: var(--aws-squid-ink);
}
.deckhub-chat-tabs {
  min-height: 38px;
  padding: 0 12px 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(22, 29, 38, .09);
}
.deckhub-chat-tabs-list {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.deckhub-chat-tabs-list::-webkit-scrollbar { display: none; }
.deckhub-chat-tab {
  max-width: 170px;
  min-width: 72px;
  height: 29px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: rgba(22, 29, 38, .54);
}
.deckhub-chat-tab:hover {
  background: rgba(22, 29, 38, .05);
  color: var(--aws-squid-ink);
}
.deckhub-chat-tab.active {
  border-color: rgba(173, 92, 255, .24);
  background: rgba(173, 92, 255, .09);
  color: #6f2ba9;
}
.deckhub-chat-tab-select {
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 10px;
  flex: 1;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--aws-font);
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.deckhub-chat-tab-close {
  width: 25px;
  height: 100%;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: rgba(22, 29, 38, .4);
  cursor: pointer;
  opacity: .55;
  transition: color .15s ease, opacity .15s ease, background .15s ease;
}
.deckhub-chat-tab-close svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.deckhub-chat-tab:hover .deckhub-chat-tab-close,
.deckhub-chat-tab.active .deckhub-chat-tab-close { opacity: 1; }
.deckhub-chat-tab-close:hover {
  color: #b12704;
  background: rgba(209, 60, 60, .09);
}
.deckhub-chat-tab-select:disabled,
.deckhub-chat-tab-close:disabled { cursor: wait; }
.deckhub-chat-tab-new {
  width: 29px;
  height: 29px;
  padding: 0;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(22, 29, 38, .1);
  border-radius: 50%;
  background: #fff;
  color: rgba(22, 29, 38, .58);
  cursor: pointer;
}
.deckhub-chat-tab-new:hover {
  border-color: rgba(173, 92, 255, .35);
  color: #6f2ba9;
}
.deckhub-chat-tab-new:disabled {
  cursor: wait;
  opacity: .45;
}

.deckhub-chat-confirm-veil {
  position: absolute;
  z-index: 8;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(22, 29, 38, .34);
  backdrop-filter: blur(3px);
}
.deckhub-chat-confirm-veil[hidden] { display: none; }
.deckhub-chat-confirm {
  width: min(100%, 350px);
  padding: 20px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid rgba(22, 29, 38, .11);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(22, 29, 38, .24);
}
.deckhub-chat-confirm-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #b12704;
  background: rgba(209, 60, 60, .1);
}
.deckhub-chat-confirm-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.deckhub-chat-confirm-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.deckhub-chat-confirm-copy strong {
  overflow: hidden;
  color: var(--aws-squid-ink);
  font-family: var(--aws-font);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-confirm-copy p {
  margin: 0;
  color: rgba(22, 29, 38, .62);
  font-family: var(--aws-font);
  font-size: 12px;
  line-height: 1.45;
}
.deckhub-chat-confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.deckhub-chat-confirm-actions button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(22, 29, 38, .15);
  border-radius: 6px;
  background: #fff;
  color: var(--aws-squid-ink);
  font-family: var(--aws-font);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.deckhub-chat-confirm-actions button:hover { background: #f4f5f6; }
.deckhub-chat-confirm-actions .danger {
  border-color: #b12704;
  color: #fff;
  background: #b12704;
}
.deckhub-chat-confirm-actions .danger:hover { background: #8f1f06; }

.deckhub-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--aws-font);
  font-size: 14px;
  line-height: 1.5;
}
.deckhub-chat-empty {
  color: rgba(22, 29, 38, .52);
  font-size: 13px;
  margin: auto 0;
  text-align: center;
  padding: 0 20px;
}

.deckhub-chat-msg { display: flex; }
.deckhub-chat-msg.user { justify-content: flex-end; }
.deckhub-chat-msg.assistant { justify-content: flex-start; }

.deckhub-chat-bubble {
  max-width: 86%;
  white-space: pre-wrap;
  word-break: break-word;
}
.deckhub-chat-msg.user .deckhub-chat-bubble {
  background: rgba(65, 179, 255, .12);
  border: 1px solid rgba(65, 179, 255, .32);
  border-radius: 14px 14px 4px 14px;
  padding: 9px 13px;
  color: #173247;
}
.deckhub-chat-msg.assistant .deckhub-chat-bubble {
  border-left: 2px solid var(--aws-purple);
  padding: 2px 0 2px 12px;
  color: rgba(22, 29, 38, .92);
  white-space: normal; /* markdown renderer handles its own blocks */
}
.deckhub-chat-stream-tail { display: contents; }
/* A stream that died after partial text rendered — the bubble stays (the
   words were real) but reads as visibly cut off, and the error row below
   explains; without this it looks like a complete, confident answer. */
.deckhub-chat-msg.assistant .deckhub-chat-bubble.incomplete {
  border-left-color: var(--aws-orange, #ff693c);
  opacity: .65;
}
.deckhub-chat-msg.assistant .deckhub-chat-bubble.incomplete::after {
  content: "· · · interrupted";
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--aws-orange, #ff693c);
}

/* ---------- assistant markdown ---------- */
.deckhub-chat-bubble p { margin: 0 0 8px; }
.deckhub-chat-bubble p:last-child { margin-bottom: 0; }
.deckhub-chat-bubble h4 {
  margin: 12px 0 6px;
  font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--dhc-blue-text);
}
.deckhub-chat-bubble ul, .deckhub-chat-bubble ol { margin: 0 0 8px; padding-left: 20px; }
.deckhub-chat-bubble li { margin: 2px 0; }
.deckhub-chat-bubble code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: rgba(22, 29, 38, .07);
  border-radius: 4px;
  padding: 1px 5px;
}
.deckhub-chat-bubble pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #202833;
  border: 1px solid rgba(22, 29, 38, .14);
  color: #f6f7fa;
  border-radius: 10px;
  overflow-x: auto;
}
.deckhub-chat-bubble pre code { background: none; padding: 0; font-size: 12px; line-height: 1.5; }
.deckhub-chat-bubble table {
  margin: 0 0 8px;
  border-collapse: collapse;
  font-size: 12.5px;
  width: 100%;
}
.deckhub-chat-bubble th, .deckhub-chat-bubble td {
  padding: 5px 9px;
  border: 1px solid rgba(22, 29, 38, .14);
  text-align: left;
  vertical-align: top;
}
.deckhub-chat-bubble th {
  font-size: 10.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--dhc-blue-text);
  background: rgba(22, 29, 38, .045);
}
.deckhub-chat-bubble a { color: var(--dhc-blue-text); text-decoration: none; }
.deckhub-chat-bubble a:hover { text-decoration: underline; }

/* ---------- inline slide preview component ----------
   Same scaled-1280x720-static-iframe trick as the gallery cards / search
   hits: the iframe loads the REAL deck through the edge-auth gate, so
   authorization is enforced per fetch. 320x180 = scale .25. */
.deckhub-chat-slide {
  display: block;
  position: relative;
  margin: 8px 0;
  width: 320px; height: 180px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(22, 29, 38, .14);
  box-shadow: 0 10px 26px -12px rgba(22, 29, 38, .4);
  text-decoration: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.deckhub-chat-slide:hover {
  border-color: rgba(173, 92, 255, .62);
  box-shadow: 0 13px 30px -12px rgba(22, 29, 38, .46);
  transform: translateY(-1px);
  text-decoration: none;
}
.deckhub-chat-slide:focus-visible {
  outline: 3px solid rgba(65, 179, 255, .45);
  outline-offset: 2px;
}
.deckhub-chat-slide iframe {
  display: block;
  width: 1280px; height: 720px;
  border: 0; pointer-events: none;
  transform: scale(.25); transform-origin: top left;
  background: #fff;
}
/* Split-mode DVT mint denied: quiet placeholder in the frame's slot —
   never a framed 404 (dais deck-view ticket contract). */
.deckhub-chat-slide .deckhub-chat-slide-denied {
  display: flex; align-items: center; justify-content: center;
  width: 320px; height: 180px;
  font-size: 12px; font-weight: 700;
  color: rgba(22, 29, 38, .45);
  background: rgba(22, 29, 38, .05);
}
.deckhub-chat-slide .deckhub-chat-slide-open {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 10px;
  font-size: 10.5px; font-weight: 700;
  font-family: ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, .9);
  background: linear-gradient(180deg, transparent, rgba(15, 20, 26, .85) 40%);
  text-decoration: none;
  opacity: 0;
  transition: opacity .18s ease;
}
.deckhub-chat-slide:hover .deckhub-chat-slide-open { opacity: 1; }

.deckhub-chat-open-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid rgba(173, 92, 255, .28);
  border-left: 3px solid var(--aws-purple);
  border-radius: 8px;
  background: rgba(173, 92, 255, .07);
  color: #6f2ba9 !important;
  font-weight: 700;
  text-decoration: none !important;
}
.deckhub-chat-open-action > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}
.deckhub-chat-open-action > span:last-child {
  flex: 0 0 auto;
  white-space: nowrap;
  word-break: normal;
}
.deckhub-chat-open-action:hover {
  background: rgba(173, 92, 255, .12);
  border-color: rgba(173, 92, 255, .45);
}
.deckhub-chat-open-action.popup-blocked::after {
  content: "Popup blocked - click to open";
  font-size: 10px;
  font-weight: 500;
  color: rgba(22, 29, 38, .55);
}
.deckhub-chat-viewer-action {
  display: inline-flex;
  margin: 6px 0;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(65, 179, 255, .1);
  color: #1474a8;
  font-size: 11px;
  font-weight: 700;
}

/* Streaming/thinking indicator — a blinking cursor, not bouncing dots. */
.deckhub-chat-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--aws-blue);
  animation: dhc-blink 1s step-end infinite;
}
@keyframes dhc-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Collapsed tool-call chip */
.deckhub-chat-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(22, 29, 38, .055);
  color: rgba(22, 29, 38, .62);
  font-size: 12px;
  border: 0;
  cursor: default;
  font-family: var(--aws-font);
}

.deckhub-chat-draft-card {
  width: 100%;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(173, 92, 255, .3);
  border-left: 3px solid var(--aws-purple);
  border-radius: 8px;
  background: rgba(173, 92, 255, .07);
}
.deckhub-chat-draft-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.deckhub-chat-draft-kicker {
  color: #6f2ba9;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.deckhub-chat-draft-copy strong {
  color: var(--aws-squid-ink);
  font-size: 12px;
}
.deckhub-chat-draft-status {
  overflow: hidden;
  color: rgba(22, 29, 38, .55);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-draft-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.deckhub-chat-viewer-draft-actions {
  flex-wrap: nowrap;
}
.deckhub-chat-draft-actions button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(22, 29, 38, .14);
  border-radius: 6px;
  background: #fff;
  color: rgba(22, 29, 38, .7);
  font-family: var(--aws-font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.deckhub-chat-draft-actions button.primary {
  border-color: #8d39cc;
  background: #8d39cc;
  color: #fff;
}
.deckhub-chat-draft-actions button:disabled {
  cursor: wait;
  opacity: .55;
}
/* Fetch-approval card (chat agent paused before an outbound web request
   it could not vouch for — fetch_policy.py). Amber: a warning, not a
   suggestion. The full URL is shown; Deny is the default action. */
.deckhub-chat-fetch-card {
  flex-direction: column;
  align-items: stretch;
  border-color: rgba(255, 153, 0, .45);
  border-left-color: #ff9900;
  background: rgba(255, 153, 0, .09);
}
.deckhub-chat-fetch-card .deckhub-chat-draft-kicker {
  color: #8a4b00;
}
.deckhub-chat-fetch-card .deckhub-chat-draft-status {
  white-space: normal;
}
.deckhub-chat-fetch-url {
  display: block;
  margin: 4px 0 2px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(22, 29, 38, .06);
  color: var(--aws-squid-ink);
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: all;
}
.deckhub-chat-fetch-reasons {
  margin: 0 0 4px;
  padding-left: 16px;
  color: rgba(22, 29, 38, .72);
  font-size: 11px;
}
.deckhub-chat-fetch-card .deckhub-chat-draft-actions {
  align-self: flex-end;
}
.deckhub-chat-draft-actions button.danger {
  border-color: #8a4b00;
  background: #8a4b00;
  color: #fff;
}
.deckhub-chat-draft-card.applied {
  border-color: rgba(0, 145, 82, .3);
  border-left-color: #009152;
  background: rgba(0, 145, 82, .07);
}
.deckhub-chat-draft-card.discarded { opacity: .62; }
.deckhub-chat-draft-card.applied .deckhub-chat-draft-actions,
.deckhub-chat-draft-card.discarded .deckhub-chat-draft-actions { display: none; }
.deckhub-chat-draft-card.stale {
  border-color: rgba(191, 115, 0, .35);
  border-left-color: #bf7300;
  background: rgba(191, 115, 0, .06);
}
.deckhub-chat-draft-card.applying {
  border-color: rgba(65, 179, 255, .38);
  border-left-color: var(--aws-blue);
  background: rgba(65, 179, 255, .07);
}
.deckhub-chat-draft-applying {
  display: inline-flex;
  min-width: 94px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #1474a8;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.deckhub-chat-draft-applying i {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(20, 116, 168, .22);
  border-top-color: #1474a8;
  border-radius: 50%;
  animation: dhc-draft-spin .8s linear infinite;
}
@keyframes dhc-draft-spin {
  to { transform: rotate(360deg); }
}
.deckhub-chat-draft-card.expired {
  opacity: .62;
  border-color: rgba(22, 29, 38, .18);
  border-left-color: rgba(22, 29, 38, .3);
  background: rgba(22, 29, 38, .04);
}

/* Suggestions tray — the single draft mutation surface between the
   transcript and the composer. Same compact row language as the draft
   cards it replaced in the transcript. */
.deckhub-chat-suggestions {
  flex: 0 0 auto;
  border-top: 1px solid rgba(22, 29, 38, .1);
  background: rgba(173, 92, 255, .04);
}
.deckhub-chat-suggestions-head {
  width: 100%;
  min-height: 34px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  font-family: var(--aws-font);
  cursor: pointer;
}
.deckhub-chat-suggestions-count {
  color: #6f2ba9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}
.deckhub-chat-suggestions-expiry {
  flex: 1;
  overflow: hidden;
  color: rgba(22, 29, 38, .55);
  font-size: 10.5px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-suggestions-chevron {
  flex: 0 0 auto;
  color: rgba(22, 29, 38, .55);
  transition: transform .18s ease;
}
.deckhub-chat-suggestions-head[aria-expanded="false"] .deckhub-chat-suggestions-chevron {
  transform: rotate(180deg);
}
.deckhub-chat-suggestions-list {
  max-height: 220px;
  padding: 0 12px 10px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

/* Pending-suggestion badges: launcher total + per-tab counts. */
.deckhub-chat-tab-count {
  margin-left: 6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(141, 57, 204, .16);
  color: #6f2ba9;
  font-size: 9.5px;
  font-weight: 800;
}

.deckhub-chat-error {
  color: #a42323;
  font-size: 13px;
  border-left: 2px solid #ff5c5c;
  padding-left: 12px;
}

/* #deckname autocomplete — floats ABOVE the input row */
.deckhub-chat-autocomplete {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% + 6px);
  max-height: 220px;
  overflow-y: auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(173, 92, 255, .25);
  box-shadow: 0 -8px 24px rgba(22, 29, 38, .16);
  display: none;
  z-index: 5;
}
.deckhub-chat-autocomplete.open { display: block; }
.deckhub-chat-ac-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: border-color .12s ease;
}
.deckhub-chat-ac-row .swatch {
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: var(--aws-purple);
  flex-shrink: 0;
}
.deckhub-chat-ac-row .info { min-width: 0; }
.deckhub-chat-ac-row .title {
  font-family: var(--aws-font);
  font-size: 13px;
  color: var(--aws-squid-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-ac-row .rel {
  font-size: 11px;
  color: rgba(22, 29, 38, .5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-ac-row:hover,
.deckhub-chat-ac-row.active {
  background: rgba(173, 92, 255, .1);
  border-left-color: var(--aws-purple);
}
.deckhub-chat-ac-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: rgba(22, 29, 38, .48);
  font-family: var(--aws-font);
}

/* Pending attachment card, shown above the input */
.deckhub-chat-attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
}
.deckhub-chat-attachment-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border-radius: 10px;
  background: rgba(22, 29, 38, .04);
  border: 1px solid rgba(22, 29, 38, .1);
  max-width: 220px;
}
.deckhub-chat-attachment-card .thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(22, 29, 38, .08);
  flex-shrink: 0;
}
.deckhub-chat-attachment-card .name {
  font-size: 12px;
  color: var(--aws-squid-ink);
  font-family: var(--aws-font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deckhub-chat-attachment-card .size {
  font-size: 10px;
  color: rgba(22, 29, 38, .48);
}
.deckhub-chat-attachment-card .remove {
  border: 0;
  background: none;
  color: rgba(22, 29, 38, .5);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  flex-shrink: 0;
}
.deckhub-chat-attachment-card .remove:hover { color: var(--aws-squid-ink); }
.deckhub-chat-attachment-card.uploading { opacity: .6; }
.deckhub-chat-attachment-card.failed { border-color: rgba(255, 92, 92, .4); }

.deckhub-chat-foot {
  flex-shrink: 0;
  position: relative;
  padding: 10px 16px 14px;
}
.deckhub-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid transparent;
  background-image: linear-gradient(90deg, transparent, rgba(173, 92, 255, .35), transparent);
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-position: top;
  padding-top: 10px;
}
.deckhub-chat-input {
  flex: 1;
  min-height: 20px;
  max-height: 120px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--aws-squid-ink);
  font-family: var(--aws-font);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}
.deckhub-chat-input::placeholder { color: rgba(22, 29, 38, .4); }

.deckhub-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--aws-purple);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transform: scale(0);
  transition: transform .15s cubic-bezier(.2, .7, .3, 1), opacity .15s ease;
  opacity: 0;
}
.deckhub-chat-send.ready { transform: scale(1); opacity: 1; }
.deckhub-chat-send:disabled { opacity: .45; cursor: default; }

.deckhub-chat-attach-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: rgba(22, 29, 38, .5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease;
}
.deckhub-chat-attach-btn:hover {
  background: rgba(22, 29, 38, .07);
  color: var(--aws-squid-ink);
}

/* Mic button — same circular ghost-button styling as attach; pulses red
   border/glow while listening. Removed from the DOM entirely (see chat.js)
   when SpeechRecognition isn't available, so no [hidden] state exists. */
.deckhub-chat-mic-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: rgba(22, 29, 38, .5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.deckhub-chat-mic-btn:hover {
  background: rgba(22, 29, 38, .07);
  color: var(--aws-squid-ink);
}
.deckhub-chat-mic-btn.listening {
  background: rgba(255, 92, 92, .12);
  color: #d13c3c;
  box-shadow: 0 0 0 1px rgba(255, 92, 92, .4);
  animation: dhc-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes dhc-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 92, 92, .4); }
  50% { box-shadow: 0 0 0 5px rgba(255, 92, 92, .18); }
}
@media (prefers-reduced-motion: reduce) {
  .deckhub-chat-activity-mark i,
  .deckhub-chat-mic-btn.listening,
  .deckhub-chat-draft-applying i { animation: none; }
}
.deckhub-chat-mic-hint {
  min-height: 0;
  margin-top: 4px;
  padding-left: 2px;
  color: #a42323;
  font-family: var(--aws-font);
  font-size: 11px;
}
.deckhub-chat-mic-hint:empty { display: none; }

@media (max-width: 1120px) {
  .deckhub-chat-viewer { right: 392px; min-width: 480px; }
  .deckhub-chat-viewer-draft { grid-template-columns: 1fr auto; }
  .deckhub-chat-viewer-draft-copy { grid-column: 1 / -1; }
  .deckhub-chat-panel { width: 360px; }
  .deckhub-chat-resize-handle { display: none; }
}

@media (max-width: 520px) {
  .deckhub-chat-panel { right: 8px; left: 8px; top: 8px; bottom: 8px; width: auto; }
  .deckhub-chat-launcher { right: 16px; bottom: 16px; }
}

/* Attachments shown ON the sent user bubble — the transcript records what
   was attached, not just the words. */
.deckhub-chat-sent-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.deckhub-chat-sent-attachment {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 180px;
}
.deckhub-chat-sent-attachment img {
  display: block;
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(22, 29, 38, .14);
}
.deckhub-chat-sent-attachment span {
  font-size: 10.5px;
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
