:root {
  --ei-ai-bg: #060b1a;
  --ei-ai-panel: #0b1326;
  --ei-ai-panel-2: #111c32;
  --ei-ai-user: #5b48ea;
  --ei-ai-text: #e8eefc;
  --ei-ai-muted: #91a0ba;
  --ei-ai-border: rgba(148, 163, 184, .2);
  --ei-ai-ring: rgba(98, 140, 255, .55);
  --ei-ai-blue: #6aa7ff;
  --ei-ai-green: #48df87;
  --ei-ai-danger: #ff5b6b;
  --ei-ai-shadow: 0 24px 70px rgba(2, 6, 23, .45);
}

#ei-ai-assistant-widget,
#ei-ai-assistant-widget * {
  box-sizing: border-box;
}

#ei-ai-assistant-widget {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ei-ai-text);
  position: relative;
  z-index: 2147483000;
}

.ei-ai-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 22px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, #2f5de6, #12285e);
  box-shadow: 0 18px 44px rgba(20, 45, 120, .45);
  display: grid;
  place-items: center;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}

.ei-ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 54px rgba(20, 45, 120, .55);
}

.ei-ai-launcher__pulse {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--ei-ai-green);
  border: 2px solid #16316f;
  box-shadow: 0 0 0 4px rgba(72, 223, 135, .14);
}

.ei-ai-panel {
  position: fixed;
  right: 28px;
  bottom: 92px;
  width: 382px;
  height: 575px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 115px);
  background: var(--ei-ai-bg);
  border: 1px solid rgba(108, 125, 170, .16);
  border-radius: 0;
  box-shadow: var(--ei-ai-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.ei-ai.is-open .ei-ai-panel {
  display: flex;
}

.ei-ai.is-open .ei-ai-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(.94);
}

.ei-ai.is-expanded .ei-ai-panel {
  width: min(760px, calc(100vw - 38px));
  height: min(760px, calc(100vh - 44px));
  right: 19px;
  bottom: 22px;
  border-radius: 18px;
}

.ei-ai-header {
  flex: 0 0 auto;
  height: 74px;
  padding: 16px 16px;
  background: #0d1629;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ei-ai-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ei-ai-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, #ff7a59 0 22%, #2ed47a 23% 42%, #2d57e6 43% 70%, #071127 71%);
}

.ei-ai-avatar__mark {
  width: 18px;
  height: 18px;
  border-radius: 7px;
  background: #071127;
  color: #f5f7ff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.ei-ai-avatar__online {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--ei-ai-green);
  border: 2px solid #0d1629;
}

.ei-ai-title {
  font-size: 14px;
  font-weight: 650;
  color: #fff;
  line-height: 1.2;
}

.ei-ai-status {
  margin-top: 3px;
  color: var(--ei-ai-green);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.ei-ai-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ei-ai-icon-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #91b6ec;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}

.ei-ai-icon-btn:hover {
  background: rgba(106, 167, 255, .11);
  color: #d9e7ff;
}

.ei-ai-icon-btn:active {
  transform: scale(.96);
}

.ei-ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 16px 14px;
  overflow-y: auto;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 18% 0%, rgba(87, 104, 255, .06), transparent 30%),
    var(--ei-ai-bg);
}

.ei-ai-messages::-webkit-scrollbar,
.ei-ai-files::-webkit-scrollbar {
  width: 8px;
}

.ei-ai-messages::-webkit-scrollbar-track,
.ei-ai-files::-webkit-scrollbar-track {
  background: transparent;
}

.ei-ai-messages::-webkit-scrollbar-thumb,
.ei-ai-files::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .38);
  border-radius: 999px;
}

.ei-ai-row {
  display: flex;
  margin-bottom: 16px;
}

.ei-ai-row.is-user {
  justify-content: flex-end;
}

.ei-ai-bubble {
  max-width: 90%;
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ei-ai-text);
  word-wrap: break-word;
  white-space: normal;
}

.ei-ai-row.is-assistant .ei-ai-bubble {
  background: #202b40;
  color: #eef4ff;
  border-bottom-left-radius: 5px;
}

.ei-ai-row.is-user .ei-ai-bubble {
  background: var(--ei-ai-user);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.ei-ai-bubble p {
  margin: 0 0 9px;
}

.ei-ai-bubble p:last-child {
  margin-bottom: 0;
}

.ei-ai-bubble ul,
.ei-ai-bubble ol {
  margin: 7px 0 7px 20px;
  padding: 0;
}

.ei-ai-bubble li {
  margin: 3px 0;
}

.ei-ai-bubble code {
  color: #dce8ff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 1px 4px;
  font-size: 12px;
}

.ei-ai-bubble pre {
  white-space: pre-wrap;
  overflow: auto;
  background: rgba(0,0,0,.23);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px;
  padding: 10px;
}

.ei-ai-tools {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 10px;
}

.ei-ai-tool-btn {
  border: 1px solid rgba(148, 163, 184, .22);
  background: rgba(15, 23, 42, .38);
  color: #a7b4cf;
  font-size: 11px;
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

.ei-ai-tool-btn i {
  font-size: 11px;
  line-height: 1;
}

.ei-ai-tool-btn:hover {
  color: #eef4ff;
  border-color: rgba(148, 163, 184, .36);
}

.ei-ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ei-ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(232, 238, 252, .75);
  animation: eiTyping 1s infinite ease-in-out;
}

.ei-ai-typing span:nth-child(2) { animation-delay: .13s; }
.ei-ai-typing span:nth-child(3) { animation-delay: .26s; }

@keyframes eiTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.ei-ai-attachments {
  flex: 0 0 auto;
  padding: 9px 16px 8px;
  background: #0d1629;
  border-top: 1px solid rgba(148, 163, 184, .1);
}

.ei-ai-files {
  max-height: 72px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 7px;
}

.ei-ai-file {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 7px 9px;
  border: 1px solid rgba(106, 167, 255, .2);
  background: rgba(15, 23, 42, .28);
  border-radius: 10px;
  color: #aebbd4;
  font-size: 12px;
}

.ei-ai-file__dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #8794ad;
}

.ei-ai-file.is-ready .ei-ai-file__dot { background: var(--ei-ai-green); }
.ei-ai-file.is-processing .ei-ai-file__dot { background: #ffd166; }
.ei-ai-file.is-error .ei-ai-file__dot { background: var(--ei-ai-danger); }

.ei-ai-file__name {
  color: #d4def2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ei-ai-file__meta {
  margin-left: auto;
  color: #7e8da8;
  white-space: nowrap;
}

.ei-ai-file__remove {
  border: 0;
  background: transparent;
  color: var(--ei-ai-danger);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.ei-ai-attach {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #70aaff;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.ei-ai-attach input {
  display: none;
}

.ei-ai-attach:hover {
  color: #9ac3ff;
}

.ei-ai-attach__plus {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(112, 170, 255, .45);
  border-radius: 7px;
  font-size: 15px;
  font-weight: 500;
}

.ei-ai-notice {
  margin-top: 8px;
  color: #aebbd4;
  border: 1px solid rgba(106, 167, 255, .18);
  background: rgba(106, 167, 255, .08);
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 12px;
  line-height: 1.35;
}

.ei-ai-notice.is-error {
  color: #ffd1d6;
  border-color: rgba(255, 91, 107, .28);
  background: rgba(255, 91, 107, .1);
}

.ei-ai-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 0 16px 10px;
  background: #0d1629;
}

.ei-ai-composer textarea {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid rgba(108, 116, 255, .75);
  border-radius: 8px;
  padding: 12px 12px;
  color: #e8eefc;
  background: #060b1a;
  outline: none;
  font-size: 14px;
  line-height: 1.35;
}

.ei-ai-composer textarea::placeholder {
  color: #8995ad;
}

.ei-ai-composer textarea:focus {
  border-color: #7ca8ff;
  box-shadow: 0 0 0 3px rgba(124, 168, 255, .14);
}

.ei-ai-send {
  flex: 0 0 auto;
  width: 46px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: #655cff;
  display: grid;
  place-items: center;
  transition: transform .14s ease, color .14s ease, background .14s ease;
}

.ei-ai-send:hover {
  color: #8ea7ff;
  background: rgba(101, 92, 255, .08);
}

.ei-ai-send:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.ei-ai-launcher i {
  font-size: 25px;
  line-height: 1;
}

.ei-ai-icon-btn i {
  font-size: 14px;
  line-height: 1;
}

.ei-ai-send i {
  font-size: 21px;
  line-height: 1;
}

.ei-ai-attach__plus i {
  font-size: 10px;
  line-height: 1;
}

.ei-ai-powered {
  flex: 0 0 auto;
  padding: 0 16px 15px;
  text-align: center;
  font-size: 10px;
  color: #6880ab;
  background: #0d1629;
}

@media (max-width: 520px) {
  .ei-ai-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
  }

  .ei-ai.is-expanded .ei-ai-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .ei-ai-launcher {
    right: 17px;
    bottom: 17px;
  }
}

.ei-ai-bubble h1,
.ei-ai-bubble h2,
.ei-ai-bubble h3,
.ei-ai-bubble h4,
.ei-ai-bubble h5,
.ei-ai-bubble h6 {
  color: #f5f8ff;
  font-weight: 700;
  line-height: 1.25;
  margin: 12px 0 8px;
}

.ei-ai-bubble h1 { font-size: 20px; }
.ei-ai-bubble h2 { font-size: 18px; }
.ei-ai-bubble h3 { font-size: 16px; }
.ei-ai-bubble h4,
.ei-ai-bubble h5,
.ei-ai-bubble h6 { font-size: 14px; }

.ei-ai-bubble table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  line-height: 1.35;
  background: rgba(15, 23, 42, .28);
  border: 1px solid rgba(148, 163, 184, .24);
}

.ei-ai-bubble th,
.ei-ai-bubble td {
  border: 1px solid rgba(148, 163, 184, .22);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.ei-ai-bubble th {
  color: #f4f7ff;
  background: rgba(148, 163, 184, .12);
  font-weight: 700;
}

.ei-ai-bubble tr:nth-child(even) td {
  background: rgba(255, 255, 255, .025);
}

.ei-ai-bubble blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid #6aa7ff;
  background: rgba(106, 167, 255, .08);
  color: #dbe7ff;
  border-radius: 8px;
}

.ei-ai-bubble hr {
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, .2);
  margin: 12px 0;
}

.ei-ai-bubble a {
  color: #8dbbff;
  text-decoration: underline;
}

.ei-ai-bubble img {
  max-width: 100%;
  border-radius: 10px;
  margin: 8px 0;
}

.ei-ai-bubble del {
  color: #9ca8bf;
}

.ei-ai-bubble input[type="checkbox"] {
  margin-right: 6px;
}

.ei-ai-bubble pre {
  white-space: pre;
  overflow-x: auto;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 10px;
  padding: 10px;
}

.ei-ai-bubble pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.ei-ai-row.is-assistant .ei-ai-bubble {
  overflow-x: auto;
}
/* Private Mode */
.ei-ai.is-private-mode .ei-ai-panel {
  border-color: rgba(168, 85, 247, .42);
  box-shadow: var(--ei-ai-shadow), 0 0 0 1px rgba(168, 85, 247, .12), 0 0 32px rgba(88, 28, 135, .28);
}

.ei-ai.is-private-mode .ei-ai-header {
  background:
    linear-gradient(90deg, rgba(88, 28, 135, .22), transparent 62%),
    #0d1629;
}

.ei-ai-private-mode {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(168, 85, 247, .22);
  background:
    radial-gradient(circle at 10% 50%, rgba(168, 85, 247, .18), transparent 34%),
    rgba(28, 16, 48, .86);
  color: #eadcff;
}

.ei-ai-private-mode[hidden] {
  display: none !important;
}

.ei-ai-private-mode__main {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ei-ai-private-mode__main i {
  font-size: 12px;
  color: #c084fc;
}

.ei-ai-private-mode__meta {
  color: #bfa7df;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ei-ai.is-private-mode .ei-ai-attachments {
  background:
    linear-gradient(90deg, rgba(88, 28, 135, .13), transparent 70%),
    #0d1629;
}

.ei-ai.is-private-mode .ei-ai-file {
  border-color: rgba(168, 85, 247, .28);
  background: rgba(42, 24, 72, .36);
}

@media (max-width: 520px) {
  .ei-ai-private-mode {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* Patch 3 UI polish: composer attachment button + custom Private Mode tooltip */
.ei-ai-attachments[hidden] {
  display: none !important;
}

.ei-ai-composer .ei-ai-attach {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(112, 170, 255, .28);
  border-radius: 8px;
  background: rgba(106, 167, 255, .06);
  color: #8dbbff;
  cursor: pointer;
  transition: transform .14s ease, color .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.ei-ai-composer .ei-ai-attach:hover {
  color: #dbeafe;
  background: rgba(106, 167, 255, .12);
  border-color: rgba(141, 187, 255, .5);
  box-shadow: 0 0 0 3px rgba(106, 167, 255, .08);
}

.ei-ai-composer .ei-ai-attach:active {
  transform: scale(.96);
}

.ei-ai-composer .ei-ai-attach input {
  display: none;
}

.ei-ai-attach__icon {
  display: grid;
  place-items: center;
  line-height: 1;
}

.ei-ai-attach__icon i {
  font-size: 18px;
  line-height: 1;
}

.ei-ai-attach__text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.ei-ai.is-private-mode .ei-ai-composer .ei-ai-attach {
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, .34);
  background: rgba(168, 85, 247, .09);
}

.ei-ai.is-private-mode .ei-ai-composer .ei-ai-attach:hover {
  color: #f3e8ff;
  border-color: rgba(216, 180, 254, .55);
  background: rgba(168, 85, 247, .16);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, .1);
}

.ei-ai-private-mode {
  position: relative;
  cursor: help;
  outline: none;
}

.ei-ai-private-mode::before,
.ei-ai-private-mode::after {
  position: absolute;
  left: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .16s ease, transform .16s ease;
  z-index: 30;
}

.ei-ai-private-mode::before {
  content: "";
  top: calc(100% + 4px);
  width: 12px;
  height: 12px;
  margin-left: 12px;
  transform: translateY(-4px) rotate(45deg);
  background: linear-gradient(135deg, rgba(44, 25, 74, .98), rgba(17, 24, 39, .98));
  border-left: 1px solid rgba(216, 180, 254, .22);
  border-top: 1px solid rgba(216, 180, 254, .22);
}

.ei-ai-private-mode::after {
  content: attr(data-tooltip);
  top: calc(100% + 10px);
  width: min(330px, calc(100% - 32px));
  padding: 12px 13px;
  border: 1px solid rgba(216, 180, 254, .24);
  border-radius: 13px;
  color: #f5ecff;
  background:
    radial-gradient(circle at 12% 0%, rgba(216, 180, 254, .18), transparent 34%),
    linear-gradient(135deg, rgba(44, 25, 74, .98), rgba(17, 24, 39, .98));
  box-shadow: 0 18px 42px rgba(2, 6, 23, .48), 0 0 0 1px rgba(168, 85, 247, .08) inset;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
}

.ei-ai-private-mode:hover::before,
.ei-ai-private-mode:hover::after,
.ei-ai-private-mode:focus-visible::before,
.ei-ai-private-mode:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.ei-ai-private-mode:hover::before,
.ei-ai-private-mode:focus-visible::before {
  transform: translateY(0) rotate(45deg);
}

.ei-ai-private-mode:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(216, 180, 254, .32);
}

@media (max-width: 520px) {
  .ei-ai-private-mode::before,
  .ei-ai-private-mode::after {
    left: 14px;
  }

  .ei-ai-private-mode::after {
    width: calc(100vw - 42px);
    max-width: calc(100vw - 42px);
  }
}

/* Patch 4: AI Energy */
.ei-ai-energy {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(72, 223, 135, .42);
  border-radius: 999px;
  background: rgba(72, 223, 135, .08);
  color: #d8ffe8;
  cursor: help;
  outline: none;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.ei-ai-energy[hidden] {
  display: none !important;
}

.ei-ai-energy__icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  line-height: 1;
}

.ei-ai-energy__icon i {
  font-size: 10px;
  line-height: 1;
}

.ei-ai-energy__label {
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.ei-ai-energy.is-green {
  border-color: rgba(72, 223, 135, .48);
  background: rgba(72, 223, 135, .10);
  color: #d8ffe8;
  box-shadow: 0 0 0 3px rgba(72, 223, 135, .04);
}

.ei-ai-energy.is-yellow {
  border-color: rgba(255, 209, 102, .52);
  background: rgba(255, 209, 102, .10);
  color: #fff1bf;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .04);
}

.ei-ai-energy.is-red {
  border-color: rgba(255, 91, 107, .54);
  background: rgba(255, 91, 107, .11);
  color: #ffd4d9;
  box-shadow: 0 0 0 3px rgba(255, 91, 107, .04);
}

.ei-ai-energy.is-recharging,
.ei-ai-energy.is-locked {
  border-color: rgba(148, 163, 184, .36);
  background: rgba(148, 163, 184, .09);
  color: #d3dbea;
}

.ei-ai-energy.is-recharging .ei-ai-energy__icon i {
  animation: eiEnergyPulse 1.15s infinite ease-in-out;
}

@keyframes eiEnergyPulse {
  0%, 100% { opacity: .45; transform: scale(.94); }
  45% { opacity: 1; transform: scale(1.08); }
}

.ei-ai-energy::before,
.ei-ai-energy::after {
  position: absolute;
  left: 50%;
  right: auto;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity .16s ease, transform .16s ease;
  z-index: 999;
}

.ei-ai-energy::before {
  content: "";
  top: calc(100% + 4px);
  width: 12px;
  height: 12px;
  transform: translate(-50%, -4px) rotate(45deg);
  background: linear-gradient(135deg, rgba(13, 22, 41, .98), rgba(17, 24, 39, .98));
  border-left: 1px solid rgba(148, 163, 184, .22);
  border-top: 1px solid rgba(148, 163, 184, .22);
}

.ei-ai-energy::after {
  content: attr(data-tooltip);
  top: calc(100% + 10px);
  width: 300px;
  max-width: calc(100vw - 42px);
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 13px;
  color: #eef4ff;
  background:
    radial-gradient(circle at 12% 0%, rgba(106, 167, 255, .16), transparent 34%),
    linear-gradient(135deg, rgba(13, 22, 41, .98), rgba(17, 24, 39, .98));
  box-shadow: 0 18px 42px rgba(2, 6, 23, .48), 0 0 0 1px rgba(148, 163, 184, .08) inset;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.42;
  white-space: normal;
  text-align: left;
}

.ei-ai-energy:hover::before,
.ei-ai-energy:hover::after,
.ei-ai-energy:focus-visible::before,
.ei-ai-energy:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ei-ai-energy:hover::before,
.ei-ai-energy:focus-visible::before {
  transform: translate(-50%, 0) rotate(45deg);
}

.ei-ai-energy:focus-visible {
  box-shadow: 0 0 0 3px rgba(106, 167, 255, .14);
}

.ei-ai.is-energy-blocked .ei-ai-composer textarea {
  opacity: .68;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .ei-ai-energy {
    min-width: 44px;
    padding: 0 7px;
  }

  .ei-ai-energy__label {
    display: none;
  }
}

.ei-ai-header {
  position: relative;
  z-index: 120;
  overflow: visible;
}

.ei-ai-actions {
  position: relative;
  z-index: 130;
  overflow: visible;
}

.ei-ai-energy {
  z-index: 140;
}

/* Patch 4b: responsive assistant tables */
.ei-ai-row.is-assistant .ei-ai-bubble {
  max-width: 90%;
  overflow-x: hidden;
}

.ei-ai.is-expanded .ei-ai-row.is-assistant .ei-ai-bubble {
  max-width: 86%;
}

.ei-ai-row.is-user .ei-ai-bubble {
  max-width: 78%;
}

.ei-ai-bubble table code,
.ei-ai-bubble table strong {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .ei-ai-row.is-assistant .ei-ai-bubble {
    max-width: 94%;
  }

  .ei-ai-bubble table {
    font-size: 12px;
  }

  .ei-ai-bubble th,
  .ei-ai-bubble td {
    padding: 6px 7px;
  }
}