/* PrepBuddy shared: PB's conversation, one recipe for both audiences (04-prototype/shared/ai.css, prefix ai-). Moved up from learner/shared/ai.css on 2026-10-20
   (backlog row 54, "one recipe, one file": the portal's PB panel draws the same turns), together with the AI note and the AI label, which were pursue.css's and news.css's.
   The learner's thread (chat 07; was shared/coach.css for Practice 13 until 2026-10-20, renamed with the persona, pb.md): a pushed page with the page bar, PB's avatar, the
   name and the meter; the thread; the shared message bar (.cbar.msg, learner feed.css). Two modes, one recipe: home (the whole history as topics, each under its context row,
   PB's own lines between them) and subject (the context card above the thread; from 1024 dp two columns: the context beside the conversation, a destination page, never a
   dialog). The portal's panel (admin/shared/ai-panel.css, prefix aip-) composes the same turn, note, card, citation and chip recipes. The option rows are the shared .pr-opt
   (components.css); the day chips are the conversation's .cv-day (learner conversation.css); PB's avatar is the shared mark (shared/avatar.js, PBAvatar.pb); the turn
   markup is shared/ai-turn.js (PBAiTurn). Spec: 02-foundations/components (PbAiTurn, PbAiNote, PbAiLabel, PbAiCitation, PbAiMeter). Tokens only. */

/* ---------- the layout ---------- */
.ai-wrap { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.ai-side { display: flex; flex-direction: column; gap: 8px; }
.ai-main { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
@media (min-width: 1024px) {
  .ai-wrap:not(.home) { flex-direction: row; align-items: stretch; gap: 24px; }
  .ai-wrap:not(.home) .ai-side { flex: 0 0 360px; align-self: flex-start; position: sticky; top: 16px; }
  .ai-main { flex: 1; min-width: 0; }
  /* the conversation is one centred column (2026-10-20, owner: "learner ai chat is bad"): the thread, the hello, the chips and the message bar share a 760 dp measure beside the context, and the bar is the field alone, no frame around the frame */
  .ai-main > * { width: 100%; max-width: 760px; margin-inline: auto; }
  .ai-main .cbar { margin-inline: auto; padding-inline: 0; border-top: 0; border-radius: 0; background: transparent; box-shadow: none; bottom: 16px; }
  .ai-main .cbar .box { min-height: 52px; background: var(--surface); }
  .ai-main .ai-chips .fc, .ai-main .ai-chips .chip { min-height: 40px; padding-block: 4px; font-size: calc(14px * var(--font-scale)); }
  .ai-main:has(.ai-hello) .ai-chips { justify-content: center; }
}

/* ---------- the meter (the page bar's end): n left today, a tap opens the day's count ---------- */
.ai-meter { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 999px; font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--primary-text); background: color-mix(in srgb, var(--primary) 12%, transparent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-meter .mi { font-size: 16px; }
.ai-meter.out { color: var(--warning-text); background: var(--warning-container); }
@media (max-width: 420px) { .ai-meter { padding: 4px 12px; font-size: calc(12px * var(--font-scale)); max-width: 96px; white-space: normal; text-align: center; line-height: 1.15; } .ai-meter .mi { display: none; } }   /* a phone: the name keeps its room in Tamil and Hindi */

/* ---------- the context: the question, lesson, job, company or path this topic is about ---------- */
.ai-fold { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 56px; padding: 8px 12px 8px 16px; text-align: start; color: var(--text-primary); }
.ai-fold .tx { gap: 0; }
.ai-fold .tx b { font-size: calc(14px * var(--font-scale)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-fold .tx span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.ai-fold .mi:last-child { color: var(--text-secondary); }
.ai-ctx { display: flex; flex-direction: column; gap: 8px; }
.ai-ctx .k { font-size: calc(12px * var(--font-scale)); font-weight: 700; letter-spacing: .04em; color: var(--text-secondary); }
.ai-ctx .stem { margin: 0; font-size: calc(15px * var(--font-scale)); line-height: 1.5; color: var(--text-primary); }
.ai-ctx .why { margin: 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--primary); font-size: calc(13px * var(--font-scale)); line-height: 1.5; color: var(--text-secondary); }
.ai-ctx .why b { color: var(--text-primary); }
.ai-ctx .pu-path { box-shadow: none; padding: 0; }   /* the path as the context: the same panel, inside the card */
@media (min-width: 1024px) { .ai-fold { display: none; } }   /* the context is always open beside the thread */
.ai-lesson { display: flex; align-items: center; gap: 12px; }
.ai-lesson .ic { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); }
.ai-lesson .tx { flex: initial; gap: 4px; }
.ai-lesson .tx b { font-size: calc(15px * var(--font-scale)); font-weight: 600; line-height: 1.35; }
.ai-lesson .tx span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }

/* ---------- the home thread: a topic opens with its row (the way a reply quote names what it answers); PB's first word carries a kicker ---------- */
.ai-topic { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; margin-top: 8px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); color: var(--text-primary); text-decoration: none; }
.ai-topic .ic { width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); }
.ai-topic .ic .mi { font-size: 20px; }
.ai-topic .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-topic .tx b { font-size: calc(14px * var(--font-scale)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-topic .tx span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-topic > .mi:last-child { color: var(--text-secondary); flex-shrink: 0; }
.ai-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: calc(12px * var(--font-scale)); font-weight: 700; letter-spacing: .02em; color: var(--primary-text); }
.ai-kicker .mi { font-size: 14px; }
.ai-hello { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px 8px; text-align: center; }
.ai-hello .ic { display: inline-flex; }
.ai-hello h2 { margin: 8px 0 0; font-size: calc(20px * var(--font-scale)); font-weight: 700; }
.ai-hello p { margin: 0; max-width: 360px; font-size: calc(14px * var(--font-scale)); line-height: 1.5; color: var(--text-secondary); }
.ai-hello + .ai-chips { justify-content: center; }

/* ---------- the thread: the Learner's turns at the end, PB's turns as flat blocks ---------- */
.ai-thread { display: flex; flex-direction: column; gap: 16px; padding-block: 4px 8px; }
.ai-thread .cv-day { margin: 8px 0 0; }
.ai-q { align-self: flex-end; max-width: min(85%, 520px); padding: 12px 16px; border-radius: 20px 20px 4px 20px; background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--text-primary); font-size: calc(15px * var(--font-scale)); line-height: 1.5; overflow-wrap: anywhere; }
[dir="rtl"] .ai-q { border-radius: 20px 20px 20px 4px; }
.ai-a { display: flex; gap: 12px; align-items: flex-start; }
.ai-a .av { display: inline-flex; flex-shrink: 0; }
.ai-a .bd { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-a .ai-p { margin: 0; font-size: calc(15px * var(--font-scale)); line-height: 1.6; color: var(--text-primary); overflow-wrap: anywhere; }   /* an answer paragraph (.tx is the shared text column, components.css) */
.ai-a .ai-p + .ai-p { margin-top: 4px; }
.ai-a .ai-p.dim { color: var(--text-secondary); }
.ai-a.gone .ai-p { color: var(--text-secondary); font-style: italic; }
.ai-caret { display: inline-block; width: 8px; height: 1em; margin-inline-start: 2px; vertical-align: text-bottom; border-radius: 4px; background: var(--primary); animation: ai-blink 500ms steps(2, start) infinite; }
@keyframes ai-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .ai-caret { animation: none; } }
.ai-wait { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: calc(14px * var(--font-scale)); }
.ai-wait .spinner { display: inline-block; }

/* ---------- a card instead of prose (pb.md): a practice set, a path change, a reminder, a resume check, a hand-off, the next step; for staff (2026-10-20) Take me there, Open the sheet, a checklist, the morning list, the handover ---------- */
.ai-card { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
.ai-card .ai-card-ic { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); }
.ai-card .ai-card-ic .mi { font-size: 24px; }
.ai-card .ai-card-tx { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-card .ai-card-tx b { font-size: calc(15px * var(--font-scale)); font-weight: 600; line-height: 1.35; }
.ai-card .ai-card-tx span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.ai-card .ai-card-draft { display: block; margin-top: 6px; padding: 8px 12px; border-inline-start: 3px solid var(--primary); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--primary) 6%, transparent); font-size: calc(13px * var(--font-scale)); line-height: 1.5; color: var(--text-primary); quotes: none; }
.ai-card .btn { flex-shrink: 0; }
.ai-card[data-card="PATH_CHANGE"] { flex-direction: column; align-items: stretch; }
.ai-card[data-card="PATH_CHANGE"] .pu-path { box-shadow: none; padding: 0; }
.ai-card-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
/* the weekly recap card (WEEK_RECAP, 2026-10-27, weekly-recap.md): Your week, four flat tiles in two columns (four from 600 dp), PB's one line, a round Share; no glow, no red, no down arrow */
.ai-card[data-card="WEEK_RECAP"] { flex-direction: column; align-items: stretch; gap: 10px; }
.ai-week-head { display: flex; align-items: center; gap: 8px; }
.ai-week-head b { flex: 1 1 auto; min-width: 0; font-size: calc(15px * var(--font-scale)); font-weight: 600; line-height: 1.35; }
.ai-week-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .ai-week-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ai-week-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ai-week-tile .mi { font-size: 20px; color: var(--primary-text); }
.ai-week-tile b { font-size: calc(18px * var(--font-scale)); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ai-week-tile span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.ai-week-tile b span { font-size: inherit; color: inherit; }
.ai-week-tile b.ai-week-sk { font-size: calc(14px * var(--font-scale)); font-weight: 600; line-height: 1.4; }
.ai-week-up { display: inline-flex; align-items: center; gap: 2px; font-style: normal; font-size: calc(12px * var(--font-scale)); font-weight: 600; color: var(--success-text); }
.ai-week-up .mi { font-size: 14px; color: inherit; }
.ai-week-line { margin: 0; font-size: calc(14px * var(--font-scale)); line-height: 1.5; color: var(--text-primary); }
/* the steps of a CHECKLIST or the MORNING_LIST card (2026-10-20): numbered, each with its line and a round Take me there */
.ai-card[data-card="CHECKLIST"], .ai-card[data-card="MORNING_LIST"] { flex-direction: column; align-items: stretch; gap: 8px; }
.ai-steps { margin: 0; padding: 0; list-style: none; counter-reset: ai-step; display: flex; flex-direction: column; }
.ai-steps li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 0; counter-increment: ai-step; }
.ai-steps li + li { box-shadow: 0 -1px 0 var(--border); }
.ai-steps li::before { content: counter(ai-step); width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: calc(13px * var(--font-scale)); font-weight: 700; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); font-variant-numeric: tabular-nums; }
.ai-steps .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-steps .tx b { font-size: calc(14px * var(--font-scale)); font-weight: 600; line-height: 1.35; }
.ai-steps .tx span { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.ai-steps .tbtn { flex-shrink: 0; }

/* ---------- sources under an answer, the citations of a staff answer, follow-up chips, the notes ---------- */
.ai-srcs { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-src { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 999px; font-size: calc(12px * var(--font-scale)); font-weight: 600; color: var(--text-secondary); background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
a.ai-src, button.ai-src { min-height: 44px; }
a.ai-src, a.ai-cite { text-decoration: none; }   /* a chip that opens its source is a control, not a text link: the pill is the affordance, never an underline too (the owner, 2026-11-14) */
a.ai-src:hover, button.ai-src:hover { color: var(--primary-text); }
.ai-src .mi { font-size: 16px; }
/* a citation (PbAiCitation, 2026-10-20): the kind's icon, the title, the line (a status line and date, the value in force, who and when, the rule); a proposed record says so */
.ai-cite { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 6px 12px; border-radius: 16px; font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); text-align: start; }
a.ai-cite:hover { color: var(--primary-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 55%, transparent); }
.ai-cite .mi { font-size: 16px; flex-shrink: 0; color: var(--primary-text); }
.ai-cite .tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ai-cite .tx b { font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.ai-cite .tx span { overflow-wrap: anywhere; }
.ai-cite .prop { display: inline-flex; align-items: center; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--warning-container); color: var(--warning-text); margin-inline-start: 4px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-chips .fc, .ai-chips .chip { min-height: 44px; flex: 0 1 auto; max-width: 100%; height: auto; padding-block: 8px; border-radius: 20px; white-space: normal; text-align: start; line-height: 1.25; }   /* a long follow-up wraps inside the chip instead of leaving the screen (F4 sweep, 320 dp and 1.43x text) */
.ai-note { display: flex; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--info) 12%, transparent); color: var(--text-primary); font-size: calc(13px * var(--font-scale)); line-height: 1.5; }
.ai-note .mi { font-size: 18px; flex-shrink: 0; margin-top: 1px; color: var(--info-text); }
.ai-note.warn { background: var(--warning-container); } .ai-note.warn .mi { color: var(--warning-text); }
.ai-note.err { background: var(--error-container); } .ai-note.err .mi { color: var(--error-text); }
.ai-first { margin: 0; text-align: center; font-size: calc(12px * var(--font-scale)); line-height: 1.5; color: var(--text-secondary); }

/* ---------- the AI label (PbAiLabel; was news.css .nw-ai) and the AI note (PbAiNote; was pursue.css): the label, the grounding line, the report flag. Moved here 2026-10-20 ---------- */
.nw-ai { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: calc(12px * var(--font-scale)); font-weight: 700; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); }
.nw-ai .mi { font-size: 14px; }
.nw-ai.sm { padding: 0 8px; vertical-align: 1px; } .nw-ai.sm .mi { font-size: 12px; }   /* the lead's summary line in a list: AI text is labelled wherever it shows */
.pu-ainote { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.pu-ground { order: 3; flex: 1 0 100%; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 4px; border-radius: 12px; font-size: calc(12px * var(--font-scale)); line-height: 1.4; color: var(--text-secondary); text-align: start; }   /* its own row under the label and the flag */
.pu-ground .mi { font-size: 16px; flex-shrink: 0; }
.pu-flag { margin-inline-start: auto; order: 2; }
.pu-flag:disabled { opacity: .5; }

/* ---------- the end of the day's help: replaces the composer's line ---------- */
.ai-end { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0; }
.ai-end .tx { display: block; flex: 1 1 200px; font-size: calc(14px * var(--font-scale)); line-height: 1.5; color: var(--text-primary); }
.ai-end .tx small { display: block; margin-top: 4px; font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.cbar .ai-stop { width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--error-text); background: var(--error-container); }
.cbar .ai-stop .mi { font-size: 22px; }

/* ---------- the meter's sheet ---------- */
.ai-day { display: flex; flex-direction: column; gap: 12px; }
/* the day count's bar is the shared .progress.lg (components.css), its fill primary, not reward */
.ai-day .row { display: flex; justify-content: space-between; gap: 12px; font-size: calc(14px * var(--font-scale)); color: var(--text-primary); }
.ai-day .row span:last-child { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- PB's pinned row in the chat list (chat 00): the shared chat row with PB's mark; no ring, no dot, no long press ---------- */
.ai-row .ai-av { display: inline-flex; flex-shrink: 0; }

/* ---------- What PB remembers (settings 05): the lines with a delete icon each ---------- */
.ai-mem { display: flex; flex-direction: column; }
.ai-mem .lrow .tx span { color: var(--text-secondary); }
.ai-mem-empty { padding: 24px 16px; text-align: center; color: var(--text-secondary); font-size: calc(14px * var(--font-scale)); line-height: 1.5; }
.ai-reads { display: flex; flex-direction: column; gap: 16px; margin: 4px 0 12px; }
.ai-reads > div { display: flex; gap: 12px; align-items: flex-start; font-size: calc(14px * var(--font-scale)); line-height: 1.5; color: var(--text-secondary); }
.ai-reads .mi { font-size: 22px; color: var(--primary-text); flex-shrink: 0; margin-top: 1px; }
.ai-reads b { display: block; color: var(--text-primary); }
/* the study plan card (STUDY_PLAN; study-plan.md decisions 6 to 9; backlog row 66; 2026-10-27, proposed): the title with a round pencil, the plan's progress bar (the shared .progress.lg),
   the meta line and the state's one line; the offer without a plan is the plain card row with a round calendar icon. No red, no down arrow: the state is words only */
.ai-plan { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-plan-head { display: flex; align-items: center; gap: 8px; }
.ai-plan-head b { flex: 1 1 auto; min-width: 0; font-size: calc(15px * var(--font-scale)); font-weight: 600; line-height: 1.35; }
.ai-plan-meta { margin: 0; font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }
.ai-plan-line { margin: 0; font-size: calc(14px * var(--font-scale)); line-height: 1.5; }
.ai-plan-sel { appearance: none; -webkit-appearance: none; flex: 1; min-width: 0; height: 100%; min-height: calc(var(--dn-field, 52px) - 4px); border: none; outline: none; background: transparent; color: var(--text-primary); font: inherit; font-size: calc(var(--dn-field-text, 14px) * var(--font-scale)); }   /* the plan sheet's Select in the field frame (PbSelect, the field shape) */
