/* Commandry, the project assistant (chat.js): floating button, bottom right, and a movable, resizable chat window.
   Uses the app's color tokens from app.css, so it follows light and dark mode. */
.cmd-launch {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--surface); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 25, 45, .28), 0 1px 3px rgba(15, 25, 45, .2); transition: transform .15s, box-shadow .15s;
}
.cmd-launch:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 25, 45, .32), 0 1px 3px rgba(15, 25, 45, .2); }
.cmd-launch:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.cmd-launch svg { width: 32px; height: 32px; }
.cmd-launch.cmd-on { transform: scale(.92); }
.cmd-bubble { fill: currentColor; }
.cmd-c { fill: var(--accent); } /* the Commandry bar mark inside the bubble */

.cmd-panel {
  position: fixed; z-index: 61; left: auto; top: auto; right: 20px; bottom: 92px; width: 400px; height: 560px;
  display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(15, 25, 45, .3), 0 2px 6px rgba(15, 25, 45, .14); overflow: hidden;
  font-size: 14.5px; line-height: 1.5;
}
.cmd-panel[hidden] { display: none; }
.cmd-panel.cmd-dragging { user-select: none; }
.cmd-grip {
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; z-index: 2; cursor: nwse-resize;
  background: linear-gradient(135deg, var(--muted) 0 1.5px, transparent 1.5px 4px, var(--muted) 4px 5.5px, transparent 5.5px) no-repeat 4px 4px / 9px 9px;
  opacity: .55;
}
.cmd-grip:hover { opacity: 1; }
.cmd-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--accent-soft); cursor: move; touch-action: none;
}
.cmd-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--surface); display: grid; place-items: center; flex: none; }
.cmd-avatar svg { width: 22px; height: 22px; }
.cmd-title { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.cmd-title b { font-size: 15px; }
.cmd-title small { color: var(--muted); font-size: 12px; }
.cmd-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 6px; padding: 4px 9px; font: inherit; font-size: 12.5px; cursor: pointer; }
.cmd-btn:hover { color: var(--ink); border-color: var(--ink); }
.cmd-btn:focus-visible, .cmd-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmd-x { font-size: 18px; line-height: 1; padding: 3px 9px 5px; }

.cmd-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.cmd-msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.cmd-user { align-self: flex-end; background: var(--accent); color: var(--surface); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.cmd-bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cmd-bot.cmd-err { border-color: #c2410c; }
.cmd-md > :first-child { margin-top: 0; }
.cmd-md > :last-child { margin-bottom: 0; }
.cmd-md p, .cmd-md ul, .cmd-md ol, .cmd-md pre, .cmd-md .cmd-tablewrap { margin: 0 0 8px; }
.cmd-md ul, .cmd-md ol { padding-left: 20px; }
.cmd-md li + li { margin-top: 2px; }
.cmd-md .cmd-h { font-weight: 700; }
.cmd-md code { font-family: var(--f-mono); font-size: .88em; background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; }
.cmd-md pre { background: var(--accent-soft); padding: 8px 10px; border-radius: 8px; overflow-x: auto; }
.cmd-md pre code { background: none; padding: 0; }
.cmd-md a { overflow-wrap: anywhere; }
.cmd-tablewrap { overflow-x: auto; }
.cmd-md table { border-collapse: collapse; font-size: 13px; }
.cmd-md th, .cmd-md td { border: 1px solid var(--line); padding: 3px 7px; text-align: left; vertical-align: top; }
.cmd-md th { background: var(--accent-soft); }
.cmd-update { color: var(--muted); font-size: 13px; font-style: italic; margin: 0 0 6px; padding-left: 10px; border-left: 2px solid var(--line); }
.cmd-status { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.cmd-status i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: cmd-dot 1.1s infinite ease-in-out; }
.cmd-status i:nth-child(2) { animation-delay: .15s; }
.cmd-status i:nth-child(3) { animation-delay: .3s; }
.cmd-status span { margin-left: 5px; }
@keyframes cmd-dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.cmd-sources { margin-top: 6px; font-size: 13px; color: var(--muted); }
.cmd-sources summary { cursor: pointer; }
.cmd-sources ul { margin: 4px 0 0; padding-left: 18px; }
.cmd-changed { margin: 6px 0 0; font-size: 12.5px; font-weight: 600; color: var(--ok); }
.cmd-changed::before { content: "✓ "; }
.cmd-notice { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--support-soft); color: var(--ink); font-size: 13.5px; }

.cmd-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.cmd-form textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font: inherit; color: var(--ink);
  background: var(--bg); max-height: 160px; line-height: 1.4;
}
.cmd-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.cmd-send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; }
.cmd-send:disabled { opacity: .45; cursor: not-allowed; }
.cmd-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cmd-send.cmd-stop svg { fill: currentColor; stroke: none; }
.cmd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones: the chat takes the whole screen; the button stays out of the way of the bottom of the page. */
@media (max-width: 599px) {
  .cmd-panel { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; border: 0; }
  .cmd-grip { display: none; }
  .cmd-head { cursor: default; }
  .cmd-launch { right: 16px; bottom: 16px; width: 52px; height: 52px; }
  .cmd-launch.cmd-on { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cmd-launch { transition: none; }
  .cmd-status i { animation: none; opacity: .7; }
}
