/* Claude assistant: chat layout, message thread, confirmation cards, composer, Brief me and Plan my day.
   Tokens from app.css only, so light and dark both follow the theme. */

.ai-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.ai-layout + .card { margin-top: var(--s5); }

/* ---------- conversation list */
.ai-convs { position: sticky; top: 74px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; overflow: hidden; }
.ai-convs .card-head .more { margin-left: auto; }
.ai-conv-list { list-style: none; margin: 0; padding: var(--s2); overflow-y: auto; flex: 1 1 auto; scrollbar-width: thin; }
.ai-conv-list a { display: block; padding: 10px var(--s3); border-radius: 10px; color: var(--text); }
.ai-conv-list a:hover { background: var(--surface-2); text-decoration: none; }
.ai-conv-list a[aria-current="page"] { background: var(--accent-soft); }
.ai-conv-title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-conv-meta { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.ai-pending-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--violet); display: inline-block; }
.ai-quick { padding: 0 var(--s4) var(--s4); border-top: 1px solid var(--border); }
.ai-quick .divider-label { margin-top: var(--s4); }
.ai-quick-grid { display: flex; flex-wrap: wrap; gap: var(--s2); }
.ai-quick-grid .chip { color: var(--text-2); }
.ai-quick-grid .chip:hover { background: var(--accent-soft); color: var(--accent-text); text-decoration: none; }

/* ---------- chat panel */
.ai-chat { display: flex; flex-direction: column; min-height: 620px; }
.ai-chat-head { gap: var(--s2); }
.ai-chat-title { min-width: 0; }
.ai-chat-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.ai-conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.ai-conn.on .ai-conn-dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.ai-conn.off .ai-conn-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.ai-scroll { flex: 1 1 auto; padding: var(--s6) var(--s6) var(--s4); background:
  radial-gradient(120% 60% at 100% 0%, var(--accent-soft) 0%, transparent 60%); border-radius: 0; }

/* ---------- welcome */
.ai-welcome { max-width: 620px; margin: var(--s6) auto var(--s4); text-align: center; }
.ai-welcome-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; color: #fff;
  background-color: var(--primary); background-image: linear-gradient(135deg, var(--primary) 0%, var(--violet) 140%);
  box-shadow: var(--shadow-2); margin-bottom: var(--s4); }
.ai-welcome h3 { font-size: 22px; margin-bottom: var(--s2); }
.ai-welcome > p { max-width: 52ch; margin: 0 auto var(--s5); }
.ai-suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); text-align: left; }
.ai-suggestions form { display: block; }
.ai-suggestion { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: var(--s2);
  justify-content: space-between; padding: 12px var(--s4); border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: 14px; box-shadow: var(--shadow-1); line-height: 1.35; }
.ai-suggestion .icon { color: var(--faint); }
.ai-suggestion:hover { border-color: var(--border-strong); background: var(--surface-2); }
.ai-suggestion:hover .icon { color: var(--accent); }
.ai-suggestion:focus-visible { box-shadow: var(--focus); }

/* ---------- thread */
.ai-thread { list-style: none; margin: 0 auto; padding: 0; max-width: 760px; display: flex; flex-direction: column; gap: var(--s5); }
.ai-msg { display: flex; gap: var(--s3); min-width: 0; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: min(78%, 560px); padding: 10px var(--s4); border-radius: 16px 16px 4px 16px; background: var(--primary);
  color: var(--on-primary); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; box-shadow: var(--shadow-1); }
.ai-avatar { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--accent-text);
  background: var(--accent-soft); border: 1px solid var(--border); margin-top: 2px; }
.ai-body { flex: 1 1 auto; min-width: 0; }
.ai-looked { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ai-looked::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.ai-msg.quiet .ai-looked { margin: 6px 0 0; }
.ai-text { line-height: 1.6; overflow-wrap: anywhere; color: var(--text); }
.ai-text p { margin: 0 0 var(--s3); }
.ai-text p:last-child, .ai-text ul:last-child, .ai-text ol:last-child { margin-bottom: 0; }
.ai-text ul, .ai-text ol { margin: 0 0 var(--s3); padding-left: 1.3em; }
.ai-text li { margin: 3px 0; }
.ai-text li::marker { color: var(--accent); }
.ai-text .ai-h { font-weight: 600; margin-bottom: var(--s2); }
.ai-text code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.ai-msg.event { justify-content: center; }
.ai-msg.event span { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; max-width: 100%; text-align: center; overflow-wrap: anywhere; }
.ai-end { height: 1px; }

/* ---------- confirmation card */
.ai-action { margin-top: var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  box-shadow: var(--shadow-2); overflow: hidden; max-width: 560px; position: relative; }
.ai-action::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--violet), var(--lavender)); }
.ai-action.done::before { background: var(--good); } .ai-action.cancelled::before, .ai-action.expired::before { background: var(--border-strong); }
.ai-action.failed::before { background: var(--danger); }
.ai-action.cancelled, .ai-action.expired { box-shadow: none; }
.ai-action-head { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4) 0 var(--s5); }
.ai-action-icon { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.ai-action.done .ai-action-icon { background: var(--good-soft); color: var(--good); }
.ai-action.failed .ai-action-icon { background: var(--danger-soft); color: var(--danger); }
.ai-action.cancelled .ai-action-icon, .ai-action.expired .ai-action-icon { background: var(--neutral-soft); color: var(--neutral); }
.ai-action-kicker { font: 600 11px/1.3 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); }
.ai-action.done .ai-action-kicker { color: var(--good); } .ai-action.failed .ai-action-kicker { color: var(--danger); }
.ai-action.cancelled .ai-action-kicker, .ai-action.expired .ai-action-kicker { color: var(--muted); }
.ai-action-title { font-weight: 600; margin-top: 2px; }
.ai-action.cancelled .ai-action-title, .ai-action.expired .ai-action-title { color: var(--muted); }
.ai-action-lines { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--s4); margin: var(--s3) var(--s4) 0 var(--s5);
  padding: var(--s3) 0 0; border-top: 1px dashed var(--border); font-size: 13.5px; }
.ai-action-lines dt { color: var(--muted); } .ai-action-lines dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.ai-action-note { margin: var(--s3) var(--s4) 0 var(--s5); font-size: 13px; color: var(--muted); }
.ai-action-buttons { padding: var(--s3) var(--s4) var(--s4) var(--s5); }
.ai-action-buttons form { display: flex; gap: var(--s2); flex-wrap: wrap; }
.ai-action > :last-child:not(.ai-action-buttons) { margin-bottom: var(--s4); }

/* ---------- composer */
.ai-composer { padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--border); background: var(--surface);
  border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0; }
.ai-composer-box { display: flex; align-items: flex-end; gap: var(--s2); padding: 6px 6px 6px var(--s4); border: 1px solid var(--border-strong);
  border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-1); max-width: 820px; margin: 0 auto; }
.ai-composer-box:focus-within { border-color: var(--violet); box-shadow: var(--focus); }
.ai-composer textarea { flex: 1 1 auto; min-width: 0; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  font: 400 15px/1.5 var(--font); padding: 8px 0; min-height: 40px; max-height: 220px; }
.ai-composer textarea::placeholder { color: var(--faint); }
.ai-send { height: 40px; border-radius: 12px; }
.ai-composer-foot { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; font-size: 12px; color: var(--muted);
  max-width: 820px; margin: var(--s2) auto 0; }
.ai-keys kbd { font-size: 10.5px; }
.ai-working { display: flex; align-items: center; gap: var(--s2); justify-content: center; font-size: 13px; color: var(--muted); margin-top: var(--s2); }
.ai-working[hidden] { display: none; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .3; animation: ai-pulse 1.2s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-pulse { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.ai-composer.busy .ai-send { opacity: .6; pointer-events: none; }
.ai-msg.pending .ai-bubble { opacity: .75; }

/* ---------- Brief me and Plan my day */
.ai-brief-text { font-size: 15px; }
.ai-mistakes { margin-top: var(--s4); }
.ai-brief .card-head .status { margin-left: auto; }
.ai-brief .card-head .more { margin-left: var(--s2); }
.ai-brief .status.ai-dot-only { width: 10px; height: 10px; padding: 0; border-radius: 50%; background: currentColor; flex: none; }
.ai-plan-filter { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding-bottom: var(--s3); }
.ai-plan-phrase { padding-top: 0; }
.ai-timeline { list-style: none; margin: 0; padding: 0 var(--s5) var(--s3); }
.ai-tl { display: flex; align-items: flex-start; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--border); }
.ai-tl:last-child { border-bottom: 0; }
.ai-tl-time { flex: none; width: 92px; font: 600 12.5px/1.5 var(--font); color: var(--text-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ai-tl-bar { flex: none; width: 4px; align-self: stretch; border-radius: 4px; background: linear-gradient(180deg, var(--violet), var(--lavender)); }
.ai-tl.event .ai-tl-bar { background: var(--border-strong); }
.ai-tl.event .title { color: var(--text-2); }
.ai-tl .title { font-weight: 500; }
.ai-tl .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: var(--s2); flex-wrap: wrap; }
.ai-tl .meta > * + *::before { content: "·"; margin-right: var(--s2); color: var(--faint); }
.ai-overdue { color: var(--danger); font-weight: 600; }
.ai-unplaced { padding-top: 0; }
.ai-unplaced ul { margin: 0; padding-left: 1.2em; }
.ai-plan-foot form { gap: var(--s3); }

/* ---------- wide screens: the thread scrolls inside the panel, the composer stays at its foot */
@media (min-width: 1081px) {
  .ai-chat { height: calc(100vh - 96px); min-height: 560px; max-height: 980px; position: sticky; top: 74px; }
  .ai-scroll { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
  .ai-composer { position: static; }
}

/* ---------- responsive */
@media (max-width: 1180px) { .ai-layout { grid-template-columns: 250px minmax(0, 1fr); } }
@media (max-width: 1080px) {
  .ai-layout { grid-template-columns: minmax(0, 1fr); }
  .ai-convs { position: static; max-height: none; order: 2; }
  .ai-conv-list { max-height: 260px; }
}
@media (max-width: 600px) {
  .ai-scroll { padding: var(--s4) var(--s4) var(--s3); }
  .ai-composer { padding: var(--s3) var(--s3) var(--s3); }
  .ai-suggestions { grid-template-columns: minmax(0, 1fr); }
  .ai-bubble { max-width: 88%; }
  .ai-avatar { display: none; }
  .ai-keys { display: none; }
  .ai-send span { display: none; }
  .ai-send { width: 40px; padding: 0; }
  .ai-chat { min-height: 0; }
  .ai-welcome { margin-top: var(--s2); }
  .ai-action-lines { grid-template-columns: minmax(0, 1fr); gap: 0; } .ai-action-lines dd { margin-bottom: var(--s2); }
  .ai-timeline { padding: 0 var(--s4) var(--s3); }
  .ai-tl-time { width: 80px; }
}

/* ---------- 2.0: Ask Claude about this, protection, How I got this */
.ai-about { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s6); border-bottom: 1px solid var(--border);
  background: var(--surface-2); min-width: 0; }
.ai-about-icon { flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); }
.ai-about .grow { min-width: 0; }
.ai-about-kicker { display: block; font-size: 12px; color: var(--muted); }
.ai-about-title { display: block; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-about-hint { flex: none; }
.ai-about.lost .ai-about-icon { background: var(--warn-soft); color: var(--warn); }
.ai-protect { display: inline-flex; align-items: center; gap: 4px; margin-left: var(--s2); color: var(--text-2); white-space: nowrap; }
.ai-protect .icon { color: var(--good); }

.ai-how { margin-top: var(--s3); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.ai-how > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding: 8px var(--s3); font-size: 13px; color: var(--text-2); border-radius: 12px; min-height: 24px; }
.ai-how > summary::-webkit-details-marker { display: none; }
.ai-how > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s ease; margin-right: 2px; }
.ai-how[open] > summary::before { transform: rotate(45deg); }
.ai-how > summary:hover { background: var(--surface-2); }
.ai-how > summary:focus-visible { box-shadow: var(--focus); outline: none; }
.ai-how-label { font-weight: 600; color: var(--text); }
.ai-how-protect { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--good); }
.ai-how-protect.demo { color: var(--text-2); }
.ai-how-body { padding: 0 var(--s3) var(--s3); display: grid; gap: var(--s2); font-size: 13px; }
.ai-how-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: var(--s2); align-items: start; }
.ai-how-k { color: var(--muted); font-size: 12px; padding-top: 1px; }
.ai-how-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; overflow-wrap: anywhere; }
.ai-how-chips { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-how-chips .chip { font-size: 12px; }
.ai-how-err { color: var(--danger); }

.ai-models { border-top: 1px solid var(--border); }
.ai-model-list { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: 6px; }
.ai-model-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.ai-model-role { font-weight: 600; min-width: 88px; }

@media (max-width: 640px) {
  .ai-about { padding: 10px var(--s4); flex-wrap: wrap; }
  .ai-about-hint { display: none; }
  .ai-how-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ai-protect { margin-left: 0; }
}
