:root {
  --benji-night: #071f33;
  --benji-navy: #112f48;
  --benji-blue: #0f6fe8;
  --benji-cyan: #54d8ff;
  --benji-gold: #f3bd32;
  --benji-ink: #162532;
  --benji-muted: #637889;
}

.benji-widget {
  position: fixed;
  z-index: 10000;
  right: 22px;
  bottom: 20px;
  display: none;
  color: var(--benji-ink);
  font-family: Montserrat, Arial, sans-serif;
}

.benji-widget.is-authorised { display: block; }

.benji-mark {
  position: relative;
  display: block;
  width: 48px;
  height: 46px;
  flex: 0 0 48px;
  filter: drop-shadow(0 0 5px rgba(84, 216, 255, .92)) drop-shadow(0 0 15px rgba(15, 111, 232, .68));
}

.benji-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.benji-triangle { fill: rgba(4, 37, 69, .42); stroke-linejoin: round; }
.benji-triangle.outer { stroke: #50dbff; stroke-width: 3.1; }
.benji-triangle.middle { stroke: #288cff; stroke-width: 2.7; }
.benji-triangle.inner { fill: rgba(16, 104, 218, .28); stroke: #83efff; stroke-width: 2.3; }
.benji-cap { fill: none; stroke: #fff; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

.benji-launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  border: 1px solid rgba(109, 216, 255, .48);
  border-radius: 999px;
  padding: 5px 14px 5px 8px;
  background: linear-gradient(135deg, var(--benji-night), #164a71);
  color: #fff;
  box-shadow: 0 14px 40px rgba(7, 31, 51, .34), 0 0 20px rgba(28, 138, 226, .22);
  cursor: pointer;
  font: 750 13px/1 Montserrat, Arial, sans-serif;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.benji-launcher:hover {
  border-color: #79e6ff;
  box-shadow: 0 16px 42px rgba(7, 31, 51, .4), 0 0 25px rgba(50, 183, 255, .42);
  transform: translateY(-2px);
}

.benji-launcher.is-attention { animation: benji-attention 5s ease-in-out 1; }
.benji-online { width: 7px; height: 7px; border-radius: 50%; background: #69e0a2; box-shadow: 0 0 0 3px rgba(105, 224, 162, .14), 0 0 10px #69e0a2; }

@keyframes benji-attention {
  0%, 12%, 26%, 40%, 100% { transform: translateY(0) rotate(0); }
  7% { transform: translateY(-7px) rotate(-1deg); }
  19% { transform: translateY(-5px) rotate(1deg); }
  33% { transform: translateY(-3px); }
}

.benji-window {
  position: absolute;
  right: 0;
  bottom: 65px;
  width: min(430px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 105px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #a9cadd;
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 75px rgba(9, 36, 53, .33), 0 0 38px rgba(30, 133, 214, .12);
  transform-origin: bottom right;
}

.benji-window[hidden] { display: none; }
.benji-head { position: relative; display: flex; align-items: center; gap: 9px; min-height: 66px; padding: 10px 14px; background: linear-gradient(120deg, #071f33, #153d5a 72%, #125d8f); color: #fff; }
.benji-head::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: linear-gradient(90deg, transparent, var(--benji-cyan), var(--benji-gold), transparent); }
.benji-head .benji-mark { width: 43px; height: 42px; flex-basis: 43px; }
.benji-head-copy { display: grid; gap: 3px; }
.benji-head strong { font-size: 15px; }
.benji-head small { color: #bdd8e8; font-size: 10px; }
.benji-head-actions { display: flex; gap: 3px; margin-left: auto; }
.benji-icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: #fff; font: 700 20px Arial; cursor: pointer; }
.benji-icon-button:hover { background: rgba(255, 255, 255, .12); }

.benji-body { min-height: 0; background: radial-gradient(circle at 90% 4%, rgba(90, 209, 255, .12), transparent 27%), linear-gradient(#f5fafe, #fff); }
.benji-home { height: 100%; box-sizing: border-box; overflow: auto; padding: 26px 20px 20px; }
.benji-home[hidden], .benji-chat[hidden] { display: none; }
.benji-home-intro { padding: 2px 2px 20px; }
.benji-kicker { margin: 0 0 7px; color: var(--benji-blue); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.benji-home h1 { margin: 0; color: var(--benji-night); font-size: clamp(25px, 5vw, 31px); line-height: 1.15; letter-spacing: -.035em; }
.benji-home h1 small { color: #26495f; font-size: .68em; font-weight: 700; letter-spacing: -.025em; }
.benji-account-note { margin: 13px 0 0; color: var(--benji-muted); font-size: 11px; line-height: 1.6; }
.benji-account-summary { margin: 12px 0 0; border-left: 3px solid var(--benji-cyan); border-radius: 3px; padding: 8px 10px; background: rgba(220, 244, 255, .58); color: #31566d; font-size: 9px; font-weight: 650; line-height: 1.5; }

.benji-home-ideas { display: grid; gap: 8px; }
.benji-home-ideas button { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; width: 100%; border: 1px solid #c9dde9; border-radius: 13px; padding: 12px 13px; background: rgba(255, 255, 255, .92); color: var(--benji-ink); text-align: left; cursor: pointer; box-shadow: 0 5px 16px rgba(29, 87, 119, .06); transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.benji-home-ideas button:hover { border-color: #66bde9; box-shadow: 0 8px 22px rgba(29, 111, 163, .12); transform: translateY(-1px); }
.benji-home-ideas strong { font-size: 11px; }
.benji-home-ideas span { grid-column: 1; overflow: hidden; color: var(--benji-muted); font-size: 9px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.benji-home-ideas b { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--benji-blue); font-size: 17px; }

.benji-recents { margin-top: 24px; }
.benji-recents-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.benji-recents-head strong { color: var(--benji-night); font-size: 12px; }
.benji-recents-head span { color: var(--benji-muted); font-size: 8px; }
.benji-chat-list { display: grid; gap: 7px; }
.benji-empty-chats { margin: 0; border: 1px dashed #c9d9e3; border-radius: 12px; padding: 16px; color: var(--benji-muted); font-size: 9px; line-height: 1.5; text-align: center; }
.benji-chat-card { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid #dae6ed; border-radius: 11px; padding: 10px 11px; background: #fff; text-align: left; cursor: pointer; }
.benji-chat-card:hover { border-color: #8bc9e8; background: #f8fcff; }
.benji-chat-card > span { display: grid; min-width: 0; flex: 1; gap: 3px; }
.benji-chat-card strong, .benji-chat-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.benji-chat-card strong { color: #18384d; font-size: 10px; }
.benji-chat-card small { color: var(--benji-muted); font-size: 8px; }
.benji-chat-card time { flex: 0 0 auto; color: #7b8e9a; font-size: 8px; }

.benji-chat { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; min-height: 0; }
.benji-back { justify-self: start; margin: 10px 14px 0; border: 0; padding: 5px 2px; background: transparent; color: #37627b; font: 700 9px/1 Montserrat, Arial, sans-serif; cursor: pointer; }
.benji-back:hover { color: var(--benji-blue); }
.benji-messages { min-height: 0; overflow: auto; padding: 12px 16px 16px; scroll-behavior: smooth; }
.benji-message { max-width: 89%; margin: 0 0 12px; }
.benji-message p { margin: 0; border-radius: 13px; padding: 11px 13px; white-space: pre-wrap; font-size: 12px; line-height: 1.6; }
.benji-message.bot p { border: 1px solid #d6e5ed; border-top-left-radius: 4px; background: rgba(255, 255, 255, .97); }
.benji-message.user { margin-left: auto; }
.benji-message.user p { border-top-right-radius: 4px; background: linear-gradient(135deg, #0c66d6, #1188d9); color: #fff; }
.benji-message.error p { border: 1px solid #f0c7c3; background: #fff4f2; color: #8e342e; }
.benji-sources { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 0; }
.benji-sources a { border: 1px solid #bdd8e8; border-radius: 999px; padding: 5px 8px; background: #f5fbff; color: #0b5eb7; font-size: 9px; font-weight: 750; text-decoration: none; }
.benji-sources a:hover { text-decoration: underline; }
.benji-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 13px; }
.benji-suggestions button { border: 1px solid #c2d9e7; border-radius: 999px; padding: 7px 9px; background: #eef8fd; color: #214b67; font: 750 9px/1.3 Montserrat, Arial, sans-serif; cursor: pointer; }
.benji-thinking { display: flex; gap: 4px; padding: 12px; }
.benji-thinking i { width: 6px; height: 6px; border-radius: 50%; background: #258ed2; animation: benji-pulse 1s infinite alternate; }
.benji-thinking i:nth-child(2) { animation-delay: .18s; }
.benji-thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes benji-pulse { to { opacity: .22; transform: translateY(-3px); } }

.benji-compose { padding: 10px 12px 12px; border-top: 1px solid #d8e5ec; background: #fff; }
.benji-privacy { margin: 0 0 7px; color: var(--benji-muted); font-size: 8px; line-height: 1.35; }
.benji-form { display: flex; align-items: flex-end; gap: 7px; }
.benji-form textarea { box-sizing: border-box; width: 100%; min-height: 44px; max-height: 105px; resize: none; border: 1px solid #b9cbd6; border-radius: 11px; padding: 11px 12px; outline: 0; font: 500 11px/1.4 Montserrat, Arial, sans-serif; }
.benji-form textarea:focus { border-color: var(--benji-blue); box-shadow: 0 0 0 3px rgba(15, 111, 232, .12); }
.benji-send { flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 11px; background: linear-gradient(135deg, #0e6fe3, #0b93d4); color: #fff; font-size: 20px; cursor: pointer; box-shadow: 0 6px 18px rgba(15, 111, 232, .25); }
.benji-send:disabled { opacity: .5; cursor: wait; }

.benji-context-host { position: relative; }
.benji-context-pin { position: absolute; z-index: 25; top: 12px; right: 12px; display: grid; place-items: center; width: 52px; height: 52px; border: 0; padding: 2px; background: transparent; cursor: pointer; }
.benji-context-pin .benji-mark { width: 48px; height: 46px; transition: filter .18s ease, transform .18s ease; }
.benji-context-pin > span:last-child { position: absolute; z-index: 30; top: calc(100% + 7px); right: 0; visibility: hidden; width: 220px; border: 1px solid #59bee8; border-radius: 11px; padding: 11px 12px; background: #08263b; color: #fff; box-shadow: 0 14px 32px rgba(7, 31, 51, .28); opacity: 0; transform: translateY(-4px); text-align: left; pointer-events: none; transition: .16s ease; }
.benji-context-pin > span:last-child strong { display: block; margin-bottom: 4px; color: #7ee7ff; font-size: 10px; }
.benji-context-pin > span:last-child { font-size: 9px; line-height: 1.45; }
.benji-context-pin:hover .benji-mark, .benji-context-pin:focus-visible .benji-mark { filter: drop-shadow(0 0 7px #54d8ff) drop-shadow(0 0 20px #0f6fe8); transform: translateY(-2px) scale(1.06); }
.benji-context-pin:hover > span:last-child, .benji-context-pin:focus-visible > span:last-child { visibility: visible; opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .benji-widget { right: 14px; bottom: 14px; }
  .benji-launcher-label, .benji-online { display: none; }
  .benji-launcher { padding: 6px 8px; }
  .benji-window { position: fixed; inset: 10px; width: auto; height: auto; max-height: none; }
  .benji-context-pin { top: 8px; right: 8px; }
  .benji-context-pin > span:last-child { width: min(220px, calc(100vw - 54px)); }
}

@media (prefers-reduced-motion: reduce) {
  .benji-launcher.is-attention, .benji-thinking i { animation: none; }
  .benji-launcher, .benji-context-pin .benji-mark, .benji-messages { transition: none; scroll-behavior: auto; }
}
