/* AI Chat Assistant — "modern" widget. Colours from the settings page: --aica-ink / --aica-accent / --aica-on-accent. */
.aicm { --aica-ink: #0a0d14; --aica-accent: #f59e0b; --aica-on-accent: #0a0d14; --aica-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --m-line: #e7e9ee; --m-mute: #667085; --m-soft: #f5f6f8; --m-deep: color-mix(in srgb, var(--aica-accent) 62%, #000);
  position: fixed; right: 24px; bottom: 24px; z-index: 99990; font-family: var(--aica-font); text-align: left; color: #0a0d14; -webkit-font-smoothing: antialiased; }
.aicm.is-left { right: auto; left: 24px; }
.aicm, .aicm * { box-sizing: border-box; }
.aicm button, .aicm textarea { margin: 0; font-family: var(--aica-font); letter-spacing: normal; text-transform: none; text-shadow: none; min-height: 0; line-height: 1.3; }
.aicm button { -webkit-appearance: none; appearance: none; }
.aicm svg { display: block; flex: none; }
.aicm h2, .aicm h3, .aicm p { margin: 0; padding: 0; font-family: var(--aica-font); letter-spacing: normal; text-transform: none; }

/* launcher */
.aicm-launch { position: relative; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--aica-accent); color: var(--aica-on-accent); cursor: pointer; box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--aica-accent) 70%, transparent), 0 2px 6px -2px rgba(15, 23, 42, 0.2); transition: transform 0.18s ease; }
.aicm-launch:hover, .aicm-launch:focus { background: var(--aica-accent); color: var(--aica-on-accent); transform: scale(1.05); }
.aicm-launch > span { position: absolute; display: grid; place-items: center; transition: opacity 0.18s, transform 0.18s; }
.aicm-launch svg { width: 26px; height: 26px; }
.aicm-l-open svg { width: 30px; height: 30px; }
.aicm-l-open .aicm-bub-shape { fill: #fff; }
/* launcher: three "typing" dots inside the bubble (runs regardless of reduced-motion, owner's choice) */
.aicm-l-open .aicm-dot { fill: var(--aica-accent); stroke: none; transform-box: fill-box; transform-origin: center; animation: aicmTalk 1.5s infinite ease-in-out; }
.aicm-l-open .aicm-dot:nth-of-type(2) { animation-delay: 0.18s; }
.aicm-l-open .aicm-dot:nth-of-type(3) { animation-delay: 0.36s; }
@keyframes aicmTalk { 0%, 55%, 100% { opacity: 0.55; transform: translateY(0.5px); } 25% { opacity: 1; transform: translateY(-2px); } }
.aicm-l-close { opacity: 0; transform: rotate(-90deg); }
.aicm.is-open .aicm-l-open { opacity: 0; transform: rotate(90deg) scale(0.6); }
.aicm.is-open .aicm-l-close { opacity: 1; transform: none; }

/* teaser */
.aicm-teaser { position: absolute; right: 0; bottom: 70px; width: 260px; padding: 14px 34px 14px 16px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--m-line), 0 12px 32px -14px rgba(15, 23, 42, 0.3); animation: aicmUp 0.25s ease both; }
.aicm.is-left .aicm-teaser { right: auto; left: 0; }
.aicm-teaser[hidden] { display: none; }
.aicm-teaser-t { display: block; width: 100%; padding: 0; border: 0; background: none; color: #0a0d14; font-size: 14px; font-weight: 500; line-height: 1.45; text-align: left; cursor: pointer; }
.aicm-teaser-t:hover, .aicm-teaser-t:focus { background: none; color: #0a0d14; }
.aicm-teaser-x { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #98a2b3; cursor: pointer; }
.aicm-teaser-x:hover, .aicm-teaser-x:focus { background: var(--m-soft); color: #0a0d14; }
.aicm-teaser-x svg { width: 14px; height: 14px; }

/* panel */
.aicm-panel { position: absolute; right: 0; bottom: 72px; display: flex; flex-direction: column; width: 400px; height: min(660px, calc(100vh - 120px)); border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06), 0 24px 56px -18px rgba(15, 23, 42, 0.32); overflow: hidden; transform-origin: bottom right; animation: aicmIn 0.2s ease both; }
.aicm.is-left .aicm-panel { right: auto; left: 0; transform-origin: bottom left; }
.aicm-panel[hidden] { display: none; }
@keyframes aicmIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes aicmUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.aicm-btn { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; opacity: 0.75; }
.aicm-btn:hover, .aicm-btn:focus { background: rgba(127, 127, 127, 0.14); color: inherit; opacity: 1; }
.aicm-btn svg { width: 18px; height: 18px; }
.aicm-ico { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 8px; background: color-mix(in srgb, var(--aica-accent) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--aica-accent) 38%, transparent); color: var(--aica-accent); }
.aicm-ico svg { width: 17px; height: 17px; }
.aicm-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--m-mute); }
.aicm-status i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }

.aicm .aicm-note { flex: none; padding: 6px 20px 12px; font-size: 11.5px; line-height: 1.45; text-align: center; text-wrap: pretty; color: #98a2b3; }

/* chat */
.aicm-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; background: #fff; }
.aicm-bar { display: flex; align-items: center; gap: 10px; flex: none; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--m-line); background: #fff; color: #0a0d14; }
.aicm-bar-t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.aicm-bar-t b { overflow: hidden; font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.aicm-bar .aicm-status { margin-top: 1px; font-size: 12px; }
.aicm-bar .aicm-ico { color: var(--m-deep); }
.aicm-log { flex: 1; overflow-y: auto; padding: 20px 16px 8px; scroll-behavior: smooth; }
.aicm-msg { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 12px; animation: aicmUp 0.2s ease both; }
.aicm-msg.is-user { justify-content: flex-end; }
.aicm-ava { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; background: color-mix(in srgb, var(--aica-accent) 14%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--aica-accent) 35%, #fff); color: var(--m-deep); }
.aicm-ava svg { width: 14px; height: 14px; }
.aicm-ico.is-img, .aicm-ava.is-img { background: none; box-shadow: none; overflow: hidden; }
.aicm-ico.is-img img, .aicm-ava.is-img img { display: block; width: 100%; height: 100%; max-width: none; margin: 0; border-radius: inherit; object-fit: cover; }
.aicm-bub { max-width: 82%; text-wrap: pretty; padding: 10px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.aicm-msg.is-bot .aicm-bub { background: var(--m-soft); color: #0a0d14; border-bottom-left-radius: 4px; }
.aicm-msg.is-user .aicm-bub { background: var(--aica-ink); color: #fff; border-bottom-right-radius: 4px; }
.aicm-bub p { margin: 0; font-size: inherit; line-height: inherit; color: inherit; }
.aicm-bub p + p, .aicm-bub p + ul, .aicm-bub ul + p { margin-top: 8px; }
.aicm-bub ul { margin: 8px 0 0; padding-left: 18px; list-style: disc; }
.aicm-bub li { margin: 0; }
.aicm-bub li + li { margin-top: 3px; }
.aicm-bub strong { font-weight: 600; color: inherit; }
.aicm-bub a { color: var(--m-deep); font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--aica-accent) 55%, transparent); text-underline-offset: 2px; }
.aicm-msg.is-typing .aicm-bub { display: inline-flex; gap: 4px; padding: 14px 16px; }
.aicm-msg.is-typing i { width: 6px; height: 6px; border-radius: 50%; background: #98a2b3; animation: aicmDot 1s infinite ease-in-out; }
.aicm-msg.is-typing i:nth-child(2) { animation-delay: 0.15s; }
.aicm-msg.is-typing i:nth-child(3) { animation-delay: 0.3s; }
.aicm-sugg { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 0 0 12px 34px; animation: aicmUp 0.2s ease both; }
.aicm-sugg button { max-width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: #fff; box-shadow: inset 0 0 0 1px var(--m-line); color: #0a0d14; font-size: 13.5px; font-weight: 500; line-height: 1.35; text-align: left; cursor: pointer; transition: box-shadow 0.12s, background 0.12s; }
.aicm-sugg button:hover, .aicm-sugg button:focus { background: color-mix(in srgb, var(--aica-accent) 8%, #fff); box-shadow: inset 0 0 0 1px var(--aica-accent); color: #0a0d14; }
@keyframes aicmDot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.aicm-handoff { margin: 0 0 12px 34px; padding: 12px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--m-line), 0 2px 6px -2px rgba(15, 23, 42, 0.08); animation: aicmUp 0.2s ease both; }
.aicm-handoff b { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.aicm-handoff div { display: flex; flex-wrap: wrap; gap: 6px; }
.aicm-handoff a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--m-line); color: #0a0d14; font-size: 13px; font-weight: 600; text-decoration: none; transition: box-shadow 0.12s, background 0.12s; }
.aicm-handoff a:hover, .aicm-handoff a:focus { background: color-mix(in srgb, var(--aica-accent) 8%, #fff); box-shadow: inset 0 0 0 1px var(--aica-accent); color: #0a0d14; }
.aicm-handoff svg { width: 15px; height: 15px; color: var(--m-deep); }
.aicm-compose { flex: none; margin: 0; padding: 8px 12px 4px; background: #fff; }
.aicm-field { display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 14px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px #d0d5dd, 0 1px 2px rgba(15, 23, 42, 0.05); transition: box-shadow 0.15s; }
.aicm-field:focus-within { box-shadow: inset 0 0 0 1.5px var(--aica-accent), 0 0 0 4px color-mix(in srgb, var(--aica-accent) 16%, transparent); }
.aicm-field textarea { flex: 1; width: auto; min-height: 36px; max-height: 120px; padding: 8px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: #0a0d14; font-size: 14.5px; line-height: 1.4; resize: none; outline: 0; }
.aicm-field textarea:focus { background: transparent; box-shadow: none; outline: 0; }
.aicm-field textarea::placeholder { color: #98a2b3; }
.aicm-field button { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: var(--aica-accent); color: var(--aica-on-accent); cursor: pointer; transition: opacity 0.15s; }
.aicm-field button:hover, .aicm-field button:focus { background: var(--aica-accent); color: var(--aica-on-accent); }
.aicm-field button svg { width: 18px; height: 18px; }
.aicm-compose.is-busy button { opacity: 0.45; pointer-events: none; }

@media (max-width: 640px) {
  .aicm, .aicm.is-left { right: 16px; left: auto; bottom: 16px; }
  .aicm.is-left { right: auto; left: 16px; }
  .aicm-launch { width: 52px; height: 52px; }
  .aicm:not(.teaser-m) .aicm-teaser { display: none; }
  .aicm-teaser { width: min(260px, calc(100vw - 32px)); bottom: 64px; }
  .aicm.is-open { inset: 0; }
  .aicm.is-open .aicm-launch { display: none; }
  .aicm-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; animation-name: aicmUp; }
  .aicm-field textarea { font-size: 16px; }   /* no iOS zoom on focus */
}
@media (prefers-reduced-motion: reduce) {
  .aicm-panel, .aicm-msg, .aicm-handoff, .aicm-teaser { animation: none; }
}

.aicm-compose:last-child { padding-bottom: 12px; }
