/* Max in the corner: the launcher, the bubble, the panel, the page and the console.
   Everything works without JavaScript; the script only swaps the bubble's text
   for the nudge, streams answers into the panel and remembers a dismissal. */

.mx { position: fixed; right: 12px; bottom: calc(var(--tabbar, 64px) + env(safe-area-inset-bottom, 0px) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: calc(100vw - 24px); font-family: var(--sans); }
/* The tab bar is gone at desktop widths, so the corner is the corner. */
@media (min-width: 1100px) { .mx { right: 20px; bottom: 20px; } }
@media print { .mx { display: none; } }

/* The bubble: what Max is asking for on this screen. Shown after four seconds by CSS alone. */
.mx__bubble { position: relative; max-width: 300px; background: var(--ink); color: var(--bone-0); border-radius: 12px 12px 2px 12px; padding: 10px 34px 10px 14px; font-size: 13.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0, 62, 50, .28); opacity: 0; transform: translateY(6px); animation: mx-rise .35s ease-out 4s forwards; }
.mx__bubble[hidden], .mx.is-quiet .mx__bubble, .mx:has(details[open]) .mx__bubble { display: none; }
.mx__bubble-t { margin: 0; }
.mx__bubble-t a { color: var(--mint); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; margin-left: 2px; }
.mx__bubble-t a[hidden] { display: none; }
.mx__dismiss { position: absolute; top: 4px; right: 4px; margin: 0; }
.mx__x { position: absolute; top: 4px; right: 4px; background: none; border: 0; color: var(--bone-0); opacity: .75; font-size: 16px; line-height: 1; padding: 4px 6px; cursor: pointer; border-radius: 6px; }
.mx__dismiss .mx__x { position: static; }
.mx__x:hover { opacity: 1; }
.mx__x[hidden] { display: none; }
.mx.mx--now .mx__bubble { animation-delay: 0s; }
@keyframes mx-rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .mx__bubble { animation: none; opacity: 1; transform: none; } }

/* The launcher: the round Max. A <details> summary, so it opens without a script. */
.mx__d { position: relative; }
.mx__launch { list-style: none; cursor: pointer; display: block; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--bone-0); background: var(--dew); box-shadow: 0 8px 24px rgba(0, 62, 50, .3); overflow: hidden; }
.mx__launch::-webkit-details-marker { display: none; }
.mx__launch::marker { content: ""; }
.mx__launch img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mx__launch:hover, .mx__d[open] .mx__launch { border-color: var(--mint); }
.mx__launch:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; }

/* The panel. On a phone it fills the screen between the top bar and the launcher, never covering the tab bar. */
.mx__panel { position: fixed; left: 12px; right: 12px; top: calc(var(--top, 56px) + 12px); bottom: calc(var(--tabbar, 64px) + env(safe-area-inset-bottom, 0px) + 80px); display: flex; flex-direction: column; background: var(--bone-0); color: var(--ink); border: 1px solid var(--bone-3); border-radius: 14px; box-shadow: 0 18px 50px rgba(16, 19, 18, .22); overflow: hidden; }
@media (min-width: 720px) { .mx__panel { left: auto; width: 380px; top: auto; height: min(600px, calc(100vh - 140px)); } }
@media (min-width: 1100px) { .mx__panel { right: 20px; bottom: 88px; } }
.mx__head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--ink); color: var(--bone-0); }
.mx__head img { width: 36px; height: 36px; border-radius: 50%; }
.mx__name { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.mx__name b { font-size: 15px; }
.mx__name span { font-size: 12px; color: var(--mist); }
.mx__full { font-size: 12.5px; color: var(--bone-0); text-decoration: underline; text-underline-offset: 2px; }
.mx__full:focus-visible, .mx__x:focus-visible { outline-color: var(--mint); }
.mx__links { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--bone-3); }
.mx__links a { font-size: 13px; font-weight: 600; color: var(--field); text-decoration: none; background: var(--bone-1); border: 1px solid var(--bone-3); border-radius: 999px; padding: 6px 11px; }
.mx__links a:hover { background: var(--dew); }
.mx__count { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--bone-0); background: var(--field); padding: 1px 6px; border-radius: 2px; margin-left: 4px; }

/* The chat. Without a script: a line and a form. With one: a log, the chips and the same form. */
.mx__chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mx__hi { margin: 0; padding: 12px 12px 0; font-size: 13.5px; color: var(--ink-3); }
.mx__log { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.mx__log > :first-child { margin-top: auto; }
.mx__msg { max-width: 90%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.mx__msg.max { background: var(--bone-2); color: var(--ink); align-self: flex-start; border-bottom-left-radius: 3px; }
.mx__msg.me { background: var(--ink); color: var(--bone-0); align-self: flex-end; border-bottom-right-radius: 3px; }
.mx__msg.err { background: var(--bad-bg); color: var(--bad-ink); align-self: flex-start; }
.mx__msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.mx__dots span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--field); animation: mx-blink 1.2s infinite ease-in-out; }
.mx__dots span:nth-child(2) { animation-delay: .15s; }
.mx__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes mx-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mx__dots span { animation: none; opacity: .6; } }
.mx__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.mx__chip { background: var(--bone-0); border: 1px solid var(--bone-3); color: var(--field); border-radius: 999px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.mx__chip:hover { background: var(--dew); }
.mx__form { display: flex; gap: 8px; margin: auto 0 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--bone-3); }
.mx__in { flex: 1; min-width: 0; border: 1px solid var(--bone-3); border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--bone-0); color: var(--ink); }
.mx__send { background: var(--ink); color: var(--bone-0); border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.mx__send:hover { background: var(--field); }
.mx__send:disabled { background: var(--bone-3); color: var(--ink-3); cursor: default; }

/* Room under every page, so the launcher never sits on the last button. */
body.pg .main { padding-bottom: calc(var(--tabbar, 64px) + 100px); }
@media (min-width: 1100px) { body.pg .main { padding-bottom: 100px; } }

/* ---------------------------------------------------------------- the page */
.mx-page__ask { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.mx-page__ask img { border-radius: 50%; flex: none; }
.mx-page__ask p { flex: 1; min-width: 200px; margin: 0; font-size: 15px; line-height: 1.5; }
.mx-page__ask p a { margin-left: 6px; font-weight: 600; color: var(--field); }
.mx-page__log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.mx-page__turn { padding: 10px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; }
.mx-page__turn.max { background: var(--bone-2); }
.mx-page__turn.me { background: var(--dew); }
.mx-page__turn p { margin: 0; }
.mx-page__turn p + p { margin-top: 8px; }
.mx-page__who { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 3px; }
.mx-page__form { margin-top: 12px; }
.mx-page__links { display: flex; flex-direction: column; gap: 2px; }
.mx-page__links a { display: block; padding: 8px 0; font-weight: 600; color: var(--field); text-decoration: none; border-bottom: 1px solid var(--bone-2); }
.mx-page__links a:last-child { border-bottom: 0; }
.mx-page__links .badge { font-family: var(--mono); font-size: 11px; background: var(--field); color: var(--bone-0); padding: 1px 6px; border-radius: 2px; margin-left: 6px; }

/* ---------------------------------------------------------------- the console */
.mx-ops__lead { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--bone-2); }
.mx-ops__lead:last-child { border-bottom: 0; }
.mx-ops__lead.done { opacity: .7; }
.mx-ops__lead-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mx-ops__lead-b p { margin: 4px 0; }
.mx-ops__c { border-bottom: 1px solid var(--bone-2); padding: 8px 0; }
.mx-ops__c summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 14px; }
.mx-ops__c summary::-webkit-details-marker { display: none; }
.mx-ops__q { flex-basis: 100%; color: var(--ink-3); font-size: 13.5px; }
.mx-ops__turns { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 4px; }
.mx-ops__turn { padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.mx-ops__turn.max { background: var(--bone-2); }
.mx-ops__turn.me { background: var(--dew); }
.mx-ops__turn p { margin: 0; }
.mx-ops__who { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 2px; }
