#xh-canvas-agent-root {
  position: fixed;
  inset: 0;
  /* Normal canvas chrome tops out below 200; the full-screen media viewer is
     z-index 220 and must remain above Agent so its download/close controls work. */
  z-index: 200;
  pointer-events: none;
  color: #f5f7fa;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

#xh-canvas-agent-root *,
#xh-canvas-agent-root *::before,
#xh-canvas-agent-root *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

.xh-agent-launch {
  position: fixed;
  right: 10px;
  top: var(--xh-agent-top, 14px);
  display: flex;
  width: 86px;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  background: #292b30;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 140ms ease, transform 140ms ease, background 140ms ease;
}

.xh-agent-launch:hover { background: #23262b; }
.xh-agent-launch strong { font-size: 13px; font-weight: 700; }
.xh-agent-launch.is-hidden { opacity: 0; transform: translateX(18px); pointer-events: none; }

.xh-agent-brand-mark {
  display: inline-flex;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #21e6be;
  color: #07251f;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.xh-agent-launch-icon {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 18px;
  flex: 0 0 22px;
  align-items: center;
  justify-content: center;
  border: 2px solid currentColor;
  border-radius: 5px;
  color: #f5f5f5;
}
.xh-agent-launch > .xh-agent-launch-icon { transform: scale(.72); }

/* Keep the canvas full width while Agent is closed. Only the native top action
   group moves left so Agent shares the same row and background. */
.xh-agent-host-actions {
  margin-right: 96px !important;
  transform: none !important;
  transition: margin-right 160ms ease !important;
}

html.xh-agent-panel-open body > #root {
  width: calc(100% - 420px) !important;
  max-width: calc(100% - 420px) !important;
  overflow: hidden !important;
  transition: width 190ms ease, max-width 190ms ease;
}
.xh-agent-launch-icon::before,
.xh-agent-launch-icon::after,
.xh-agent-launch-icon i { content: ""; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.xh-agent-launch-icon::before { left: 4px; }
.xh-agent-launch-icon i { left: 8px; }
.xh-agent-launch-icon::after { left: 12px; }

.xh-agent-panel {
  position: fixed;
  inset: 0 0 0 auto;
  display: flex;
  width: min(420px, 100vw);
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid #30343b;
  background: #202122;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
  transition: opacity 160ms ease, transform 190ms ease;
}

.xh-agent-panel.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); }

.xh-agent-header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #34373d;
  padding: 0 15px;
  background: #202122;
}

.xh-agent-brand { display: flex; min-width: 0; align-items: center; gap: 10px; }
.xh-agent-brand strong { overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-header-actions { display: flex; gap: 4px; }
.xh-agent-header-actions button,
.xh-agent-icon-button {
  display: inline-flex;
  width: 31px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b8bdc6;
  cursor: pointer;
  font-size: 16px;
}
.xh-agent-header-actions .xh-agent-cli-button { width: 40px; height: 40px; border-radius: 10px; background: #3a3b3d; color: #fff; }
.xh-agent-header-actions .xh-agent-cli-button .xh-agent-launch-icon { transform: scale(.76); }

.xh-agent-header-actions button:hover,
.xh-agent-icon-button:hover { background: #292c31; color: #fff; }

.xh-agent-error {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #6b3035;
  background: #321d20;
  padding: 10px 14px;
  color: #ffb9bd;
  font-size: 12px;
  line-height: 1.5;
}

.xh-agent-error button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 17px; }
.xh-agent-body { min-height: 0; flex: 1; overflow: hidden; }

.xh-agent-home {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 0 10px 12px;
}

.xh-agent-home-space { min-height: 210px; flex: 1; }
.xh-agent-starter { flex: 0 0 auto; padding: 0 2px 14px; }
.xh-agent-starter-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
.xh-agent-starter-head strong { color: #f0f1f2; font-size: 16px; font-weight: 650; }
.xh-agent-starter-head button { border: 0; background: transparent; color: #9299a1; cursor: pointer; font-size: 12px; }
.xh-agent-starter-robot { margin-right: 8px; color: #fff; }
.xh-agent-home-composer { position: relative; flex: 0 0 auto; border: 1px solid #46494d; border-radius: 14px; background: #262728; padding: 0 8px 8px; }
.xh-agent-home-composer .xh-agent-composer { border: 0; background: transparent; padding: 8px 0 0; }
.xh-agent-home-composer .xh-agent-composer:focus-within { border-color: transparent; }
.xh-agent-home-composer .xh-agent-composer textarea { min-height: 60px; resize: none; }
.xh-agent-bottom-tools { position: relative; display: grid; min-height: 45px; grid-template-columns: repeat(4, minmax(54px, 1fr)); align-items: center; gap: 4px; padding-top: 4px; color: #93999f; }
.xh-agent-bottom-tools > button { display: inline-grid; height: 39px; grid-template-columns: 20px auto; align-items: center; justify-content: center; gap: 5px; border: 0; border-radius: 7px; background: transparent; color: #a3a9b1; cursor: pointer; }
.xh-agent-bottom-tools > button i { font-size: 18px; font-style: normal; line-height: 1; }
.xh-agent-bottom-tools > button small { font-size: 10px; white-space: nowrap; }
.xh-agent-bottom-tools > button:hover,
.xh-agent-bottom-tools > button.is-active { background: #3b3d40; color: #fff; }
.xh-agent-reference-count,
.xh-agent-model-label { display: none; }

.xh-agent-greeting { display: flex; flex-direction: column; gap: 4px; padding: 0 7px 20px; }
.xh-agent-greeting span { color: #25e0bd; font-size: 13px; font-weight: 700; }
.xh-agent-greeting strong { color: #fff; font-size: 22px; line-height: 1.3; }
.xh-agent-section-label { padding: 0 3px 9px; color: #c4c8cf; font-size: 12px; }
.xh-agent-skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.xh-agent-skill,
.xh-agent-free-chat {
  display: grid;
  width: 100%;
  min-height: 62px;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid #565b64;
  border-radius: 14px;
  background: #242526;
  padding: 9px 12px;
  color: #f4f5f6;
  cursor: pointer;
  text-align: left;
}

.xh-agent-skill:hover,
.xh-agent-free-chat:hover { border-color: #23d9b7; background: #202524; }
.xh-agent-skill-icon { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 50%; background: #343638; color: #d8dadd; font-size: 18px; text-align: center; }
.xh-agent-skill-thumb { display: block; width: 48px; height: 42px; border-radius: 9px; background-image: url('/assets/agent-skill-recommendations-v1.webp?v=1'); background-repeat: no-repeat; background-size: 200% 200%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.xh-agent-skill-thumb.is-one-line { background-position: 0 0; }
.xh-agent-skill-thumb.is-general-video { background-position: 100% 0; }
.xh-agent-skill-thumb.is-script-storyboard { background-position: 0 100%; }
.xh-agent-skill-thumb.is-video-clone { background-position: 100% 100%; }
.xh-agent-skill:has(.xh-agent-skill-thumb) { grid-template-columns: 48px minmax(0,1fr); }
.xh-agent-skill-copy { min-width: 0; }
.xh-agent-skill-copy strong,
.xh-agent-free-chat strong { display: block; margin-bottom: 3px; font-size: 14px; font-weight: 700; line-height: 1.25; }
.xh-agent-skill-copy small,
.xh-agent-free-chat small { display: block; overflow: hidden; color: #9ca2ad; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-skill-copy em { display: none; }
.xh-agent-chevron,
.xh-agent-free-chat b { color: #bec3ca; font-size: 22px; font-weight: 400; }
.xh-agent-free-chat { margin-top: 8px; }
.xh-agent-free-chat > span { color: #25e0bd; font-size: 23px; text-align: center; }

.xh-agent-loading,
.xh-agent-empty {
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #9299a3;
  font-size: 13px;
  text-align: center;
}

.xh-agent-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #24dfbb;
  border-radius: 50%;
  animation: xh-agent-spin 800ms linear infinite;
}

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

.xh-agent-conversation { display: flex; height: 100%; min-height: 0; flex-direction: column; }
.xh-agent-conversation-toolbar {
  display: grid;
  min-height: 52px;
  grid-template-columns: 72px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid #30343a;
  padding: 7px 10px;
}

.xh-agent-text-button {
  border: 0;
  background: transparent;
  color: #aeb4bd;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.xh-agent-text-button:hover { color: #fff; }
.xh-agent-current-skill { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 8px; }
.xh-agent-current-skill strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-direction { min-width: 0; max-width: 128px; border: 1px solid #42474f; border-radius: 5px; background: #202328; padding: 4px 22px 4px 7px; color: #dbe0e5; font-size: 11px; }

.xh-agent-chat { min-height: 0; flex: 1; overflow-y: auto; padding: 14px 15px 18px; scroll-behavior: smooth; }
.xh-agent-chat-empty { min-height: 100%; padding: 34px; line-height: 1.7; }
.xh-agent-message { margin-bottom: 15px; }
.xh-agent-message-meta { display: flex; justify-content: space-between; margin-bottom: 5px; color: #7f8792; font-size: 10px; }
.xh-agent-message-content { border: 1px solid #343840; border-radius: 7px; background: #1b1e21; padding: 10px 12px; color: #e8eaed; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.xh-agent-message.is-user .xh-agent-message-content { border-color: #2d6459; background: #18302b; }
.xh-agent-message.is-user { margin-left: 38px; }
.xh-agent-message.is-agent { margin-right: 22px; }

.xh-agent-run,
.xh-agent-command {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 9px 0;
  border: 1px solid #3a3f47;
  border-radius: 7px;
  background: #1c1f23;
  padding: 9px 11px;
  color: #bfc4cc;
  font-size: 12px;
}

.xh-agent-run button,
.xh-agent-command button { margin-left: auto; border: 0; background: transparent; color: #29dab8; cursor: pointer; }
.xh-agent-approval { margin: 12px 0; border: 1px solid #3c6e64; border-radius: 7px; background: #192824; padding: 12px; }
.xh-agent-approval-title { color: #f3f6f5; font-size: 13px; font-weight: 700; }
.xh-agent-approval p { margin: 7px 0; color: #b9c0c5; font-size: 12px; line-height: 1.55; }
.xh-agent-points { color: #f2c26d; font-size: 11px; }
.xh-agent-approval-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 11px; }
.xh-agent-approval-actions button { height: 31px; border: 1px solid #555c65; border-radius: 6px; background: transparent; padding: 0 13px; color: #e5e8eb; cursor: pointer; }
.xh-agent-approval-actions button.is-primary { border-color: #25dbb7; background: #25dbb7; color: #0b231e; font-weight: 700; }

.xh-agent-composer-wrap { position: relative; border-top: 1px solid #34383f; background: #181a1d; padding: 9px 11px 12px; }
.xh-agent-composer-tools { display: flex; min-height: 28px; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.xh-agent-composer-tools button { border: 0; border-radius: 5px; background: transparent; padding: 5px 7px; color: #aeb5be; cursor: pointer; font-size: 12px; }
.xh-agent-composer-tools button:hover,
.xh-agent-composer-tools button.has-selection { background: #24342f; color: #2ce0bc; }
.xh-agent-composer-tools span { overflow: hidden; max-width: 185px; color: #737b87; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-composer { display: grid; grid-template-columns: minmax(0, 1fr) 38px; align-items: end; gap: 8px; border: 1px solid #4a5059; border-radius: 7px; background: #202327; padding: 7px; }
.xh-agent-composer:focus-within { border-color: #25d9b6; }
.xh-agent-composer textarea { width: 100%; min-height: 50px; max-height: 150px; resize: vertical; border: 0; outline: 0; background: transparent; color: #f3f4f6; font: inherit; font-size: 13px; line-height: 1.55; }
.xh-agent-composer textarea::placeholder { color: #777f8a; }
.xh-agent-composer > button { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: #25dfba; color: #09251f; cursor: pointer; font-size: 21px; font-weight: 800; }
.xh-agent-composer > button:disabled { background: #3a3e44; color: #777d85; cursor: default; }

.xh-agent-material-popover { position: absolute; right: 10px; bottom: calc(100% - 4px); left: 10px; overflow: hidden; border: 1px solid #484e57; border-radius: 7px; background: #1c1f22; box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.35); }
.xh-agent-material-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #343940; padding: 10px 11px; color: #e6e8eb; font-size: 12px; }
.xh-agent-material-head button { border: 0; background: transparent; color: #8c949e; cursor: pointer; }
.xh-agent-material-list { max-height: 280px; overflow-y: auto; padding: 5px; }
.xh-agent-material-row { display: grid; min-height: 50px; grid-template-columns: 18px 42px minmax(0, 1fr); align-items: center; gap: 9px; border-radius: 5px; padding: 5px; cursor: pointer; }
.xh-agent-material-row:hover { background: #292d31; }
.xh-agent-material-row input { accent-color: #26dfba; }
.xh-agent-material-row img,
.xh-agent-material-placeholder { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 4px; background: #33373d; color: #a9b0ba; object-fit: cover; }
.xh-agent-material-row span:last-child { min-width: 0; }
.xh-agent-material-row strong { display: block; overflow: hidden; color: #e3e6ea; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-material-row small { color: #7f8791; font-size: 10px; }

.xh-agent-skill-drawer,
.xh-agent-library {
  position: absolute;
  right: 9px;
  bottom: 55px;
  left: 9px;
  z-index: 12;
  display: flex;
  max-height: min(470px, calc(100dvh - 130px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #45484e;
  border-radius: 14px;
  background: #191a1c;
  box-shadow: 0 -18px 70px rgba(0,0,0,.55);
  pointer-events: auto;
}
.xh-agent-drawer-head { display: flex; min-height: 52px; align-items: center; justify-content: space-between; padding: 0 13px; }
.xh-agent-drawer-head strong { color: #f5f5f6; font-size: 15px; }
.xh-agent-drawer-head > div { display: flex; gap: 8px; }
.xh-agent-drawer-head button { border: 1px solid #3d4147; border-radius: 8px; background: #202225; padding: 6px 10px; color: #e1e3e6; cursor: pointer; }
.xh-agent-drawer-tabs { display: flex; gap: 17px; padding: 0 13px 10px; color: #727983; font-size: 12px; }
.xh-agent-drawer-tabs b { color: #fff; }
.xh-agent-skill-search { display: flex; width: min(215px, calc(100% - 24px)); height: 34px; align-items: center; align-self: flex-end; gap: 7px; margin: 0 12px 8px; border-radius: 8px; background: #26282b; padding: 0 10px; color: #8e959e; }
.xh-agent-skill-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #f2f3f4; }
.xh-agent-all-skills { min-height: 0; overflow-y: auto; padding: 3px 9px 12px; }
.xh-agent-all-skill { display: grid; width: 100%; min-height: 68px; grid-template-columns: 36px minmax(0,1fr); align-items: center; gap: 10px; border: 0; border-radius: 9px; background: transparent; padding: 7px 9px; color: #fff; cursor: pointer; text-align: left; }
.xh-agent-all-skill:hover { background: #282a2d; }
.xh-agent-all-skill .xh-agent-skill-icon { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.xh-agent-all-skill .xh-agent-skill-copy strong { display: inline; margin-right: 7px; font-size: 13px; }
.xh-agent-all-skill .xh-agent-skill-copy small { display: inline; max-width: 190px; border-radius: 4px; background: #303236; padding: 3px 6px; color: #a5abb2; }
.xh-agent-all-skill .xh-agent-skill-copy em { display: block; overflow: hidden; margin-top: 5px; color: #858c96; font-size: 11px; font-style: normal; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }

.xh-agent-mini-menu,
.xh-agent-add-menu { position: absolute; z-index: 15; overflow: hidden; border: 1px solid #44484f; border-radius: 12px; background: #191b1e; box-shadow: 0 16px 50px rgba(0,0,0,.5); }
.xh-agent-add-menu { bottom: 51px; left: 7px; width: 154px; padding: 6px; }
.xh-agent-add-menu button { display: block; width: 100%; height: 39px; border: 0; border-radius: 7px; background: transparent; padding: 0 10px; color: #e9ebee; cursor: pointer; text-align: left; }
.xh-agent-add-menu button:hover { background: #2b2e33; }
.xh-agent-model-menu { bottom: 51px; left: 42px; width: 330px; max-height: 380px; overflow-y: auto; padding: 8px; }
.xh-agent-model-menu > strong { display: block; padding: 6px 8px 9px; font-size: 13px; }
.xh-agent-model-menu button { position: relative; display: block; width: 100%; min-height: 50px; border: 0; border-radius: 8px; background: transparent; padding: 7px 34px 7px 9px; color: #e7e9ec; cursor: pointer; text-align: left; }
.xh-agent-model-menu button:hover,
.xh-agent-model-menu button.is-active { background: #292c30; }
.xh-agent-model-menu button span,
.xh-agent-model-menu button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-model-menu button span { font-size: 12px; font-weight: 700; }
.xh-agent-model-menu button small { margin-top: 4px; color: #7f8791; font-size: 10px; }
.xh-agent-model-menu button b { position: absolute; top: 17px; right: 12px; color: #23dfb9; }
.xh-agent-run-mode-menu { right: 7px; bottom: 51px; left: auto; width: 285px; padding: 6px; }
.xh-agent-run-mode-menu button { display: flex; width: 100%; min-height: 68px; align-items: center; justify-content: space-between; border: 0; border-radius: 8px; background: transparent; padding: 8px 12px; color: #e7e9ec; cursor: pointer; text-align: left; }
.xh-agent-run-mode-menu button:hover,
.xh-agent-run-mode-menu button.is-active { background: #26292d; }
.xh-agent-run-mode-menu button span { display: grid; grid-template-columns: 26px 1fr; align-items: center; }
.xh-agent-run-mode-menu button b { font-size: 13px; }
.xh-agent-run-mode-menu button small { grid-column: 2; margin-top: 5px; color: #8b929c; font-size: 11px; }
.xh-agent-run-mode-menu button i { color: #fff; font-style: normal; }
.xh-agent-library { padding-bottom: 10px; }
.xh-agent-library > .xh-agent-loading { min-height: 180px; }
.xh-agent-library-item { display: grid; min-height: 62px; grid-template-columns: 46px minmax(0,1fr) 24px; align-items: center; gap: 10px; margin: 2px 9px; border: 0; border-radius: 8px; background: transparent; padding: 7px; color: #fff; cursor: pointer; text-align: left; }
.xh-agent-library-item:hover { background: #292c30; }
.xh-agent-library-item img,
.xh-agent-library-item > span { display: inline-flex; width: 46px; height: 46px; align-items: center; justify-content: center; border-radius: 6px; background: #33373c; object-fit: cover; }
.xh-agent-library-item strong,
.xh-agent-library-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xh-agent-library-item small { margin-top: 4px; color: #818993; font-size: 10px; }
.xh-agent-library-item > b { color: #2ce1bc; font-size: 18px; }

@media (max-width: 560px) {
  .xh-agent-panel { width: 100vw; }
  .xh-agent-launch { right: 8px; top: 12px; width: 82px; }
  html.xh-agent-panel-open body > #root { width: 100% !important; max-width: 100% !important; }
  .xh-agent-host-actions { transform: none !important; }
  .xh-agent-message.is-user { margin-left: 20px; }
}

@media (max-height: 680px) {
  .xh-agent-home-space { min-height: 80px; }
}
