/* TruthLock site assistant (chat.js). Ported from the Iron Rod Systems assistant; the rules
   below use that site's token names, mapped here onto TruthLock's palette and type in site.css. */
.tla-chat, .tla-lightbox {
  --bg: var(--paper); --bg-2: #ffffff; --fg: var(--ink); --muted: var(--ink-3); --line: var(--rule);
  --iron: #141821; --iron-fg: #e8eaf0;
  --font-display: var(--display); --font-body: var(--body); --font-mono: var(--mono);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tla-chat { --bg-2: var(--paper-2); --iron: #0b0d12; } }
:root[data-theme="dark"] .tla-chat { --bg-2: var(--paper-2); --iron: #0b0d12; }

/* ===== Site assistant ===== */
.tla-chat { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; font-family: var(--font-body); }
.tla-bubble { display: inline-flex; align-items: center; gap: 0.55rem; background: var(--fg); color: var(--bg); border: 0; border-radius: 999px; padding: 0.55rem 1rem 0.55rem 0.55rem; font: 600 0.95rem var(--font-body); cursor: pointer; box-shadow: 0 14px 30px -14px rgba(0,0,0,0.5); transition: transform 0.25s, background 0.25s; }
.tla-bubble:hover { transform: translateY(-2px); background: var(--accent); color: var(--accent-ink); }
.tla-bubble-icon { width: 34px; height: 34px; border-radius: 50%; background: transparent; color: #E9EDF1; display: grid; place-items: center; } .tla-bubble-icon svg { width: 26px; height: 26px; }
.tla-chat.open .tla-bubble-text { display: none; }
.tla-panel[hidden] { display: none !important; }
.tla-panel { padding: 0; margin: 0; position: absolute; right: 0; bottom: 60px; width: min(420px, calc(100vw - 32px)); height: min(680px, calc(100vh - 110px)); background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); box-shadow: 0 30px 60px -30px rgba(0,0,0,0.55); display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; transition: width 0.3s cubic-bezier(.2,.8,.2,1), height 0.3s cubic-bezier(.2,.8,.2,1); animation: tla-in 0.25s cubic-bezier(.2,.8,.2,1); }
@keyframes tla-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.tla-chat.wide .tla-panel { width: min(880px, calc(100vw - 32px)); height: min(880px, calc(100vh - 110px)); }
.tla-chat.wide .tla-msg { max-width: 76%; font-size: 1.02rem; } .tla-chat.wide .tla-card { max-width: 520px; } .tla-chat.wide .tla-log { padding: 1.2rem 1.4rem; }
.tla-expand { background: none; border: 0; color: var(--iron-fg); cursor: pointer; padding: 0.3rem; display: grid; place-items: center; opacity: 0.85; border-radius: 6px; }
.tla-expand:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.tla-head { display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 0.9rem; background: var(--iron); color: var(--iron-fg); }
.tla-avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.08); display: grid; place-items: center; flex: 0 0 auto; } .tla-avatar svg { width: 26px; height: 26px; color: #E9EDF1; }
.tla-head-text { flex: 1; min-width: 0; } .tla-head b { font-family: var(--font-display); font-size: 1rem; display: block; }
.tla-live { display: block; font: 500 0.7rem/1.3 var(--font-mono); color: #8f9de6; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tla-close { background: none; border: 0; color: var(--iron-fg); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.tla-log { flex: 1; overflow-y: auto; padding: 0.9rem 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; min-height: 0; overflow-anchor: none; }
.tla-msg { max-width: 92%; padding: 0.7rem 0.9rem; border-radius: 12px; font-size: 0.95rem; line-height: 1.5; }
.tla-msg p { margin: 0; } .tla-msg p + p, .tla-msg ul, .tla-msg ol, .tla-msg p + h4, .tla-msg ul + p, .tla-msg ol + p { margin-top: 0.55rem; }
.tla-msg ul, .tla-msg ol { padding-left: 1.2rem; } .tla-msg li { margin-top: 0.2rem; } .tla-msg li::marker { color: var(--accent); }
.tla-msg h4 { font: 650 0.95rem/1.3 var(--font-display); margin: 0.75rem 0 0.25rem; letter-spacing: 0; } .tla-msg h4:first-child { margin-top: 0; }
.tla-msg b { font-weight: 650; } .tla-bot b { color: var(--fg); } .tla-msg code { font: 0.85em var(--font-mono); background: color-mix(in srgb, var(--fg) 7%, transparent); padding: 0.05em 0.35em; border-radius: 4px; }
.tla-msg a { color: var(--accent); text-decoration-thickness: 1px; }
.tla-bot { background: var(--bg); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 1px 0 rgba(0,0,0,0.03); }
.tla-body > p:first-child { font-weight: 500; }
.tla-user { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 4px; }
.tla-dots { display: inline-flex; gap: 4px; padding: 0.2rem 0; } .tla-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: tla-dot 1.2s infinite ease-in-out; } .tla-dots i:nth-child(2) { animation-delay: 0.15s; } .tla-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tla-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.tla-steps { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; } .tla-steps span { font: 500 0.68rem var(--font-mono); letter-spacing: 0.03em; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 0.1rem 0.5rem; }
.tla-src { margin-top: 0.55rem; padding-top: 0.45rem; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tla-src-label, .tla-verify-label { font: 500 0.66rem var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-right: 0.2rem; }
.tla-src a { font-size: 0.78rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.55rem; text-decoration: none; color: var(--accent); }
.tla-verify { margin-top: 0.6rem; padding: 0.5rem 0.65rem; border-radius: 8px; border: 1px solid var(--line); border-left: 4px solid var(--unconfirmed); background: color-mix(in srgb, var(--unconfirmed) 8%, transparent); font-size: 0.8rem; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.6rem; align-items: center; }
.tla-verify.is-verified, .tla-verify.is-clear { border-left-color: var(--verified); background: color-mix(in srgb, var(--verified) 8%, transparent); }
.tla-verify.is-contradicted, .tla-verify.is-hold { border-left-color: var(--contradicted); background: color-mix(in srgb, var(--contradicted) 8%, transparent); }
.tla-verify-icon { width: 22px; height: 22px; color: var(--fg); } .tla-verify-icon svg { width: 22px; height: 22px; }
.tla-verify-text { display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; align-items: baseline; min-width: 0; }
.tla-verify-fast, .tla-verify-full { font-weight: 600; } .tla-verify-link { grid-column: 2; color: var(--accent); font-weight: 600; text-decoration: none; }
.tla-src a img { width: 14px; height: 14px; vertical-align: -2px; margin-right: 0.3rem; border-radius: 3px; }
.tla-card { margin-top: 0.6rem; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-2); font-size: 0.9rem; max-width: 440px; box-shadow: 0 12px 30px -24px rgba(0,0,0,0.5); }
.tla-card > b, .tla-card-body b { font-family: var(--font-display); font-size: 1rem; display: block; }
.tla-card > b { padding: 0.6rem 0.8rem 0; } .tla-card img { display: block; width: 100%; height: auto; background: var(--iron); border-bottom: 1px solid var(--line); }
.tla-card-body { padding: 0.7rem 0.8rem; } .tla-card-body p { color: var(--muted); margin-top: 0.2rem; } .tla-card-body ul { margin-top: 0.4rem; padding-left: 1.1rem; }
.tla-card-links { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.8rem 0.7rem; } .tla-card-links a { font-size: 0.8rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.6rem; text-decoration: none; color: var(--accent); }
.tla-plans { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); padding: 0.6rem 0.8rem; }
.tla-plan { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem; } .tla-plan-name { font: 500 0.68rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: block; } .tla-plan-price { font: 700 1.05rem var(--font-display); display: block; margin: 0.15rem 0 0.3rem; font-variant-numeric: tabular-nums; } .tla-plan ul { padding-left: 1rem; font-size: 0.78rem; color: var(--muted); }
.tla-card-note { padding: 0 0.8rem 0.4rem; color: var(--muted); font-size: 0.82rem; }
.tla-contact { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.8rem 0.8rem; align-items: center; } .tla-contact a { font-size: 0.85rem; } .tla-contact .btn { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.tla-chips { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.8rem 0.35rem 0.9rem; border-top: 1px solid var(--line); min-width: 0; }
.tla-chips[hidden] { display: none; }
.tla-chips-label { font: 500 0.66rem var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); flex: 0 0 auto; }
.tla-chips-row { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 2rem; }
.tla-chips-row::-webkit-scrollbar { display: none; }
.tla-chip { flex: 0 0 auto; background: transparent; border: 1px solid var(--line); color: var(--fg); border-radius: 999px; padding: 0.22rem 0.65rem; font: 500 0.8rem var(--font-body); cursor: pointer; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tla-chip:hover { border-color: var(--accent); color: var(--accent); }
.tla-form { display: flex; gap: 0.45rem; padding: 0.6rem 0.8rem; border-top: 1px solid var(--line); align-items: flex-end; }
.tla-form[hidden] { display: none; }
.tla-form textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 10px; padding: 0.55rem 0.7rem; font: 0.95rem var(--font-body); line-height: 1.4; max-height: 120px; min-width: 0; }
.tla-send, .tla-mic { width: 40px; height: 40px; border-radius: 50%; border: 0; font-size: 1.1rem; cursor: pointer; flex: 0 0 auto; }
.tla-send { background: var(--fg); color: var(--bg); } .tla-send:disabled { opacity: 0.4; cursor: default; }
.tla-mic { background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; } .tla-mic[hidden] { display: none; } .tla-mic.on { color: #fff; background: var(--contradicted); border-color: var(--contradicted); animation: tla-pulse 1s infinite; }
@keyframes tla-pulse { 50% { box-shadow: 0 0 0 6px rgba(192,57,43,0.25); } }
.tla-lead { display: grid; gap: 0.45rem; padding: 0.7rem 0.8rem; border-top: 1px solid var(--line); } .tla-lead[hidden] { display: none; }
.tla-lead-head { display: flex; justify-content: space-between; align-items: center; } .tla-lead-head b { font-family: var(--font-display); }
.tla-lead-x { background: none; border: 0; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
.tla-lead input, .tla-lead textarea { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 8px; padding: 0.5rem 0.65rem; font: 0.92rem var(--font-body); width: 100%; }
.tla-lead-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; } .tla-lead-note { font-size: 0.78rem; color: var(--muted); } .tla-lead .btn { padding: 0.5rem 0.9rem; font-size: 0.9rem; }
.tla-lead-msg { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.tla-foot { display: flex; gap: 0.5rem; justify-content: center; padding: 0.4rem 0.8rem 0.6rem; font-size: 0.78rem; color: var(--muted); }
.tla-link { color: var(--muted); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.tla-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 520px) { .tla-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; bottom: 0; } .tla-chat.open .tla-bubble { display: none; } .tla-expand { display: none; } }
@media (prefers-reduced-motion: reduce) { .tla-bubble, .tla-panel { transition: none; animation: none; } .tla-dots i, .tla-mic.on { animation: none; } }

.tla-verify-btn { grid-column: 2; justify-self: start; background: transparent; border: 1px solid var(--line); color: var(--accent); border-radius: 999px; padding: 0.2rem 0.7rem; font: 600 0.78rem var(--font-body); cursor: pointer; }
.tla-verify-btn:hover { border-color: var(--accent); } .tla-verify-btn:disabled { opacity: 0.6; cursor: default; }

.tla-verify-why { font-size: 0.78rem; color: var(--muted); width: 100%; } .tla-verify-why summary { cursor: pointer; color: var(--accent); font-weight: 600; } .tla-verify-why p { margin: 0.25rem 0 0; }

.tla-verify.is-available { border-left-color: var(--line); background: transparent; }
.tla-verify.is-pending { border-left-color: var(--unconfirmed); }
.tla-verify.is-supported { border-left-color: var(--verified); background: color-mix(in srgb, var(--verified) 8%, transparent); }
.tla-verify.is-unconfirmed { border-left-color: var(--unconfirmed); }
.tla-verify-dots { grid-column: 2; }

/* ===== Image viewer ===== */
.tla-card img { cursor: zoom-in; }
.tla-lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10,13,17,0.92); display: grid; place-items: center; padding: clamp(16px, 4vw, 48px); cursor: zoom-out; }
.tla-lightbox[hidden] { display: none; }
.tla-lightbox figure { margin: 0; max-width: min(1400px, 100%); max-height: 100%; display: grid; gap: 0.6rem; justify-items: center; }
.tla-lightbox img { max-width: 100%; max-height: calc(100vh - 110px); width: auto; height: auto; border-radius: 8px; box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8); background: #fff; cursor: zoom-out; }
.tla-lightbox figcaption { color: #E9EDF1; font: 0.9rem var(--font-body); text-align: center; }
.tla-lb-close { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; background: #fff; color: #1F262E; border: 0; border-radius: 999px; padding: 0.55rem 1rem; font: 600 0.95rem var(--font-body); cursor: pointer; box-shadow: 0 8px 24px -8px rgba(0,0,0,0.6); }
.tla-lb-close:hover { background: var(--unconfirmed); }
body.tla-lb-open { overflow: hidden; }

.tla-card video { display: block; width: 100%; height: auto; background: #000; aspect-ratio: 16 / 9; }

/* ===== Chat panel: stand off the page ===== */
.tla-panel { --tla-surface: #FFFFFF; background: var(--tla-surface); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), 0 40px 90px -30px rgba(0,0,0,0.55), 0 10px 30px -14px rgba(0,0,0,0.35); }
.tla-panel .tla-log { background: color-mix(in srgb, var(--accent) 3%, var(--tla-surface)); }
.tla-bot { background: var(--tla-surface); }
.tla-form, .tla-chips, .tla-foot, .tla-lead { background: var(--tla-surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tla-panel { --tla-surface: #1C242E; border-color: color-mix(in srgb, #8f9de6 40%, var(--line)); box-shadow: 0 0 0 4px rgba(143,157,230,0.14), 0 40px 90px -30px rgba(0,0,0,0.85), 0 10px 30px -14px rgba(0,0,0,0.6); } }
:root[data-theme="dark"] .tla-panel { --tla-surface: #1C242E; border-color: color-mix(in srgb, #8f9de6 40%, var(--line)); box-shadow: 0 0 0 4px rgba(143,157,230,0.14), 0 40px 90px -30px rgba(0,0,0,0.85), 0 10px 30px -14px rgba(0,0,0,0.6); }
.tla-bubble { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), 0 14px 30px -14px rgba(0,0,0,0.6); }
.tla-verify.is-live { border-left-color: var(--muted); background: color-mix(in srgb, var(--fg) 4%, transparent); display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; align-items: baseline; }
.tla-verify.is-live .tla-verify-badge { font: 600 0.72rem var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tla-verify.is-live .tla-verify-text { display: inline; color: var(--muted); font-size: 0.85rem; }

.tla-chip-more { border-style: dashed; color: var(--muted); flex: 0 0 auto; } .tla-chip-more::before { content: "↻ "; }
.tla-open { display: inline-block; margin-top: 0.6rem; font-size: 0.9rem; padding: 0.5rem 0.9rem; }
