/* ─────────────────────────────────────────────────────────────
   Sparky panel — the AI tutor, right side
───────────────────────────────────────────────────────────── */

#sparky-panel {
  width: 330px;
  display: flex;
  flex-direction: column;
  background: var(--shell);
  border-left: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
  font-size: 13px;
  color: var(--ink);
}

/* ── Header ───────────────────────────────────────────────── */
.sparky-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sparky-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #f59e0b, #d97706);
  box-shadow: 0 2px 8px rgba(217,119,6,0.3);
  flex-shrink: 0;
}
.sparky-title { flex: 1; min-width: 0; }
.sparky-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 14px; letter-spacing: -0.2px; }

/* ── Messages ─────────────────────────────────────────────── */
#sparky-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#sparky-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 8px 4px;
  min-height: 0;
}
#sparky-welcome.hidden { display: none; }
.sparky-welcome-title { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }

#sparky-suggestions { display: flex; flex-direction: column; gap: 7px; width: 100%; }
.sparky-suggest-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-1);
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.sparky-suggest-btn svg { color: var(--accent); flex-shrink: 0; }
.sparky-suggest-btn:hover { border-color: rgba(217,119,6,0.45); background: var(--accent-soft); }
.sparky-suggest-btn:active { transform: scale(0.99); }

.chat-msg {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 12px;
  line-height: 1.55;
  word-break: break-word;
  font-size: 12.8px;
  flex-shrink: 0;
}
.chat-msg.user {
  background: var(--ink);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.ai {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-1);
}
.chat-msg.ai p + p, .chat-msg.ai p + ul, .chat-msg.ai ul + p { margin-top: 6px; }
.chat-msg.ai ul { padding-left: 18px; }
.chat-msg.ai li + li { margin-top: 2px; }
.chat-msg.ai code {
  font: 500 11.5px ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--shell-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.chat-msg.system {
  color: var(--ink-3);
  font-size: 11.5px;
  align-self: center;
  text-align: center;
  max-width: 100%;
  padding: 0 6px;
}
.chat-msg.typing {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border: 1px solid var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.typing-label { font-size: 11.5px; color: var(--ink-3); }
.typing-dots { display: flex; align-items: center; gap: 3px; }
.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: ai-bounce 1.1s infinite ease-in-out;
  opacity: 0.5;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ── Simulator verdict on a build ─────────────────────────── */
.verify {
  align-self: stretch;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  flex-shrink: 0;
  border: 1px solid;
}
.verify.ok  { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.verify.bad { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.verify-head { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.verify.ok .verify-head svg  { color: #16a34a; }
.verify.bad .verify-head svg { color: #d97706; }
.verify-body { margin-top: 3px; }
.verify-problems { margin-top: 5px; padding-left: 16px; }
.verify-meta { margin-top: 5px; font-size: 11px; opacity: 0.75; }

/* ── Pending changes ──────────────────────────────────────── */
#sparky-pending-bar {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 0 12px 10px;
  padding: 8px 8px 8px 12px;
  background: #fff;
  border: 1px solid rgba(217,119,6,0.45);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(217,119,6,0.12);
  flex-shrink: 0;
}
#sparky-pending-count { flex: 1; font-size: 12px; font-weight: 600; color: var(--ink); }
.pending-accept, .pending-decline {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.pending-accept { background: var(--accent); border: none; color: #fff; }
.pending-accept:hover { background: var(--accent-hover); }
.pending-decline { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.pending-decline:hover { background: var(--shell-2); color: var(--ink); }

/* ── Input ─────────────────────────────────────────────────── */
#sparky-input-row { padding: 0 12px 12px; flex-shrink: 0; }
.sparky-input-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sparky-input-box:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
#sparky-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}
#sparky-input:focus-visible { box-shadow: none; }
#sparky-input::placeholder { color: var(--ink-3); }
#sparky-send {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, opacity 0.12s;
}
#sparky-send:hover { background: var(--accent-hover); }
#sparky-send[disabled] { opacity: 0.45; cursor: default; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) and (min-height: 600px) {
  #sparky-panel { width: 100%; height: 34vh; border-left: none; border-top: 1px solid var(--line); }
  .sparky-header { padding: 8px 12px; }
}
@media (max-width: 640px) {
  #sparky-panel { height: 30vh; }
}
