/* ============================================================
   Alpha Finance v2: Alpha AI
   A chat over the desk's data: a beta pill in the header, the standing
   notice, an acknowledgement gate, the conversation, and the sources
   with their times beside it. Loaded after alpha.css and article.css;
   terminal.css follows.
   ============================================================ */

body.ai .section { padding: 18px 0 24px; }

/* ---------- view header ---------- */

.aihero { border-bottom: 1px solid var(--line); }
.aihero-inner { padding: 16px 0 14px; }
.aihero h1 { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.aihero .dek { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--text-2); max-width: 760px; }
.ai-beta, .ai-beta-s {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--heat) 60%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--heat) 14%, transparent);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--heat);
  vertical-align: middle;
}
.ai-beta-s { height: 15px; padding: 0 5px; font-size: 8.5px; }
.feed {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  margin-top: 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em; color: var(--muted);
}
.feed b { font-weight: 500; color: var(--text-2); }
.feed .dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--faint); vertical-align: 1px; }
.feed.is-live .dot { background: var(--lime); box-shadow: 0 0 6px color-mix(in srgb, var(--lime) 60%, transparent); }
.feed.is-down .dot { background: var(--neg); }

/* ---------- the disclaimer, top right of the header ---------- */

.aihero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.aihero-main { min-width: 0; }
/* a text-only note, right-aligned to the title, never taller than the title block */
.ai-disc {
  flex: 0 1 300px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  margin-top: 4px;
  text-align: right;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
}
.ai-disc b { font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--heat); }
.ai-disc a { font-size: 10.5px; color: var(--muted); text-decoration: underline; }
.ai-disc a:hover { color: var(--text); }

/* ---------- layout ---------- */

.ai-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.ai-main { min-width: 0; }
.ai-side { display: flex; flex-direction: column; gap: 10px; }
.ai-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.ai-box h4 { margin-bottom: 8px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.ai-box-n { margin-top: 8px; font-size: 11px; line-height: 1.45; color: var(--muted); }
.ai-src { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.ai-src li { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-2); }
.ai-src li::before { content: ""; width: 5px; height: 5px; margin-top: 7px; border-radius: 50%; background: var(--lime); flex-shrink: 0; }
.ai-src li { justify-content: flex-start; }
.ai-src li span { flex: 1; }
.ai-src li.is-off::before { background: var(--faint); }
.ai-src li.is-off span { color: var(--muted); }
.ai-src b { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; color: var(--faint); white-space: nowrap; }
.ai-src b[hidden] { display: none; }
.ai-wont { list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }
.ai-wont li::before { content: "×"; margin-right: 8px; color: var(--neg-text); font-weight: 600; }

/* ---------- buttons ---------- */

.ai-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.ai-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); }
.ai-btn:disabled { opacity: 0.5; cursor: default; }
.ai-btn-lime { background: var(--lime); border-color: var(--lime); color: #0a0b0d; }
.ai-btn-lime:hover:not(:disabled) { color: #0a0b0d; background: var(--lime-dim); border-color: var(--lime-dim); }
.ai-btn[hidden] { display: none; }
.ai-link { border: 0; background: none; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
.ai-link:hover { color: var(--text); }

/* ---------- the gate ---------- */

/* A consent card, not a wall of text: a shield header, four cells with a mark
   each (the "not advice" cell in amber, the one that matters most), and a
   foot that carries the standing disclaimer beside the button. */
.ai-gate { border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); overflow: hidden; }
.ai-gate[hidden] { display: none; }

.ai-gate-h { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.ai-gate-ic {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--lime) 32%, var(--line-2));
  background: color-mix(in srgb, var(--lime) 8%, var(--bg));
  color: var(--lime);
}
.ai-gate-ic svg { width: 20px; height: 20px; }
.ai-gate h2 { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
.ai-gate-h p { margin-top: 3px; font-size: 12.5px; color: var(--muted); }

/* hairlines between cells come from the grid's own background showing through the gap */
.ai-gate-grid { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.ai-gate-grid li { display: flex; gap: 14px; padding: 18px 22px 19px; background: var(--panel); }
.ai-gate-grid .ic {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; margin-top: 1px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--lime-dim);
}
.ai-gate-grid .ic svg { width: 16px; height: 16px; }
.ai-gate-grid .is-warn .ic { color: var(--heat); border-color: color-mix(in srgb, var(--heat) 35%, var(--line-2)); background: color-mix(in srgb, var(--heat) 7%, var(--bg)); }
.ai-gate-grid b { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.ai-gate-grid p { margin-top: 4px; font-size: 13px; line-height: 1.55; color: var(--text-2); }

.ai-gate-f { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--bg-2); }
.ai-gate-f p { flex: 1 1 260px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }
/* the two links travel together, so the dot never ends a line on its own */
.ai-gate-links { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.ai-gate-links i { font-style: normal; color: var(--faint); }
.ai-gate-f a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.ai-gate-f a:hover { color: var(--lime); text-decoration-color: var(--lime-dim); }
.ai-gate-f .ai-btn { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ai-gate-f .ai-btn svg { width: 14px; height: 14px; transition: transform 0.15s; }
.ai-gate-f .ai-btn:hover svg { transform: translateX(2px); }

@media (max-width: 760px) {
  .ai-gate-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-gate-f .ai-btn { width: 100%; justify-content: center; }
}

/* ---------- the chat ---------- */

.ai-chat { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.ai-chat[hidden] { display: none; }
.ai-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 64vh;
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
/* one gutter down the whole column: the suggestion cards, the message
   bubbles, the ask box and the line under it all start at the log's 16px,
   so the panel reads as one edge rather than three */
.ai-empty { display: flex; flex-direction: column; gap: 16px; padding: 8px 0 4px; }
.ai-empty[hidden] { display: none; }
.ai-hello { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ai-hello-ic { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; margin-bottom: 4px; border-radius: 9px; background: rgba(200, 255, 80, 0.08); color: var(--lime); }
.ai-hello-ic svg { width: 18px; height: 18px; }
.ai-hello h3 { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.ai-hello p { max-width: 520px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.ai-sugg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ai-sugg button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 74px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-2);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.ai-sugg button small { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.ai-sugg button:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.ai-sugg button:hover small { color: var(--lime); }

.ai-msg { display: flex; flex-direction: column; max-width: 82%; }
.ai-msg.is-user { align-self: flex-end; align-items: flex-end; }
.ai-msg.is-ai, .ai-msg.is-note { align-self: flex-start; }
.ai-msg-in {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.ai-msg.is-user .ai-msg-in { background: var(--panel-2); border-color: var(--line-2); color: var(--text); border-bottom-right-radius: 3px; }
.ai-msg.is-ai .ai-msg-in { background: var(--bg-2); border-bottom-left-radius: 3px; }
.ai-msg.is-note .ai-msg-in { border-style: dashed; color: var(--muted); }
.ai-msg-in p + p, .ai-msg-in ul + p, .ai-msg-in p + ul { margin-top: 8px; }
.ai-msg-in ul { padding-left: 18px; }
.ai-msg-in li + li { margin-top: 3px; }
.ai-msg-in b { color: var(--text); font-weight: 600; }
.ai-dim { color: var(--faint); font-size: 12px; }
.ai-msg-f { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; padding: 0 4px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; color: var(--faint); }
.ai-next { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ai-next-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-right: 2px; }
.ai-next button {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
  font-size: 12px;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.ai-next button:hover { color: var(--text); border-color: var(--lime); }
/* while it waits: the feeds being read, then the model's thinking, folded to
   one line once the answer starts */
.ai-think { margin: 0; }
.ai-think summary { display: flex; align-items: center; gap: 10px; list-style: none; cursor: default; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--text-2); }
.ai-think summary::-webkit-details-marker { display: none; }
.ai-think.is-done summary { cursor: pointer; color: var(--faint); font-size: 10px; }
.ai-think.is-done summary::before { content: "\25B8"; font-size: 9px; }
.ai-think.is-done[open] summary::before { content: "\25BE"; }
.ai-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ai-steps li { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); }
.ai-steps li::before { content: "\2713"; margin-right: 6px; color: var(--pos-text); }
.ai-steps li small { margin-left: 6px; font-size: 9.5px; color: var(--faint); }
.ai-think-t { max-height: 96px; overflow: hidden; margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--line-2); font-size: 12px; line-height: 1.5; color: var(--muted); white-space: pre-wrap; }
.ai-think.is-done .ai-think-t { max-height: 260px; overflow: auto; }
.ai-think.is-done .ai-steps, .ai-think.is-done .ai-think-t { margin-top: 8px; }
.ai-think + .ai-body { margin-top: 10px; }
.ai-msg-in a { color: var(--lime); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--lime) 40%, transparent); }
.ai-msg-in a:hover { border-bottom-color: var(--lime); }
.ai-srcs { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ai-srcs a { padding: 1px 7px; border: 1px solid var(--line); border-radius: 10px; color: var(--text-2); text-decoration: none; letter-spacing: 0.03em; transition: color 0.12s, border-color 0.12s; }
.ai-srcs a:hover { color: var(--lime); border-color: var(--lime); }
.ai-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: ai-blink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: 0.2s; }
.ai-typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.ai-form { padding: 10px 16px 8px; border-top: 1px solid var(--line); background: var(--panel); }
.ai-field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-field:focus-within { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(184, 242, 75, 0.12); }
.ai-field textarea {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  padding: 6px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  resize: none;
  outline: none;
}
.ai-field textarea::placeholder { color: var(--muted); }
.ai-field textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.ai-send {
  display: inline-flex;
  width: 34px; height: 34px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  background: var(--lime);
  color: #0a0b0d;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
}
.ai-send svg { width: 16px; height: 16px; }
.ai-send:hover:not(:disabled) { background: var(--lime-dim); }
.ai-send:disabled { opacity: 0.4; cursor: default; }
.ai-send.is-stop { background: var(--panel-2); color: var(--text); }
.ai-send[hidden] { display: none; }
.ai-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 16px 10px; font-size: 11px; line-height: 1.4; color: var(--muted); }
.ai-foot-t { display: inline-flex; align-items: center; gap: 6px; }
.ai-foot .ai-link { margin-left: auto; }
.ai-quota { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--text-2); white-space: nowrap; cursor: help; }
.ai-quota.is-low { color: var(--heat); }
.ai-quota.is-out { color: var(--neg-text); }
.ai-count { font-family: var(--mono); font-size: 10px; color: var(--faint); white-space: nowrap; }
.ai-count[hidden] { display: none; }

/* ---------- responsive ---------- */

@media (max-width: 1200px) {
  .ai-sugg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .aihero-row { flex-direction: column; gap: 10px; }
  .ai-disc { flex-basis: auto; align-items: flex-start; text-align: left; margin-top: 0; }
  .ai-grid { grid-template-columns: 1fr; }
  .ai-side { flex-direction: row; flex-wrap: wrap; }
  .ai-box { flex: 1 1 260px; }
}
@media (max-width: 640px) {
  .ai-msg { max-width: 94%; }
  .ai-sugg { grid-template-columns: 1fr; }
}

/* locked for the day: the suggestions dim with the box */
.ai-sugg button:disabled, .ai-next button:disabled { opacity: 0.45; cursor: default; pointer-events: none; }
