/* ============================================================
   AI demo section — "Ask the engine"
   BYOK chat, login-gated, real LLM, ephemeral session memory
   ============================================================ */
.ask { background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; }
.ask-grid { display: grid; grid-template-columns: 0.82fr 1.18fr; gap: 48px; align-items: stretch; margin-top: 44px; }
@media (max-width: 940px){ .ask-grid { grid-template-columns: 1fr; gap: 30px; } }

.ask-copy .lede { margin-bottom: 26px; }
.ask-facts { display: grid; gap: 0; border-top: 1px solid var(--border); }
.ask-facts .row { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: start; }
.ask-facts .row .k { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.ask-facts .row .v { font-size: 14.5px; color: var(--text-2); }
.ask-facts .row .v b { color: var(--text); font-weight: 600; }

/* chat shell */
.chat {
  display: flex; flex-direction: column; height: 620px; max-height: 82vh;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.chat-av { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chat-av svg { width: 19px; height: 19px; }
.chat-id { line-height: 1.2; }
.chat-id .nm { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.chat-id .nm .live { font-size: 10px; letter-spacing: .08em; color: #5fb87a; border: 1px solid color-mix(in srgb,#5fb87a 40%, transparent); border-radius: 5px; padding: 1px 5px; font-weight: 600; }
.chat-id .nm .off { color: var(--muted); border-color: var(--border-2); }
.chat-id .sub { font-size: 12px; color: var(--muted); }
.chat-chips { margin-left: auto; display: flex; gap: 7px; }
.chat-chip { font-size: 11px; color: var(--text-2); border: 1px solid var(--border-2); border-radius: 999px; padding: 3px 9px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chat-chip .d { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
@media (max-width: 560px){ .chat-chips { display: none; } }

/* messages */
.chat-body { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 86%; }
.msg .b { padding: 11px 14px; border-radius: 13px; font-size: 14.5px; line-height: 1.55; }
.msg.bot { align-self: flex-start; }
.msg.bot .b { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; color: var(--text); }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .b { background: var(--accent-btn); color: #fff; border-top-right-radius: 4px; }
.msg .ic { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); align-self: flex-end; }
.msg .ic svg { width: 15px; height: 15px; }
.msg.me .ic { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.msg .b a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg .nav-pill { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 4px 9px; }

/* typing dots */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bob 1s infinite; }
.typing i:nth-child(2){ animation-delay: .15s; } .typing i:nth-child(3){ animation-delay: .3s; }
@keyframes bob { 0%,60%,100%{ transform: translateY(0); opacity:.5; } 30%{ transform: translateY(-4px); opacity:1; } }

/* suggestion chips */
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.sug { font-size: 12.5px; color: var(--text-2); border: 1px solid var(--border-2); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: all .18s; }
.sug:hover { border-color: var(--accent); color: var(--accent); }

/* input */
.chat-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface-2); align-items: flex-end; }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  border-radius: 11px; padding: 11px 13px; font: inherit; font-size: 14.5px; line-height: 1.45; max-height: 120px; min-height: 44px;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }
.chat-input textarea:disabled { opacity: .5; cursor: not-allowed; }
.send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 11px; background: var(--accent-btn); color: #fff;
  cursor: pointer; display: grid; place-items: center; transition: background .2s, opacity .2s;
}
.send:hover { background: var(--accent-btn-h); }
.send:disabled { opacity: .4; cursor: not-allowed; }
.send svg { width: 19px; height: 19px; }
.chat-foot { font-size: 11.5px; color: var(--muted); padding: 0 18px 14px; display: flex; justify-content: space-between; gap: 10px; }
.chat-foot .turns b { color: var(--text-2); }

/* lock overlay (logged-out / no key) */
.chat-lock {
  position: absolute; inset: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(7px); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; gap: 14px;
}
.chat-lock.hidden { display: none; }
.chat-lock .lockic { width: 50px; height: 50px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.chat-lock .lockic svg { width: 25px; height: 25px; }
.chat-lock h4 { margin: 0; font-size: 19px; }
.chat-lock p { margin: 0; font-size: 14px; color: var(--text-2); max-width: 36ch; }

/* key modal */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(5,8,14,0.62); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(480px, 100%); background: var(--surface); border: 1px solid var(--border-2); border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6); overflow: hidden; transform: translateY(10px) scale(.98); transition: transform .25s;
  max-height: 92vh; overflow-y: auto;
}
.modal-back.open .modal { transform: none; }
.modal-head { padding: 20px 22px 0; }
.modal-head h3 { margin: 0 0 4px; font-size: 19px; }
.modal-head p { margin: 0; font-size: 13.5px; color: var(--muted); }
.modal-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px; }

/* login step */
.step { border: 1px solid var(--border); border-radius: 12px; padding: 15px; background: var(--surface-2); }
.step.done { border-color: color-mix(in srgb,#5fb87a 45%, transparent); }
.step .st-top { display: flex; align-items: center; gap: 10px; }
.step .st-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.step.done .st-n { background: #5fb87a; color: #fff; }
.step .st-t { font-size: 14.5px; font-weight: 600; }
.step .st-d { font-size: 13px; color: var(--text-2); margin: 8px 0 0; }

.warn { border: 1px solid color-mix(in srgb, #e0a23c 40%, transparent); background: color-mix(in srgb, #e0a23c 9%, transparent); border-radius: 11px; padding: 13px 14px; display: flex; gap: 11px; }
.warn .wic { color: #e0a23c; flex: none; }
.warn .wic svg { width: 19px; height: 19px; }
.warn p { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.warn p b { color: var(--text); font-weight: 600; }

.cost { border: 1px solid var(--border-2); border-radius: 11px; overflow: hidden; }
.cost .ct { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 14px 6px; }
.cost .cr { display: flex; justify-content: space-between; padding: 7px 14px; font-size: 13.5px; border-top: 1px solid var(--border); color: var(--text-2); }
.cost .cr b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cost .cr .est { color: var(--muted); font-size: 11.5px; }

.keyfield { display: flex; flex-direction: column; gap: 7px; }
.keyfield label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.keyfield input {
  border: 1px solid var(--border-2); background: var(--code-bg); color: var(--text); border-radius: 10px;
  padding: 11px 13px; font-family: "JetBrains Mono", monospace; font-size: 13px;
}
.keyfield input:focus { outline: none; border-color: var(--accent); }
.keyfield input:disabled { opacity: .45; }

/* provider + model picker */
.modelpick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mp-col { display: flex; flex-direction: column; gap: 7px; }
.mp-col label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.selwrap { position: relative; }
.selwrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.selwrap select {
  width: 100%; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border-2); background: var(--code-bg); color: var(--text);
  border-radius: 10px; padding: 11px 30px 11px 13px; font: inherit; font-size: 13.5px; cursor: pointer;
  font-family: "JetBrains Mono", monospace;
}
.selwrap select:focus { outline: none; border-color: var(--accent); }
.selwrap select:disabled { opacity: .45; cursor: not-allowed; }

/* editable model field */
.modelin {
  width: 100%; border: 1px solid var(--border-2); background: var(--code-bg); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-family: "JetBrains Mono", monospace; font-size: 13.5px;
}
.modelin:focus { outline: none; border-color: var(--accent); }
.modelin:disabled { opacity: .45; cursor: not-allowed; }
.mp-hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }

.modal label.chk { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; line-height: 1.45; }
.modal label.chk input { margin-top: 2px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.modal-acts { display: flex; gap: 10px; }
.modal-acts .btn { flex: 1; justify-content: center; }
.modal-x { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px; }

/* connected key bar */
.keybar { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); }
.keybar .ok { color: #5fb87a; }
.keybar .km { font-family: "JetBrains Mono", monospace; color: var(--text); }
.keybar button { margin-left: auto; background: none; border: 1px solid var(--border-2); color: var(--text-2); border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; transition: all .18s; }
.keybar button:hover { border-color: #d4694a; color: #d4694a; }
