/* Mayla, the help assistant (Components/Layout/MaylaAssistant.razor + js/onix-mayla.js):
   the launcher in the corner, the panel it opens, and the guide balloons that point at the
   real menus and buttons. The panel is the gateway's drawer (css/onix-drawer.css —
   .drawer--narrow .drawer--floating: at the right edge, with no scrim, so the screen Mayla
   explains or works on stays in view and usable); only what Mayla adds to it is here.
   Tokens only (css/onix-theme.css, css/onix-glass.css), so both themes come for free.
   Layers: launcher and panel above the page and the toasts' corner (setup balloon 190,
   toasts 200), the guide's spotlight and balloon above the shell's pop-overs, below the
   modal drawers' scrim (1300). */

.mayla { position: fixed; right: 22px; bottom: 22px; z-index: 210; font-family: var(--font-text); }

/* ── launcher ─────────────────────────────────────────────────────────── */

.mayla-launcher {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 18px 0 14px;
    border: 1px solid var(--glass-border, var(--line)); border-radius: 22px;
    background: var(--solid); color: var(--solid-ink);
    box-shadow: var(--solid-shadow, var(--shadow-md));
    font: 600 14px/1 var(--font-text); cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.mayla-launcher:hover { background: var(--solid-hover); transform: translateY(-1px); }
.mayla-launcher:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.mayla-launcher svg { width: 20px; height: 20px; color: var(--dnt-coral-300, currentColor); }
.mayla.is-open .mayla-launcher { opacity: 0; pointer-events: none; transform: scale(.9); }
/* Mayla's button is in the top bar's search pill (TopBar.razor, [data-mayla-toggle]): the corner launcher only where the
   bar is away — an embedded page (OP-032, css/onix-shell.css). It stays in the markup: the panel's avatar is its sparkle. */
html:not([data-layout="embedded"]) .shell:not(.shell--embedded) .mayla-launcher { display: none; }
/* No Mayla on the page (a portal company that keeps the assistant off, MaylaAssistant.razor): no button in the bar. */
.shell:not(:has(#onix-mayla)) [data-mayla-toggle] { display: none !important; }

/* ── panel ────────────────────────────────────────────────────────────── */

/* The box, the head and the body are the drawer's (css/onix-drawer.css). */
.mayla-panel { overflow: hidden; }
.mayla-panel[hidden] { display: none; }

/* Two rows (js/onix-mayla.js, buildPanel), so every tool stays in view at the drawer's 480px and at a phone's width:
   Mayla, History, New and ✕ on top; the mode switch, the agent selector and the automation tools on the bar under
   them — the tools take a row of their own when the bar runs out of width. */
.mayla-head { flex-direction: column; align-items: stretch; gap: 8px; }
.mayla-head-top { display: flex; align-items: center; gap: 2px; min-width: 0; }
.mayla-head-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.mayla-head-lead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mayla-avatar {
    flex: none; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--solid); color: var(--dnt-coral-300, var(--solid-ink));
}
.mayla-avatar svg { width: 20px; height: 20px; }
.mayla-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; margin: 0 8px 0 10px; line-height: 1.2; }
.mayla-titles strong { font: 700 15px/1.2 var(--font-display); }
.mayla-titles small { color: var(--muted); font-size: 12px; }
.mayla-titles strong, .mayla-titles small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mayla-close { flex: none; margin-left: 6px; }

.mayla-iconbtn {
    flex: none; width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.mayla-iconbtn:hover { background: var(--panel-hover); color: var(--ink); }
.mayla-iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.mayla-iconbtn svg { width: 18px; height: 18px; }

.mayla-body { flex: 1; overflow-y: auto; padding: 14px 16px 6px; scroll-behavior: smooth; }

.mayla-overline {
    display: block; margin: 0 0 6px;
    color: var(--muted); font: 600 11px/1.3 var(--font-text); letter-spacing: .06em; text-transform: uppercase;
}
.mayla-intro { margin: 2px 0 14px; color: var(--ink-soft, var(--ink)); font-size: 14px; line-height: 1.5; }
.mayla-note { margin: 4px 0 10px; color: var(--muted); font-size: 13px; }

.mayla-samples { display: flex; flex-wrap: wrap; gap: 6px; }
.mayla-chip {
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--panel); color: var(--ink);
    padding: 6px 12px; font: 500 13px/1.25 var(--font-text); text-align: left; cursor: pointer;
}
.mayla-chip:hover { border-color: var(--brand); color: var(--brand-strong, var(--brand)); background: var(--brand-soft); }
.mayla-chip--source { padding: 3px 10px; font-size: 12px; }

.mayla-live { margin-bottom: 12px; }
.mayla-live[hidden], .mayla-empty[hidden] { display: none; }

/* a question and what came back */
.mayla-turn { padding: 4px 0 14px; border-bottom: 1px solid var(--hairline, var(--line)); margin-bottom: 14px; }
.mayla-turn:last-child { border-bottom: 0; }
.mayla-q {
    margin: 0 0 10px auto; max-width: 85%; width: fit-content;
    padding: 8px 12px; border-radius: 14px 14px 4px 14px;
    background: var(--solid); color: var(--solid-ink);
    font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mayla-answer {
    padding: 10px 12px; border-radius: 14px 14px 14px 4px;
    background: var(--bg-soft, var(--panel-2)); border: 1px solid var(--line);
    font-size: 14px; line-height: 1.5;
}
.mayla-answer > * + * { margin-top: 8px; }
.mayla-text p { margin: 0 0 6px; }
.mayla-text ol, .mayla-text ul { margin: 0 0 6px; padding-left: 20px; }
.mayla-text li + li { margin-top: 2px; }
.mayla-text code { font-size: 12.5px; background: var(--panel); padding: 0 4px; border-radius: 4px; }
.mayla-pending { display: flex; gap: 10px; align-items: flex-start; }
.mayla-pending small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.mayla-failed { border-color: var(--warn-soft, var(--line)); background: var(--warn-soft, var(--panel-2)); }
.mayla-failed p { margin: 0; }
.mayla-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mayla-sources .mayla-overline { margin: 0 4px 0 0; }
.mayla-showme { margin-top: 10px; }

.mayla-dots {
    flex: none; width: 27px; height: 18px; margin-top: 1px;
    background: radial-gradient(circle, var(--brand) 3px, transparent 3.5px) 0 50% / 9px 9px repeat-x;
    animation: mayla-dots 1.1s infinite linear;
}
@keyframes mayla-dots { 0% { opacity: .35; } 50% { opacity: 1; } 100% { opacity: .35; } }

/* guide topics */
.mayla-hits { margin-top: 12px; }
.mayla-hit {
    padding: 10px 12px; margin-bottom: 8px;
    border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--panel);
}
.mayla-hit-where { color: var(--muted); font-size: 12px; margin-bottom: 2px; overflow-wrap: anywhere; }
.mayla-hit-title {
    display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
    color: var(--ink); font: 600 14px/1.35 var(--font-text);
}
.mayla-hit-title:hover { color: var(--brand-strong, var(--brand)); }
.mayla-hit-snippet { margin: 4px 0 0; color: var(--ink-soft, var(--muted)); font-size: 13px; line-height: 1.45; }
.mayla-hit-steps { display: none; margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.45; }
.mayla-hit-steps li + li { margin-top: 3px; }
.mayla-hit.is-expanded .mayla-hit-steps { display: block; }
.mayla-hit.is-expanded .mayla-hit-snippet { display: none; }
.mayla-hit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mayla-hit--compact { padding: 8px 10px; }

/* the question box */
.mayla-ask {
    display: flex; align-items: flex-end; gap: 8px;
    margin: 0; padding: 10px 12px;
    border-top: 1px solid var(--hairline, var(--line));
}
.mayla-input {
    flex: 1; resize: none; min-height: 40px; max-height: 140px;
    padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 20px;
    background: var(--panel); color: var(--ink);
    font: 14px/1.4 var(--font-text);
}
.mayla-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.mayla-send {
    flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0;
    display: grid; place-items: center; cursor: pointer;
    background: var(--solid); color: var(--solid-ink);
}
.mayla-send:hover { background: var(--solid-hover); }
.mayla-send:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.mayla-send svg { width: 18px; height: 18px; }
.mayla-foot { padding: 0 16px 10px; color: var(--muted-2, var(--muted)); font-size: 11px; text-align: center; }

/* ── agent mode: the switch, the attached file, a job's progress and report ── */

.mayla-mode {
    flex: none; display: inline-flex; padding: 2px; gap: 2px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
}
.mayla-mode-btn {
    border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer;
    background: transparent; color: var(--muted); font: 600 12px/1.2 var(--font-text);
}
.mayla-mode-btn:hover { color: var(--ink); }
.mayla-mode-btn[aria-pressed="true"] { background: var(--solid); color: var(--solid-ink); }
.mayla-mode-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.mayla-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px 0; }
.mayla-attach[hidden] { display: none; }
.mayla-file {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--brand-soft); color: var(--ink); font-size: 12.5px;
}
.mayla-file svg { width: 14px; height: 14px; flex: none; color: var(--brand); }
.mayla-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 600; }
.mayla-file-rows { color: var(--muted); }
.mayla-file .mayla-iconbtn { width: 22px; height: 22px; }
.mayla-file .mayla-iconbtn svg { width: 13px; height: 13px; color: inherit; }
.mayla-attach-error { width: 100%; margin: 0; color: var(--danger); font-size: 12.5px; }
.mayla-attach-btn { color: var(--muted); }
.mayla-attach-btn[hidden] { display: none; }
.mayla-attach-btn.is-busy { animation: mayla-dots 1.1s infinite linear; }
.mayla-file-input { display: none; }
.mayla-q-file { display: block; margin-top: 4px; font-size: 12px; opacity: .85; }

.mayla-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.mayla-progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }
.mayla-counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mayla-count {
    display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
    font: 600 12px/1.4 var(--font-text); background: var(--panel); border: 1px solid var(--line); color: var(--ink);
}
.mayla-count--created { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong, var(--brand)); }
.mayla-count--updated { background: var(--info-soft, var(--panel)); border-color: transparent; color: var(--info, var(--ink)); }
.mayla-count--skipped { background: var(--warn-soft, var(--panel)); border-color: transparent; color: var(--warn, var(--ink)); }
.mayla-count--failed { background: var(--danger-soft, var(--panel)); border-color: transparent; color: var(--danger, var(--ink)); }
.mayla-count--none { opacity: .6; }

.mayla-items { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.mayla-items li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 5px 0; border-top: 1px solid var(--hairline, var(--line)); }
.mayla-items li:first-child { border-top: 0; }
.mayla-badge {
    flex: none; padding: 1px 7px; border-radius: 999px;
    font: 600 11px/1.5 var(--font-text); text-transform: uppercase; letter-spacing: .03em;
    background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.mayla-badge--created { color: var(--brand-strong, var(--brand)); border-color: var(--brand-soft-2, var(--line)); }
.mayla-badge--updated { color: var(--info, var(--ink)); }
.mayla-badge--skipped { color: var(--warn, var(--ink)); }
.mayla-badge--failed { color: var(--danger, var(--ink)); }
.mayla-item-row { color: var(--muted); font-size: 12px; }
.mayla-item-name { font-weight: 600; overflow-wrap: anywhere; }
.mayla-item-name a { color: var(--brand-strong, var(--brand)); text-decoration: none; }
.mayla-item-name a:hover { text-decoration: underline; }
.mayla-item-msg { width: 100%; color: var(--muted); font-size: 12.5px; }
.mayla-items.is-folded li:nth-child(n+11) { display: none; }
.mayla-more { margin-top: 6px; }

/* agent mode on the screen: the steps Mayla took, the control it is using, the Allow it waits for — the drawer stays
   as it is, the screen Mayla works on in view at its left (a phone folds it to a sheet, below) */
.mayla-steps { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.45; }
.mayla-step { padding: 3px 0 3px 18px; position: relative; overflow-wrap: anywhere; }
.mayla-step::before { content: ""; position: absolute; left: 4px; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.mayla-step--say { color: var(--ink); }
.mayla-step--say::before { background: var(--brand); }
.mayla-step--act { color: var(--muted); font-size: 12.5px; }
.mayla-step--you {
    margin: 4px 0 4px auto; width: fit-content; max-width: 85%; padding: 5px 10px; border-radius: 12px 12px 4px 12px;
    background: var(--solid); color: var(--solid-ink);
}
.mayla-step--you::before { display: none; }
.mayla-screen .mayla-pending { margin-top: 2px; }
.mayla-screen > .button { margin-top: 8px; }
.mayla-confirm { padding: 10px 12px; border-radius: var(--radius-md); background: var(--warn-soft, var(--panel)); border: 1px solid var(--line); }
.mayla-confirm p { margin: 0; font-weight: 600; }
.mayla-spot.is-agent { animation: none; box-shadow: 0 0 0 3px var(--brand), 0 0 0 9999px rgba(9, 15, 35, .12); }
.mayla-act {
    position: fixed; z-index: 1251; max-width: 320px; padding: 6px 10px; border-radius: 10px;
    background: var(--solid); color: var(--solid-ink); box-shadow: var(--shadow-md);
    font: 600 12.5px/1.35 var(--font-text); pointer-events: none;
}
.mayla-act[hidden] { display: none; }

/* the commands: every task of the guide, listed by app */
.mayla-cmd-app { margin: 10px 0 4px; color: var(--muted); font: 600 12px/1.3 var(--font-text); }
.mayla-cmd {
    display: block; width: 100%; margin: 0 0 4px; padding: 7px 10px; text-align: left; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); color: var(--ink);
}
.mayla-cmd:hover { border-color: var(--brand); background: var(--brand-soft); }
.mayla-cmd:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.mayla-cmd-title { display: block; font: 600 13.5px/1.3 var(--font-text); }
.mayla-cmd-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
/* a job of the catalogue (records from a list or the person's words), told apart from a task of the guide */
.mayla-cmd--job { border-left: 3px solid var(--warn, var(--brand)); }
/* a button, link, row or tab of the page itself ("On this screen"): a pick is clicked at once */
.mayla-cmd--screen { border-left: 3px solid var(--good, var(--brand)); }
.mayla-file--cmd { background: var(--panel); }
.mayla-file--cmd svg { color: var(--warn, var(--brand)); }
.mayla-cmds-btn { color: var(--muted); }
.mayla-cmds-btn[hidden] { display: none; }

.mayla-needs { border-left: 3px solid var(--brand); }
.mayla-needs .mayla-overline { margin-bottom: 4px; }
.mayla-needs-hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

/* ── guide balloons ───────────────────────────────────────────────────── */

.mayla-spot {
    position: fixed; z-index: 1240; pointer-events: none;
    border-radius: 10px;
    box-shadow: 0 0 0 3px var(--brand), 0 0 0 9999px rgba(9, 15, 35, .28);
    transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease;
    animation: mayla-pulse 1.6s ease-in-out infinite;
}
.mayla-spot[hidden] { display: none; }
@keyframes mayla-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--brand), 0 0 0 9999px rgba(9, 15, 35, .28); }
    50% { box-shadow: 0 0 0 6px var(--brand-soft-2, var(--brand)), 0 0 0 9999px rgba(9, 15, 35, .28); }
}

.mayla-balloon {
    position: fixed; z-index: 1250;
    width: min(340px, calc(100vw - 24px));
    padding: 12px 14px 12px;
    background: var(--glass-pop, var(--panel)); color: var(--ink);
    border: 1px solid var(--line-strong); border-left: 3px solid var(--brand);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-text);
    --arrow-x: 50%;
}
.mayla-balloon[hidden] { display: none; }
.mayla-balloon.has-arrow::before {
    content: ""; position: absolute; left: calc(var(--arrow-x) - 8px); top: -8px;
    width: 14px; height: 14px; transform: rotate(45deg);
    background: inherit; border-left: 1px solid var(--line-strong); border-top: 1px solid var(--line-strong);
}
.mayla-balloon.has-arrow.is-above::before {
    top: auto; bottom: -8px; border: 0;
    border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.mayla-balloon-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 2px 0; }
.mayla-balloon-head .mayla-overline { margin: 0; }
.mayla-balloon-head .mayla-iconbtn { width: 28px; height: 28px; }
.mayla-balloon-title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.mayla-balloon-text { margin: 0; font-size: 14px; line-height: 1.5; }
.mayla-balloon-note { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.mayla-balloon-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
    .mayla-spot, .mayla-dots, .mayla-panel, .mayla-attach-btn.is-busy { animation: none; }
    .mayla-spot { transition: none; }
}

/* ── phone: the launcher above the floating tab bar; the panel the whole screen, like every drawer —
   a sheet at the bottom while Mayla works on the screen, so the screen shows ──────────────────── */

@media (max-width: 767.98px) {
    .mayla { right: 16px; bottom: calc(100px + var(--safe-bottom, 0px)); }
    .mayla-launcher { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
    .mayla-launcher-text { display: none; }
    .mayla.is-acting .mayla-panel { top: auto; height: min(420px, 60vh); border-top: 1px solid var(--line); }
}

/* The command palette's "Ask Mayla: …" entry (app.js) is a button among its links. */
.palette-item--mayla { width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }

/* ── the slots of the panel's other scripts (window.OnixMayla.addPanelSection) ── */

/* The head's: History beside New (head), the agent selector beside the mode switch (mode), the automation tools at the
   bar's right (tools). */
.mayla-slot--head, .mayla-slot--mode, .mayla-slot--tools { display: flex; align-items: center; gap: 2px; }
.mayla-slot--tools { margin-left: auto; }
.mayla-slot--top:empty, .mayla-slot--input:empty, .mayla-slot--head:empty,
.mayla-slot--mode:empty, .mayla-slot--tools:empty { display: none; }
/* OP-030: the composer's tools between the box and Send (js/onix-mayla-speech.js: the microphone). */
.mayla-slot--composer { flex: none; display: flex; align-items: center; gap: 2px; align-self: flex-end; min-height: 40px; }
.mayla-slot--composer:empty, .mayla-slot--composer:not(:has(.mayla-iconbtn:not([hidden]))) { display: none; }
.mayla-section[hidden] { display: none; }
