/**
 * The model agent panel.
 *
 * Every rule is scoped under `.ma-panel`, and every colour comes from a token
 * defined on that element, so a host page restyles the panel by overriding the
 * tokens and nothing here reaches out into the page.
 */
.ma-panel {
  --ma-ground: rgba(12, 14, 19, 0.72);
  --ma-raised: rgba(233, 238, 247, 0.06);
  --ma-line: rgba(233, 238, 247, 0.12);
  --ma-line-strong: rgba(233, 238, 247, 0.26);
  --ma-ink: #e9eef7;
  --ma-ink-dim: rgba(233, 238, 247, 0.56);
  --ma-ink-faint: rgba(233, 238, 247, 0.42);
  --ma-accent: #ffd08a;
  --ma-radius: 12px;

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: min(384px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  color: var(--ma-ink);
  background: var(--ma-ground);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  border: 1px solid var(--ma-line);
  border-radius: var(--ma-radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  font: 400 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.ma-panel button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.ma-panel svg { width: 15px; height: 15px; display: block; flex: none; }

/* ------------------------------------------------------------------- head */

.ma-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
}

.ma-views { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--ma-raised); }
.ma-panel .ma-view {
  display: grid;
  place-items: center;
  width: 28px; height: 26px;
  border-radius: 6px;
  color: var(--ma-ink-dim);
  transition: background 140ms ease, color 140ms ease;
}
.ma-panel .ma-view span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ma-panel .ma-view:hover { color: var(--ma-ink); }
.ma-view.is-on { background: rgba(233, 238, 247, 0.92); color: #0b0e14; }

.ma-clock { margin-left: auto; }

.ma-panel .ma-fold {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  color: var(--ma-ink-dim);
  transition: color 140ms ease, transform 220ms ease;
}
.ma-panel .ma-fold:hover { color: var(--ma-ink); }
.ma-panel .ma-fold svg { width: 13px; height: 13px; }
.ma-panel.is-folded .ma-fold { transform: rotate(180deg); }
/* Folded, the panel keeps the clock, the transport and the view switcher:
   those stay useful while the reader is reading something else. */
.ma-panel.is-folded > :not(.ma-head):not(.ma-transport) { display: none; }
.ma-panel.is-folded .ma-transport { border-bottom: 0; padding-bottom: 8px; }
/* Chatless, the panel is that header for good: no log, no input, no fold. */
.ma-panel.is-chatless > :not(.ma-head):not(.ma-transport) { display: none; }
.ma-panel.is-chatless .ma-transport { border-bottom: 0; padding-bottom: 8px; }
.ma-panel.is-chatless .ma-fold { display: none; }

.ma-transport {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--ma-line);
}
.ma-panel .ma-play {
  display: grid; place-items: center;
  width: 28px; height: 26px;
  border-radius: 7px;
  background: var(--ma-raised);
  color: var(--ma-ink);
}
.ma-panel .ma-play:hover { background: rgba(233, 238, 247, 0.14); }

.ma-speeds { display: flex; flex: 1; padding: 2px; gap: 2px; border-radius: 8px; background: var(--ma-raised); }
.ma-panel .ma-speed {
  flex: 1;
  padding: 5px 4px;
  border-radius: 6px;
  font: 400 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.04em;
  color: var(--ma-ink-dim);
}
.ma-panel .ma-speed:hover { color: var(--ma-ink); }
.ma-speed.is-on { background: rgba(233, 238, 247, 0.92); color: #0b0e14; }

.ma-clock {
  font: 500 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------------- log */

.ma-log {
  /* The panel keeps a constant height whether it holds one entry or ten, so
     the page behind it never reflows as an answer arrives. */
  /* The panel is anchored to the bottom of the window, so the log grows
     upward as answers arrive and the page behind it never reflows. */
  min-height: 66px;
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ma-log::-webkit-scrollbar { width: 6px; }
.ma-log::-webkit-scrollbar-thumb { background: var(--ma-line); border-radius: 3px; }

.ma-entry p { margin: 0; }
.ma-entry.is-note p,
.ma-entry.is-said p { color: var(--ma-ink); }
.ma-entry.is-note p { color: var(--ma-ink-dim); }

.ma-entry.is-asked {
  align-self: flex-end;
  max-width: 86%;
  padding: 6px 10px;
  border-radius: 10px 10px 3px 10px;
  background: rgba(233, 238, 247, 0.1);
}

.ma-entry.is-action {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 208, 138, 0.24);
  background: rgba(255, 208, 138, 0.08);
}
.ma-entry.is-action p { color: var(--ma-accent); }
.ma-tick { color: var(--ma-accent); padding-top: 2px; }

.ma-entry.is-problem p { color: #ff9c86; }

/* ------------------------------------------------------------------ edits */

.ma-edits[hidden] { display: none; }
.ma-edits {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-top: 1px solid var(--ma-line);
  font-size: 11px;
  color: var(--ma-ink-dim);
}
.ma-panel .ma-reset {
  display: flex; align-items: center; gap: 5px;
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--ma-line);
  font-size: 11px;
  color: var(--ma-ink-dim);
}
.ma-panel .ma-reset:hover { color: var(--ma-ink); border-color: var(--ma-line-strong); }
.ma-panel .ma-reset svg { width: 12px; height: 12px; }

/* ------------------------------------------------------------ suggestions */

.ma-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 14px 0;
}
.ma-suggestions:empty { display: none; }
.ma-panel .ma-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--ma-line-strong);
  background: rgba(233, 238, 247, 0.09);
  font-size: 11.5px;
  color: var(--ma-ink-dim);
  text-align: left;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.ma-panel .ma-chip:hover {
  color: var(--ma-ink);
  border-color: rgba(233, 238, 247, 0.5);
  background: rgba(233, 238, 247, 0.16);
}

/* -------------------------------------------------------------------- ask */

.ma-ask { display: flex; align-items: center; gap: 8px; padding: 10px 14px 12px; }
.ma-input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--ma-line);
  background: rgba(233, 238, 247, 0.04);
  color: var(--ma-ink);
  font: inherit;
}
.ma-input::placeholder { color: var(--ma-ink-faint); }
.ma-input:focus { outline: none; border-color: var(--ma-line-strong); background: rgba(233, 238, 247, 0.07); }
.ma-input:disabled { opacity: 0.6; }

.ma-panel .ma-send {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  flex: none;
  border-radius: 9px;
  background: rgba(233, 238, 247, 0.92);
  color: #0b0e14;
}
.ma-panel .ma-send:hover { background: #fff; }

.ma-panel.is-busy .ma-send { background: var(--ma-accent); }

@media (max-width: 720px) {
  .ma-panel { right: 12px; left: 12px; bottom: 12px; width: auto; }
  .ma-log { max-height: 168px; }
}

@media (prefers-reduced-motion: reduce) {
  .ma-panel *, .ma-panel *::before { transition: none !important; }
}
