/* Tickelius — Asistente «Tick». Panel claro con colores propios (rojo Tickelius), igual en todas las páginas. */

#tk-chat-root, #tk-chat-root * { box-sizing: border-box; }
#tk-chat-root {
  /* Colores propios y fijos: el tema define --accent distinto según la página (en las fichas es blanco),
     así que el chat NO depende de las variables del tema. */
  --tkc-accent: #c0392b;
  --tkc-bg: #ffffff;
  --tkc-bg2: #f0f0f0;
  --tkc-text: #111111;
  --tkc-muted: rgba(0,0,0,.58);
  --tkc-border: rgba(0,0,0,.14);
  --tkc-k: 3;
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 2147483000;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--tkc-text);
}

/* Los botones del tema (Astra) pintan fondo, relleno, mayúsculas y hover propios: aquí se neutralizan */
#tk-chat-root button {
  font-family: inherit; text-transform: none; letter-spacing: normal; text-shadow: none; box-shadow: none;
  min-width: 0; min-height: 0; margin: 0; width: auto; height: auto; line-height: inherit; text-decoration: none; float: none;
}
#tk-chat-root button.tkc-x {
  flex: none !important; display: grid !important; place-items: center !important;
  width: 40px !important; height: 40px !important; padding: 0 !important; margin: 0 !important;
  background: rgba(255,255,255,.22) !important; color: #fff !important; border: 2px solid rgba(255,255,255,.85) !important; border-radius: 50% !important;
  cursor: pointer; opacity: 1 !important; box-shadow: none !important;
}
#tk-chat-root button.tkc-x:hover, #tk-chat-root button.tkc-x:focus { background: rgba(255,255,255,.4) !important; color: #fff !important; border-color: #fff !important; }
#tk-chat-root button.tkc-x svg { display: block; width: 20px; height: 20px; pointer-events: none; }
#tk-chat-root button.tkc-send { width: 42px !important; height: 42px !important; padding: 0 !important; background: var(--tkc-accent) !important; color: #fff !important; border: 0 !important; border-radius: 12px !important; }
#tk-chat-root button.tkc-tease-x { width: 24px !important; height: 24px !important; padding: 0 !important; background: none !important; border: 0 !important; color: var(--tkc-muted) !important; display: grid !important; place-items: center !important; }
#tk-chat-root button.tkc-launch { background: none !important; border: 0 !important; padding: 0 !important; }
#tk-chat-root button.tkc-chip { padding: 8px 12px !important; background: var(--tkc-bg) !important; color: var(--tkc-text) !important; border: 1.5px solid var(--tkc-border) !important; border-radius: 999px !important; }
#tk-chat-root button.tkc-chip:hover { border-color: var(--tkc-accent) !important; color: var(--tkc-accent) !important; }
#tk-chat-root .tkc-fb button { background: none !important; border: 0 !important; padding: 4px 6px !important; color: var(--tkc-text) !important; }

/* ── Muñeco (sprite pixel art: 4 fotogramas de 22×22 px) ── */
.tkc-spr {
  --k: var(--tkc-k);
  display: inline-block; flex: none;
  width: calc(22px * var(--k)); height: calc(22px * var(--k));
  background-image: var(--tkc-img); background-repeat: no-repeat;
  background-size: calc(88px * var(--k)) calc(22px * var(--k));
  background-position: 0 0;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.tkc-spr[data-f="1"] { background-position: calc(-22px * var(--k)) 0; }
.tkc-spr[data-f="2"] { background-position: calc(-44px * var(--k)) 0; }
.tkc-spr[data-f="3"] { background-position: calc(-66px * var(--k)) 0; }
.tkc-spr[data-f="0"] { animation: tkc-blink 4.6s steps(1, end) infinite; }
@keyframes tkc-blink {
  0%   { background-position: 0 0; }
  92%  { background-position: calc(-22px * var(--k)) 0; }
  96%  { background-position: 0 0; }
}

/* ── Botón flotante ── */
.tkc-lw { display: flex; align-items: flex-end; gap: 10px; }
.tkc-launch {
  display: flex; align-items: flex-end; padding: 0; margin: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tkc-launch .tkc-spr { filter: drop-shadow(0 3px 0 rgba(0,0,0,.18)); animation: tkc-bob 2.4s steps(2, end) infinite; }
.tkc-launch .tkc-spr[data-f="0"] { animation: tkc-blink 4.6s steps(1, end) infinite, tkc-bob 2.4s steps(2, end) infinite; }
.tkc-launch:hover .tkc-spr, .tkc-launch:focus-visible .tkc-spr { transform: translateY(-3px); }
.tkc-launch:focus-visible { outline: 3px solid var(--tkc-accent); outline-offset: 4px; border-radius: 10px; }
@keyframes tkc-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.tkc-tease {
  position: relative; max-width: 220px; padding: 10px 28px 10px 12px; margin-bottom: 14px; text-align: left; cursor: pointer;
  background: var(--tkc-bg); color: var(--tkc-text); border: 2px solid var(--tkc-text); border-radius: 4px;
  box-shadow: 3px 3px 0 var(--tkc-text); font-size: 14px; font-weight: 600; line-height: 1.3;
}
.tkc-tease::after { content: ""; position: absolute; right: -9px; bottom: 10px; width: 10px; height: 10px; background: var(--tkc-bg);
  border-top: 2px solid var(--tkc-text); border-right: 2px solid var(--tkc-text); transform: rotate(45deg) translate(-3px, 3px); }
.tkc-tease-x { position: absolute; top: 3px; right: 3px; cursor: pointer; }
.tkc-tease[hidden] { display: none; }

/* ── Panel ── */
.tkc-panel {
  position: absolute; right: 0; bottom: 0; width: 380px; max-width: calc(100vw - 32px);
  height: min(600px, calc(100dvh - 40px)); height: min(600px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--tkc-bg); border: 1px solid var(--tkc-border); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28), 0 2px 8px rgba(0,0,0,.12);
  transform-origin: bottom right; animation: tkc-in .18s ease-out;
}
@supports (height: 100dvh) { .tkc-panel { height: min(600px, calc(100dvh - 40px)); } }
.tkc-panel[hidden] { display: none; }
@keyframes tkc-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

.tkc-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--tkc-accent); color: #fff; }
.tkc-head .tkc-spr { --k: 2; background-color: rgba(255,255,255,.16); border-radius: 8px; }
.tkc-head-t { flex: 1; min-width: 0; }
.tkc-head-t strong { display: block; font-size: 16px; line-height: 1.2; }
.tkc-head-t span { display: block; font-size: 12px; opacity: .9; }
.tkc-x:focus-visible, .tkc-send:focus-visible, .tkc-chip:focus-visible, .tkc-btn:focus-visible, .tkc-fb button:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
.tkc-body .tkc-chip:focus-visible, .tkc-body .tkc-btn:focus-visible, .tkc-fb button:focus-visible, .tkc-send:focus-visible { outline-color: var(--tkc-accent); }

.tkc-body { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scroll-behavior: smooth; }
.tkc-row { display: flex; gap: 8px; align-items: flex-end; }
.tkc-row.u { justify-content: flex-end; }
.tkc-row .tkc-spr { --k: 1; margin-bottom: 2px; }
.tkc-msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; word-wrap: break-word; overflow-wrap: anywhere; }
.tkc-row.a .tkc-msg { background: var(--tkc-bg2); color: var(--tkc-text); border-bottom-left-radius: 4px; }
.tkc-row.u .tkc-msg { background: var(--tkc-accent); color: #fff; border-bottom-right-radius: 4px; }
.tkc-msg strong { font-weight: 700; }
.tkc-msg ul { margin: 4px 0 0; padding-left: 18px; }
.tkc-msg li { margin: 2px 0; }
.tkc-acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 0 30px; }
.tkc-btn {
  display: inline-block; padding: 8px 12px; border-radius: 18px; background: var(--tkc-bg); color: var(--tkc-accent) !important;
  border: 1.5px solid var(--tkc-accent); font-weight: 600; font-size: 14px; text-decoration: none !important; line-height: 1.2;
}
.tkc-btn:hover { background: var(--tkc-accent); color: #fff !important; }
.tkc-fb { display: flex; gap: 4px; margin: -4px 0 0 30px; }
.tkc-fb button { border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; opacity: .55; color: var(--tkc-text); }
.tkc-fb button:hover { opacity: 1; background: var(--tkc-bg2); }
.tkc-fb[data-done] button { pointer-events: none; opacity: .25; }
.tkc-fb[data-done] span { font-size: 12px; color: var(--tkc-muted); align-self: center; }

.tkc-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.tkc-typing i { width: 7px; height: 7px; background: var(--tkc-muted); border-radius: 1px; animation: tkc-dot 1s steps(2, end) infinite; }
.tkc-typing i:nth-child(2) { animation-delay: .2s; } .tkc-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes tkc-dot { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.tkc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 10px; }
.tkc-chip { padding: 8px 12px; border-radius: 999px; background: var(--tkc-bg); color: var(--tkc-text); border: 1.5px solid var(--tkc-border); font: inherit; font-size: 14px; cursor: pointer; line-height: 1.2; }
.tkc-chip:hover { border-color: var(--tkc-accent); color: var(--tkc-accent); }
.tkc-chips:empty { display: none; }

.tkc-form { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 10px; border-top: 1px solid var(--tkc-border); background: var(--tkc-bg); }
.tkc-in {
  flex: 1; min-height: 42px; max-height: 110px; resize: none; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--tkc-border);
  background: var(--tkc-bg); color: var(--tkc-text); font: inherit; font-size: 16px; line-height: 1.35; outline: none;
}
.tkc-in:focus { border-color: var(--tkc-accent); }
.tkc-send { flex: none; width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--tkc-accent); color: #fff; cursor: pointer; display: grid; place-items: center; }
.tkc-send:disabled { opacity: .45; cursor: default; }
.tkc-send svg { width: 20px; height: 20px; }
.tkc-foot { padding: 0 12px 10px; font-size: 11.5px; line-height: 1.35; color: var(--tkc-muted); background: var(--tkc-bg); }
.tkc-foot a { color: inherit; text-decoration: underline; }

.tkc-open .tkc-lw { display: none; }

/* ── Móvil: hoja a pantalla completa ── */
@media (max-width: 560px) {
  #tk-chat-root { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .tkc-tease { max-width: 190px; }
  .tkc-panel { position: fixed; inset: 0; width: auto; max-width: none; height: auto; border-radius: 0; border: 0; animation: tkc-up .2s ease-out; }
  .tkc-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .tkc-form { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .tkc-msg { max-width: 86%; }
  @keyframes tkc-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
html.tkc-lock, html.tkc-lock body { overflow: hidden !important; }
@media (min-width: 561px) { html.tkc-lock, html.tkc-lock body { overflow: visible !important; } }

@media print { #tk-chat-root { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  #tk-chat-root *, #tk-chat-root *::before { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
