/* 3.2 ai: the floating assistant (bottom right on every signed-in page) and Administration > AI assistant.
   The button sits above the phone tab bar and above the "create" button (.fab) on My day and Tasks; at 600 px and
   below the panel becomes a full-height sheet that stops at the tab bar. */

.ai-fly { --fly-size: 56px; --fly-gap: var(--s6); --fly-bottom: calc(var(--fly-gap) + var(--safe-bottom)); }
.ai-fly-btn { position: fixed; z-index: 42; right: calc(var(--fly-gap) + var(--safe-right)); bottom: var(--fly-bottom);
  display: grid; place-items: center; width: var(--fly-size); height: var(--fly-size); border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 130%); color: #FFFFFF;
  box-shadow: 0 10px 28px -8px rgba(21, 16, 42, .55), 0 0 0 1px rgba(255, 255, 255, .08) inset;
  transition: transform .15s ease, box-shadow .15s ease; }
.ai-fly-btn:hover { transform: translateY(-1px); text-decoration: none; filter: brightness(1.08); }
.ai-fly-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.ai-fly-mark, .ai-fly-head-mark { display: block; width: 30px; height: 30px; background: #FFFFFF;
  -webkit-mask: url(../brand/core-mark.svg) center / contain no-repeat; mask: url(../brand/core-mark.svg) center / contain no-repeat; }
.ai-fly-head-mark { width: 26px; height: 26px; flex: none; background: var(--accent-text); }
.ai-fly.is-open .ai-fly-btn { box-shadow: 0 0 0 3px var(--lavender, #D9CCFF), 0 10px 28px -8px rgba(21, 16, 42, .55); }
.ai-fly.is-here .ai-fly-btn { display: none; }      /* the full assistant is already on the page */

.ai-fly-panel { position: fixed; z-index: 70; right: calc(var(--fly-gap) + var(--safe-right));
  bottom: calc(var(--fly-bottom) + var(--fly-size) + var(--s3)); width: min(400px, calc(100vw - 2 * var(--s4)));
  height: min(600px, calc(100vh - var(--fly-size) - 3 * var(--s6))); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop); overflow: hidden; }
.ai-fly-panel[hidden] { display: none; }
.ai-fly-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s4) var(--s2) var(--s5); }
.ai-fly-titles { flex: 1 1 auto; min-width: 0; }
.ai-fly-head h2 { font: 700 18px/1.2 var(--font-display); margin: 2px 0 0; }
.ai-fly-status { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 0 var(--s5) var(--s3);
  font-size: 12.5px; line-height: 1.4; color: var(--muted); border-bottom: 1px solid var(--border); }
.ai-fly-status .icon { flex: none; margin-top: 2px; color: var(--accent-text); }
.ai-fly-scroll { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--s4) var(--s5); }
.ai-fly-log { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.ai-fly-log > li { min-width: 0; overflow-wrap: anywhere; }
.ai-fly-hello p { margin: 0 0 var(--s3); color: var(--text-2); }
.ai-fly-try { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.ai-fly-try .chip { cursor: pointer; font: inherit; font-size: 13px; min-height: 32px; }
.ai-fly-q { justify-self: end; max-width: 88%; padding: var(--s2) var(--s3); border-radius: 14px 14px 4px 14px;
  background: var(--primary); color: #FFFFFF; }
.ai-fly-a { padding: var(--s3); border-radius: 14px 14px 14px 4px; background: var(--surface-2); border: 1px solid var(--border); }
.ai-fly-a p { margin: 0 0 var(--s2); } .ai-fly-a p:last-child { margin-bottom: 0; }
.ai-fly-a ul, .ai-fly-a ol { margin: 0 0 var(--s2); padding-left: 1.2em; }
.ai-fly-a.error { background: transparent; border-color: #B91C1C; }
.ai-fly-note { margin: var(--s2) 0 0; font-size: 12.5px; color: var(--muted); }
.ai-fly-cards { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.ai-fly-cards > li, .ai-fly-a { min-width: 0; max-width: 100%; }
.ai-fly-log { grid-template-columns: minmax(0, 1fr); }
.ai-fly-card { display: flex; min-width: 0; max-width: 100%; align-items: center; gap: var(--s3); min-height: 44px; padding: 6px var(--s3); border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.ai-fly-card:hover { background: var(--surface-3); text-decoration: none; }
.ai-fly-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.ai-fly-card .icon { flex: none; color: var(--accent-text); }
.ai-fly-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.ai-fly-card-label { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.ai-fly-card-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-fly-open { margin-top: var(--s3); }
.ai-fly-working { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 13px; }
.ai-fly-working i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ai-fly-dot 1s infinite ease-in-out; }
.ai-fly-working i:nth-child(2) { animation-delay: .15s; } .ai-fly-working i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-fly-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-fly-working i { animation: none; } .ai-fly-btn { transition: none; } }
.ai-fly-form { display: flex; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.ai-fly-form .input { flex: 1 1 auto; min-width: 0; }
.ai-fly-send { flex: none; padding-left: var(--s3); padding-right: var(--s3); }
.ai-fly-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: 0 var(--s4) var(--s3); font-size: 12px; color: var(--muted); }
.ai-fly-foot form { margin: 0; }
.ai-fly-linkbtn { border: 0; background: none; padding: 4px 0; min-height: 24px; font: inherit; color: var(--accent-text); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; }
.ai-fly-linkbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* room at the end of every page so the button never covers the last line */
body:has(.ai-fly:not(.is-here)) .content { padding-bottom: calc(var(--s12) + 56px); }

@media (max-width: 900px) {
  .ai-fly { --fly-size: 50px; --fly-gap: var(--s4); --fly-bottom: calc(var(--tabbar-h, 0px) + var(--safe-bottom) + var(--s4)); }
  /* My day and Tasks show the round "create" button in the same corner: sit above it */
  .has-fab .ai-fly { --fly-bottom: calc(var(--tabbar-h, 0px) + var(--safe-bottom) + var(--s4) + 58px + var(--s3)); }
  .ai-fly-mark { width: 26px; height: 26px; }
  body:has(.ai-fly:not(.is-here)) .content {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--fab-room, 0px) + 50px + var(--s8)); }
  .ai-fly-keys { display: none; }
}
@media (max-width: 600px) {
  /* a full-height sheet above the tab bar */
  .ai-fly-panel { left: 0; right: 0; top: 0; bottom: calc(var(--tabbar-h, 0px) + var(--safe-bottom)); width: auto; height: auto;
    border-radius: 0; border: 0; border-bottom: 1px solid var(--border); padding-top: var(--safe-top);
    padding-left: var(--safe-left); padding-right: var(--safe-right); }
  .ai-fly.is-open .ai-fly-btn { display: none; }
  .ai-fly-form .input { font-size: 16px; }
  .ai-fly-head .icon-btn { width: var(--tap, 44px); height: var(--tap, 44px); }
}
@media print { .ai-fly { display: none !important; } }

/* Administration > AI assistant */
.ai-set-privacy { border-left: 4px solid #A04A06; }
.ai-set-choices { display: grid; gap: var(--s2); margin: 0; padding: 0; border: 0; }
.ai-set-choice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid var(--border);
  border-radius: var(--r); cursor: pointer; }
.ai-set-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ai-set-choice input { margin-top: 3px; flex: none; }
.ai-set-choice span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-set-choice .muted { font-size: 13px; }
.ai-set-steps { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.ai-set-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.ai-launcher-pref { gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 600px) { .ai-set-limits { grid-template-columns: minmax(0, 1fr); } }
.ai-set-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.ai-fly-a .ai-fly-cards { padding-left: 0; margin-bottom: 0; }
