/* AI tools (aitools.js): Ask the Codex, AI studio, extraction / names / seed / continuity dialogs, profiles editor.
   Only theme variables are used, so light and dark both work. Class prefix: ai-t- */

.ai-t-offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- shared bits ---------- */
.ai-t-dialog { gap: 16px; }
.ai-t-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ai-t-body > * { min-width: 0; }
.ai-t-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.ai-t-dim { opacity: .62; }
.ai-t-progress { display: flex; flex-direction: column; gap: 10px; }
.ai-t-tail { max-height: 150px; }
.ai-t-nothing { margin: 0; padding: 10px 14px; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-dim); font-size: 14px; }
.ai-t-results-wrap, .ai-t-results, .ai-t-empty, .ai-t-done, .ai-t-failure { display: flex; flex-direction: column; gap: 12px; }
.ai-t-sub { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); }
.ai-t-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.ai-t-result { max-height: 52vh; overflow: auto; padding: 4px 16px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.ai-t-result h2, .ai-t-result h3 { margin-top: 14px; }

/* source / compared-article chips */
.ai-t-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ai-t-sources .connections-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-t-sources-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); }
.ai-t-sources .connection-chip { padding: 4px 11px; font-size: 12px; max-width: 100%; text-align: left; }

/* [n] citation buttons inside an answer */
.ai-t-answer { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; color: var(--text); font-size: calc(15px * var(--ts, 1)); }
.ai-t-cite {
  font: inherit; font-size: 11px; font-weight: 700; line-height: 1; vertical-align: baseline;
  min-width: 20px; padding: 2px 6px; margin: 0 1px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--accent-bright);
}
.ai-t-cite:hover { border-color: var(--accent); background: var(--bg-panel); }

/* ---------- ask page ---------- */
.ai-t-explain { margin: 4px 0 14px !important; max-width: 72ch; line-height: 1.55; }
.ai-t-log { display: flex; flex-direction: column; gap: 16px; margin-bottom: 14px; }
.ai-t-turn { display: flex; flex-direction: column; gap: 8px; }
.ai-t-q, .ai-t-a { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); min-width: 0; }
.ai-t-q { background: var(--bg-raised); align-self: flex-start; max-width: min(100%, 640px); }
.ai-t-a { background: var(--bg-panel); border-left: 3px solid var(--ai); }
.ai-t-who { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); }
.ai-t-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); font-size: calc(15px * var(--ts, 1)); }
.ai-t-empty-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ai-t-empty-log[hidden] { display: none; }
.ai-t-empty-log .chip { text-align: left; }
.ai-t-composer { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.ai-t-input {
  font: inherit; font-size: 14px; line-height: 1.5; width: 100%; resize: vertical; min-height: 72px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.ai-t-input:focus { outline: 2px solid var(--accent-bright); outline-offset: 1px; border-color: var(--accent); }

/* ---------- studio ---------- */
.ai-t-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.ai-t-card {
  font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; border: 1px solid var(--border); border-top: 3px solid var(--ai); border-radius: 12px;
  background: var(--bg-panel); color: var(--text);
}
.ai-t-card:hover { border-color: var(--accent); background: var(--bg-raised); }
.ai-t-card-title { font-weight: 700; color: var(--accent-bright); font-size: 15px; }
.ai-t-card-text { font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.ai-t-jobs-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-t-jobs-head .home-h { margin-right: auto; }
.ai-t-jobs { display: flex; flex-direction: column; gap: 8px; }
.ai-t-job { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.ai-t-job-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.ai-t-job-text { overflow-wrap: anywhere; color: var(--text); min-width: 0; }
.ai-t-job-time { margin-left: auto; }
.ai-t-job .connection-chip { padding: 3px 10px; font-size: 12px; }

/* ---------- tick lists in the extraction dialogs ---------- */
.ai-t-picklist { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); max-height: 44vh; overflow: auto; }
.ai-t-pick { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text); }
.ai-t-pick:last-child { border-bottom: 0; }
.ai-t-pick:hover { background: var(--bg-raised); }
.ai-t-pick input { accent-color: var(--accent); margin-top: 3px; flex: none; width: auto !important; }
.ai-t-pick-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.ai-t-idea-desc { display: block; margin-top: 3px; }
.ai-t-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-t-pick-chip { border: 1px solid var(--border); border-radius: 14px; padding: 4px 12px 4px 10px; background: var(--bg-raised); align-items: center; font-size: 13px; }
.ai-t-pick-chip:last-child { border-bottom: 1px solid var(--border); }
.ai-t-pick-chip input { margin-top: 0; }

/* ---------- article chooser ---------- */
.ai-t-chooser { display: flex; flex-direction: column; gap: 10px; }
.ai-t-chosen { display: flex; flex-wrap: wrap; gap: 7px; min-height: 30px; align-items: center; }
.ai-t-chosen-chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 4px 3px 11px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-raised); font-size: 13px; max-width: 100%; }
.ai-t-chosen-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.ai-t-chip-x { font: inherit; font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: 0; }
.ai-t-chip-x:hover { color: var(--bad); background: var(--bg-panel); }

/* ---------- name generator ---------- */
.ai-t-name-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); max-height: 46vh; overflow: auto; }
.ai-t-name-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ai-t-name-row:last-child { border-bottom: 0; }
.ai-t-name { font-weight: 700; color: var(--text); margin-right: auto; overflow-wrap: anywhere; min-width: 0; }

/* ---------- article toolbar ---------- */
.ai-t-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }

/* ---------- model profiles (Settings dialog) ---------- */
.ai-t-profiles { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ai-t-prof-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.ai-t-prof-table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: 13px; }
.ai-t-prof-table th, .ai-t-prof-table td { padding: 6px 8px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.ai-t-prof-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); background: var(--bg-panel); white-space: nowrap; }
.ai-t-prof-table tbody tr:last-child th, .ai-t-prof-table tbody tr:last-child td { border-bottom: 0; }
.ai-t-prof-label { font-weight: 400; color: var(--text); min-width: 150px; }
.ai-t-prof-label span { display: block; }
.ai-t-prof-hint { font-size: 11px; color: var(--text-faint); }
.ai-t-profiles input.ai-t-prof-input,
.dialog .ai-t-profiles input.ai-t-prof-input {
  font: inherit; font-size: 13px; padding: 5px 8px; width: 100%; min-width: 70px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
}
.ai-t-prof-table td:nth-child(2) input { min-width: 140px; }

/* ---------- AI inbox additions (tools.js) ---------- */
.ai-t-inbox-note { margin: 4px 0 10px; }
.ai-t-inbox-note[hidden], .ai-t-inbox-skipped[hidden] { display: none; }
.ai-t-inbox-skipped { margin: 4px 0 12px; padding: 10px 14px; border: 1px solid var(--bad); border-radius: 10px; background: var(--bg-panel); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ai-t-inbox-skiplist { margin: 0; padding-left: 18px; }
.ai-t-inbox-check { accent-color: var(--accent); width: 16px; height: 16px; margin: 0 6px 0 0; flex: none; cursor: pointer; }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .ai-t-dialog { padding: 18px 16px; }
  .ai-t-row { grid-template-columns: 1fr; }
  .ai-t-q { max-width: 100%; }
  .ai-t-chosen-title { max-width: 150px; }
  .ai-t-job-time { margin-left: 0; width: 100%; }
  .ai-t-cards { grid-template-columns: 1fr; }
}
