/*
 * Agent 1.1.15 is an additive layer for the Router's native composer.
 * It never replaces, clones, moves, or owns the native .hhsw-composer,
 * its parameter menus, references, frames, billing, or generation route.
 * During a full-auto handoff only, the native controls are temporarily
 * obscured in place so Router state can settle without exposing internals.
 * Router remains the sole owner of document scrolling; Agent-owned surfaces
 * opt out of document scroll anchoring and only scroll their own popovers.
 */

/* Safety net for pages that were hydrated by an older Agent asset before the
 * 1.1.11 cache-busted script removes the redundant internal session control. */
#hhAgentSessionControls,
.hh-agent-session-controls {
  display: none !important;
}

.hh-agent-turn-controller {
  display: none !important;
}

.hh-agent-timeline,
.hh-agent-turn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 22px;
  margin: 12px 0 24px;
  padding: 2px 0;
  color: #dcebf2;
  overflow-x: clip;
  overflow-anchor: none;
}

.hh-agent-timeline[hidden],
.hh-agent-turn[hidden] {
  display: none !important;
}

.hh-agent-session-controls {
  position: relative;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hh-agent-session-controls > button,
.hh-agent-session-switcher > button {
  min-height: 36px;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid rgba(76, 132, 154, .42);
  border-radius: 10px;
  background: rgba(5, 29, 43, .78);
  color: #b9d1da;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.hh-agent-session-controls > button:first-child {
  border-color: rgba(201, 159, 70, .5);
  color: #e8c77b;
}

.hh-agent-session-controls button:disabled {
  opacity: .48;
  cursor: wait;
}

.hh-agent-session-switcher {
  position: relative;
  min-width: 0;
}

.hh-agent-session-switcher > button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hh-agent-session-switcher > button b {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #65d2e3;
  color: #06202d;
  font-size: 11px;
}

.hh-agent-session-switcher > button i {
  color: #6f97a7;
  font-style: normal;
}

.hh-agent-session-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2600;
  width: min(300px, calc(100vw - 32px));
  max-height: min(360px, calc(100vh - 100px));
  display: grid;
  gap: 5px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(74, 132, 155, .45);
  border-radius: 14px;
  background: #061c2a;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .34);
}

.hh-agent-session-menu[hidden] {
  display: none !important;
}

.hh-agent-session-menu button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #a9c5d0;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  text-align: left;
}

.hh-agent-session-menu button:hover,
.hh-agent-session-menu button.is-selected {
  background: rgba(18, 63, 82, .82);
  color: #e0f3f7;
}

.hh-agent-session-menu button span {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-agent-session-menu button i {
  color: #6dd6e6;
  font-style: normal;
}

.hh-agent-session-menu p {
  margin: 0;
  padding: 12px;
  color: #7898a6;
  font-size: 12px;
}

.hh-agent-message {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.hh-agent-message.is-user {
  justify-content: flex-end;
  padding-left: clamp(32px, 16vw, 220px);
}

.hh-agent-message.is-assistant {
  padding-right: clamp(18px, 10vw, 150px);
}

.hh-agent-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 170, 73, .72);
  border-radius: 50%;
  background: rgba(7, 28, 41, .94);
  color: #e2b85d;
  font: 800 14px/1 Georgia, serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.hh-agent-message-content {
  min-width: 0;
  max-width: min(820px, 100%);
  display: grid;
  gap: 8px;
}

.hh-agent-message.is-user .hh-agent-message-content {
  justify-items: end;
}

.hh-agent-message-label {
  color: #789aaa;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
}

.hh-agent-message.is-assistant .hh-agent-message-label {
  color: #c9a54f;
}

.hh-agent-bubble {
  max-width: 100%;
  padding: 13px 16px;
  border: 1px solid rgba(64, 121, 145, .38);
  border-radius: 14px;
  background: rgba(6, 30, 44, .88);
  color: #dcebf2;
  font-size: 14px;
  line-height: 1.72;
  overflow-wrap: anywhere;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}

.hh-agent-message.is-user .hh-agent-bubble {
  border-color: rgba(194, 153, 68, .38);
  background: rgba(35, 42, 43, .92);
  color: #f1eadb;
}

.hh-agent-message-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.hh-agent-message-refs span,
.hh-agent-plan-specs span {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid rgba(75, 135, 158, .35);
  border-radius: 999px;
  background: rgba(8, 40, 56, .8);
  color: #a9c9d6;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-agent-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.hh-agent-suggestions button {
  min-height: 34px;
  max-width: 100%;
  padding: 6px 11px;
  border: 1px solid rgba(72, 133, 157, .46);
  border-radius: 10px;
  background: rgba(5, 29, 43, .75);
  color: #9fc9d7;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.hh-agent-suggestions button:hover,
.hh-agent-suggestions button:focus-visible {
  border-color: rgba(86, 205, 224, .78);
  background: rgba(9, 47, 65, .94);
  color: #daf7ff;
  outline: none;
}

.hh-agent-plan {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(196, 155, 70, .45);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(12, 43, 59, .96), rgba(5, 25, 38, .96));
  box-shadow: 0 18px 46px rgba(0, 0, 0, .18);
}

.hh-agent-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hh-agent-plan-head div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.hh-agent-plan-head span {
  color: #80a9b8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.hh-agent-plan-head b {
  color: #efcc7d;
  font-size: 16px;
}

.hh-agent-plan-head em {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid rgba(202, 161, 72, .4);
  border-radius: 999px;
  background: rgba(40, 38, 29, .68);
  color: #e9c371;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.hh-agent-plan p {
  margin: 0;
  color: #d9e7ed;
  font-size: 14px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.hh-agent-plan-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.hh-agent-plan-actions {
  display: flex;
  justify-content: flex-end;
}

.hh-agent-plan-actions button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(222, 176, 77, .72);
  border-radius: 10px;
  background: linear-gradient(180deg, #e3b85f, #c89237);
  color: #101820;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(185, 130, 39, .18);
}

.hh-agent-plan-actions button:hover,
.hh-agent-plan-actions button:focus-visible {
  filter: brightness(1.07);
  outline: 2px solid rgba(230, 190, 103, .35);
  outline-offset: 2px;
}

.hh-agent-plan small {
  color: #7596a4;
  font-size: 11px;
  line-height: 1.55;
}

.hh-agent-generation,
.hh-agent-generation * {
  box-sizing: border-box;
}

.hh-agent-generation {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 14px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(69, 139, 164, .5);
  border-radius: 17px;
  background:
    radial-gradient(circle at 100% 0, rgba(68, 188, 210, .1), transparent 34%),
    linear-gradient(145deg, rgba(7, 32, 47, .98), rgba(4, 21, 33, .98));
  color: #dcecf2;
  box-shadow:
    0 18px 48px rgba(0, 0, 0, .22),
    inset 0 1px 0 rgba(255, 255, 255, .025);
}

.hh-agent-generation.is-complete {
  border-color: rgba(83, 179, 157, .5);
}

.hh-agent-generation.is-failed,
.hh-agent-generation.has-error {
  border-color: rgba(221, 104, 95, .52);
}

.hh-agent-generation-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hh-agent-generation-title {
  min-width: 0;
  margin: 0;
  color: #f1d28b;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: .01em;
  overflow-wrap: anywhere;
}

.hh-agent-generation-status {
  flex: 0 0 auto;
  max-width: 45%;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid rgba(94, 200, 219, .42);
  border-radius: 999px;
  background: rgba(13, 62, 78, .75);
  color: #96e2ed;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

.hh-agent-generation.is-complete .hh-agent-generation-status,
.hh-agent-generation-status.is-complete {
  border-color: rgba(97, 205, 175, .48);
  background: rgba(24, 79, 67, .72);
  color: #9aebd2;
}

.hh-agent-generation.is-failed .hh-agent-generation-status,
.hh-agent-generation.has-error .hh-agent-generation-status,
.hh-agent-generation-status.is-failed,
.hh-agent-generation-status.is-error {
  border-color: rgba(235, 116, 105, .52);
  background: rgba(91, 35, 35, .72);
  color: #ffc0b7;
}

.hh-agent-generation-specs {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.hh-agent-generation-specs > span,
.hh-agent-generation-specs > b,
.hh-agent-generation-specs > em {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  overflow: hidden;
  border: 1px solid rgba(71, 131, 154, .38);
  border-radius: 999px;
  background: rgba(8, 41, 57, .74);
  color: #a9cad5;
  font-size: 11px;
  font-style: normal;
  font-weight: 750;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-agent-generation-prompt {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 11px 13px;
  border-left: 3px solid rgba(214, 171, 79, .78);
  border-radius: 0 10px 10px 0;
  background: rgba(3, 20, 30, .58);
  color: #c8dbe2;
  font-size: 13px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hh-agent-generation-progress {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(65, 129, 151, .4);
  border-radius: 999px;
  background: rgba(2, 18, 28, .9);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, .32);
}

.hh-agent-generation-progress-bar {
  width: var(--hh-agent-generation-progress, 8%);
  min-width: 8px;
  max-width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #55cada 0%, #81e2dc 58%, #e5bd63 100%);
  box-shadow: 0 0 14px rgba(91, 211, 224, .38);
  transition: width .3s ease;
}

.hh-agent-generation-media {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  overflow: hidden;
  border-radius: 13px;
  background: rgba(2, 15, 24, .78);
}

.hh-agent-generation-asset {
  position: relative;
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(72, 132, 155, .38);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(17, 52, 67, .78), rgba(2, 17, 27, .96));
  color: #9bbbc7;
  text-decoration: none;
}

.hh-agent-generation-asset:hover,
.hh-agent-generation-asset:focus-visible {
  border-color: rgba(103, 214, 230, .78);
  outline: none;
  box-shadow: 0 0 0 2px rgba(83, 199, 219, .14);
}

.hh-agent-generation-asset > img,
.hh-agent-generation-asset > video,
img.hh-agent-generation-asset,
video.hh-agent-generation-asset {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: block;
  border: 0;
  object-fit: cover;
}

.hh-agent-generation-asset > video,
video.hh-agent-generation-asset {
  background: #020b11;
  object-fit: contain;
}

.hh-agent-generation-error {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(229, 108, 99, .46);
  border-radius: 11px;
  background: rgba(87, 31, 32, .52);
  color: #ffc5bd;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hh-agent-thinking {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(70, 134, 157, .38);
  border-radius: 13px;
  background: rgba(6, 30, 44, .82);
  color: #a9c8d4;
  font-size: 13px;
}

.hh-agent-thinking i {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid rgba(99, 200, 220, .25);
  border-top-color: #65d4e7;
  border-radius: 50%;
  animation: hh-agent-spin .8s linear infinite;
}

.hh-agent-composer-status {
  width: 100%;
  min-height: 18px;
  margin-top: 8px;
  color: #83b9c9;
  font-size: 12px;
  line-height: 1.5;
}

.hh-agent-composer-status[hidden] {
  display: none !important;
}

.hh-agent-composer-status.is-error {
  color: #ffb2a5;
}

.hh-agent-composer-status.is-notice {
  color: #8ed0dc;
}

@keyframes hh-agent-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .hh-agent-session-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .hh-agent-session-controls > button,
  .hh-agent-session-switcher > button {
    max-width: 180px;
  }

  .hh-agent-timeline,
  .hh-agent-turn {
    gap: 17px;
    margin: 8px 0 18px;
  }

  .hh-agent-message.is-user {
    padding-left: 24px;
  }

  .hh-agent-message.is-assistant {
    padding-right: 0;
  }

  .hh-agent-avatar {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
    font-size: 12px;
  }

  .hh-agent-bubble,
  .hh-agent-plan {
    padding: 12px;
  }

  .hh-agent-plan-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hh-agent-plan-actions {
    justify-content: stretch;
  }

  .hh-agent-plan-actions button {
    width: 100%;
  }

  .hh-agent-generation {
    gap: 12px;
    padding: 13px;
    border-radius: 14px;
  }

  .hh-agent-generation-media {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hh-agent-generation-prompt {
    padding: 10px 11px;
    font-size: 12px;
  }
}

@media (max-width: 460px) {
  .hh-agent-generation-head {
    align-items: stretch;
    flex-direction: column;
  }

  .hh-agent-generation-status {
    align-self: flex-start;
    max-width: 100%;
  }

  .hh-agent-generation-media {
    grid-template-columns: minmax(0, 1fr);
  }

  .hh-agent-generation-specs > span,
  .hh-agent-generation-specs > b,
  .hh-agent-generation-specs > em {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hh-agent-thinking i {
    animation-duration: 1.5s;
  }

  .hh-agent-generation-progress-bar {
    transition: none;
  }
}
