/* ===========================================================
   css/max.css — Max inside Weather Protocol (js/max/max.js)
   Floating button, side panel (full screen on phones), "Explain"
   chips. Uses the theme's accent so it fits every theme.
   =========================================================== */

/* the floating button */
.max-fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 8000;
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 13px;
  border: 1px solid var(--a-line); border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--a);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px -8px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .2), 0 0 18px -6px var(--a-glow);
  font: 600 14px/1 inherit; letter-spacing: .04em;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background .15s, box-shadow .15s;
  animation: max-in .35s cubic-bezier(.2, .8, .2, 1);
}
.max-fab:hover { transform: translateY(-2px); background: var(--panel); box-shadow: 0 14px 32px -8px rgba(0, 0, 0, .6), 0 0 22px -4px var(--a-glow); }
.max-fab:focus-visible { outline: 2px solid var(--a); outline-offset: 3px; }
.max-fab.on { background: var(--a); color: #000; border-color: var(--a); }
@keyframes max-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
body.max-on:not(.max-hide) #toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
body.max-hide .max-fab { display: none; }   /* no Max on the radar page (his call) */

.max-face .max-eyes { transform-origin: 12px 12px; animation: max-blink 5.5s infinite; }
@keyframes max-blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }

/* the panel */
.max-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 8100; width: min(420px, 100vw);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--fg); border-left: 1px solid var(--line-2);
  box-shadow: -18px 0 48px -12px rgba(0, 0, 0, .55);
  transform: translateX(104%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
.max-panel.open { transform: none; visibility: visible; }
@media (min-width: 1100px) { body.max-open #app { margin-right: 420px; transition: margin-right .28s cubic-bezier(.2, .8, .2, 1); } }
@media (max-width: 700px) { .max-panel { width: 100vw; border-left: 0; } body.max-open .max-fab { display: none; } }

.max-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--line); color: var(--a); }
.max-head b { color: var(--fg-hi); font-size: 15px; letter-spacing: .03em; }
.max-tag { font-size: 10px; font-weight: 700; letter-spacing: .1em; padding: 2px 6px; border-radius: 999px; border: 1px solid var(--a-line); color: var(--a); }
.max-head .grow { flex: 1; }
.max-head .icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-btn, 6px); background: none; color: var(--fg-2); cursor: pointer; }
.max-head .icon-btn:hover { background: var(--a-wash); color: var(--a); }

.max-list { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.max-empty { margin: auto 0; display: flex; flex-direction: column; gap: 12px; color: var(--fg-2); }
.max-empty p { margin: 0; line-height: 1.5; }
.max-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.max-chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--fg);
  font: inherit; font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s;
}
.max-chip:hover { border-color: var(--a-line); color: var(--a); }

.max-msg { font-size: 14.5px; line-height: 1.55; max-width: 100%; overflow-wrap: anywhere; }
.max-msg.user { align-self: flex-end; max-width: 86%; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--a-wash); border: 1px solid var(--a-line); color: var(--fg-hi); white-space: pre-wrap; }
.max-msg.max { display: flex; flex-direction: column; gap: 8px; }
.max-md p { margin: 0 0 8px; }
.max-md p:last-child { margin-bottom: 0; }
.max-md .max-h { font-weight: 700; color: var(--fg-hi); }
.max-md ul { margin: 0 0 8px; padding-left: 20px; }
.max-md code { font-size: .92em; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); }
.max-md a, .max-sources a { color: var(--a); }
.max-steps { display: flex; flex-direction: column; gap: 4px; }
.max-step { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg-3); }
.max-step.done svg { color: var(--ok); }
.max-step.fail svg { color: var(--danger); }
.max-sources { display: flex; flex-wrap: wrap; gap: 6px; }
.max-sources a { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.max-error { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--warn); }
.max-spin { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--a); animation: max-spin .8s linear infinite; }
@keyframes max-spin { to { transform: rotate(360deg); } }

/* Yes / No cards (event changes, reports) */
.max-card { padding: 12px 14px; border-radius: var(--r-lg, 14px); border: 1px solid var(--a-line); background: var(--a-wash); display: flex; flex-direction: column; gap: 4px; }
.max-card b { color: var(--fg-hi); }
.max-card-line { font-size: 13.5px; color: var(--fg-2); white-space: pre-wrap; }
.max-card.done { font-size: 12.5px; color: var(--fg-3); background: none; border-style: dashed; padding: 6px 12px; }

.max-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--line); }
.max-input {
  flex: 1; resize: none; min-height: 40px; max-height: 140px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg); font: inherit; font-size: 14.5px; line-height: 1.4;
}
.max-input:focus { outline: none; border-color: var(--a-line); box-shadow: 0 0 0 3px var(--a-wash); }
.max-send { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.max-send svg { transform: rotate(-90deg); }
.max-send.busy svg { transform: none; }
.max-foot { padding: 2px 14px calc(10px + env(safe-area-inset-bottom, 0px)); font-size: 11.5px; color: var(--fg-3); }

/* "Explain" chips on alerts, Health cards and the radar */
.max-explain {
  display: inline-flex; align-items: center; gap: 5px; margin: 10px 0 0; padding: 4px 10px 4px 7px; width: fit-content; align-self: flex-start; justify-self: start;
  border-radius: 999px; border: 1px solid var(--a-line); background: transparent; color: var(--a);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .02em; cursor: pointer; transition: background .15s;
}
.max-explain:hover { background: var(--a-wash); }
.max-explain-out {
  margin-top: 8px; padding: 10px 12px; border-radius: var(--r, 10px); border-left: 2px solid var(--a);
  background: var(--a-wash); font-size: 13.5px; line-height: 1.5; color: var(--fg);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.max-more { font-size: 12px; padding: 4px 10px; }
.max-local { font-size: 11.5px; color: var(--fg-3); }

@media (prefers-reduced-motion: reduce) { .max-fab, .max-panel, .max-face .max-eyes { animation: none; transition: none; } }
@media print { .max-fab, .max-panel, .max-explain, .max-explain-out { display: none !important; } }
